1set optimizer_switch='materialization=on'; 2set @old_opt_switch=@@optimizer_switch; 3set optimizer_switch='subquery_materialization_cost_based=off'; 4drop table if exists t0, t1, t2, t10, t11, t12; 5create table t1 (a int not null, b int, primary key (a)); 6create table t2 (a int not null, primary key (a)); 7create table t3 (a int not null, b int, primary key (a)); 8insert into t1 values (1,10), (2,20), (3,30), (4,40); 9insert into t2 values (2), (3), (4), (5); 10insert into t3 values (10,3), (20,4), (30,5); 11select * from t2 where t2.a in (select a from t1); 12a 132 143 154 16explain extended select * from t2 where t2.a in (select a from t1); 17id select_type table type possible_keys key key_len ref rows filtered Extra 181 PRIMARY t2 index NULL PRIMARY 4 NULL 4 100.00 Using where; Using index 192 SUBQUERY t1 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index 20Warnings: 21Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where 1 ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on <auto_key> where ((`test`.`t2`.`a` = `materialized-subquery`.`a`))))) 22select * from t2 where t2.a in (select a from t1 where t1.b <> 30); 23a 242 254 26explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); 27id select_type table type possible_keys key key_len ref rows filtered Extra 281 PRIMARY t2 index NULL PRIMARY 4 NULL 4 100.00 Using where; Using index 292 SUBQUERY t1 ALL PRIMARY NULL NULL NULL 4 100.00 Using where 30Warnings: 31Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where (`test`.`t1`.`b` <> 30) ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on <auto_key> where ((`test`.`t2`.`a` = `materialized-subquery`.`a`))))) 32select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); 33a 342 353 36explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); 37id select_type table type possible_keys key key_len ref rows filtered Extra 381 PRIMARY t2 index NULL PRIMARY 4 NULL 4 100.00 Using where; Using index 392 SUBQUERY t3 index PRIMARY PRIMARY 4 NULL 3 100.00 Using index 402 SUBQUERY t1 ALL PRIMARY NULL NULL NULL 4 100.00 Using where; Using join buffer (Block Nested Loop) 41Warnings: 42Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where (`test`.`t1`.`b` = `test`.`t3`.`a`) ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on <auto_key> where ((`test`.`t2`.`a` = `materialized-subquery`.`a`))))) 43drop table t1, t2, t3; 44create table t1 (a int, b int, index a (a,b)); 45create table t2 (a int, index a (a)); 46create table t3 (a int, b int, index a (a)); 47insert into t1 values (1,10), (2,20), (3,30), (4,40); 48create table t0(a int); 49insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 50insert into t1 51select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; 52insert into t2 values (2), (3), (4), (5); 53insert into t3 values (10,3), (20,4), (30,5); 54select * from t2 where t2.a in (select a from t1); 55a 562 573 584 59explain extended select * from t2 where t2.a in (select a from t1); 60id select_type table type possible_keys key key_len ref rows filtered Extra 611 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index 622 SUBQUERY t1 index a a 10 NULL 10004 100.00 Using index 63Warnings: 64Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where 1 ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on <auto_key> where ((`test`.`t2`.`a` = `materialized-subquery`.`a`))))) 65select * from t2 where t2.a in (select a from t1 where t1.b <> 30); 66a 672 684 69explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); 70id select_type table type possible_keys key key_len ref rows filtered Extra 711 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index 722 SUBQUERY t1 index a a 10 NULL 10004 100.00 Using where; Using index 73Warnings: 74Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where (`test`.`t1`.`b` <> 30) ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on <auto_key> where ((`test`.`t2`.`a` = `materialized-subquery`.`a`))))) 75select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); 76a 772 783 79explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); 80id select_type table type possible_keys key key_len ref rows filtered Extra 811 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index 822 SUBQUERY t3 index a a 5 NULL 3 100.00 Using index 832 SUBQUERY t1 index a a 10 NULL 10004 75.00 Using where; Using index; Using join buffer (Block Nested Loop) 84Warnings: 85Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where (`test`.`t1`.`b` = `test`.`t3`.`a`) ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on <auto_key> where ((`test`.`t2`.`a` = `materialized-subquery`.`a`))))) 86insert into t1 values (3,31); 87select * from t2 where t2.a in (select a from t1 where t1.b <> 30); 88a 892 903 914 92select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); 93a 942 954 96explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); 97id select_type table type possible_keys key key_len ref rows filtered Extra 981 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index 992 SUBQUERY t1 index a a 10 NULL 10005 100.00 Using where; Using index 100Warnings: 101Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where (`test`.`t1`.`b` <> 30) ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on <auto_key> where ((`test`.`t2`.`a` = `materialized-subquery`.`a`))))) 102drop table t0, t1, t2, t3; 103create table t0 (a int); 104insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 105create table t1(a int, b int); 106insert into t1 values (0,0),(1,1),(2,2); 107create table t2 as select * from t1; 108create table t11(a int, b int); 109create table t10 (pk int, a int, primary key(pk)); 110insert into t10 select a,a from t0; 111create table t12 like t10; 112insert into t12 select * from t10; 113Flattened because of dependency, t10=func(t1) 114explain select * from t1 where a in (select pk from t10); 115id select_type table type possible_keys key key_len ref rows Extra 1161 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where 1172 SUBQUERY t10 index PRIMARY PRIMARY 4 NULL 10 Using index 118select * from t1 where a in (select pk from t10); 119a b 1200 0 1211 1 1222 2 123A confluent case of dependency 124explain select * from t1 where a in (select a from t10 where pk=12); 125id select_type table type possible_keys key key_len ref rows Extra 1261 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where 1272 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 128select * from t1 where a in (select a from t10 where pk=12); 129a b 130explain select * from t1 where a in (select a from t10 where pk=9); 131id select_type table type possible_keys key key_len ref rows Extra 1321 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where 1332 SUBQUERY t10 const PRIMARY PRIMARY 4 const 1 NULL 134select * from t1 where a in (select a from t10 where pk=9); 135a b 136An empty table inside 137explain select * from t1 where a in (select a from t11); 138id select_type table type possible_keys key key_len ref rows Extra 1391 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where 1402 SUBQUERY t11 system NULL NULL NULL NULL 0 const row not found 141select * from t1 where a in (select a from t11); 142a b 143explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); 144id select_type table type possible_keys key key_len ref rows Extra 1451 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where 1463 SUBQUERY t10 index PRIMARY PRIMARY 4 NULL 10 Using index 1472 SUBQUERY t10 index PRIMARY PRIMARY 4 NULL 10 Using index 148select * from t1 where a in (select pk from t10) and b in (select pk from t10); 149a b 1500 0 1511 1 1522 2 153flattening a nested subquery 154explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); 155id select_type table type possible_keys key key_len ref rows Extra 1561 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where 1572 SUBQUERY t10 ALL PRIMARY NULL NULL NULL 10 Using where 1583 SUBQUERY t12 index PRIMARY PRIMARY 4 NULL 10 Using index 159select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); 160a b 1610 0 1621 1 1632 2 164flattening subquery w/ several tables 165explain extended select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); 166id select_type table type possible_keys key key_len ref rows filtered Extra 1671 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 1682 SUBQUERY t10 ALL PRIMARY NULL NULL NULL 10 100.00 Using where 1692 SUBQUERY t12 eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index 170Warnings: 171Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (/* select#2 */ select `test`.`t10`.`pk` from `test`.`t10` join `test`.`t12` where (`test`.`t12`.`pk` = `test`.`t10`.`a`) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on <auto_key> where ((`test`.`t1`.`a` = `materialized-subquery`.`pk`))))) 172subqueries within outer joins go into ON expr. 173explAin extended 174select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A And B.A in (select pk from t10)); 175id select_type tABle type possiBle_keys key key_len ref rows filtered ExtrA 1761 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 NULL 1771 PRIMARY A ALL NULL NULL NULL NULL 3 100.00 Using where; Using join Buffer (Block Nested Loop) 1781 PRIMARY B ALL NULL NULL NULL NULL 3 100.00 Using where; Using join Buffer (Block Nested Loop) 1792 SUBQUERY t10 index PRIMARY PRIMARY 4 NULL 10 100.00 Using index 180Warnings: 181Note 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`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`A`.`A` = `test`.`t1`.`A`) And <in_optimizer>(`test`.`B`.`A`,`test`.`B`.`A` in ( <mAteriAlize> (/* select#2 */ select `test`.`t10`.`pk` from `test`.`t10` where 1 ), <primAry_index_lookup>(`test`.`B`.`A` in <temporAry tABle> on <Auto_key> where ((`test`.`B`.`A` = `mAteriAlized-suBquery`.`pk`))))))) where 1 182t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" 183explAin extended 184select * from t1 left join t2 on (t2.A= t1.A And t2.A in (select pk from t10)); 185id select_type tABle type possiBle_keys key key_len ref rows filtered ExtrA 1861 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 NULL 1871 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join Buffer (Block Nested Loop) 1882 SUBQUERY t10 index PRIMARY PRIMARY 4 NULL 10 100.00 Using index 189Warnings: 190Note 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`.`A` = `test`.`t1`.`A`) And <in_optimizer>(`test`.`t2`.`A`,`test`.`t2`.`A` in ( <mAteriAlize> (/* select#2 */ select `test`.`t10`.`pk` from `test`.`t10` where 1 ), <primAry_index_lookup>(`test`.`t2`.`A` in <temporAry tABle> on <Auto_key> where ((`test`.`t2`.`A` = `mAteriAlized-suBquery`.`pk`))))))) where 1 191we shouldn't flatten if we're going to get a join of > MAX_TABLES. 192explain select * from 193t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, 194t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, 195t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, 196t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, 197t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 198where 199s00.a in ( 200select m00.a from 201t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, 202t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 203); 204id select_type table type possible_keys key key_len ref rows Extra 2051 PRIMARY s00 ALL NULL NULL NULL NULL 3 Using where 2061 PRIMARY s01 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2071 PRIMARY s02 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2081 PRIMARY s03 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2091 PRIMARY s04 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2101 PRIMARY s05 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2111 PRIMARY s06 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2121 PRIMARY s07 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2131 PRIMARY s08 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2141 PRIMARY s09 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2151 PRIMARY s10 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2161 PRIMARY s11 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2171 PRIMARY s12 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2181 PRIMARY s13 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2191 PRIMARY s14 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2201 PRIMARY s15 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2211 PRIMARY s16 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2221 PRIMARY s17 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2231 PRIMARY s18 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2241 PRIMARY s19 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2251 PRIMARY s20 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2261 PRIMARY s21 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2271 PRIMARY s22 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2281 PRIMARY s23 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2291 PRIMARY s24 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2301 PRIMARY s25 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2311 PRIMARY s26 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2321 PRIMARY s27 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2331 PRIMARY s28 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2341 PRIMARY s29 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2351 PRIMARY s30 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2361 PRIMARY s31 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2371 PRIMARY s32 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2381 PRIMARY s33 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2391 PRIMARY s34 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2401 PRIMARY s35 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2411 PRIMARY s36 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2421 PRIMARY s37 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2431 PRIMARY s38 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2441 PRIMARY s39 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2451 PRIMARY s40 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2461 PRIMARY s41 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2471 PRIMARY s42 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2481 PRIMARY s43 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2491 PRIMARY s44 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2501 PRIMARY s45 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2511 PRIMARY s46 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2521 PRIMARY s47 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2531 PRIMARY s48 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2541 PRIMARY s49 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2552 SUBQUERY m00 ALL NULL NULL NULL NULL 3 NULL 2562 SUBQUERY m01 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2572 SUBQUERY m02 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2582 SUBQUERY m03 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2592 SUBQUERY m04 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2602 SUBQUERY m05 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2612 SUBQUERY m06 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2622 SUBQUERY m07 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2632 SUBQUERY m08 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2642 SUBQUERY m09 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2652 SUBQUERY m10 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2662 SUBQUERY m11 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2672 SUBQUERY m12 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2682 SUBQUERY m13 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2692 SUBQUERY m14 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2702 SUBQUERY m15 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2712 SUBQUERY m16 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2722 SUBQUERY m17 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2732 SUBQUERY m18 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2742 SUBQUERY m19 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 275select * from 276t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) 277where t1.a < 5; 278a b a b 2790 0 0 0 2801 1 1 1 2812 2 2 2 282prepare s1 from 283' select * from 284 t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) 285 where t1.a < 5'; 286execute s1; 287a b a b 2880 0 0 0 2891 1 1 1 2902 2 2 2 291execute s1; 292a b a b 2930 0 0 0 2941 1 1 1 2952 2 2 2 296insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; 297explain extended select * from t1 where a in (select pk from t10 where pk<3); 298id select_type table type possible_keys key key_len ref rows filtered Extra 2991 PRIMARY t1 ALL NULL NULL NULL NULL 103 100.00 Using where 3002 SUBQUERY t10 range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index 301Warnings: 302Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (/* select#2 */ select `test`.`t10`.`pk` from `test`.`t10` where (`test`.`t10`.`pk` < 3) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on <auto_key> where ((`test`.`t1`.`a` = `materialized-subquery`.`pk`))))) 303drop table t0, t1, t2; 304drop table t10, t11, t12; 305# 306# Check that subqueries with outer joins or straight_join work for 307# different permutations of const and non-const tables. (Ref. Bug#46692) 308# 309CREATE TABLE t1 (i INTEGER); 310CREATE TABLE t2 (i INTEGER); 311CREATE TABLE t3 (i INTEGER); 312SELECT (SELECT COUNT(*) from t1) AS c1, 313(SELECT COUNT(*) from t2) AS c2, 314(SELECT COUNT(*) from t3) AS c3; 315c1 c2 c3 3160 0 0 317EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 318(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 319id select_type table type possible_keys key key_len ref rows Extra 3201 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 3212 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 322SELECT * FROM t1 WHERE (t1.i) IN 323(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 324i 325PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 326(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 327EXECUTE stmt; 328i 329EXECUTE stmt; 330i 331DEALLOCATE PREPARE stmt; 332EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 333(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 334id select_type table type possible_keys key key_len ref rows Extra 3351 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 3362 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 337SELECT * FROM t1 WHERE (t1.i) IN 338(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 339i 340PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 341(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 342EXECUTE stmt; 343i 344EXECUTE stmt; 345i 346DEALLOCATE PREPARE stmt; 347EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 348(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 349id select_type table type possible_keys key key_len ref rows Extra 3501 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 3512 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 352SELECT * FROM t1 WHERE (t1.i) IN 353(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 354i 355EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 356(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 357id select_type table type possible_keys key key_len ref rows Extra 3581 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 3592 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 3602 SUBQUERY t3 system NULL NULL NULL NULL 0 const row not found 361SELECT * FROM t1 WHERE (t1.i) IN 362(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 363i 364EXPLAIN SELECT * FROM t1 WHERE (11) IN 365(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 366id select_type table type possible_keys key key_len ref rows Extra 3671 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 3682 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 369SELECT * FROM t1 WHERE (11) IN 370(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 371i 372EXPLAIN SELECT * FROM t1 WHERE (11) IN 373(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 374id select_type table type possible_keys key key_len ref rows Extra 3751 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 3762 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 377SELECT * FROM t1 WHERE (11) IN 378(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 379i 380EXPLAIN SELECT * FROM t1 WHERE (11) IN 381(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 382id select_type table type possible_keys key key_len ref rows Extra 3831 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 3842 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 385SELECT * FROM t1 WHERE (11) IN 386(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 387i 388EXPLAIN SELECT * FROM t1 WHERE (11) IN 389(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 390id select_type table type possible_keys key key_len ref rows Extra 3911 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 3922 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 393SELECT * FROM t1 WHERE (11) IN 394(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 395i 396INSERT INTO t3 VALUES (2); 397SELECT (SELECT COUNT(*) from t1) AS c1, 398(SELECT COUNT(*) from t2) AS c2, 399(SELECT COUNT(*) from t3) AS c3; 400c1 c2 c3 4010 0 1 402EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 403(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 404id select_type table type possible_keys key key_len ref rows Extra 4051 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 4062 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 407SELECT * FROM t1 WHERE (t1.i) IN 408(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 409i 410PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 411(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 412EXECUTE stmt; 413i 414EXECUTE stmt; 415i 416DEALLOCATE PREPARE stmt; 417EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 418(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 419id select_type table type possible_keys key key_len ref rows Extra 4201 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 4212 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 422SELECT * FROM t1 WHERE (t1.i) IN 423(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 424i 425PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 426(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 427EXECUTE stmt; 428i 429EXECUTE stmt; 430i 431DEALLOCATE PREPARE stmt; 432EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 433(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 434id select_type table type possible_keys key key_len ref rows Extra 4351 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 4362 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 4372 SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 438SELECT * FROM t1 WHERE (t1.i) IN 439(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 440i 441EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 442(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 443id select_type table type possible_keys key key_len ref rows Extra 4441 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 4452 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 4462 SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 447SELECT * FROM t1 WHERE (t1.i) IN 448(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 449i 450EXPLAIN SELECT * FROM t1 WHERE (11) IN 451(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 452id select_type table type possible_keys key key_len ref rows Extra 4531 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 4542 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 455SELECT * FROM t1 WHERE (11) IN 456(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 457i 458EXPLAIN SELECT * FROM t1 WHERE (11) IN 459(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 460id select_type table type possible_keys key key_len ref rows Extra 4611 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 4622 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 463SELECT * FROM t1 WHERE (11) IN 464(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 465i 466EXPLAIN SELECT * FROM t1 WHERE (11) IN 467(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 468id select_type table type possible_keys key key_len ref rows Extra 4691 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 4702 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 471SELECT * FROM t1 WHERE (11) IN 472(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 473i 474EXPLAIN SELECT * FROM t1 WHERE (11) IN 475(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 476id select_type table type possible_keys key key_len ref rows Extra 4771 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 4782 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 479SELECT * FROM t1 WHERE (11) IN 480(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 481i 482INSERT INTO t3 VALUES (1); 483SELECT (SELECT COUNT(*) from t1) AS c1, 484(SELECT COUNT(*) from t2) AS c2, 485(SELECT COUNT(*) from t3) AS c3; 486c1 c2 c3 4870 0 2 488EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 489(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 490id select_type table type possible_keys key key_len ref rows Extra 4911 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 4922 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 493SELECT * FROM t1 WHERE (t1.i) IN 494(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 495i 496PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 497(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 498EXECUTE stmt; 499i 500EXECUTE stmt; 501i 502DEALLOCATE PREPARE stmt; 503EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 504(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 505id select_type table type possible_keys key key_len ref rows Extra 5061 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 5072 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 508SELECT * FROM t1 WHERE (t1.i) IN 509(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 510i 511PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 512(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 513EXECUTE stmt; 514i 515EXECUTE stmt; 516i 517DEALLOCATE PREPARE stmt; 518EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 519(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 520id select_type table type possible_keys key key_len ref rows Extra 5211 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 5222 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 5232 SUBQUERY t3 ALL NULL NULL NULL NULL 2 NULL 524SELECT * FROM t1 WHERE (t1.i) IN 525(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 526i 527EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 528(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 529id select_type table type possible_keys key key_len ref rows Extra 5301 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 5312 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 5322 SUBQUERY t3 ALL NULL NULL NULL NULL 2 NULL 533SELECT * FROM t1 WHERE (t1.i) IN 534(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 535i 536EXPLAIN SELECT * FROM t1 WHERE (11) IN 537(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 538id select_type table type possible_keys key key_len ref rows Extra 5391 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 5402 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 541SELECT * FROM t1 WHERE (11) IN 542(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 543i 544EXPLAIN SELECT * FROM t1 WHERE (11) IN 545(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 546id select_type table type possible_keys key key_len ref rows Extra 5471 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 5482 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 549SELECT * FROM t1 WHERE (11) IN 550(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 551i 552EXPLAIN SELECT * FROM t1 WHERE (11) IN 553(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 554id select_type table type possible_keys key key_len ref rows Extra 5551 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 5562 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 5572 SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where 558SELECT * FROM t1 WHERE (11) IN 559(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 560i 561EXPLAIN SELECT * FROM t1 WHERE (11) IN 562(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 563id select_type table type possible_keys key key_len ref rows Extra 5641 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 5652 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 566SELECT * FROM t1 WHERE (11) IN 567(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 568i 569INSERT INTO t3 VALUES (0); 570DELETE FROM t3; 571INSERT INTO t2 VALUES (2); 572SELECT (SELECT COUNT(*) from t1) AS c1, 573(SELECT COUNT(*) from t2) AS c2, 574(SELECT COUNT(*) from t3) AS c3; 575c1 c2 c3 5760 1 0 577EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 578(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 579id select_type table type possible_keys key key_len ref rows Extra 5801 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 5812 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 582SELECT * FROM t1 WHERE (t1.i) IN 583(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 584i 585PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 586(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 587EXECUTE stmt; 588i 589EXECUTE stmt; 590i 591DEALLOCATE PREPARE stmt; 592EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 593(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 594id select_type table type possible_keys key key_len ref rows Extra 5951 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 5962 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 597SELECT * FROM t1 WHERE (t1.i) IN 598(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 599i 600PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 601(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 602EXECUTE stmt; 603i 604EXECUTE stmt; 605i 606DEALLOCATE PREPARE stmt; 607EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 608(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 609id select_type table type possible_keys key key_len ref rows Extra 6101 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 6112 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 612SELECT * FROM t1 WHERE (t1.i) IN 613(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 614i 615EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 616(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 617id select_type table type possible_keys key key_len ref rows Extra 6181 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 6192 SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 6202 SUBQUERY t3 system NULL NULL NULL NULL 0 const row not found 621SELECT * FROM t1 WHERE (t1.i) IN 622(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 623i 624EXPLAIN SELECT * FROM t1 WHERE (11) IN 625(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 626id select_type table type possible_keys key key_len ref rows Extra 6271 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 6282 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 629SELECT * FROM t1 WHERE (11) IN 630(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 631i 632EXPLAIN SELECT * FROM t1 WHERE (11) IN 633(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 634id select_type table type possible_keys key key_len ref rows Extra 6351 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 6362 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 637SELECT * FROM t1 WHERE (11) IN 638(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 639i 640EXPLAIN SELECT * FROM t1 WHERE (11) IN 641(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 642id select_type table type possible_keys key key_len ref rows Extra 6431 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 6442 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 645SELECT * FROM t1 WHERE (11) IN 646(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 647i 648EXPLAIN SELECT * FROM t1 WHERE (11) IN 649(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 650id select_type table type possible_keys key key_len ref rows Extra 6511 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 6522 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 653SELECT * FROM t1 WHERE (11) IN 654(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 655i 656INSERT INTO t3 VALUES (2); 657SELECT (SELECT COUNT(*) from t1) AS c1, 658(SELECT COUNT(*) from t2) AS c2, 659(SELECT COUNT(*) from t3) AS c3; 660c1 c2 c3 6610 1 1 662EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 663(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 664id select_type table type possible_keys key key_len ref rows Extra 6651 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 6662 SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 6672 SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 668SELECT * FROM t1 WHERE (t1.i) IN 669(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 670i 671PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 672(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 673EXECUTE stmt; 674i 675EXECUTE stmt; 676i 677DEALLOCATE PREPARE stmt; 678EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 679(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 680id select_type table type possible_keys key key_len ref rows Extra 6811 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 6822 SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 6832 SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 684SELECT * FROM t1 WHERE (t1.i) IN 685(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 686i 687PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 688(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 689EXECUTE stmt; 690i 691EXECUTE stmt; 692i 693DEALLOCATE PREPARE stmt; 694EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 695(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 696id select_type table type possible_keys key key_len ref rows Extra 6971 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 6982 SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 6992 SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 700SELECT * FROM t1 WHERE (t1.i) IN 701(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 702i 703EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 704(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 705id select_type table type possible_keys key key_len ref rows Extra 7061 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 7072 SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 7082 SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 709SELECT * FROM t1 WHERE (t1.i) IN 710(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 711i 712EXPLAIN SELECT * FROM t1 WHERE (11) IN 713(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 714id select_type table type possible_keys key key_len ref rows Extra 7151 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 7162 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 717SELECT * FROM t1 WHERE (11) IN 718(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 719i 720EXPLAIN SELECT * FROM t1 WHERE (11) IN 721(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 722id select_type table type possible_keys key key_len ref rows Extra 7231 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 7242 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 725SELECT * FROM t1 WHERE (11) IN 726(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 727i 728EXPLAIN SELECT * FROM t1 WHERE (11) IN 729(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 730id select_type table type possible_keys key key_len ref rows Extra 7311 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 7322 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 733SELECT * FROM t1 WHERE (11) IN 734(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 735i 736EXPLAIN SELECT * FROM t1 WHERE (11) IN 737(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 738id select_type table type possible_keys key key_len ref rows Extra 7391 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 7402 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 741SELECT * FROM t1 WHERE (11) IN 742(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 743i 744INSERT INTO t3 VALUES (1); 745SELECT (SELECT COUNT(*) from t1) AS c1, 746(SELECT COUNT(*) from t2) AS c2, 747(SELECT COUNT(*) from t3) AS c3; 748c1 c2 c3 7490 1 2 750EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 751(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 752id select_type table type possible_keys key key_len ref rows Extra 7531 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 7542 SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 7552 SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where 756SELECT * FROM t1 WHERE (t1.i) IN 757(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 758i 759PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 760(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 761EXECUTE stmt; 762i 763EXECUTE stmt; 764i 765DEALLOCATE PREPARE stmt; 766EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 767(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 768id select_type table type possible_keys key key_len ref rows Extra 7691 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 7702 SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 7712 SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where 772SELECT * FROM t1 WHERE (t1.i) IN 773(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 774i 775PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 776(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 777EXECUTE stmt; 778i 779EXECUTE stmt; 780i 781DEALLOCATE PREPARE stmt; 782EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 783(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 784id select_type table type possible_keys key key_len ref rows Extra 7851 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 7862 SUBQUERY t3 ALL NULL NULL NULL NULL 2 NULL 7872 SUBQUERY t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 788SELECT * FROM t1 WHERE (t1.i) IN 789(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 790i 791EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 792(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 793id select_type table type possible_keys key key_len ref rows Extra 7941 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 7952 SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 7962 SUBQUERY t3 ALL NULL NULL NULL NULL 2 NULL 797SELECT * FROM t1 WHERE (t1.i) IN 798(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 799i 800EXPLAIN SELECT * FROM t1 WHERE (11) IN 801(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 802id select_type table type possible_keys key key_len ref rows Extra 8031 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 8042 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 805SELECT * FROM t1 WHERE (11) IN 806(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 807i 808EXPLAIN SELECT * FROM t1 WHERE (11) IN 809(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 810id select_type table type possible_keys key key_len ref rows Extra 8111 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 8122 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 813SELECT * FROM t1 WHERE (11) IN 814(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 815i 816EXPLAIN SELECT * FROM t1 WHERE (11) IN 817(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 818id select_type table type possible_keys key key_len ref rows Extra 8191 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 8202 SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where 8212 SUBQUERY t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 822SELECT * FROM t1 WHERE (11) IN 823(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 824i 825EXPLAIN SELECT * FROM t1 WHERE (11) IN 826(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 827id select_type table type possible_keys key key_len ref rows Extra 8281 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 8292 SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 8302 SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where 831SELECT * FROM t1 WHERE (11) IN 832(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 833i 834INSERT INTO t3 VALUES (0); 835DELETE FROM t3; 836INSERT INTO t2 VALUES (1); 837SELECT (SELECT COUNT(*) from t1) AS c1, 838(SELECT COUNT(*) from t2) AS c2, 839(SELECT COUNT(*) from t3) AS c3; 840c1 c2 c3 8410 2 0 842EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 843(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 844id select_type table type possible_keys key key_len ref rows Extra 8451 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 8462 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 847SELECT * FROM t1 WHERE (t1.i) IN 848(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 849i 850PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 851(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 852EXECUTE stmt; 853i 854EXECUTE stmt; 855i 856DEALLOCATE PREPARE stmt; 857EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 858(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 859id select_type table type possible_keys key key_len ref rows Extra 8601 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 8612 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 862SELECT * FROM t1 WHERE (t1.i) IN 863(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 864i 865PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 866(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 867EXECUTE stmt; 868i 869EXECUTE stmt; 870i 871DEALLOCATE PREPARE stmt; 872EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 873(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 874id select_type table type possible_keys key key_len ref rows Extra 8751 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 8762 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 877SELECT * FROM t1 WHERE (t1.i) IN 878(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 879i 880EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 881(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 882id select_type table type possible_keys key key_len ref rows Extra 8831 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 8842 SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 8852 SUBQUERY t3 ALL NULL NULL NULL NULL 0 Using join buffer (Block Nested Loop) 886SELECT * FROM t1 WHERE (t1.i) IN 887(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 888i 889EXPLAIN SELECT * FROM t1 WHERE (11) IN 890(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 891id select_type table type possible_keys key key_len ref rows Extra 8921 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 8932 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 894SELECT * FROM t1 WHERE (11) IN 895(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 896i 897EXPLAIN SELECT * FROM t1 WHERE (11) IN 898(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 899id select_type table type possible_keys key key_len ref rows Extra 9001 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 9012 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 902SELECT * FROM t1 WHERE (11) IN 903(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 904i 905EXPLAIN SELECT * FROM t1 WHERE (11) IN 906(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 907id select_type table type possible_keys key key_len ref rows Extra 9081 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 9092 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 910SELECT * FROM t1 WHERE (11) IN 911(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 912i 913EXPLAIN SELECT * FROM t1 WHERE (11) IN 914(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 915id select_type table type possible_keys key key_len ref rows Extra 9161 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 9172 SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 9182 SUBQUERY t3 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop) 919SELECT * FROM t1 WHERE (11) IN 920(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 921i 922INSERT INTO t3 VALUES (2); 923SELECT (SELECT COUNT(*) from t1) AS c1, 924(SELECT COUNT(*) from t2) AS c2, 925(SELECT COUNT(*) from t3) AS c3; 926c1 c2 c3 9270 2 1 928EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 929(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 930id select_type table type possible_keys key key_len ref rows Extra 9311 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 9322 SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 9332 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 934SELECT * FROM t1 WHERE (t1.i) IN 935(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 936i 937PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 938(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 939EXECUTE stmt; 940i 941EXECUTE stmt; 942i 943DEALLOCATE PREPARE stmt; 944EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 945(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 946id select_type table type possible_keys key key_len ref rows Extra 9471 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 9482 SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 9492 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 950SELECT * FROM t1 WHERE (t1.i) IN 951(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 952i 953PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 954(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 955EXECUTE stmt; 956i 957EXECUTE stmt; 958i 959DEALLOCATE PREPARE stmt; 960EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 961(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 962id select_type table type possible_keys key key_len ref rows Extra 9631 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 9642 SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 9652 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 966SELECT * FROM t1 WHERE (t1.i) IN 967(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 968i 969EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 970(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 971id select_type table type possible_keys key key_len ref rows Extra 9721 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 9732 SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 9742 SUBQUERY t3 ALL NULL NULL NULL NULL 1 Using join buffer (Block Nested Loop) 975SELECT * FROM t1 WHERE (t1.i) IN 976(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 977i 978EXPLAIN SELECT * FROM t1 WHERE (11) IN 979(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 980id select_type table type possible_keys key key_len ref rows Extra 9811 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 9822 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 983SELECT * FROM t1 WHERE (11) IN 984(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 985i 986EXPLAIN SELECT * FROM t1 WHERE (11) IN 987(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 988id select_type table type possible_keys key key_len ref rows Extra 9891 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 9902 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 991SELECT * FROM t1 WHERE (11) IN 992(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 993i 994EXPLAIN SELECT * FROM t1 WHERE (11) IN 995(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 996id select_type table type possible_keys key key_len ref rows Extra 9971 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 9982 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 999SELECT * FROM t1 WHERE (11) IN 1000(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1001i 1002EXPLAIN SELECT * FROM t1 WHERE (11) IN 1003(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1004id select_type table type possible_keys key key_len ref rows Extra 10051 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 10062 SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 10072 SUBQUERY t3 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 1008SELECT * FROM t1 WHERE (11) IN 1009(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1010i 1011INSERT INTO t3 VALUES (1); 1012SELECT (SELECT COUNT(*) from t1) AS c1, 1013(SELECT COUNT(*) from t2) AS c2, 1014(SELECT COUNT(*) from t3) AS c3; 1015c1 c2 c3 10160 2 2 1017EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1018(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1019id select_type table type possible_keys key key_len ref rows Extra 10201 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 10212 SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 10222 SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 1023SELECT * FROM t1 WHERE (t1.i) IN 1024(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1025i 1026PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1027(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1028EXECUTE stmt; 1029i 1030EXECUTE stmt; 1031i 1032DEALLOCATE PREPARE stmt; 1033EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1034(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1035id select_type table type possible_keys key key_len ref rows Extra 10361 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 10372 SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 10382 SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 1039SELECT * FROM t1 WHERE (t1.i) IN 1040(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1041i 1042PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1043(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1044EXECUTE stmt; 1045i 1046EXECUTE stmt; 1047i 1048DEALLOCATE PREPARE stmt; 1049EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1050(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1051id select_type table type possible_keys key key_len ref rows Extra 10521 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 10532 SUBQUERY t3 ALL NULL NULL NULL NULL 2 NULL 10542 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 1055SELECT * FROM t1 WHERE (t1.i) IN 1056(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1057i 1058EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1059(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1060id select_type table type possible_keys key key_len ref rows Extra 10611 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 10622 SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 10632 SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop) 1064SELECT * FROM t1 WHERE (t1.i) IN 1065(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1066i 1067EXPLAIN SELECT * FROM t1 WHERE (11) IN 1068(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1069id select_type table type possible_keys key key_len ref rows Extra 10701 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 10712 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 10722 SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 1073SELECT * FROM t1 WHERE (11) IN 1074(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1075i 1076EXPLAIN SELECT * FROM t1 WHERE (11) IN 1077(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1078id select_type table type possible_keys key key_len ref rows Extra 10791 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 10802 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 1081SELECT * FROM t1 WHERE (11) IN 1082(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1083i 1084EXPLAIN SELECT * FROM t1 WHERE (11) IN 1085(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1086id select_type table type possible_keys key key_len ref rows Extra 10871 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 10882 SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where 10892 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 1090SELECT * FROM t1 WHERE (11) IN 1091(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1092i 1093EXPLAIN SELECT * FROM t1 WHERE (11) IN 1094(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1095id select_type table type possible_keys key key_len ref rows Extra 10961 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 10972 SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 10982 SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 1099SELECT * FROM t1 WHERE (11) IN 1100(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1101i 1102INSERT INTO t3 VALUES (0); 1103DELETE FROM t3; 1104INSERT INTO t2 VALUES (0); 1105DELETE FROM t2; 1106INSERT INTO t1 VALUES (2); 1107SELECT (SELECT COUNT(*) from t1) AS c1, 1108(SELECT COUNT(*) from t2) AS c2, 1109(SELECT COUNT(*) from t3) AS c3; 1110c1 c2 c3 11111 0 0 1112EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1113(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1114id select_type table type possible_keys key key_len ref rows Extra 11151 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 11162 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1117SELECT * FROM t1 WHERE (t1.i) IN 1118(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1119i 1120PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1121(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1122EXECUTE stmt; 1123i 1124EXECUTE stmt; 1125i 1126DEALLOCATE PREPARE stmt; 1127EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1128(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1129id select_type table type possible_keys key key_len ref rows Extra 11301 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 11312 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1132SELECT * FROM t1 WHERE (t1.i) IN 1133(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1134i 1135PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1136(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1137EXECUTE stmt; 1138i 1139EXECUTE stmt; 1140i 1141DEALLOCATE PREPARE stmt; 1142EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1143(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1144id select_type table type possible_keys key key_len ref rows Extra 11451 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 11462 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1147SELECT * FROM t1 WHERE (t1.i) IN 1148(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1149i 1150EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1151(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1152id select_type table type possible_keys key key_len ref rows Extra 11531 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 11542 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1155SELECT * FROM t1 WHERE (t1.i) IN 1156(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1157i 1158EXPLAIN SELECT * FROM t1 WHERE (11) IN 1159(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1160id select_type table type possible_keys key key_len ref rows Extra 11611 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 11622 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1163SELECT * FROM t1 WHERE (11) IN 1164(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1165i 1166EXPLAIN SELECT * FROM t1 WHERE (11) IN 1167(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1168id select_type table type possible_keys key key_len ref rows Extra 11691 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 11702 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1171SELECT * FROM t1 WHERE (11) IN 1172(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1173i 1174EXPLAIN SELECT * FROM t1 WHERE (11) IN 1175(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1176id select_type table type possible_keys key key_len ref rows Extra 11771 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 11782 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1179SELECT * FROM t1 WHERE (11) IN 1180(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1181i 1182EXPLAIN SELECT * FROM t1 WHERE (11) IN 1183(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1184id select_type table type possible_keys key key_len ref rows Extra 11851 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 11862 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1187SELECT * FROM t1 WHERE (11) IN 1188(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1189i 1190INSERT INTO t3 VALUES (2); 1191SELECT (SELECT COUNT(*) from t1) AS c1, 1192(SELECT COUNT(*) from t2) AS c2, 1193(SELECT COUNT(*) from t3) AS c3; 1194c1 c2 c3 11951 0 1 1196EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1197(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1198id select_type table type possible_keys key key_len ref rows Extra 11991 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 12002 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1201SELECT * FROM t1 WHERE (t1.i) IN 1202(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1203i 1204PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1205(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1206EXECUTE stmt; 1207i 1208EXECUTE stmt; 1209i 1210DEALLOCATE PREPARE stmt; 1211EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1212(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1213id select_type table type possible_keys key key_len ref rows Extra 12141 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 12152 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1216SELECT * FROM t1 WHERE (t1.i) IN 1217(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1218i 1219PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1220(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1221EXECUTE stmt; 1222i 1223EXECUTE stmt; 1224i 1225DEALLOCATE PREPARE stmt; 1226EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1227(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1228id select_type table type possible_keys key key_len ref rows Extra 12291 PRIMARY t1 system NULL NULL NULL NULL 1 NULL 12302 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 12312 DEPENDENT SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 1232SELECT * FROM t1 WHERE (t1.i) IN 1233(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1234i 12352 1236EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1237(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1238id select_type table type possible_keys key key_len ref rows Extra 12391 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 12402 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1241SELECT * FROM t1 WHERE (t1.i) IN 1242(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1243i 1244EXPLAIN SELECT * FROM t1 WHERE (11) IN 1245(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1246id select_type table type possible_keys key key_len ref rows Extra 12471 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 12482 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1249SELECT * FROM t1 WHERE (11) IN 1250(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1251i 1252EXPLAIN SELECT * FROM t1 WHERE (11) IN 1253(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1254id select_type table type possible_keys key key_len ref rows Extra 12551 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 12562 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1257SELECT * FROM t1 WHERE (11) IN 1258(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1259i 1260EXPLAIN SELECT * FROM t1 WHERE (11) IN 1261(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1262id select_type table type possible_keys key key_len ref rows Extra 12631 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 12642 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1265SELECT * FROM t1 WHERE (11) IN 1266(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1267i 1268EXPLAIN SELECT * FROM t1 WHERE (11) IN 1269(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1270id select_type table type possible_keys key key_len ref rows Extra 12711 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 12722 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1273SELECT * FROM t1 WHERE (11) IN 1274(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1275i 1276INSERT INTO t3 VALUES (1); 1277SELECT (SELECT COUNT(*) from t1) AS c1, 1278(SELECT COUNT(*) from t2) AS c2, 1279(SELECT COUNT(*) from t3) AS c3; 1280c1 c2 c3 12811 0 2 1282EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1283(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1284id select_type table type possible_keys key key_len ref rows Extra 12851 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 12862 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1287SELECT * FROM t1 WHERE (t1.i) IN 1288(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1289i 1290PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1291(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1292EXECUTE stmt; 1293i 1294EXECUTE stmt; 1295i 1296DEALLOCATE PREPARE stmt; 1297EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1298(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1299id select_type table type possible_keys key key_len ref rows Extra 13001 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 13012 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1302SELECT * FROM t1 WHERE (t1.i) IN 1303(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1304i 1305PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1306(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1307EXECUTE stmt; 1308i 1309EXECUTE stmt; 1310i 1311DEALLOCATE PREPARE stmt; 1312EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1313(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1314id select_type table type possible_keys key key_len ref rows Extra 13151 PRIMARY t1 system NULL NULL NULL NULL 1 NULL 13162 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 13172 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where 1318SELECT * FROM t1 WHERE (t1.i) IN 1319(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1320i 13212 1322EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1323(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1324id select_type table type possible_keys key key_len ref rows Extra 13251 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 13262 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1327SELECT * FROM t1 WHERE (t1.i) IN 1328(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1329i 1330EXPLAIN SELECT * FROM t1 WHERE (11) IN 1331(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1332id select_type table type possible_keys key key_len ref rows Extra 13331 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 13342 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1335SELECT * FROM t1 WHERE (11) IN 1336(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1337i 1338EXPLAIN SELECT * FROM t1 WHERE (11) IN 1339(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1340id select_type table type possible_keys key key_len ref rows Extra 13411 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 13422 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1343SELECT * FROM t1 WHERE (11) IN 1344(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1345i 1346EXPLAIN SELECT * FROM t1 WHERE (11) IN 1347(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1348id select_type table type possible_keys key key_len ref rows Extra 13491 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 13502 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 13512 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where 1352SELECT * FROM t1 WHERE (11) IN 1353(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1354i 1355EXPLAIN SELECT * FROM t1 WHERE (11) IN 1356(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1357id select_type table type possible_keys key key_len ref rows Extra 13581 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 13592 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1360SELECT * FROM t1 WHERE (11) IN 1361(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1362i 1363INSERT INTO t3 VALUES (0); 1364DELETE FROM t3; 1365INSERT INTO t2 VALUES (2); 1366SELECT (SELECT COUNT(*) from t1) AS c1, 1367(SELECT COUNT(*) from t2) AS c2, 1368(SELECT COUNT(*) from t3) AS c3; 1369c1 c2 c3 13701 1 0 1371EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1372(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1373id select_type table type possible_keys key key_len ref rows Extra 13741 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 13752 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1376SELECT * FROM t1 WHERE (t1.i) IN 1377(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1378i 1379PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1380(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1381EXECUTE stmt; 1382i 1383EXECUTE stmt; 1384i 1385DEALLOCATE PREPARE stmt; 1386EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1387(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1388id select_type table type possible_keys key key_len ref rows Extra 13891 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 13902 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1391SELECT * FROM t1 WHERE (t1.i) IN 1392(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1393i 1394PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1395(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1396EXECUTE stmt; 1397i 1398EXECUTE stmt; 1399i 1400DEALLOCATE PREPARE stmt; 1401EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1402(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1403id select_type table type possible_keys key key_len ref rows Extra 14041 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 14052 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1406SELECT * FROM t1 WHERE (t1.i) IN 1407(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1408i 1409EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1410(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1411id select_type table type possible_keys key key_len ref rows Extra 14121 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 14132 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1414SELECT * FROM t1 WHERE (t1.i) IN 1415(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1416i 1417EXPLAIN SELECT * FROM t1 WHERE (11) IN 1418(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1419id select_type table type possible_keys key key_len ref rows Extra 14201 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 14212 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1422SELECT * FROM t1 WHERE (11) IN 1423(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1424i 1425EXPLAIN SELECT * FROM t1 WHERE (11) IN 1426(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1427id select_type table type possible_keys key key_len ref rows Extra 14281 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 14292 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1430SELECT * FROM t1 WHERE (11) IN 1431(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1432i 1433EXPLAIN SELECT * FROM t1 WHERE (11) IN 1434(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1435id select_type table type possible_keys key key_len ref rows Extra 14361 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 14372 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1438SELECT * FROM t1 WHERE (11) IN 1439(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1440i 1441EXPLAIN SELECT * FROM t1 WHERE (11) IN 1442(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1443id select_type table type possible_keys key key_len ref rows Extra 14441 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 14452 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1446SELECT * FROM t1 WHERE (11) IN 1447(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1448i 1449INSERT INTO t3 VALUES (2); 1450SELECT (SELECT COUNT(*) from t1) AS c1, 1451(SELECT COUNT(*) from t2) AS c2, 1452(SELECT COUNT(*) from t3) AS c3; 1453c1 c2 c3 14541 1 1 1455EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1456(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1457id select_type table type possible_keys key key_len ref rows Extra 14581 PRIMARY t1 system NULL NULL NULL NULL 1 NULL 14592 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 14602 DEPENDENT SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 1461SELECT * FROM t1 WHERE (t1.i) IN 1462(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1463i 14642 1465PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1466(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1467EXECUTE stmt; 1468i 14692 1470EXECUTE stmt; 1471i 14722 1473DEALLOCATE PREPARE stmt; 1474EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1475(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1476id select_type table type possible_keys key key_len ref rows Extra 14771 PRIMARY t1 system NULL NULL NULL NULL 1 NULL 14782 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 14792 DEPENDENT SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 1480SELECT * FROM t1 WHERE (t1.i) IN 1481(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1482i 14832 1484PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1485(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1486EXECUTE stmt; 1487i 14882 1489EXECUTE stmt; 1490i 14912 1492DEALLOCATE PREPARE stmt; 1493EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1494(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1495id select_type table type possible_keys key key_len ref rows Extra 14961 PRIMARY t1 system NULL NULL NULL NULL 1 NULL 14972 DEPENDENT SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 14982 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 1499SELECT * FROM t1 WHERE (t1.i) IN 1500(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1501i 15022 1503EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1504(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1505id select_type table type possible_keys key key_len ref rows Extra 15061 PRIMARY t1 system NULL NULL NULL NULL 1 NULL 15072 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 15082 DEPENDENT SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 1509SELECT * FROM t1 WHERE (t1.i) IN 1510(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1511i 15122 1513EXPLAIN SELECT * FROM t1 WHERE (11) IN 1514(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1515id select_type table type possible_keys key key_len ref rows Extra 15161 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 15172 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1518SELECT * FROM t1 WHERE (11) IN 1519(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1520i 1521EXPLAIN SELECT * FROM t1 WHERE (11) IN 1522(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1523id select_type table type possible_keys key key_len ref rows Extra 15241 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 15252 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1526SELECT * FROM t1 WHERE (11) IN 1527(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1528i 1529EXPLAIN SELECT * FROM t1 WHERE (11) IN 1530(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1531id select_type table type possible_keys key key_len ref rows Extra 15321 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 15332 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1534SELECT * FROM t1 WHERE (11) IN 1535(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1536i 1537EXPLAIN SELECT * FROM t1 WHERE (11) IN 1538(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1539id select_type table type possible_keys key key_len ref rows Extra 15401 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 15412 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1542SELECT * FROM t1 WHERE (11) IN 1543(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1544i 1545INSERT INTO t3 VALUES (1); 1546SELECT (SELECT COUNT(*) from t1) AS c1, 1547(SELECT COUNT(*) from t2) AS c2, 1548(SELECT COUNT(*) from t3) AS c3; 1549c1 c2 c3 15501 1 2 1551EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1552(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1553id select_type table type possible_keys key key_len ref rows Extra 15541 PRIMARY t1 system NULL NULL NULL NULL 1 NULL 15552 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 15562 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where 1557SELECT * FROM t1 WHERE (t1.i) IN 1558(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1559i 15602 1561PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1562(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1563EXECUTE stmt; 1564i 15652 1566EXECUTE stmt; 1567i 15682 1569DEALLOCATE PREPARE stmt; 1570EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1571(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1572id select_type table type possible_keys key key_len ref rows Extra 15731 PRIMARY t1 system NULL NULL NULL NULL 1 NULL 15742 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 15752 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where 1576SELECT * FROM t1 WHERE (t1.i) IN 1577(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1578i 15792 1580PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1581(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1582EXECUTE stmt; 1583i 15842 1585EXECUTE stmt; 1586i 15872 1588DEALLOCATE PREPARE stmt; 1589EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1590(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1591id select_type table type possible_keys key key_len ref rows Extra 15921 PRIMARY t1 system NULL NULL NULL NULL 1 NULL 15932 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where 15942 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 1595SELECT * FROM t1 WHERE (t1.i) IN 1596(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1597i 15982 1599EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1600(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1601id select_type table type possible_keys key key_len ref rows Extra 16021 PRIMARY t1 system NULL NULL NULL NULL 1 NULL 16032 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 16042 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where 1605SELECT * FROM t1 WHERE (t1.i) IN 1606(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1607i 16082 1609EXPLAIN SELECT * FROM t1 WHERE (11) IN 1610(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1611id select_type table type possible_keys key key_len ref rows Extra 16121 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 16132 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1614SELECT * FROM t1 WHERE (11) IN 1615(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1616i 1617EXPLAIN SELECT * FROM t1 WHERE (11) IN 1618(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1619id select_type table type possible_keys key key_len ref rows Extra 16201 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 16212 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1622SELECT * FROM t1 WHERE (11) IN 1623(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1624i 1625EXPLAIN SELECT * FROM t1 WHERE (11) IN 1626(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1627id select_type table type possible_keys key key_len ref rows Extra 16281 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 16292 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where 16302 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 1631SELECT * FROM t1 WHERE (11) IN 1632(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1633i 1634EXPLAIN SELECT * FROM t1 WHERE (11) IN 1635(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1636id select_type table type possible_keys key key_len ref rows Extra 16371 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 16382 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 16392 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where 1640SELECT * FROM t1 WHERE (11) IN 1641(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1642i 1643INSERT INTO t3 VALUES (0); 1644DELETE FROM t3; 1645INSERT INTO t2 VALUES (1); 1646SELECT (SELECT COUNT(*) from t1) AS c1, 1647(SELECT COUNT(*) from t2) AS c2, 1648(SELECT COUNT(*) from t3) AS c3; 1649c1 c2 c3 16501 2 0 1651EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1652(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1653id select_type table type possible_keys key key_len ref rows Extra 16541 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 16552 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1656SELECT * FROM t1 WHERE (t1.i) IN 1657(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1658i 1659PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1660(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1661EXECUTE stmt; 1662i 1663EXECUTE stmt; 1664i 1665DEALLOCATE PREPARE stmt; 1666EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1667(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1668id select_type table type possible_keys key key_len ref rows Extra 16691 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 16702 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1671SELECT * FROM t1 WHERE (t1.i) IN 1672(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1673i 1674PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1675(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1676EXECUTE stmt; 1677i 1678EXECUTE stmt; 1679i 1680DEALLOCATE PREPARE stmt; 1681EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1682(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1683id select_type table type possible_keys key key_len ref rows Extra 16841 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 16852 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1686SELECT * FROM t1 WHERE (t1.i) IN 1687(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1688i 1689EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1690(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1691id select_type table type possible_keys key key_len ref rows Extra 16921 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 16932 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 16942 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop) 1695SELECT * FROM t1 WHERE (t1.i) IN 1696(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1697i 1698EXPLAIN SELECT * FROM t1 WHERE (11) IN 1699(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1700id select_type table type possible_keys key key_len ref rows Extra 17011 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 17022 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1703SELECT * FROM t1 WHERE (11) IN 1704(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1705i 1706EXPLAIN SELECT * FROM t1 WHERE (11) IN 1707(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1708id select_type table type possible_keys key key_len ref rows Extra 17091 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 17102 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1711SELECT * FROM t1 WHERE (11) IN 1712(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1713i 1714EXPLAIN SELECT * FROM t1 WHERE (11) IN 1715(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1716id select_type table type possible_keys key key_len ref rows Extra 17171 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 17182 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1719SELECT * FROM t1 WHERE (11) IN 1720(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1721i 1722EXPLAIN SELECT * FROM t1 WHERE (11) IN 1723(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1724id select_type table type possible_keys key key_len ref rows Extra 17251 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 17262 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 17272 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop) 1728SELECT * FROM t1 WHERE (11) IN 1729(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1730i 1731INSERT INTO t3 VALUES (2); 1732SELECT (SELECT COUNT(*) from t1) AS c1, 1733(SELECT COUNT(*) from t2) AS c2, 1734(SELECT COUNT(*) from t3) AS c3; 1735c1 c2 c3 17361 2 1 1737EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1738(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1739id select_type table type possible_keys key key_len ref rows Extra 17401 PRIMARY t1 system NULL NULL NULL NULL 1 NULL 17412 DEPENDENT SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 17422 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 1743SELECT * FROM t1 WHERE (t1.i) IN 1744(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1745i 17462 1747PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1748(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1749EXECUTE stmt; 1750i 17512 1752EXECUTE stmt; 1753i 17542 1755DEALLOCATE PREPARE stmt; 1756EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1757(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1758id select_type table type possible_keys key key_len ref rows Extra 17591 PRIMARY t1 system NULL NULL NULL NULL 1 NULL 17602 DEPENDENT SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 17612 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 1762SELECT * FROM t1 WHERE (t1.i) IN 1763(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1764i 17652 1766PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1767(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1768EXECUTE stmt; 1769i 17702 1771EXECUTE stmt; 1772i 17732 1774DEALLOCATE PREPARE stmt; 1775EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1776(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1777id select_type table type possible_keys key key_len ref rows Extra 17781 PRIMARY t1 system NULL NULL NULL NULL 1 NULL 17792 DEPENDENT SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 17802 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 1781SELECT * FROM t1 WHERE (t1.i) IN 1782(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1783i 17842 1785EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1786(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1787id select_type table type possible_keys key key_len ref rows Extra 17881 PRIMARY t1 system NULL NULL NULL NULL 1 NULL 17892 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 17902 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 1791SELECT * FROM t1 WHERE (t1.i) IN 1792(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1793i 17942 1795EXPLAIN SELECT * FROM t1 WHERE (11) IN 1796(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1797id select_type table type possible_keys key key_len ref rows Extra 17981 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 17992 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1800SELECT * FROM t1 WHERE (11) IN 1801(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1802i 1803EXPLAIN SELECT * FROM t1 WHERE (11) IN 1804(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1805id select_type table type possible_keys key key_len ref rows Extra 18061 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 18072 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1808SELECT * FROM t1 WHERE (11) IN 1809(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1810i 1811EXPLAIN SELECT * FROM t1 WHERE (11) IN 1812(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1813id select_type table type possible_keys key key_len ref rows Extra 18141 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 18152 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1816SELECT * FROM t1 WHERE (11) IN 1817(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1818i 1819EXPLAIN SELECT * FROM t1 WHERE (11) IN 1820(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1821id select_type table type possible_keys key key_len ref rows Extra 18221 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 18232 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 18242 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 1825SELECT * FROM t1 WHERE (11) IN 1826(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1827i 1828INSERT INTO t3 VALUES (1); 1829SELECT (SELECT COUNT(*) from t1) AS c1, 1830(SELECT COUNT(*) from t2) AS c2, 1831(SELECT COUNT(*) from t3) AS c3; 1832c1 c2 c3 18331 2 2 1834EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1835(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1836id select_type table type possible_keys key key_len ref rows Extra 18371 PRIMARY t1 system NULL NULL NULL NULL 1 NULL 18382 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 18392 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 1840SELECT * FROM t1 WHERE (t1.i) IN 1841(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1842i 18432 1844PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1845(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1846EXECUTE stmt; 1847i 18482 1849EXECUTE stmt; 1850i 18512 1852DEALLOCATE PREPARE stmt; 1853EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1854(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1855id select_type table type possible_keys key key_len ref rows Extra 18561 PRIMARY t1 system NULL NULL NULL NULL 1 NULL 18572 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 18582 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 1859SELECT * FROM t1 WHERE (t1.i) IN 1860(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1861i 18622 1863PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1864(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1865EXECUTE stmt; 1866i 18672 1868EXECUTE stmt; 1869i 18702 1871DEALLOCATE PREPARE stmt; 1872EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1873(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1874id select_type table type possible_keys key key_len ref rows Extra 18751 PRIMARY t1 system NULL NULL NULL NULL 1 NULL 18762 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where 18772 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 1878SELECT * FROM t1 WHERE (t1.i) IN 1879(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1880i 18812 1882EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1883(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1884id select_type table type possible_keys key key_len ref rows Extra 18851 PRIMARY t1 system NULL NULL NULL NULL 1 NULL 18862 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 18872 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 1888SELECT * FROM t1 WHERE (t1.i) IN 1889(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1890i 18912 1892EXPLAIN SELECT * FROM t1 WHERE (11) IN 1893(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1894id select_type table type possible_keys key key_len ref rows Extra 18951 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 18962 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 18972 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 1898SELECT * FROM t1 WHERE (11) IN 1899(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1900i 1901EXPLAIN SELECT * FROM t1 WHERE (11) IN 1902(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1903id select_type table type possible_keys key key_len ref rows Extra 19041 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 19052 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 19062 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 1907SELECT * FROM t1 WHERE (11) IN 1908(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1909i 1910EXPLAIN SELECT * FROM t1 WHERE (11) IN 1911(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1912id select_type table type possible_keys key key_len ref rows Extra 19131 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 19142 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where 19152 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 1916SELECT * FROM t1 WHERE (11) IN 1917(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1918i 1919EXPLAIN SELECT * FROM t1 WHERE (11) IN 1920(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1921id select_type table type possible_keys key key_len ref rows Extra 19221 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 19232 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 19242 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 1925SELECT * FROM t1 WHERE (11) IN 1926(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1927i 1928INSERT INTO t3 VALUES (0); 1929DELETE FROM t3; 1930INSERT INTO t2 VALUES (0); 1931DELETE FROM t2; 1932INSERT INTO t1 VALUES (1); 1933SELECT (SELECT COUNT(*) from t1) AS c1, 1934(SELECT COUNT(*) from t2) AS c2, 1935(SELECT COUNT(*) from t3) AS c3; 1936c1 c2 c3 19372 0 0 1938EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1939(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1940id select_type table type possible_keys key key_len ref rows Extra 19411 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 19422 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1943SELECT * FROM t1 WHERE (t1.i) IN 1944(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1945i 1946PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1947(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1948EXECUTE stmt; 1949i 1950EXECUTE stmt; 1951i 1952DEALLOCATE PREPARE stmt; 1953EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1954(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1955id select_type table type possible_keys key key_len ref rows Extra 19561 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 19572 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1958SELECT * FROM t1 WHERE (t1.i) IN 1959(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1960i 1961PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1962(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1963EXECUTE stmt; 1964i 1965EXECUTE stmt; 1966i 1967DEALLOCATE PREPARE stmt; 1968EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1969(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1970id select_type table type possible_keys key key_len ref rows Extra 19711 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 19722 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1973SELECT * FROM t1 WHERE (t1.i) IN 1974(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1975i 1976EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1977(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1978id select_type table type possible_keys key key_len ref rows Extra 19791 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 19802 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 19812 SUBQUERY t3 system NULL NULL NULL NULL 0 const row not found 1982SELECT * FROM t1 WHERE (t1.i) IN 1983(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1984i 1985EXPLAIN SELECT * FROM t1 WHERE (11) IN 1986(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1987id select_type table type possible_keys key key_len ref rows Extra 19881 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 19892 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1990SELECT * FROM t1 WHERE (11) IN 1991(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1992i 1993EXPLAIN SELECT * FROM t1 WHERE (11) IN 1994(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1995id select_type table type possible_keys key key_len ref rows Extra 19961 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 19972 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1998SELECT * FROM t1 WHERE (11) IN 1999(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2000i 2001EXPLAIN SELECT * FROM t1 WHERE (11) IN 2002(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2003id select_type table type possible_keys key key_len ref rows Extra 20041 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 20052 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 2006SELECT * FROM t1 WHERE (11) IN 2007(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2008i 2009EXPLAIN SELECT * FROM t1 WHERE (11) IN 2010(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2011id select_type table type possible_keys key key_len ref rows Extra 20121 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 20132 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 2014SELECT * FROM t1 WHERE (11) IN 2015(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2016i 2017INSERT INTO t3 VALUES (2); 2018SELECT (SELECT COUNT(*) from t1) AS c1, 2019(SELECT COUNT(*) from t2) AS c2, 2020(SELECT COUNT(*) from t3) AS c3; 2021c1 c2 c3 20222 0 1 2023EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2024(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2025id select_type table type possible_keys key key_len ref rows Extra 20261 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 20272 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2028SELECT * FROM t1 WHERE (t1.i) IN 2029(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2030i 2031PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2032(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 2033EXECUTE stmt; 2034i 2035EXECUTE stmt; 2036i 2037DEALLOCATE PREPARE stmt; 2038EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2039(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2040id select_type table type possible_keys key key_len ref rows Extra 20411 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 20422 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2043SELECT * FROM t1 WHERE (t1.i) IN 2044(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2045i 2046PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2047(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 2048EXECUTE stmt; 2049i 2050EXECUTE stmt; 2051i 2052DEALLOCATE PREPARE stmt; 2053EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2054(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2055id select_type table type possible_keys key key_len ref rows Extra 20561 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 20572 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 20582 SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 2059SELECT * FROM t1 WHERE (t1.i) IN 2060(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2061i 20622 2063EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2064(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2065id select_type table type possible_keys key key_len ref rows Extra 20661 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 20672 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 20682 SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 2069SELECT * FROM t1 WHERE (t1.i) IN 2070(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2071i 2072EXPLAIN SELECT * FROM t1 WHERE (11) IN 2073(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2074id select_type table type possible_keys key key_len ref rows Extra 20751 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 20762 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 2077SELECT * FROM t1 WHERE (11) IN 2078(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2079i 2080EXPLAIN SELECT * FROM t1 WHERE (11) IN 2081(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2082id select_type table type possible_keys key key_len ref rows Extra 20831 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 20842 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2085SELECT * FROM t1 WHERE (11) IN 2086(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2087i 2088EXPLAIN SELECT * FROM t1 WHERE (11) IN 2089(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2090id select_type table type possible_keys key key_len ref rows Extra 20911 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 20922 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2093SELECT * FROM t1 WHERE (11) IN 2094(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2095i 2096EXPLAIN SELECT * FROM t1 WHERE (11) IN 2097(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2098id select_type table type possible_keys key key_len ref rows Extra 20991 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 21002 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 2101SELECT * FROM t1 WHERE (11) IN 2102(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2103i 2104INSERT INTO t3 VALUES (1); 2105SELECT (SELECT COUNT(*) from t1) AS c1, 2106(SELECT COUNT(*) from t2) AS c2, 2107(SELECT COUNT(*) from t3) AS c3; 2108c1 c2 c3 21092 0 2 2110EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2111(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2112id select_type table type possible_keys key key_len ref rows Extra 21131 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 21142 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2115SELECT * FROM t1 WHERE (t1.i) IN 2116(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2117i 2118PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2119(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 2120EXECUTE stmt; 2121i 2122EXECUTE stmt; 2123i 2124DEALLOCATE PREPARE stmt; 2125EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2126(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2127id select_type table type possible_keys key key_len ref rows Extra 21281 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 21292 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2130SELECT * FROM t1 WHERE (t1.i) IN 2131(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2132i 2133PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2134(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 2135EXECUTE stmt; 2136i 2137EXECUTE stmt; 2138i 2139DEALLOCATE PREPARE stmt; 2140EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2141(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2142id select_type table type possible_keys key key_len ref rows Extra 21431 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 21442 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 21452 SUBQUERY t3 ALL NULL NULL NULL NULL 2 NULL 2146SELECT * FROM t1 WHERE (t1.i) IN 2147(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2148i 21492 21501 2151EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2152(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2153id select_type table type possible_keys key key_len ref rows Extra 21541 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 21552 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 21562 SUBQUERY t3 ALL NULL NULL NULL NULL 2 NULL 2157SELECT * FROM t1 WHERE (t1.i) IN 2158(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2159i 2160EXPLAIN SELECT * FROM t1 WHERE (11) IN 2161(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2162id select_type table type possible_keys key key_len ref rows Extra 21631 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 21642 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 2165SELECT * FROM t1 WHERE (11) IN 2166(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2167i 2168EXPLAIN SELECT * FROM t1 WHERE (11) IN 2169(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2170id select_type table type possible_keys key key_len ref rows Extra 21711 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 21722 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2173SELECT * FROM t1 WHERE (11) IN 2174(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2175i 2176EXPLAIN SELECT * FROM t1 WHERE (11) IN 2177(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2178id select_type table type possible_keys key key_len ref rows Extra 21791 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 21802 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found 21812 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where 2182SELECT * FROM t1 WHERE (11) IN 2183(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2184i 2185EXPLAIN SELECT * FROM t1 WHERE (11) IN 2186(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2187id select_type table type possible_keys key key_len ref rows Extra 21881 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 21892 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 2190SELECT * FROM t1 WHERE (11) IN 2191(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2192i 2193INSERT INTO t3 VALUES (0); 2194DELETE FROM t3; 2195INSERT INTO t2 VALUES (2); 2196SELECT (SELECT COUNT(*) from t1) AS c1, 2197(SELECT COUNT(*) from t2) AS c2, 2198(SELECT COUNT(*) from t3) AS c3; 2199c1 c2 c3 22002 1 0 2201EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2202(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2203id select_type table type possible_keys key key_len ref rows Extra 22041 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 22052 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2206SELECT * FROM t1 WHERE (t1.i) IN 2207(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2208i 2209PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2210(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 2211EXECUTE stmt; 2212i 2213EXECUTE stmt; 2214i 2215DEALLOCATE PREPARE stmt; 2216EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2217(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2218id select_type table type possible_keys key key_len ref rows Extra 22191 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 22202 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2221SELECT * FROM t1 WHERE (t1.i) IN 2222(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2223i 2224PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2225(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 2226EXECUTE stmt; 2227i 2228EXECUTE stmt; 2229i 2230DEALLOCATE PREPARE stmt; 2231EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2232(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2233id select_type table type possible_keys key key_len ref rows Extra 22341 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 22352 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2236SELECT * FROM t1 WHERE (t1.i) IN 2237(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2238i 2239EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2240(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2241id select_type table type possible_keys key key_len ref rows Extra 22421 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 22432 SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 22442 SUBQUERY t3 system NULL NULL NULL NULL 0 const row not found 2245SELECT * FROM t1 WHERE (t1.i) IN 2246(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2247i 2248EXPLAIN SELECT * FROM t1 WHERE (11) IN 2249(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2250id select_type table type possible_keys key key_len ref rows Extra 22511 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 22522 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 2253SELECT * FROM t1 WHERE (11) IN 2254(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2255i 2256EXPLAIN SELECT * FROM t1 WHERE (11) IN 2257(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2258id select_type table type possible_keys key key_len ref rows Extra 22591 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 22602 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2261SELECT * FROM t1 WHERE (11) IN 2262(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2263i 2264EXPLAIN SELECT * FROM t1 WHERE (11) IN 2265(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2266id select_type table type possible_keys key key_len ref rows Extra 22671 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 22682 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 2269SELECT * FROM t1 WHERE (11) IN 2270(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2271i 2272EXPLAIN SELECT * FROM t1 WHERE (11) IN 2273(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2274id select_type table type possible_keys key key_len ref rows Extra 22751 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 22762 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 2277SELECT * FROM t1 WHERE (11) IN 2278(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2279i 2280INSERT INTO t3 VALUES (2); 2281SELECT (SELECT COUNT(*) from t1) AS c1, 2282(SELECT COUNT(*) from t2) AS c2, 2283(SELECT COUNT(*) from t3) AS c3; 2284c1 c2 c3 22852 1 1 2286EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2287(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2288id select_type table type possible_keys key key_len ref rows Extra 22891 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 22902 SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 22912 SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 2292SELECT * FROM t1 WHERE (t1.i) IN 2293(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2294i 22952 2296PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2297(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 2298EXECUTE stmt; 2299i 23002 2301EXECUTE stmt; 2302i 23032 2304DEALLOCATE PREPARE stmt; 2305EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2306(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2307id select_type table type possible_keys key key_len ref rows Extra 23081 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 23092 SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 23102 SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 2311SELECT * FROM t1 WHERE (t1.i) IN 2312(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2313i 23142 2315PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2316(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 2317EXECUTE stmt; 2318i 23192 2320EXECUTE stmt; 2321i 23222 2323DEALLOCATE PREPARE stmt; 2324EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2325(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2326id select_type table type possible_keys key key_len ref rows Extra 23271 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 23282 SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 23292 SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 2330SELECT * FROM t1 WHERE (t1.i) IN 2331(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2332i 23332 2334EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2335(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2336id select_type table type possible_keys key key_len ref rows Extra 23371 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 23382 SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 23392 SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 2340SELECT * FROM t1 WHERE (t1.i) IN 2341(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2342i 23432 2344EXPLAIN SELECT * FROM t1 WHERE (11) IN 2345(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2346id select_type table type possible_keys key key_len ref rows Extra 23471 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 23482 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2349SELECT * FROM t1 WHERE (11) IN 2350(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2351i 2352EXPLAIN SELECT * FROM t1 WHERE (11) IN 2353(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2354id select_type table type possible_keys key key_len ref rows Extra 23551 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 23562 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2357SELECT * FROM t1 WHERE (11) IN 2358(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2359i 2360EXPLAIN SELECT * FROM t1 WHERE (11) IN 2361(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2362id select_type table type possible_keys key key_len ref rows Extra 23631 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 23642 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2365SELECT * FROM t1 WHERE (11) IN 2366(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2367i 2368EXPLAIN SELECT * FROM t1 WHERE (11) IN 2369(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2370id select_type table type possible_keys key key_len ref rows Extra 23711 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 23722 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2373SELECT * FROM t1 WHERE (11) IN 2374(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2375i 2376INSERT INTO t3 VALUES (1); 2377SELECT (SELECT COUNT(*) from t1) AS c1, 2378(SELECT COUNT(*) from t2) AS c2, 2379(SELECT COUNT(*) from t3) AS c3; 2380c1 c2 c3 23812 1 2 2382EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2383(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2384id select_type table type possible_keys key key_len ref rows Extra 23851 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 23862 SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 23872 SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where 2388SELECT * FROM t1 WHERE (t1.i) IN 2389(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2390i 23912 2392PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2393(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 2394EXECUTE stmt; 2395i 23962 2397EXECUTE stmt; 2398i 23992 2400DEALLOCATE PREPARE stmt; 2401EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2402(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2403id select_type table type possible_keys key key_len ref rows Extra 24041 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 24052 SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 24062 SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where 2407SELECT * FROM t1 WHERE (t1.i) IN 2408(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2409i 24102 2411PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2412(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 2413EXECUTE stmt; 2414i 24152 2416EXECUTE stmt; 2417i 24182 2419DEALLOCATE PREPARE stmt; 2420EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2421(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2422id select_type table type possible_keys key key_len ref rows Extra 24231 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 24242 SUBQUERY t3 ALL NULL NULL NULL NULL 2 NULL 24252 SUBQUERY t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 2426SELECT * FROM t1 WHERE (t1.i) IN 2427(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2428i 24292 24301 2431EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2432(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2433id select_type table type possible_keys key key_len ref rows Extra 24341 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 24352 SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 24362 SUBQUERY t3 ALL NULL NULL NULL NULL 2 NULL 2437SELECT * FROM t1 WHERE (t1.i) IN 2438(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2439i 24402 24411 2442EXPLAIN SELECT * FROM t1 WHERE (11) IN 2443(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2444id select_type table type possible_keys key key_len ref rows Extra 24451 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 24462 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2447SELECT * FROM t1 WHERE (11) IN 2448(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2449i 2450EXPLAIN SELECT * FROM t1 WHERE (11) IN 2451(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2452id select_type table type possible_keys key key_len ref rows Extra 24531 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 24542 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2455SELECT * FROM t1 WHERE (11) IN 2456(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2457i 2458EXPLAIN SELECT * FROM t1 WHERE (11) IN 2459(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2460id select_type table type possible_keys key key_len ref rows Extra 24611 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 24622 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where 24632 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 2464SELECT * FROM t1 WHERE (11) IN 2465(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2466i 2467EXPLAIN SELECT * FROM t1 WHERE (11) IN 2468(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2469id select_type table type possible_keys key key_len ref rows Extra 24701 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 24712 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 1 NULL 24722 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where 2473SELECT * FROM t1 WHERE (11) IN 2474(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2475i 2476INSERT INTO t3 VALUES (0); 2477DELETE FROM t3; 2478INSERT INTO t2 VALUES (1); 2479SELECT (SELECT COUNT(*) from t1) AS c1, 2480(SELECT COUNT(*) from t2) AS c2, 2481(SELECT COUNT(*) from t3) AS c3; 2482c1 c2 c3 24832 2 0 2484EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2485(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2486id select_type table type possible_keys key key_len ref rows Extra 24871 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 24882 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2489SELECT * FROM t1 WHERE (t1.i) IN 2490(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2491i 2492PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2493(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 2494EXECUTE stmt; 2495i 2496EXECUTE stmt; 2497i 2498DEALLOCATE PREPARE stmt; 2499EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2500(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2501id select_type table type possible_keys key key_len ref rows Extra 25021 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 25032 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2504SELECT * FROM t1 WHERE (t1.i) IN 2505(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2506i 2507PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2508(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 2509EXECUTE stmt; 2510i 2511EXECUTE stmt; 2512i 2513DEALLOCATE PREPARE stmt; 2514EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2515(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2516id select_type table type possible_keys key key_len ref rows Extra 25171 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 25182 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2519SELECT * FROM t1 WHERE (t1.i) IN 2520(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2521i 2522EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2523(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2524id select_type table type possible_keys key key_len ref rows Extra 25251 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 25262 SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 25272 SUBQUERY t3 ALL NULL NULL NULL NULL 0 Using join buffer (Block Nested Loop) 2528SELECT * FROM t1 WHERE (t1.i) IN 2529(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2530i 2531EXPLAIN SELECT * FROM t1 WHERE (11) IN 2532(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2533id select_type table type possible_keys key key_len ref rows Extra 25341 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 25352 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 2536SELECT * FROM t1 WHERE (11) IN 2537(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2538i 2539EXPLAIN SELECT * FROM t1 WHERE (11) IN 2540(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2541id select_type table type possible_keys key key_len ref rows Extra 25421 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 25432 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2544SELECT * FROM t1 WHERE (11) IN 2545(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2546i 2547EXPLAIN SELECT * FROM t1 WHERE (11) IN 2548(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2549id select_type table type possible_keys key key_len ref rows Extra 25501 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 25512 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table 2552SELECT * FROM t1 WHERE (11) IN 2553(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2554i 2555EXPLAIN SELECT * FROM t1 WHERE (11) IN 2556(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2557id select_type table type possible_keys key key_len ref rows Extra 25581 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 25592 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 25602 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop) 2561SELECT * FROM t1 WHERE (11) IN 2562(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2563i 2564INSERT INTO t3 VALUES (2); 2565SELECT (SELECT COUNT(*) from t1) AS c1, 2566(SELECT COUNT(*) from t2) AS c2, 2567(SELECT COUNT(*) from t3) AS c3; 2568c1 c2 c3 25692 2 1 2570EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2571(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2572id select_type table type possible_keys key key_len ref rows Extra 25731 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 25742 SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 25752 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 2576SELECT * FROM t1 WHERE (t1.i) IN 2577(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2578i 25792 2580PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2581(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 2582EXECUTE stmt; 2583i 25842 2585EXECUTE stmt; 2586i 25872 2588DEALLOCATE PREPARE stmt; 2589EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2590(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2591id select_type table type possible_keys key key_len ref rows Extra 25921 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 25932 SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 25942 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 2595SELECT * FROM t1 WHERE (t1.i) IN 2596(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2597i 25982 2599PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2600(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 2601EXECUTE stmt; 2602i 26032 2604EXECUTE stmt; 2605i 26062 2607DEALLOCATE PREPARE stmt; 2608EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2609(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2610id select_type table type possible_keys key key_len ref rows Extra 26111 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 26122 SUBQUERY t3 system NULL NULL NULL NULL 1 NULL 26132 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 2614SELECT * FROM t1 WHERE (t1.i) IN 2615(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2616i 26172 2618EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2619(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2620id select_type table type possible_keys key key_len ref rows Extra 26211 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 26222 SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 26232 SUBQUERY t3 ALL NULL NULL NULL NULL 1 Using join buffer (Block Nested Loop) 2624SELECT * FROM t1 WHERE (t1.i) IN 2625(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2626i 26272 2628EXPLAIN SELECT * FROM t1 WHERE (11) IN 2629(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2630id select_type table type possible_keys key key_len ref rows Extra 26311 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 26322 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2633SELECT * FROM t1 WHERE (11) IN 2634(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2635i 2636EXPLAIN SELECT * FROM t1 WHERE (11) IN 2637(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2638id select_type table type possible_keys key key_len ref rows Extra 26391 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 26402 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2641SELECT * FROM t1 WHERE (11) IN 2642(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2643i 2644EXPLAIN SELECT * FROM t1 WHERE (11) IN 2645(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2646id select_type table type possible_keys key key_len ref rows Extra 26471 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 26482 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2649SELECT * FROM t1 WHERE (11) IN 2650(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2651i 2652EXPLAIN SELECT * FROM t1 WHERE (11) IN 2653(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2654id select_type table type possible_keys key key_len ref rows Extra 26551 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 26562 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 26572 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 2658SELECT * FROM t1 WHERE (11) IN 2659(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2660i 2661INSERT INTO t3 VALUES (1); 2662SELECT (SELECT COUNT(*) from t1) AS c1, 2663(SELECT COUNT(*) from t2) AS c2, 2664(SELECT COUNT(*) from t3) AS c3; 2665c1 c2 c3 26662 2 2 2667EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2668(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2669id select_type table type possible_keys key key_len ref rows Extra 26701 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 26712 SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 26722 SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 2673SELECT * FROM t1 WHERE (t1.i) IN 2674(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2675i 26762 26771 2678PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2679(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 2680EXECUTE stmt; 2681i 26822 26831 2684EXECUTE stmt; 2685i 26862 26871 2688DEALLOCATE PREPARE stmt; 2689EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2690(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2691id select_type table type possible_keys key key_len ref rows Extra 26921 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 26932 SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 26942 SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 2695SELECT * FROM t1 WHERE (t1.i) IN 2696(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2697i 26982 26991 2700PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2701(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 2702EXECUTE stmt; 2703i 27042 27051 2706EXECUTE stmt; 2707i 27082 27091 2710DEALLOCATE PREPARE stmt; 2711EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2712(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2713id select_type table type possible_keys key key_len ref rows Extra 27141 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 27152 SUBQUERY t3 ALL NULL NULL NULL NULL 2 NULL 27162 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 2717SELECT * FROM t1 WHERE (t1.i) IN 2718(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2719i 27202 27211 2722EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2723(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2724id select_type table type possible_keys key key_len ref rows Extra 27251 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 27262 SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 27272 SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop) 2728SELECT * FROM t1 WHERE (t1.i) IN 2729(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2730i 27312 27321 2733EXPLAIN SELECT * FROM t1 WHERE (11) IN 2734(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2735id select_type table type possible_keys key key_len ref rows Extra 27361 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 27372 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 27382 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 2739SELECT * FROM t1 WHERE (11) IN 2740(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2741i 2742EXPLAIN SELECT * FROM t1 WHERE (11) IN 2743(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2744id select_type table type possible_keys key key_len ref rows Extra 27451 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 27462 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 27472 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 2748SELECT * FROM t1 WHERE (11) IN 2749(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2750i 2751EXPLAIN SELECT * FROM t1 WHERE (11) IN 2752(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2753id select_type table type possible_keys key key_len ref rows Extra 27541 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 27552 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where 27562 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 2757SELECT * FROM t1 WHERE (11) IN 2758(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2759i 2760EXPLAIN SELECT * FROM t1 WHERE (11) IN 2761(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2762id select_type table type possible_keys key key_len ref rows Extra 27631 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 27642 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 27652 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 2766SELECT * FROM t1 WHERE (11) IN 2767(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2768i 2769INSERT INTO t3 VALUES (0); 2770DELETE FROM t3; 2771INSERT INTO t2 VALUES (0); 2772DELETE FROM t2; 2773INSERT INTO t1 VALUES (0); 2774DROP TABLE t1, t2, t3; 2775create table x1(k int primary key, d1 int, d2 int); 2776create table x2(k int primary key, d1 int, d2 int); 2777insert into x1 values 2778(10, 10, 10), 2779(20, 20, 20), 2780(21, 20, null), 2781(30, null, 30), 2782(40, 40, 40); 2783insert into x2 values 2784(10, 10, 10), 2785(20, 20, 20), 2786(21, 20, null), 2787(30, null, 30); 2788select * 2789from x1 2790where (d1, d2) in (select d1, d2 2791from x2); 2792k d1 d2 279310 10 10 279420 20 20 2795select * 2796from x1 2797where (d1, d2) in (select d1, d2 2798from x2) is true; 2799k d1 d2 280010 10 10 280120 20 20 2802select * 2803from x1 2804where (d1, d2) in (select d1, d2 2805from x2) is false; 2806k d1 d2 280740 40 40 2808select * 2809from x1 2810where (d1, d2) in (select d1, d2 2811from x2) is unknown; 2812k d1 d2 281321 20 NULL 281430 NULL 30 2815select * 2816from x1 2817where d1 in (select d1 2818from x2 2819where x1.d2=x2.d2); 2820k d1 d2 282110 10 10 282220 20 20 2823select * 2824from x1 2825where d1 in (select d1 2826from x2 2827where x1.d2=x2.d2) is true; 2828k d1 d2 282910 10 10 283020 20 20 2831select * 2832from x1 2833where d1 in (select d1 2834from x2 2835where x1.d2=x2.d2) is false; 2836k d1 d2 283721 20 NULL 283840 40 40 2839select * 2840from x1 2841where d1 in (select d1 2842from x2 2843where x1.d2=x2.d2) is unknown; 2844k d1 d2 284530 NULL 30 2846select * 2847from x1 2848where 1 in (select 1 2849from x2 2850where x1.d1=x2.d1 and x1.d2=x2.d2); 2851k d1 d2 285210 10 10 285320 20 20 2854select * 2855from x1 2856where 1 in (select 1 2857from x2 2858where x1.d1=x2.d1 and x1.d2=x2.d2) is true; 2859k d1 d2 286010 10 10 286120 20 20 2862select * 2863from x1 2864where 1 in (select 1 2865from x2 2866where x1.d1=x2.d1 and x1.d2=x2.d2) is false; 2867k d1 d2 286821 20 NULL 286930 NULL 30 287040 40 40 2871select * 2872from x1 2873where 1 in (select 1 2874from x2 2875where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; 2876k d1 d2 2877select * 2878from x1 2879where exists (select * 2880from x2 2881where x1.d1=x2.d1 and x1.d2=x2.d2); 2882k d1 d2 288310 10 10 288420 20 20 2885drop table x1; 2886drop table x2; 2887CREATE TABLE t1 ( 2888a int(11) NOT NULL, 2889b int(11) NOT NULL, 2890c datetime default NULL, 2891PRIMARY KEY (a), 2892KEY idx_bc (b,c) 2893); 2894INSERT INTO t1 VALUES 2895(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), 2896(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), 2897(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), 2898(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), 2899(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), 2900(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), 2901(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), 2902(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), 2903(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), 2904(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), 2905(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), 2906(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), 2907(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), 2908(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), 2909(154503,67,'2005-10-28 11:52:38'); 2910create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; 2911create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; 2912create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; 2913create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; 2914update t22 set c = '2005-12-08 15:58:27' where a = 255; 2915explain select t21.* from t21,t22 where t21.a = t22.a and 2916t22.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; 2917id select_type table type possible_keys key key_len ref rows Extra 29181 PRIMARY t21 ALL NULL NULL NULL NULL 26 Using where; Using temporary; Using filesort 29191 PRIMARY t22 ALL NULL NULL NULL NULL 26 Using where; Using join buffer (Block Nested Loop) 29202 SUBQUERY t11 ALL NULL NULL NULL NULL 8 Using where 29212 SUBQUERY t12 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop) 2922explain format=json select * from t1 where a in (select a from t11); 2923EXPLAIN 2924{ 2925 "query_block": { 2926 "select_id": 1, 2927 "table": { 2928 "table_name": "t1", 2929 "access_type": "ALL", 2930 "rows": 32, 2931 "filtered": 100, 2932 "attached_condition": "<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (/* select#2 */ select `test`.`t11`.`a` from `test`.`t11` where 1 ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on <auto_key> where ((`test`.`t1`.`a` = `materialized-subquery`.`a`)))))", 2933 "attached_subqueries": [ 2934 { 2935 "table": { 2936 "table_name": "<materialized_subquery>", 2937 "access_type": "eq_ref", 2938 "key": "<auto_key>", 2939 "key_length": "4", 2940 "rows": 1, 2941 "materialized_from_subquery": { 2942 "using_temporary_table": true, 2943 "dependent": true, 2944 "cacheable": false, 2945 "query_block": { 2946 "select_id": 2, 2947 "table": { 2948 "table_name": "t11", 2949 "access_type": "ALL", 2950 "rows": 8, 2951 "filtered": 100 2952 } 2953 } 2954 } 2955 } 2956 } 2957 ] 2958 } 2959 } 2960} 2961Warnings: 2962Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (/* select#2 */ select `test`.`t11`.`a` from `test`.`t11` where 1 ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on <auto_key> where ((`test`.`t1`.`a` = `materialized-subquery`.`a`))))) 2963select t21.* from t21,t22 where t21.a = t22.a and 2964t22.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; 2965a b c 2966256 67 NULL 2967drop table t1, t11, t12, t21, t22; 2968create table t1(a int); 2969insert into t1 values (0),(1); 2970explain 2971select (select max(Y.a) from t1 Y where a in (select a from t1 Z) and a < X.a) as subq from t1 X; 2972id select_type table type possible_keys key key_len ref rows Extra 29731 PRIMARY X ALL NULL NULL NULL NULL 2 NULL 29742 DEPENDENT SUBQUERY Y ALL NULL NULL NULL NULL 2 Using where 29753 SUBQUERY Z ALL NULL NULL NULL NULL 2 NULL 2976select (select max(Y.a) from t1 Y where a in (select a from t1 Z) and a < X.a) as subq from t1 X; 2977subq 2978NULL 29790 2980drop table t1; 2981create table t0 (a int); 2982insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 2983create table t1 as select * from t0; 2984insert into t1 select a+10 from t0; 2985insert into t0 values(2); 2986explain select * from t1 where 2 in (select a from t0); 2987id select_type table type possible_keys key key_len ref rows Extra 29881 PRIMARY t1 ALL NULL NULL NULL NULL 20 NULL 29892 DEPENDENT SUBQUERY t0 ALL NULL NULL NULL NULL 11 Using where 2990select * from t1 where 2 in (select a from t0); 2991a 29920 29931 29942 29953 29964 29975 29986 29997 30008 30019 300210 300311 300412 300513 300614 300715 300816 300917 301018 301119 3012explain select * from (select a from t0) x where a in (select a from t1); 3013id select_type table type possible_keys key key_len ref rows Extra 30141 PRIMARY <derived2> ALL NULL NULL NULL NULL 11 Using where 30153 SUBQUERY t1 ALL NULL NULL NULL NULL 20 NULL 30162 DERIVED t0 ALL NULL NULL NULL NULL 11 NULL 3017explain format=json select * from (select a from t0) x where a in (select a from t1); 3018EXPLAIN 3019{ 3020 "query_block": { 3021 "select_id": 1, 3022 "table": { 3023 "table_name": "x", 3024 "access_type": "ALL", 3025 "rows": 11, 3026 "filtered": 100, 3027 "attached_condition": "<in_optimizer>(`x`.`a`,`x`.`a` in ( <materialize> (/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where 1 ), <primary_index_lookup>(`x`.`a` in <temporary table> on <auto_key> where ((`x`.`a` = `materialized-subquery`.`a`)))))", 3028 "attached_subqueries": [ 3029 { 3030 "table": { 3031 "table_name": "<materialized_subquery>", 3032 "access_type": "eq_ref", 3033 "key": "<auto_key>", 3034 "key_length": "5", 3035 "rows": 1, 3036 "materialized_from_subquery": { 3037 "using_temporary_table": true, 3038 "dependent": true, 3039 "cacheable": false, 3040 "query_block": { 3041 "select_id": 3, 3042 "table": { 3043 "table_name": "t1", 3044 "access_type": "ALL", 3045 "rows": 20, 3046 "filtered": 100 3047 } 3048 } 3049 } 3050 } 3051 } 3052 ], 3053 "materialized_from_subquery": { 3054 "using_temporary_table": true, 3055 "dependent": false, 3056 "cacheable": true, 3057 "query_block": { 3058 "select_id": 2, 3059 "table": { 3060 "table_name": "t0", 3061 "access_type": "ALL", 3062 "rows": 11, 3063 "filtered": 100 3064 } 3065 } 3066 } 3067 } 3068 } 3069} 3070Warnings: 3071Note 1003 /* select#1 */ select `x`.`a` AS `a` from (/* select#2 */ select `test`.`t0`.`a` AS `a` from `test`.`t0`) `x` where <in_optimizer>(`x`.`a`,`x`.`a` in ( <materialize> (/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where 1 ), <primary_index_lookup>(`x`.`a` in <temporary table> on <auto_key> where ((`x`.`a` = `materialized-subquery`.`a`))))) 3072drop table t0, t1; 3073create table t0 (a int); 3074insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 3075create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); 3076insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; 3077insert into t1 select * from t1 where kp1 < 20; 3078create table t3 (a int); 3079insert into t3 select A.a + 10*B.a from t0 A, t0 B; 3080explain select * from t3 where a in (select kp1 from t1 where kp1<20); 3081id select_type table type possible_keys key key_len ref rows Extra 30821 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where 30832 SUBQUERY t1 range kp1 kp1 5 NULL 48 Using where; Using index 3084select * from t3 where a in (select kp1 from t1 where kp1<20); 3085a 30860 30871 30882 30893 30904 30915 30926 30937 30948 30959 309610 309711 309812 309913 310014 310115 310216 310317 310418 310519 3106explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; 3107id select_type table type possible_keys key key_len ref rows Extra 31081 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where 31092 SUBQUERY t1 range kp1 kp1 5 NULL 48 Using where; Using index 3110select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; 3111a 31120 31131 31142 31153 31164 31175 31186 31197 31208 31219 312210 312311 312412 312513 312614 312715 312816 312917 313018 313119 3132create table t4 (pk int primary key); 3133insert into t4 select a from t3; 3134explain select * from t3 where a in 3135(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); 3136id select_type table type possible_keys key key_len ref rows Extra 31371 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where 31382 SUBQUERY t1 range kp1 kp1 5 NULL 48 Using where 31392 SUBQUERY t4 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 Using index 3140select * from t3 where a in 3141(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); 3142a 31430 31441 31452 31463 31474 31485 31496 31507 31518 31529 315310 315411 315512 315613 315714 315815 315916 316017 316118 316219 3163drop table t1, t3, t4; 3164create table t1 (a int); 3165insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); 3166set @save_max_heap_table_size=@@max_heap_table_size; 3167set @@max_heap_table_size= 16384; 3168# Attempt to make one test that overflows the heap table when a 3169# non-duplicate row is inserted and one test that overflows the 3170# heap table when a duplicate record is inserted. Debugging showed 3171# that these situations occurred with max_heap_table_size=16384 3172# and optimizer_join_cache_level equals 1 and 0, respectively. 3173# Finally execute a test that does not overflow the heap table. 3174explain 3175select count(*) from t0 A, t0 B, t0 C 3176where C.a in (select a from t1 D); 3177id select_type table type possible_keys key key_len ref rows Extra 31781 PRIMARY A ALL NULL NULL NULL NULL 10 NULL 31791 PRIMARY B ALL NULL NULL NULL NULL 10 Using join buffer (Block Nested Loop) 31801 PRIMARY C ALL NULL NULL NULL NULL 10 Using where; Using join buffer (Block Nested Loop) 31812 SUBQUERY D ALL NULL NULL NULL NULL 12 NULL 3182flush status; 3183select count(*) from t0 A, t0 B, t0 C 3184where C.a in (select a from t1 D); 3185count(*) 3186400 3187show status like 'Created_tmp_disk_tables'; 3188Variable_name Value 3189Created_tmp_disk_tables 0 3190set @@max_heap_table_size= @save_max_heap_table_size; 3191flush status; 3192select count(*) from t0 A, t0 B, t0 C 3193where C.a in (select a from t1 D); 3194count(*) 3195400 3196show status like 'Created_tmp_disk_tables'; 3197Variable_name Value 3198Created_tmp_disk_tables 0 3199drop table t0, t1; 3200create table t0 (a int); 3201insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 3202create table t2(a int); 3203insert into t2 values (1),(2); 3204create table t3 ( a int , filler char(100), key(a)); 3205insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; 3206explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); 3207id select_type table type possible_keys key key_len ref rows Extra 32081 PRIMARY t3 ALL a NULL NULL NULL 100 Using where 32092 SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 3210select * from t3 where a in (select a from t2); 3211a filler 32121 filler 32132 filler 3214drop table t0, t2, t3; 3215create table t1 (a date); 3216insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); 3217create table t2 (a int); 3218insert into t2 values (1),(2); 3219create table t3 (a char(10)); 3220insert into t3 select * from t1; 3221insert into t3 values (1),(2); 3222explain select * from t2 where a in (select a from t1); 3223id select_type table type possible_keys key key_len ref rows Extra 32241 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where 32252 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 4 Using where 3226explain select * from t2 where a in (select a from t2); 3227id select_type table type possible_keys key key_len ref rows Extra 32281 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where 32292 SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 3230explain select * from t2 where a in (select a from t3); 3231id select_type table type possible_keys key key_len ref rows Extra 32321 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where 32332 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 6 Using where 3234explain select * from t1 where a in (select a from t3); 3235id select_type table type possible_keys key key_len ref rows Extra 32361 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where 32372 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 6 Using where 3238drop table t1, t2, t3; 3239create table t1 (a decimal); 3240insert into t1 values (1),(2); 3241explain select * from t1 where a in (select a from t1); 3242id select_type table type possible_keys key key_len ref rows Extra 32431 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 32442 SUBQUERY t1 ALL NULL NULL NULL NULL 2 NULL 3245drop table t1; 3246create table t1 (a int); 3247insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 3248create table t2 as select * from t1; 3249create table t3 (a int, b int, filler char(100), key(a)); 3250insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; 3251explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; 3252id select_type table type possible_keys key key_len ref rows Extra 32531 PRIMARY t1 ALL NULL NULL NULL NULL 10 Using where 32541 PRIMARY t3 ALL a NULL NULL NULL 1000 Using where; Using join buffer (Block Nested Loop) 32552 SUBQUERY t2 ALL NULL NULL NULL NULL 10 NULL 3256explain 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; 3257EXPLAIN 3258{ 3259 "query_block": { 3260 "select_id": 1, 3261 "nested_loop": [ 3262 { 3263 "table": { 3264 "table_name": "t1", 3265 "access_type": "ALL", 3266 "rows": 10, 3267 "filtered": 100, 3268 "attached_condition": "(`test`.`t1`.`a` = 3)" 3269 } 3270 }, 3271 { 3272 "table": { 3273 "table_name": "t3", 3274 "access_type": "ALL", 3275 "possible_keys": [ 3276 "a" 3277 ], 3278 "rows": 1000, 3279 "filtered": 79.3, 3280 "using_join_buffer": "Block Nested Loop", 3281 "attached_condition": "(<in_optimizer>(`test`.`t3`.`a`,`test`.`t3`.`a` in ( <materialize> (/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where 1 ), <primary_index_lookup>(`test`.`t3`.`a` in <temporary table> on <auto_key> where ((`test`.`t3`.`a` = `materialized-subquery`.`a`))))) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30)))", 3282 "attached_subqueries": [ 3283 { 3284 "table": { 3285 "table_name": "<materialized_subquery>", 3286 "access_type": "eq_ref", 3287 "key": "<auto_key>", 3288 "key_length": "5", 3289 "rows": 1, 3290 "materialized_from_subquery": { 3291 "using_temporary_table": true, 3292 "dependent": true, 3293 "cacheable": false, 3294 "query_block": { 3295 "select_id": 2, 3296 "table": { 3297 "table_name": "t2", 3298 "access_type": "ALL", 3299 "rows": 10, 3300 "filtered": 100 3301 } 3302 } 3303 } 3304 } 3305 } 3306 ] 3307 } 3308 } 3309 ] 3310 } 3311} 3312Warnings: 3313Note 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` where ((`test`.`t1`.`a` = 3) and <in_optimizer>(`test`.`t3`.`a`,`test`.`t3`.`a` in ( <materialize> (/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where 1 ), <primary_index_lookup>(`test`.`t3`.`a` in <temporary table> on <auto_key> where ((`test`.`t3`.`a` = `materialized-subquery`.`a`))))) and ((`test`.`t3`.`a` < 10) or (`test`.`t3`.`a` > 30))) 3314explain select straight_join * from t1 A, t1 B where A.a in (select a from t2); 3315id select_type table type possible_keys key key_len ref rows Extra 33161 PRIMARY A ALL NULL NULL NULL NULL 10 Using where 33171 PRIMARY B ALL NULL NULL NULL NULL 10 Using join buffer (Block Nested Loop) 33182 SUBQUERY t2 ALL NULL NULL NULL NULL 10 NULL 3319explain select * from t2 where a in (select straight_join A.a from t1 A, t1 B); 3320id select_type table type possible_keys key key_len ref rows Extra 33211 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where 33222 SUBQUERY A ALL NULL NULL NULL NULL 10 NULL 33232 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer (Block Nested Loop) 3324explain select * from t2 where a in (select straight_join A.a from t1 A, t1 B); 3325id select_type table type possible_keys key key_len ref rows Extra 33261 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where 33272 SUBQUERY A ALL NULL NULL NULL NULL 10 NULL 33282 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer (Block Nested Loop) 3329explain select straight_join * from t2 X, t2 Y 3330where X.a in (select straight_join A.a from t1 A, t1 B); 3331id select_type table type possible_keys key key_len ref rows Extra 33321 PRIMARY X ALL NULL NULL NULL NULL 10 Using where 33331 PRIMARY Y ALL NULL NULL NULL NULL 10 Using join buffer (Block Nested Loop) 33342 SUBQUERY A ALL NULL NULL NULL NULL 10 NULL 33352 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer (Block Nested Loop) 3336create table t0 (a int, b int); 3337insert into t0 values(1,1); 3338explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); 3339id select_type table type possible_keys key key_len ref rows Extra 33401 PRIMARY t0 system NULL NULL NULL NULL 1 NULL 33411 PRIMARY t3 ALL a NULL NULL NULL 1000 Using where 33422 SUBQUERY t2 ALL NULL NULL NULL NULL 10 NULL 3343create table t4 as select a as x, a as y from t1; 3344explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); 3345id select_type table type possible_keys key key_len ref rows Extra 33461 PRIMARY t0 system NULL NULL NULL NULL 1 NULL 33471 PRIMARY t3 ALL a NULL NULL NULL 1000 Using where 33482 SUBQUERY t4 ALL NULL NULL NULL NULL 10 NULL 3349drop table t0,t1,t2,t3,t4; 3350create table t0 (a int); 3351insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 3352create table t1 (a int, b int, filler char(100), key(a,b)); 3353insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; 3354create table t2 as select * from t1; 3355explain select * from t2 where a in (select b from t1 where a=3); 3356id select_type table type possible_keys key key_len ref rows Extra 33571 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where 33582 SUBQUERY t1 ref a a 5 const 8 Using index 3359explain select * from t2 where (b,a) in (select a,b from t1 where a=3); 3360id select_type table type possible_keys key key_len ref rows Extra 33611 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where 33622 SUBQUERY t1 ref a a 5 const 8 Using index 3363drop table t1,t2; 3364create table t1 (a int, b int); 3365insert into t1 select a,a from t0; 3366create table t2 (a int, b int); 3367insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; 3368explain select * from t1 where (a,b) in (select a,b from t2); 3369id select_type table type possible_keys key key_len ref rows Extra 33701 PRIMARY t1 ALL NULL NULL NULL NULL 10 Using where 33712 SUBQUERY t2 ALL NULL NULL NULL NULL 100 NULL 3372drop table t0, t1, t2; 3373create table t0 (a decimal(4,2)); 3374insert into t0 values (10.24), (22.11); 3375create table t1 as select * from t0; 3376insert into t1 select * from t0; 3377explain select * from t0 where a in (select a from t1); 3378id select_type table type possible_keys key key_len ref rows Extra 33791 PRIMARY t0 ALL NULL NULL NULL NULL 2 Using where 33802 SUBQUERY t1 ALL NULL NULL NULL NULL 4 NULL 3381select * from t0 where a in (select a from t1); 3382a 338310.24 338422.11 3385drop table t0, t1; 3386create table t0(a date); 3387insert into t0 values ('2008-01-01'),('2008-02-02'); 3388create table t1 as select * from t0; 3389insert into t1 select * from t0; 3390explain select * from t0 where a in (select a from t1); 3391id select_type table type possible_keys key key_len ref rows Extra 33921 PRIMARY t0 ALL NULL NULL NULL NULL 2 Using where 33932 SUBQUERY t1 ALL NULL NULL NULL NULL 4 NULL 3394select * from t0 where a in (select a from t1); 3395a 33962008-01-01 33972008-02-02 3398drop table t0, t1; 3399create table t0(a int); 3400insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 3401create table t1 as select a as a, a as b, a as c from t0 where a < 3; 3402create table t2 as select a as a, a as b from t0 where a < 3; 3403insert into t2 select * from t2; 3404explain 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); 3405id select_type table type possible_keys key key_len ref rows Extra 34061 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where 34072 SUBQUERY X ALL NULL NULL NULL NULL 6 Using where 34082 SUBQUERY Y ALL NULL NULL NULL NULL 6 Using join buffer (Block Nested Loop) 34092 SUBQUERY Z ALL NULL NULL NULL NULL 6 Using join buffer (Block Nested Loop) 3410drop table t0,t1,t2; 3411set @save_join_buffer_size = @@join_buffer_size; 3412set join_buffer_size= 8192; 3413create table t0 (a int); 3414insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 3415create table t1 (a int, filler1 binary(200), filler2 binary(200)); 3416insert into t1 select a, 'filler123456', 'filler123456' from t0; 3417insert into t1 select a+10, 'filler123456', 'filler123456' from t0; 3418create table t2 as select * from t1; 3419insert into t1 select a+20, 'filler123456', 'filler123456' from t0; 3420insert into t1 values (2, 'duplicate ok', 'duplicate ok'); 3421insert into t1 values (18, 'duplicate ok', 'duplicate ok'); 3422insert into t2 values (3, 'duplicate ok', 'duplicate ok'); 3423insert into t2 values (19, 'duplicate ok', 'duplicate ok'); 3424explain select 3425a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z 3426from t1 ot where a in (select a from t2 it); 3427id select_type table type possible_keys key key_len ref rows Extra 34281 PRIMARY ot ALL NULL NULL NULL NULL 32 Using where 34292 SUBQUERY it ALL NULL NULL NULL NULL 22 NULL 3430select 3431a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z 3432from t1 ot where a in (select a from t2 it); 3433a mid(filler1, 1,10) Z 34340 filler1234 1 34351 filler1234 1 343610 filler1234 1 343711 filler1234 1 343812 filler1234 1 343913 filler1234 1 344014 filler1234 1 344115 filler1234 1 344216 filler1234 1 344317 filler1234 1 344418 duplicate 1 344518 filler1234 1 344619 filler1234 1 34472 duplicate 1 34482 filler1234 1 34493 filler1234 1 34504 filler1234 1 34515 filler1234 1 34526 filler1234 1 34537 filler1234 1 34548 filler1234 1 34559 filler1234 1 3456explain select 3457a, mid(filler1, 1,10), length(filler1)=length(filler2) 3458from t2 ot where a in (select a from t1 it); 3459id select_type table type possible_keys key key_len ref rows Extra 34601 PRIMARY ot ALL NULL NULL NULL NULL 22 Using where 34612 SUBQUERY it ALL NULL NULL NULL NULL 32 NULL 3462select 3463a, mid(filler1, 1,10), length(filler1)=length(filler2) 3464from t2 ot where a in (select a from t1 it); 3465a mid(filler1, 1,10) length(filler1)=length(filler2) 34660 filler1234 1 34671 filler1234 1 346810 filler1234 1 346911 filler1234 1 347012 filler1234 1 347113 filler1234 1 347214 filler1234 1 347315 filler1234 1 347416 filler1234 1 347517 filler1234 1 347618 filler1234 1 347719 duplicate 1 347819 filler1234 1 34792 filler1234 1 34803 duplicate 1 34813 filler1234 1 34824 filler1234 1 34835 filler1234 1 34846 filler1234 1 34857 filler1234 1 34868 filler1234 1 34879 filler1234 1 3488insert into t1 select a+20, 'filler123456', 'filler123456' from t0; 3489insert into t1 select a+20, 'filler123456', 'filler123456' from t0; 3490explain select 3491a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z 3492from t1 ot where a in (select a from t2 it); 3493id select_type table type possible_keys key key_len ref rows Extra 34941 PRIMARY ot ALL NULL NULL NULL NULL 52 Using where 34952 SUBQUERY it ALL NULL NULL NULL NULL 22 NULL 3496select 3497a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z 3498from t1 ot where a in (select a from t2 it); 3499a mid(filler1, 1,10) Z 35000 filler1234 1 35011 filler1234 1 350210 filler1234 1 350311 filler1234 1 350412 filler1234 1 350513 filler1234 1 350614 filler1234 1 350715 filler1234 1 350816 filler1234 1 350917 filler1234 1 351018 duplicate 1 351118 filler1234 1 351219 filler1234 1 35132 duplicate 1 35142 filler1234 1 35153 filler1234 1 35164 filler1234 1 35175 filler1234 1 35186 filler1234 1 35197 filler1234 1 35208 filler1234 1 35219 filler1234 1 3522explain select 3523a, mid(filler1, 1,10), length(filler1)=length(filler2) 3524from t2 ot where a in (select a from t1 it); 3525id select_type table type possible_keys key key_len ref rows Extra 35261 PRIMARY ot ALL NULL NULL NULL NULL 22 Using where 35272 SUBQUERY it ALL NULL NULL NULL NULL 52 NULL 3528select 3529a, mid(filler1, 1,10), length(filler1)=length(filler2) 3530from t2 ot where a in (select a from t1 it); 3531a mid(filler1, 1,10) length(filler1)=length(filler2) 35320 filler1234 1 35331 filler1234 1 353410 filler1234 1 353511 filler1234 1 353612 filler1234 1 353713 filler1234 1 353814 filler1234 1 353915 filler1234 1 354016 filler1234 1 354117 filler1234 1 354218 filler1234 1 354319 duplicate 1 354419 filler1234 1 35452 filler1234 1 35463 duplicate 1 35473 filler1234 1 35484 filler1234 1 35495 filler1234 1 35506 filler1234 1 35517 filler1234 1 35528 filler1234 1 35539 filler1234 1 3554set @@join_buffer_size = @save_join_buffer_size; 3555drop table t1, t2; 3556create table t1 (a int, b int, key(a)); 3557create table t2 (a int, b int, key(a)); 3558create table t3 (a int, b int, key(a)); 3559insert into t1 select a,a from t0; 3560insert into t2 select a,a from t0; 3561insert into t3 select a,a from t0; 3562t2 and t3 must be use 'ref', not 'ALL': 3563explain select * 3564from t0 where a in 3565(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); 3566id select_type table type possible_keys key key_len ref rows Extra 35671 PRIMARY t0 ALL NULL NULL NULL NULL 10 Using where 35682 SUBQUERY t1 index a a 5 NULL 10 Using index 35692 SUBQUERY t2 ref a a 5 test.t1.a 1 Using index 35702 SUBQUERY t3 ref a a 5 test.t1.a 1 Using index 3571drop table t0, t1,t2,t3; 3572 3573Test that neither MaterializeLookup strategy for semijoin, 3574nor subquery materialization is used when BLOBs are involved 3575(except when arguments of some functions). 3576 3577set @prefix_len = 6; 3578set @blob_len = 16; 3579set @suffix_len = @blob_len - @prefix_len; 3580create table t1_16 (a1 blob(16), a2 blob(16)); 3581create table t2_16 (b1 blob(16), b2 blob(16)); 3582create table t3_16 (c1 blob(16), c2 blob(16)); 3583insert into t1_16 values 3584(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); 3585insert into t1_16 values 3586(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 3587insert into t1_16 values 3588(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 3589insert into t2_16 values 3590(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 3591insert into t2_16 values 3592(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 3593insert into t2_16 values 3594(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 3595insert into t3_16 values 3596(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 3597insert into t3_16 values 3598(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 3599insert into t3_16 values 3600(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 3601insert into t3_16 values 3602(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); 3603explain extended select left(a1,7), left(a2,7) 3604from t1_16 3605where a1 in (select b1 from t2_16 where b1 > '0'); 3606id select_type table type possible_keys key key_len ref rows filtered Extra 36071 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where 36082 DEPENDENT SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where 3609Warnings: 3610Note 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 <in_optimizer>(`test`.`t1_16`.`a1`,<exists>(/* select#2 */ select 1 from `test`.`t2_16` where ((`test`.`t2_16`.`b1` > '0') and (<cache>(`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1`)))) 3611select left(a1,7), left(a2,7) 3612from t1_16 3613where a1 in (select b1 from t2_16 where b1 > '0'); 3614left(a1,7) left(a2,7) 36151 - 01x 2 - 01x 36161 - 02x 2 - 02x 3617explain extended select left(a1,7), left(a2,7) 3618from t1_16 3619where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); 3620id select_type table type possible_keys key key_len ref rows filtered Extra 36211 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where 36222 DEPENDENT SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where 3623Warnings: 3624Note 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 <in_optimizer>((`test`.`t1_16`.`a1`,`test`.`t1_16`.`a2`),<exists>(/* select#2 */ select 1,1 from `test`.`t2_16` where ((`test`.`t2_16`.`b1` > '0') and (<cache>(`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1`) and (<cache>(`test`.`t1_16`.`a2`) = `test`.`t2_16`.`b2`)))) 3625select left(a1,7), left(a2,7) 3626from t1_16 3627where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); 3628left(a1,7) left(a2,7) 36291 - 01x 2 - 01x 36301 - 02x 2 - 02x 3631explain extended select left(a1,7), left(a2,7) 3632from t1_16 3633where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); 3634id select_type table type possible_keys key key_len ref rows filtered Extra 36351 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where 36362 SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where 3637Warnings: 3638Note 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 <in_optimizer>(`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in ( <materialize> (/* select#2 */ select substr(`test`.`t2_16`.`b1`,1,16) from `test`.`t2_16` where (`test`.`t2_16`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1_16`.`a1` in <temporary table> on <auto_key> where ((`test`.`t1_16`.`a1` = `materialized-subquery`.`substring(b1,1,16)`))))) 3639select left(a1,7), left(a2,7) 3640from t1_16 3641where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); 3642left(a1,7) left(a2,7) 36431 - 01x 2 - 01x 36441 - 02x 2 - 02x 3645explain extended select left(a1,7), left(a2,7) 3646from t1_16 3647where a1 in (select group_concat(b1) from t2_16 group by b2); 3648id select_type table type possible_keys key key_len ref rows filtered Extra 36491 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where 36502 DEPENDENT SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using filesort 3651Warnings: 3652Note 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 <in_optimizer>(`test`.`t1_16`.`a1`,<exists>(/* select#2 */ select 1 from `test`.`t2_16` group by `test`.`t2_16`.`b2` having (<cache>(`test`.`t1_16`.`a1`) = <ref_null_helper>(group_concat(`test`.`t2_16`.`b1` separator ','))))) 3653select left(a1,7), left(a2,7) 3654from t1_16 3655where a1 in (select group_concat(b1) from t2_16 group by b2); 3656left(a1,7) left(a2,7) 36571 - 01x 2 - 01x 36581 - 02x 2 - 02x 3659set @@group_concat_max_len = 256; 3660explain extended select left(a1,7), left(a2,7) 3661from t1_16 3662where a1 in (select group_concat(b1) from t2_16 group by b2); 3663id select_type table type possible_keys key key_len ref rows filtered Extra 36641 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where 36652 SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using filesort 3666Warnings: 3667Note 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 <in_optimizer>(`test`.`t1_16`.`a1`,`test`.`t1_16`.`a1` in ( <materialize> (/* select#2 */ select group_concat(`test`.`t2_16`.`b1` separator ',') from `test`.`t2_16` group by `test`.`t2_16`.`b2` having 1 ), <primary_index_lookup>(`test`.`t1_16`.`a1` in <temporary table> on <auto_key> where ((`test`.`t1_16`.`a1` = `materialized-subquery`.`group_concat(b1)`))))) 3668select left(a1,7), left(a2,7) 3669from t1_16 3670where a1 in (select group_concat(b1) from t2_16 group by b2); 3671left(a1,7) left(a2,7) 36721 - 01x 2 - 01x 36731 - 02x 2 - 02x 3674create table t1 (a1 char(8), a2 char(8)); 3675create table t2 (b1 char(8), b2 char(8)); 3676create table t3 (c1 char(8), c2 char(8)); 3677insert into t1 values ('1 - 00', '2 - 00'); 3678insert into t1 values ('1 - 01', '2 - 01'); 3679insert into t1 values ('1 - 02', '2 - 02'); 3680insert into t2 values ('1 - 01', '2 - 01'); 3681insert into t2 values ('1 - 01', '2 - 01'); 3682insert into t2 values ('1 - 02', '2 - 02'); 3683insert into t2 values ('1 - 02', '2 - 02'); 3684insert into t2 values ('1 - 03', '2 - 03'); 3685insert into t3 values ('1 - 01', '2 - 01'); 3686insert into t3 values ('1 - 02', '2 - 02'); 3687insert into t3 values ('1 - 03', '2 - 03'); 3688insert into t3 values ('1 - 04', '2 - 04'); 3689explain extended 3690select * from t1 3691where concat(a1,'x') IN 3692(select left(a1,8) from t1_16 3693where (a1, a2) IN 3694(select t2_16.b1, t2_16.b2 from t2_16, t2 3695where t2.b2 = substring(t2_16.b2,1,6) and 3696t2.b1 IN (select c1 from t3 where c2 > '0'))); 3697id select_type table type possible_keys key key_len ref rows filtered Extra 36981 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 36992 DEPENDENT SUBQUERY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where 37003 DEPENDENT SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where 37013 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (Block Nested Loop) 37024 SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where 3703Warnings: 3704Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <in_optimizer>(concat(`test`.`t1`.`a1`,'x'),<exists>(/* select#2 */ select 1 from `test`.`t1_16` where (<in_optimizer>((`test`.`t1_16`.`a1`,`test`.`t1_16`.`a2`),<exists>(/* select#3 */ select 1,1 from `test`.`t2_16` join `test`.`t2` where ((`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and <in_optimizer>(`test`.`t2`.`b1`,`test`.`t2`.`b1` in ( <materialize> (/* select#4 */ select `test`.`t3`.`c1` from `test`.`t3` where (`test`.`t3`.`c2` > '0') ), <primary_index_lookup>(`test`.`t2`.`b1` in <temporary table> on <auto_key> where ((`test`.`t2`.`b1` = `materialized-subquery`.`c1`))))) and (<cache>(`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1`) and (<cache>(`test`.`t1_16`.`a2`) = `test`.`t2_16`.`b2`)))) and (<cache>(concat(`test`.`t1`.`a1`,'x')) = left(`test`.`t1_16`.`a1`,8))))) 3705drop table t1_16, t2_16, t3_16, t1, t2, t3; 3706set @blob_len = 512; 3707set @suffix_len = @blob_len - @prefix_len; 3708create table t1_512 (a1 blob(512), a2 blob(512)); 3709create table t2_512 (b1 blob(512), b2 blob(512)); 3710create table t3_512 (c1 blob(512), c2 blob(512)); 3711insert into t1_512 values 3712(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); 3713insert into t1_512 values 3714(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 3715insert into t1_512 values 3716(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 3717insert into t2_512 values 3718(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 3719insert into t2_512 values 3720(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 3721insert into t2_512 values 3722(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 3723insert into t3_512 values 3724(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 3725insert into t3_512 values 3726(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 3727insert into t3_512 values 3728(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 3729insert into t3_512 values 3730(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); 3731explain extended select left(a1,7), left(a2,7) 3732from t1_512 3733where a1 in (select b1 from t2_512 where b1 > '0'); 3734id select_type table type possible_keys key key_len ref rows filtered Extra 37351 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where 37362 DEPENDENT SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where 3737Warnings: 3738Note 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 <in_optimizer>(`test`.`t1_512`.`a1`,<exists>(/* select#2 */ select 1 from `test`.`t2_512` where ((`test`.`t2_512`.`b1` > '0') and (<cache>(`test`.`t1_512`.`a1`) = `test`.`t2_512`.`b1`)))) 3739select left(a1,7), left(a2,7) 3740from t1_512 3741where a1 in (select b1 from t2_512 where b1 > '0'); 3742left(a1,7) left(a2,7) 37431 - 01x 2 - 01x 37441 - 02x 2 - 02x 3745explain extended select left(a1,7), left(a2,7) 3746from t1_512 3747where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); 3748id select_type table type possible_keys key key_len ref rows filtered Extra 37491 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where 37502 DEPENDENT SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where 3751Warnings: 3752Note 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 <in_optimizer>((`test`.`t1_512`.`a1`,`test`.`t1_512`.`a2`),<exists>(/* select#2 */ select 1,1 from `test`.`t2_512` where ((`test`.`t2_512`.`b1` > '0') and (<cache>(`test`.`t1_512`.`a1`) = `test`.`t2_512`.`b1`) and (<cache>(`test`.`t1_512`.`a2`) = `test`.`t2_512`.`b2`)))) 3753select left(a1,7), left(a2,7) 3754from t1_512 3755where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); 3756left(a1,7) left(a2,7) 37571 - 01x 2 - 01x 37581 - 02x 2 - 02x 3759explain extended select left(a1,7), left(a2,7) 3760from t1_512 3761where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); 3762id select_type table type possible_keys key key_len ref rows filtered Extra 37631 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where 37642 SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where 3765Warnings: 3766Note 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 <in_optimizer>(`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( <materialize> (/* select#2 */ select substr(`test`.`t2_512`.`b1`,1,512) from `test`.`t2_512` where (`test`.`t2_512`.`b1` > '0') ), <primary_index_lookup>(`test`.`t1_512`.`a1` in <temporary table> on <auto_key> where ((`test`.`t1_512`.`a1` = `materialized-subquery`.`substring(b1,1,512)`))))) 3767select left(a1,7), left(a2,7) 3768from t1_512 3769where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); 3770left(a1,7) left(a2,7) 37711 - 01x 2 - 01x 37721 - 02x 2 - 02x 3773explain extended select left(a1,7), left(a2,7) 3774from t1_512 3775where a1 in (select group_concat(b1) from t2_512 group by b2); 3776id select_type table type possible_keys key key_len ref rows filtered Extra 37771 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where 37782 SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using filesort 3779Warnings: 3780Note 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 <in_optimizer>(`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( <materialize> (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having 1 ), <primary_index_lookup>(`test`.`t1_512`.`a1` in <temporary table> on <auto_key> where ((`test`.`t1_512`.`a1` = `materialized-subquery`.`group_concat(b1)`))))) 3781select left(a1,7), left(a2,7) 3782from t1_512 3783where a1 in (select group_concat(b1) from t2_512 group by b2); 3784left(a1,7) left(a2,7) 3785Warnings: 3786Warning 1260 Row 1 was cut by GROUP_CONCAT() 3787Warning 1260 Row 2 was cut by GROUP_CONCAT() 3788Warning 1260 Row 3 was cut by GROUP_CONCAT() 3789set @@group_concat_max_len = 256; 3790explain extended select left(a1,7), left(a2,7) 3791from t1_512 3792where a1 in (select group_concat(b1) from t2_512 group by b2); 3793id select_type table type possible_keys key key_len ref rows filtered Extra 37941 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where 37952 SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using filesort 3796Warnings: 3797Note 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 <in_optimizer>(`test`.`t1_512`.`a1`,`test`.`t1_512`.`a1` in ( <materialize> (/* select#2 */ select group_concat(`test`.`t2_512`.`b1` separator ',') from `test`.`t2_512` group by `test`.`t2_512`.`b2` having 1 ), <primary_index_lookup>(`test`.`t1_512`.`a1` in <temporary table> on <auto_key> where ((`test`.`t1_512`.`a1` = `materialized-subquery`.`group_concat(b1)`))))) 3798select left(a1,7), left(a2,7) 3799from t1_512 3800where a1 in (select group_concat(b1) from t2_512 group by b2); 3801left(a1,7) left(a2,7) 3802Warnings: 3803Warning 1260 Row 1 was cut by GROUP_CONCAT() 3804Warning 1260 Row 2 was cut by GROUP_CONCAT() 3805Warning 1260 Row 3 was cut by GROUP_CONCAT() 3806drop table t1_512, t2_512, t3_512; 3807set @blob_len = 513; 3808set @suffix_len = @blob_len - @prefix_len; 3809create table t1_513 (a1 blob(513), a2 blob(513)); 3810create table t2_513 (b1 blob(513), b2 blob(513)); 3811create table t3_513 (c1 blob(513), c2 blob(513)); 3812insert into t1_513 values 3813(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); 3814insert into t1_513 values 3815(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 3816insert into t1_513 values 3817(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 3818insert into t2_513 values 3819(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 3820insert into t2_513 values 3821(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 3822insert into t2_513 values 3823(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 3824insert into t3_513 values 3825(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 3826insert into t3_513 values 3827(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 3828insert into t3_513 values 3829(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 3830insert into t3_513 values 3831(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); 3832explain extended select left(a1,7), left(a2,7) 3833from t1_513 3834where a1 in (select b1 from t2_513 where b1 > '0'); 3835id select_type table type possible_keys key key_len ref rows filtered Extra 38361 PRIMARY t1_513 ALL NULL NULL NULL NULL 3 100.00 Using where 38372 DEPENDENT SUBQUERY t2_513 ALL NULL NULL NULL NULL 3 100.00 Using where 3838Warnings: 3839Note 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 <in_optimizer>(`test`.`t1_513`.`a1`,<exists>(/* select#2 */ select 1 from `test`.`t2_513` where ((`test`.`t2_513`.`b1` > '0') and (<cache>(`test`.`t1_513`.`a1`) = `test`.`t2_513`.`b1`)))) 3840select left(a1,7), left(a2,7) 3841from t1_513 3842where a1 in (select b1 from t2_513 where b1 > '0'); 3843left(a1,7) left(a2,7) 38441 - 01x 2 - 01x 38451 - 02x 2 - 02x 3846explain extended select left(a1,7), left(a2,7) 3847from t1_513 3848where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); 3849id select_type table type possible_keys key key_len ref rows filtered Extra 38501 PRIMARY t1_513 ALL NULL NULL NULL NULL 3 100.00 Using where 38512 DEPENDENT SUBQUERY t2_513 ALL NULL NULL NULL NULL 3 100.00 Using where 3852Warnings: 3853Note 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 <in_optimizer>((`test`.`t1_513`.`a1`,`test`.`t1_513`.`a2`),<exists>(/* select#2 */ select 1,1 from `test`.`t2_513` where ((`test`.`t2_513`.`b1` > '0') and (<cache>(`test`.`t1_513`.`a1`) = `test`.`t2_513`.`b1`) and (<cache>(`test`.`t1_513`.`a2`) = `test`.`t2_513`.`b2`)))) 3854select left(a1,7), left(a2,7) 3855from t1_513 3856where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); 3857left(a1,7) left(a2,7) 38581 - 01x 2 - 01x 38591 - 02x 2 - 02x 3860explain extended select left(a1,7), left(a2,7) 3861from t1_513 3862where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); 3863id select_type table type possible_keys key key_len ref rows filtered Extra 38641 PRIMARY t1_513 ALL NULL NULL NULL NULL 3 100.00 Using where 38652 DEPENDENT SUBQUERY t2_513 ALL NULL NULL NULL NULL 3 100.00 Using where 3866Warnings: 3867Note 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 <in_optimizer>(`test`.`t1_513`.`a1`,<exists>(/* select#2 */ select 1 from `test`.`t2_513` where ((`test`.`t2_513`.`b1` > '0') and (<cache>(`test`.`t1_513`.`a1`) = substr(`test`.`t2_513`.`b1`,1,513))))) 3868select left(a1,7), left(a2,7) 3869from t1_513 3870where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); 3871left(a1,7) left(a2,7) 38721 - 01x 2 - 01x 38731 - 02x 2 - 02x 3874explain extended select left(a1,7), left(a2,7) 3875from t1_513 3876where a1 in (select group_concat(b1) from t2_513 group by b2); 3877id select_type table type possible_keys key key_len ref rows filtered Extra 38781 PRIMARY t1_513 ALL NULL NULL NULL NULL 3 100.00 Using where 38792 SUBQUERY t2_513 ALL NULL NULL NULL NULL 3 100.00 Using filesort 3880Warnings: 3881Note 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 <in_optimizer>(`test`.`t1_513`.`a1`,`test`.`t1_513`.`a1` in ( <materialize> (/* select#2 */ select group_concat(`test`.`t2_513`.`b1` separator ',') from `test`.`t2_513` group by `test`.`t2_513`.`b2` having 1 ), <primary_index_lookup>(`test`.`t1_513`.`a1` in <temporary table> on <auto_key> where ((`test`.`t1_513`.`a1` = `materialized-subquery`.`group_concat(b1)`))))) 3882select left(a1,7), left(a2,7) 3883from t1_513 3884where a1 in (select group_concat(b1) from t2_513 group by b2); 3885left(a1,7) left(a2,7) 3886Warnings: 3887Warning 1260 Row 1 was cut by GROUP_CONCAT() 3888Warning 1260 Row 2 was cut by GROUP_CONCAT() 3889Warning 1260 Row 3 was cut by GROUP_CONCAT() 3890drop table t1_513, t2_513, t3_513; 3891set @blob_len = 1024; 3892set @suffix_len = @blob_len - @prefix_len; 3893create table t1_1024 (a1 blob(1024), a2 blob(1024)); 3894create table t2_1024 (b1 blob(1024), b2 blob(1024)); 3895create table t3_1024 (c1 blob(1024), c2 blob(1024)); 3896insert into t1_1024 values 3897(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); 3898insert into t1_1024 values 3899(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 3900insert into t1_1024 values 3901(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 3902insert into t2_1024 values 3903(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 3904insert into t2_1024 values 3905(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 3906insert into t2_1024 values 3907(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 3908insert into t3_1024 values 3909(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 3910insert into t3_1024 values 3911(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 3912insert into t3_1024 values 3913(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 3914insert into t3_1024 values 3915(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); 3916explain extended select left(a1,7), left(a2,7) 3917from t1_1024 3918where a1 in (select b1 from t2_1024 where b1 > '0'); 3919id select_type table type possible_keys key key_len ref rows filtered Extra 39201 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where 39212 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where 3922Warnings: 3923Note 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 <in_optimizer>(`test`.`t1_1024`.`a1`,<exists>(/* select#2 */ select 1 from `test`.`t2_1024` where ((`test`.`t2_1024`.`b1` > '0') and (<cache>(`test`.`t1_1024`.`a1`) = `test`.`t2_1024`.`b1`)))) 3924select left(a1,7), left(a2,7) 3925from t1_1024 3926where a1 in (select b1 from t2_1024 where b1 > '0'); 3927left(a1,7) left(a2,7) 39281 - 01x 2 - 01x 39291 - 02x 2 - 02x 3930explain extended select left(a1,7), left(a2,7) 3931from t1_1024 3932where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); 3933id select_type table type possible_keys key key_len ref rows filtered Extra 39341 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where 39352 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where 3936Warnings: 3937Note 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 <in_optimizer>((`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a2`),<exists>(/* select#2 */ select 1,1 from `test`.`t2_1024` where ((`test`.`t2_1024`.`b1` > '0') and (<cache>(`test`.`t1_1024`.`a1`) = `test`.`t2_1024`.`b1`) and (<cache>(`test`.`t1_1024`.`a2`) = `test`.`t2_1024`.`b2`)))) 3938select left(a1,7), left(a2,7) 3939from t1_1024 3940where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); 3941left(a1,7) left(a2,7) 39421 - 01x 2 - 01x 39431 - 02x 2 - 02x 3944explain extended select left(a1,7), left(a2,7) 3945from t1_1024 3946where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); 3947id select_type table type possible_keys key key_len ref rows filtered Extra 39481 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where 39492 DEPENDENT SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where 3950Warnings: 3951Note 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 <in_optimizer>(`test`.`t1_1024`.`a1`,<exists>(/* select#2 */ select 1 from `test`.`t2_1024` where ((`test`.`t2_1024`.`b1` > '0') and (<cache>(`test`.`t1_1024`.`a1`) = substr(`test`.`t2_1024`.`b1`,1,1024))))) 3952select left(a1,7), left(a2,7) 3953from t1_1024 3954where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); 3955left(a1,7) left(a2,7) 39561 - 01x 2 - 01x 39571 - 02x 2 - 02x 3958explain extended select left(a1,7), left(a2,7) 3959from t1_1024 3960where a1 in (select group_concat(b1) from t2_1024 group by b2); 3961id select_type table type possible_keys key key_len ref rows filtered Extra 39621 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where 39632 SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using filesort 3964Warnings: 3965Note 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 <in_optimizer>(`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( <materialize> (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having 1 ), <primary_index_lookup>(`test`.`t1_1024`.`a1` in <temporary table> on <auto_key> where ((`test`.`t1_1024`.`a1` = `materialized-subquery`.`group_concat(b1)`))))) 3966select left(a1,7), left(a2,7) 3967from t1_1024 3968where a1 in (select group_concat(b1) from t2_1024 group by b2); 3969left(a1,7) left(a2,7) 3970Warnings: 3971Warning 1260 Row 1 was cut by GROUP_CONCAT() 3972Warning 1260 Row 2 was cut by GROUP_CONCAT() 3973Warning 1260 Row 3 was cut by GROUP_CONCAT() 3974set @@group_concat_max_len = 256; 3975explain extended select left(a1,7), left(a2,7) 3976from t1_1024 3977where a1 in (select group_concat(b1) from t2_1024 group by b2); 3978id select_type table type possible_keys key key_len ref rows filtered Extra 39791 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where 39802 SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using filesort 3981Warnings: 3982Note 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 <in_optimizer>(`test`.`t1_1024`.`a1`,`test`.`t1_1024`.`a1` in ( <materialize> (/* select#2 */ select group_concat(`test`.`t2_1024`.`b1` separator ',') from `test`.`t2_1024` group by `test`.`t2_1024`.`b2` having 1 ), <primary_index_lookup>(`test`.`t1_1024`.`a1` in <temporary table> on <auto_key> where ((`test`.`t1_1024`.`a1` = `materialized-subquery`.`group_concat(b1)`))))) 3983select left(a1,7), left(a2,7) 3984from t1_1024 3985where a1 in (select group_concat(b1) from t2_1024 group by b2); 3986left(a1,7) left(a2,7) 3987Warnings: 3988Warning 1260 Row 1 was cut by GROUP_CONCAT() 3989Warning 1260 Row 2 was cut by GROUP_CONCAT() 3990Warning 1260 Row 3 was cut by GROUP_CONCAT() 3991drop table t1_1024, t2_1024, t3_1024; 3992set @blob_len = 1025; 3993set @suffix_len = @blob_len - @prefix_len; 3994create table t1_1025 (a1 blob(1025), a2 blob(1025)); 3995create table t2_1025 (b1 blob(1025), b2 blob(1025)); 3996create table t3_1025 (c1 blob(1025), c2 blob(1025)); 3997insert into t1_1025 values 3998(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); 3999insert into t1_1025 values 4000(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 4001insert into t1_1025 values 4002(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 4003insert into t2_1025 values 4004(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 4005insert into t2_1025 values 4006(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 4007insert into t2_1025 values 4008(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 4009insert into t3_1025 values 4010(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 4011insert into t3_1025 values 4012(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 4013insert into t3_1025 values 4014(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 4015insert into t3_1025 values 4016(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); 4017explain extended select left(a1,7), left(a2,7) 4018from t1_1025 4019where a1 in (select b1 from t2_1025 where b1 > '0'); 4020id select_type table type possible_keys key key_len ref rows filtered Extra 40211 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where 40222 DEPENDENT SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where 4023Warnings: 4024Note 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 <in_optimizer>(`test`.`t1_1025`.`a1`,<exists>(/* select#2 */ select 1 from `test`.`t2_1025` where ((`test`.`t2_1025`.`b1` > '0') and (<cache>(`test`.`t1_1025`.`a1`) = `test`.`t2_1025`.`b1`)))) 4025select left(a1,7), left(a2,7) 4026from t1_1025 4027where a1 in (select b1 from t2_1025 where b1 > '0'); 4028left(a1,7) left(a2,7) 40291 - 01x 2 - 01x 40301 - 02x 2 - 02x 4031explain extended select left(a1,7), left(a2,7) 4032from t1_1025 4033where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); 4034id select_type table type possible_keys key key_len ref rows filtered Extra 40351 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where 40362 DEPENDENT SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where 4037Warnings: 4038Note 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 <in_optimizer>((`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a2`),<exists>(/* select#2 */ select 1,1 from `test`.`t2_1025` where ((`test`.`t2_1025`.`b1` > '0') and (<cache>(`test`.`t1_1025`.`a1`) = `test`.`t2_1025`.`b1`) and (<cache>(`test`.`t1_1025`.`a2`) = `test`.`t2_1025`.`b2`)))) 4039select left(a1,7), left(a2,7) 4040from t1_1025 4041where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); 4042left(a1,7) left(a2,7) 40431 - 01x 2 - 01x 40441 - 02x 2 - 02x 4045explain extended select left(a1,7), left(a2,7) 4046from t1_1025 4047where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); 4048id select_type table type possible_keys key key_len ref rows filtered Extra 40491 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where 40502 DEPENDENT SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where 4051Warnings: 4052Note 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 <in_optimizer>(`test`.`t1_1025`.`a1`,<exists>(/* select#2 */ select 1 from `test`.`t2_1025` where ((`test`.`t2_1025`.`b1` > '0') and (<cache>(`test`.`t1_1025`.`a1`) = substr(`test`.`t2_1025`.`b1`,1,1025))))) 4053select left(a1,7), left(a2,7) 4054from t1_1025 4055where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); 4056left(a1,7) left(a2,7) 40571 - 01x 2 - 01x 40581 - 02x 2 - 02x 4059explain extended select left(a1,7), left(a2,7) 4060from t1_1025 4061where a1 in (select group_concat(b1) from t2_1025 group by b2); 4062id select_type table type possible_keys key key_len ref rows filtered Extra 40631 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where 40642 SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using filesort 4065Warnings: 4066Note 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 <in_optimizer>(`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( <materialize> (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having 1 ), <primary_index_lookup>(`test`.`t1_1025`.`a1` in <temporary table> on <auto_key> where ((`test`.`t1_1025`.`a1` = `materialized-subquery`.`group_concat(b1)`))))) 4067select left(a1,7), left(a2,7) 4068from t1_1025 4069where a1 in (select group_concat(b1) from t2_1025 group by b2); 4070left(a1,7) left(a2,7) 4071Warnings: 4072Warning 1260 Row 1 was cut by GROUP_CONCAT() 4073Warning 1260 Row 2 was cut by GROUP_CONCAT() 4074Warning 1260 Row 3 was cut by GROUP_CONCAT() 4075set @@group_concat_max_len = 256; 4076explain extended select left(a1,7), left(a2,7) 4077from t1_1025 4078where a1 in (select group_concat(b1) from t2_1025 group by b2); 4079id select_type table type possible_keys key key_len ref rows filtered Extra 40801 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where 40812 SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using filesort 4082Warnings: 4083Note 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 <in_optimizer>(`test`.`t1_1025`.`a1`,`test`.`t1_1025`.`a1` in ( <materialize> (/* select#2 */ select group_concat(`test`.`t2_1025`.`b1` separator ',') from `test`.`t2_1025` group by `test`.`t2_1025`.`b2` having 1 ), <primary_index_lookup>(`test`.`t1_1025`.`a1` in <temporary table> on <auto_key> where ((`test`.`t1_1025`.`a1` = `materialized-subquery`.`group_concat(b1)`))))) 4084select left(a1,7), left(a2,7) 4085from t1_1025 4086where a1 in (select group_concat(b1) from t2_1025 group by b2); 4087left(a1,7) left(a2,7) 4088Warnings: 4089Warning 1260 Row 1 was cut by GROUP_CONCAT() 4090Warning 1260 Row 2 was cut by GROUP_CONCAT() 4091Warning 1260 Row 3 was cut by GROUP_CONCAT() 4092drop table t1_1025, t2_1025, t3_1025; 4093# 4094# WL#5561: Enable semi join transformation with outer join. 4095# 4096CREATE TABLE ot1(a INT); 4097CREATE TABLE ot2(a INT); 4098CREATE TABLE ot3(a INT); 4099CREATE TABLE it1(a INT); 4100CREATE TABLE it2(a INT); 4101CREATE TABLE it3(a INT); 4102INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); 4103INSERT INTO ot2 VALUES(0),(2),(4),(6); 4104INSERT INTO ot3 VALUES(0),(3),(6); 4105INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); 4106INSERT INTO it2 VALUES(0),(2),(4),(6); 4107INSERT INTO it3 VALUES(0),(3),(6); 4108# Test cases, Subquery Pattern 1 4109# Example SQ1.1: 4110explain SELECT * 4111FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4112WHERE ot1.a IN (SELECT a FROM it3); 4113id select_type table type possible_keys key key_len ref rows Extra 41141 PRIMARY ot1 ALL NULL NULL NULL NULL 8 Using where 41151 PRIMARY ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop) 41162 SUBQUERY it3 ALL NULL NULL NULL NULL 3 NULL 4117SELECT * 4118FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4119WHERE ot1.a IN (SELECT a FROM it3); 4120a a 41210 0 41223 NULL 41236 6 4124# Example SQ1.2: 4125explain SELECT * 4126FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4127WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); 4128id select_type table type possible_keys key key_len ref rows Extra 41291 PRIMARY ot1 ALL NULL NULL NULL NULL 8 NULL 41301 PRIMARY ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop) 41312 SUBQUERY it3 ALL NULL NULL NULL NULL 3 NULL 4132SELECT * 4133FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4134WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); 4135a a 41360 0 41371 NULL 41383 NULL 41395 NULL 41406 6 41417 NULL 4142# Example SQ1.3: 4143explain SELECT * 4144FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4145WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); 4146id select_type table type possible_keys key key_len ref rows Extra 41471 PRIMARY ot2 ALL NULL NULL NULL NULL 4 NULL 41481 PRIMARY ot1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop) 41492 SUBQUERY it3 ALL NULL NULL NULL NULL 3 NULL 4150SELECT * 4151FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4152WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); 4153a a 41540 0 41556 6 4156# More test cases 4157SELECT * 4158FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 4159WHERE ot1.a IN (SELECT a FROM it3); 4160a a 41610 0 41623 NULL 41636 6 4164SELECT * 4165FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 4166WHERE ot1.a IN (SELECT a+0 FROM it3); 4167a a 41680 0 41693 NULL 41706 6 4171SELECT * 4172FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 4173WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); 4174a a 41750 0 41761 NULL 41773 NULL 41785 NULL 41796 6 41807 NULL 4181SELECT * 4182FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4183WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); 4184a a 41850 0 41861 NULL 41873 NULL 41885 NULL 41896 6 41907 NULL 4191SELECT * 4192FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 4193WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); 4194a a 41950 0 41966 6 4197SELECT * 4198FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4199LEFT JOIN ot3 ON ot1.a=ot3.a 4200WHERE ot1.a IN (SELECT a FROM it3); 4201a a a 42020 0 0 42033 NULL 3 42046 6 6 4205SELECT * 4206FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4207LEFT JOIN ot3 ON ot1.a=ot3.a 4208WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); 4209a a a 42100 0 0 42111 NULL NULL 42123 NULL 3 42135 NULL NULL 42146 6 6 42157 NULL NULL 4216SELECT * 4217FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4218LEFT JOIN ot3 ON ot1.a=ot3.a 4219WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); 4220a a a 42210 0 0 42221 NULL NULL 42232 2 NULL 42243 NULL 3 42254 4 NULL 42265 NULL NULL 42276 6 6 42287 NULL NULL 4229SELECT * 4230FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4231LEFT JOIN ot3 ON ot2.a=ot3.a 4232WHERE ot1.a IN (SELECT a FROM it3); 4233a a a 42340 0 0 42353 NULL NULL 42366 6 6 4237SELECT * 4238FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4239LEFT JOIN ot3 ON ot2.a=ot3.a 4240WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); 4241a a a 42420 0 0 42431 NULL NULL 42443 NULL NULL 42455 NULL NULL 42466 6 6 42477 NULL NULL 4248SELECT * 4249FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4250LEFT JOIN ot3 ON ot2.a=ot3.a 4251WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); 4252a a a 42530 0 0 42541 NULL NULL 42552 2 NULL 42563 NULL NULL 42574 4 NULL 42585 NULL NULL 42596 6 6 42607 NULL NULL 4261# Test cases, Subquery Pattern 2 4262# Example SQ2.1: 4263explain SELECT * 4264FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); 4265id select_type table type possible_keys key key_len ref rows Extra 42661 PRIMARY ot2 ALL NULL NULL NULL NULL 4 Using where 42671 PRIMARY ot1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop) 42682 SUBQUERY it3 ALL NULL NULL NULL NULL 3 NULL 4269SELECT * 4270FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); 4271a a 42720 0 42736 6 4274# Example SQ2.2: 4275explain SELECT * 4276FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) 4277AND ot2.a IN (SELECT a FROM it3); 4278id select_type table type possible_keys key key_len ref rows Extra 42791 PRIMARY ot2 ALL NULL NULL NULL NULL 4 Using where 42801 PRIMARY ot1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop) 42813 SUBQUERY it3 ALL NULL NULL NULL NULL 3 NULL 42822 SUBQUERY it2 ALL NULL NULL NULL NULL 4 NULL 4283SELECT * 4284FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) 4285AND ot2.a IN (SELECT a FROM it3); 4286a a 42870 0 42886 6 4289# More test cases 4290SELECT * 4291FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); 4292a a 42930 0 42946 6 4295SELECT * 4296FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); 4297a a 42980 0 42996 6 4300SELECT * 4301FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); 4302a a 43030 0 43046 6 4305SELECT * 4306FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); 4307a a 43080 0 43096 6 4310SELECT * 4311FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) 4312AND ot2.a IN (SELECT a+0 FROM it3); 4313a a 43140 0 43156 6 4316SELECT * 4317FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) 4318JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); 4319a a a 43200 0 0 43216 6 6 4322# Test cases, Subquery Pattern 3 4323# Example SQ3.1: 4324explain SELECT * 4325FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); 4326id select_type table type possible_keys key key_len ref rows Extra 43271 PRIMARY ot1 ALL NULL NULL NULL NULL 8 NULL 43281 PRIMARY ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop) 43292 SUBQUERY it3 ALL NULL NULL NULL NULL 3 NULL 4330SELECT * 4331FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); 4332a a 43330 0 43341 NULL 43352 NULL 43363 NULL 43374 NULL 43385 NULL 43396 6 43407 NULL 4341# Example SQ3.2: 4342explain SELECT * 4343FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); 4344id select_type table type possible_keys key key_len ref rows Extra 43451 PRIMARY ot1 ALL NULL NULL NULL NULL 8 NULL 43461 PRIMARY ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop) 43472 SUBQUERY it2 ALL NULL NULL NULL NULL 4 NULL 4348SELECT * 4349FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); 4350a a 43510 0 43521 NULL 43532 2 43543 NULL 43554 4 43565 NULL 43576 6 43587 NULL 4359# Example SQ3.3 4360explain SELECT * 4361FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) 4362AND ot2.a IN (SELECT a FROM it2); 4363id select_type table type possible_keys key key_len ref rows Extra 43641 PRIMARY ot1 ALL NULL NULL NULL NULL 8 NULL 43651 PRIMARY ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop) 43663 SUBQUERY it2 ALL NULL NULL NULL NULL 4 NULL 43672 SUBQUERY it1 ALL NULL NULL NULL NULL 8 NULL 4368SELECT * 4369FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) 4370AND ot2.a IN (SELECT a FROM it2); 4371a a 43720 0 43731 NULL 43742 2 43753 NULL 43764 4 43775 NULL 43786 6 43797 NULL 4380# Example SQ3.4 4381explain SELECT * 4382FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND 4383(ot1.a, ot2.a) IN (SELECT it1.a, it2.a 4384FROM it1 JOIN it2 ON it1.a=it2.a); 4385id select_type table type possible_keys key key_len ref rows Extra 43861 PRIMARY ot1 ALL NULL NULL NULL NULL 8 NULL 43871 PRIMARY ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop) 43882 SUBQUERY it2 ALL NULL NULL NULL NULL 4 NULL 43892 SUBQUERY it1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop) 4390SELECT * 4391FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND 4392(ot1.a, ot2.a) IN (SELECT it1.a, it2.a 4393FROM it1 JOIN it2 ON it1.a=it2.a); 4394a a 43950 0 43961 NULL 43972 2 43983 NULL 43994 4 44005 NULL 44016 6 44027 NULL 4403# More test cases 4404SELECT * 4405FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); 4406a a 44070 0 44081 NULL 44092 NULL 44103 NULL 44114 NULL 44125 NULL 44136 6 44147 NULL 4415SELECT * 4416FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); 4417a a 44180 0 44191 NULL 44202 NULL 44213 NULL 44224 NULL 44235 NULL 44246 6 44257 NULL 4426SELECT * 4427FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); 4428a a 44290 0 44301 NULL 44312 2 44323 NULL 44334 4 44345 NULL 44356 6 44367 NULL 4437SELECT * 4438FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); 4439a a 44400 0 44411 NULL 44422 2 44433 NULL 44444 4 44455 NULL 44466 6 44477 NULL 4448SELECT * 4449FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) 4450AND ot2.a IN (SELECT a+0 FROM it2); 4451a a 44520 0 44531 NULL 44542 2 44553 NULL 44564 4 44575 NULL 44586 6 44597 NULL 4460SELECT * 4461FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND 4462(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 4463FROM it1 JOIN it2 ON it1.a=it2.a); 4464a a 44650 0 44661 NULL 44672 2 44683 NULL 44694 4 44705 NULL 44716 6 44727 NULL 4473SELECT * 4474FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) 4475LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); 4476a a a 44770 0 0 44781 NULL NULL 44792 NULL NULL 44803 NULL NULL 44814 NULL NULL 44825 NULL NULL 44836 6 6 44847 NULL NULL 4485SELECT * 4486FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) 4487LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); 4488a a a 44890 0 0 44901 NULL NULL 44912 NULL NULL 44923 NULL NULL 44934 NULL NULL 44945 NULL NULL 44956 6 6 44967 NULL NULL 4497# Test cases, Subquery Pattern 4 4498# Example SQ4.1: 4499explain SELECT * 4500FROM ot1 4501LEFT JOIN 4502(ot2 JOIN ot3 ON ot2.a=ot3.a) 4503ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4504id select_type table type possible_keys key key_len ref rows Extra 45051 PRIMARY ot1 ALL NULL NULL NULL NULL 8 NULL 45061 PRIMARY ot3 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (Block Nested Loop) 45071 PRIMARY ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop) 45082 SUBQUERY it1 ALL NULL NULL NULL NULL 8 NULL 4509SELECT * 4510FROM ot1 4511LEFT JOIN 4512(ot2 JOIN ot3 ON ot2.a=ot3.a) 4513ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4514a a a 45150 0 0 45161 NULL NULL 45172 NULL NULL 45183 NULL NULL 45194 NULL NULL 45205 NULL NULL 45216 6 6 45227 NULL NULL 4523# Example SQ4.2: 4524explain SELECT * 4525FROM ot1 4526JOIN 4527(ot2 JOIN ot3 ON ot2.a=ot3.a) 4528ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4529id select_type table type possible_keys key key_len ref rows Extra 45301 PRIMARY ot3 ALL NULL NULL NULL NULL 3 Using where 45311 PRIMARY ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop) 45321 PRIMARY ot1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop) 45332 SUBQUERY it1 ALL NULL NULL NULL NULL 8 NULL 4534SELECT * 4535FROM ot1 4536JOIN 4537(ot2 JOIN ot3 ON ot2.a=ot3.a) 4538ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4539a a a 45400 0 0 45416 6 6 4542# Example SQ4.3: 4543explain SELECT * 4544FROM ot1 4545JOIN 4546(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 4547ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4548id select_type table type possible_keys key key_len ref rows Extra 45491 PRIMARY ot2 ALL NULL NULL NULL NULL 4 Using where 45501 PRIMARY ot3 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (Block Nested Loop) 45511 PRIMARY ot1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop) 45522 SUBQUERY it1 ALL NULL NULL NULL NULL 8 NULL 4553SELECT * 4554FROM ot1 4555JOIN 4556(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 4557ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4558a a a 45590 0 0 45602 2 NULL 45614 4 NULL 45626 6 6 4563# Example SQ4.4: 4564explain SELECT * 4565FROM ot1 4566LEFT JOIN 4567(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 4568ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4569id select_type table type possible_keys key key_len ref rows Extra 45701 PRIMARY ot1 ALL NULL NULL NULL NULL 8 NULL 45711 PRIMARY ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop) 45721 PRIMARY ot3 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (Block Nested Loop) 45732 SUBQUERY it1 ALL NULL NULL NULL NULL 8 NULL 4574SELECT * 4575FROM ot1 4576LEFT JOIN 4577(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 4578ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4579a a a 45800 0 0 45811 NULL NULL 45822 2 NULL 45833 NULL NULL 45844 4 NULL 45855 NULL NULL 45866 6 6 45877 NULL NULL 4588# More test cases 4589SELECT * 4590FROM ot1 4591LEFT JOIN 4592(ot2 JOIN ot3 ON ot2.a=ot3.a+0) 4593ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4594a a a 45950 0 0 45961 NULL NULL 45972 NULL NULL 45983 NULL NULL 45994 NULL NULL 46005 NULL NULL 46016 6 6 46027 NULL NULL 4603SELECT * 4604FROM ot1 4605LEFT JOIN 4606(ot2 JOIN ot3 ON ot2.a=ot3.a) 4607ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); 4608a a a 46090 0 0 46101 NULL NULL 46112 NULL NULL 46123 NULL NULL 46134 NULL NULL 46145 NULL NULL 46156 6 6 46167 NULL NULL 4617SELECT * 4618FROM ot1 4619LEFT JOIN 4620(ot2 JOIN ot3 ON ot2.a=ot3.a) 4621ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); 4622a a a 46230 0 0 46241 NULL NULL 46252 NULL NULL 46263 NULL NULL 46274 NULL NULL 46285 NULL NULL 46296 6 6 46307 NULL NULL 4631SELECT * 4632FROM ot1 4633JOIN 4634(ot2 JOIN ot3 ON ot2.a=ot3.a+0) 4635ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4636a a a 46370 0 0 46386 6 6 4639SELECT * 4640FROM ot1 4641JOIN 4642(ot2 JOIN ot3 ON ot2.a=ot3.a) 4643ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); 4644a a a 46450 0 0 46466 6 6 4647SELECT * 4648FROM ot1 4649JOIN 4650(ot2 JOIN ot3 ON ot2.a=ot3.a) 4651ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); 4652a a a 46530 0 0 46546 6 6 4655SELECT * 4656FROM ot1 4657JOIN 4658(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) 4659ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4660a a a 46610 0 0 46622 2 NULL 46634 4 NULL 46646 6 6 4665SELECT * 4666FROM ot1 4667JOIN 4668(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 4669ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); 4670a a a 46710 0 0 46722 2 NULL 46734 4 NULL 46746 6 6 4675SELECT * 4676FROM ot1 4677JOIN 4678(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 4679ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); 4680a a a 46810 0 0 46822 2 NULL 46834 4 NULL 46846 6 6 4685SELECT * 4686FROM ot1 4687LEFT JOIN 4688(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) 4689ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4690a a a 46910 0 0 46921 NULL NULL 46932 2 NULL 46943 NULL NULL 46954 4 NULL 46965 NULL NULL 46976 6 6 46987 NULL NULL 4699SELECT * 4700FROM ot1 4701LEFT JOIN 4702(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 4703ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); 4704a a a 47050 0 0 47061 NULL NULL 47072 2 NULL 47083 NULL NULL 47094 4 NULL 47105 NULL NULL 47116 6 6 47127 NULL NULL 4713SELECT * 4714FROM ot1 4715LEFT JOIN 4716(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 4717ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); 4718a a a 47190 0 0 47201 NULL NULL 47212 2 NULL 47223 NULL NULL 47234 4 NULL 47245 NULL NULL 47256 6 6 47267 NULL NULL 4727SELECT * 4728FROM ot1 4729LEFT JOIN 4730(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 4731ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) 4732LEFT JOIN 4733ot1 AS ot4 4734ON ot2.a=ot4.a; 4735a a a a 47360 0 0 0 47371 NULL NULL NULL 47382 2 NULL 2 47393 NULL NULL NULL 47404 4 NULL 4 47415 NULL NULL NULL 47426 6 6 6 47437 NULL NULL NULL 4744SELECT * 4745FROM ot1 4746LEFT JOIN 4747(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a 4748LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) 4749ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4750a a a a 47510 0 0 0 47521 NULL NULL NULL 47532 2 NULL NULL 47543 NULL NULL NULL 47554 4 NULL NULL 47565 NULL NULL NULL 47576 6 6 6 47587 NULL NULL NULL 4759DROP TABLE ot1,ot2,ot3,it1,it2,it3; 4760CREATE TABLE t ( 4761a INTEGER DEFAULT NULL 4762) ENGINE=InnoDB; 4763INSERT INTO t VALUES (1); 4764CREATE TABLE t2 ( 4765a INTEGER DEFAULT NULL 4766) ENGINE=InnoDB; 4767INSERT INTO t2 VALUES (1),(1); 4768CREATE TABLE t4 ( 4769a INTEGER DEFAULT NULL 4770) ENGINE=InnoDB; 4771INSERT INTO t4 VALUES (1),(1); 4772CREATE TABLE v ( 4773a INTEGER DEFAULT NULL 4774) ENGINE=InnoDB; 4775INSERT INTO v VALUES (1),(1); 4776explain SELECT * 4777FROM t AS t1 4778LEFT JOIN 4779(t2 4780LEFT JOIN t AS t3 4781ON t3.a IN (SELECT a FROM t AS it) 4782JOIN t4 4783ON t4.a=100 4784) 4785ON TRUE 4786WHERE t1.a IN (SELECT * FROM v AS it2); 4787id select_type table type possible_keys key key_len ref rows Extra 47881 PRIMARY t1 ALL NULL NULL NULL NULL 1 Using where 47891 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 47901 PRIMARY t3 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 47911 PRIMARY t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 47923 SUBQUERY it2 ALL NULL NULL NULL NULL 2 NULL 47932 SUBQUERY it ALL NULL NULL NULL NULL 1 NULL 4794SELECT * 4795FROM t AS t1 4796LEFT JOIN 4797(t2 4798LEFT JOIN t AS t3 4799ON t3.a IN (SELECT a FROM t AS it) 4800JOIN t4 4801ON t4.a=100 4802) 4803ON TRUE 4804WHERE t1.a IN (SELECT * FROM v AS it2); 4805a a a a 48061 NULL NULL NULL 4807DROP TABLE t,t2,t4,v; 4808# End of WL#5561 4809# 4810# Bug#48868: Left outer join in subquery causes segmentation fault in 4811# make_join_select. 4812# 4813CREATE TABLE t1 (i INTEGER); 4814INSERT INTO t1 VALUES (1); 4815INSERT INTO t1 VALUES (2); 4816CREATE TABLE t2 (i INTEGER); 4817INSERT INTO t2 VALUES(1); 4818CREATE TABLE t3 (i INTEGER); 4819INSERT INTO t3 VALUES (1); 4820INSERT INTO t3 VALUES (2); 4821SELECT * FROM t1 WHERE (t1.i) IN 4822(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 4823i 48241 4825DROP TABLE t1, t2, t3; 4826 4827Bug#37899: Wrongly checked optimization prerequisite caused failed 4828assertion. 4829 4830CREATE TABLE t1 ( 4831`pk` int(11), 4832`varchar_nokey` varchar(5) 4833); 4834INSERT INTO t1 VALUES 4835(1,'qk'),(2,'j'),(3,'aew'); 4836SELECT * 4837FROM t1 4838WHERE varchar_nokey IN ( 4839SELECT 4840varchar_nokey 4841FROM 4842t1 4843) XOR pk = 30; 4844pk varchar_nokey 48451 qk 48462 j 48473 aew 4848drop table t1; 4849# 4850# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING 4851# 4852CREATE TABLE t1 ( 4853pk int(11) NOT NULL AUTO_INCREMENT, 4854int_nokey int(11) NOT NULL, 4855time_key time NOT NULL, 4856datetime_key datetime NOT NULL, 4857datetime_nokey datetime NOT NULL, 4858varchar_key varchar(1) NOT NULL, 4859varchar_nokey varchar(1) NOT NULL, 4860PRIMARY KEY (pk), 4861KEY time_key (time_key), 4862KEY datetime_key (datetime_key), 4863KEY varchar_key (varchar_key) 4864); 4865INSERT INTO t1 VALUES 4866(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), 4867(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), 4868(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), 4869(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), 4870(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), 4871(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), 4872(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), 4873(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), 4874(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), 4875(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), 4876(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), 4877(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), 4878(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), 4879(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), 4880(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), 4881(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), 4882(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), 4883(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), 4884(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), 4885(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); 4886CREATE TABLE t2 ( 4887pk int(11) NOT NULL AUTO_INCREMENT, 4888int_nokey int(11) NOT NULL, 4889time_key time NOT NULL, 4890datetime_key datetime NOT NULL, 4891datetime_nokey datetime NOT NULL, 4892varchar_key varchar(1) NOT NULL, 4893varchar_nokey varchar(1) NOT NULL, 4894PRIMARY KEY (pk), 4895KEY time_key (time_key), 4896KEY datetime_key (datetime_key), 4897KEY varchar_key (varchar_key) 4898); 4899INSERT INTO t2 VALUES 4900(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), 4901(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); 4902SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR 4903WHERE 4904OUTR.varchar_nokey IN (SELECT 4905INNR . varchar_nokey AS Y 4906FROM t2 AS INNR 4907WHERE 4908INNR . datetime_key >= INNR . time_key OR 4909INNR . pk = INNR . int_nokey 4910) 4911AND OUTR . varchar_nokey <= 'w' 4912HAVING X > '2012-12-12'; 4913X 4914drop table t1, t2; 4915 4916Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order 4917with semijoin=on" 4918 4919CREATE TABLE t1 ( 4920varchar_key varchar(1) DEFAULT NULL, 4921KEY varchar_key (varchar_key) 4922); 4923CREATE TABLE t2 ( 4924varchar_key varchar(1) DEFAULT NULL, 4925KEY varchar_key (varchar_key) 4926); 4927INSERT INTO t2 VALUES 4928(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), 4929('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), 4930('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), 4931('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), 4932('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), 4933('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), 4934('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), 4935('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); 4936CREATE TABLE t3 ( 4937varchar_key varchar(1) DEFAULT NULL, 4938KEY varchar_key (varchar_key) 4939) ENGINE=MyISAM DEFAULT CHARSET=latin1; 4940INSERT INTO t3 VALUES 4941(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), 4942('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); 4943SELECT varchar_key FROM t3 4944WHERE (SELECT varchar_key FROM t3 4945WHERE (varchar_key,varchar_key) 4946IN (SELECT t1.varchar_key, t2 .varchar_key 4947FROM t1 RIGHT JOIN t2 ON t1.varchar_key 4948) 4949); 4950varchar_key 4951DROP TABLE t1, t2, t3; 4952# 4953# Bug#46556 Returning incorrect, empty results for some IN subqueries 4954# w/semijoin=on 4955# 4956CREATE TABLE t0 ( 4957pk INTEGER, 4958vkey VARCHAR(1), 4959vnokey VARCHAR(1), 4960PRIMARY KEY (pk), 4961KEY vkey(vkey) 4962); 4963INSERT INTO t0 4964VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); 4965EXPLAIN EXTENDED SELECT vkey FROM t0 WHERE pk IN 4966(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); 4967id select_type table type possible_keys key key_len ref rows filtered Extra 49681 PRIMARY t0 ALL NULL NULL NULL NULL 5 100.00 Using where 49692 SUBQUERY t1 ALL PRIMARY NULL NULL NULL 5 100.00 NULL 49702 SUBQUERY t2 index vkey vkey 4 NULL 5 80.00 Using where; Using index; Using join buffer (Block Nested Loop) 4971Warnings: 4972Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` where <in_optimizer>(`test`.`t0`.`pk`,`test`.`t0`.`pk` in ( <materialize> (/* select#2 */ select `test`.`t1`.`pk` from `test`.`t0` `t1` join `test`.`t0` `t2` where (`test`.`t2`.`vkey` = `test`.`t1`.`vnokey`) ), <primary_index_lookup>(`test`.`t0`.`pk` in <temporary table> on <auto_key> where ((`test`.`t0`.`pk` = `materialized-subquery`.`pk`))))) 4973SELECT vkey FROM t0 WHERE pk IN 4974(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); 4975vkey 4976g 4977v 4978t 4979u 4980n 4981DROP TABLE t0; 4982# End of bug#46556 4983# 4984# Bug#46692 "Crash occurring on queries with nested FROM subqueries 4985# using materialization." 4986# 4987CREATE TABLE t1 ( 4988pk INTEGER PRIMARY KEY, 4989int_key INTEGER, 4990KEY int_key(int_key) 4991); 4992INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); 4993CREATE TABLE t2 ( 4994pk INTEGER PRIMARY KEY, 4995int_key INTEGER, 4996KEY int_key(int_key) 4997); 4998INSERT INTO t2 VALUES (1,7),(2,2); 4999SELECT * FROM t1 WHERE (140, 4) IN 5000(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); 5001pk int_key 5002DROP TABLE t1, t2; 5003# 5004# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query 5005# causes crash." 5006# 5007CREATE TABLE t1 ( 5008pk INTEGER PRIMARY KEY, 5009int_nokey INTEGER, 5010int_key INTEGER, 5011date_key DATE, 5012datetime_nokey DATETIME, 5013varchar_nokey VARCHAR(1) 5014); 5015CREATE TABLE t2 ( 5016date_nokey DATE 5017); 5018CREATE TABLE t3 ( 5019pk INTEGER PRIMARY KEY, 5020int_nokey INTEGER, 5021date_key date, 5022varchar_key VARCHAR(1), 5023varchar_nokey VARCHAR(1), 5024KEY date_key (date_key) 5025); 5026SELECT date_key FROM t1 5027WHERE (int_key, int_nokey) 5028IN (SELECT t3.int_nokey, t3.pk 5029FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) 5030WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk 5031) 5032AND (varchar_nokey <> 'f' OR NOT int_key < 7); 5033date_key 5034# 5035# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery 5036# + AND in outer query". 5037# 5038INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), 5039(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), 5040(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), 5041(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), 5042(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), 5043(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), 5044(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), 5045(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); 5046INSERT INTO t3 VALUES (1,9,'0000-00-00','b','b'), 5047(2,2,'2002-09-17','h','h'); 5048SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey 5049WHERE t1.varchar_nokey 5050IN (SELECT varchar_nokey FROM t1 5051WHERE (pk) 5052IN (SELECT t3.int_nokey 5053FROM t3 LEFT JOIN t1 ON t1.varchar_nokey 5054WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' 5055 ) 5056); 5057varchar_nokey 5058DROP TABLE t1, t2, t3; 5059# 5060# Bug#45219 "Crash on SELECT DISTINCT query containing a 5061# LEFT JOIN in subquery" 5062# 5063CREATE TABLE t1 ( 5064pk INTEGER NOT NULL, 5065int_nokey INTEGER NOT NULL, 5066datetime_key DATETIME NOT NULL, 5067varchar_key VARCHAR(1) NOT NULL, 5068PRIMARY KEY (pk), 5069KEY datetime_key (datetime_key), 5070KEY varchar_key (varchar_key) 5071); 5072INSERT INTO t1 VALUES 5073(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), 5074(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), 5075(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), 5076(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), 5077(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), 5078(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), 5079(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), 5080(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), 5081(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), 5082(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); 5083CREATE TABLE t2 LIKE t1; 5084INSERT INTO t2 VALUES 5085(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), 5086(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), 5087(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), 5088(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), 5089(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), 5090(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), 5091(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), 5092(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), 5093(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), 5094(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); 5095CREATE TABLE t3 LIKE t1; 5096INSERT INTO t3 VALUES 5097(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); 5098SELECT DISTINCT datetime_key FROM t1 5099WHERE (int_nokey, pk) 5100IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key) 5101AND pk = 9; 5102datetime_key 5103DROP TABLE t1, t2, t3; 5104# 5105# Bug#46550 Azalea returning duplicate results for some IN subqueries 5106# w/ semijoin=on 5107# 5108DROP TABLE IF EXISTS t0, t1, t2; 5109CREATE TABLE t0 ( 5110int_key int(11) DEFAULT NULL, 5111varchar_key varchar(1) DEFAULT NULL, 5112varchar_nokey varchar(1) DEFAULT NULL, 5113KEY int_key (int_key), 5114KEY varchar_key (varchar_key,int_key) 5115); 5116INSERT INTO t0 VALUES 5117(1,'m','m'), 5118(40,'h','h'), 5119(1,'r','r'), 5120(1,'h','h'), 5121(9,'x','x'), 5122(NULL,'q','q'), 5123(NULL,'k','k'), 5124(7,'l','l'), 5125(182,'k','k'), 5126(202,'a','a'), 5127(7,'x','x'), 5128(6,'j','j'), 5129(119,'z','z'), 5130(4,'d','d'), 5131(5,'h','h'), 5132(1,'u','u'), 5133(3,'q','q'), 5134(7,'a','a'), 5135(3,'e','e'), 5136(6,'l','l'); 5137CREATE TABLE t1 ( 5138int_key int(11) DEFAULT NULL, 5139varchar_key varchar(1) DEFAULT NULL, 5140varchar_nokey varchar(1) DEFAULT NULL, 5141KEY int_key (int_key), 5142KEY varchar_key (varchar_key,int_key) 5143); 5144INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); 5145CREATE TABLE t2 ( 5146int_key int(11) DEFAULT NULL, 5147varchar_key varchar(1) DEFAULT NULL, 5148varchar_nokey varchar(1) DEFAULT NULL, 5149KEY int_key (int_key), 5150KEY varchar_key (varchar_key,int_key) 5151); 5152INSERT INTO t2 VALUES (123,NULL,NULL); 5153SELECT int_key 5154FROM t0 5155WHERE varchar_nokey IN ( 5156SELECT t1 .varchar_key from t1 5157); 5158int_key 51599 51607 5161SELECT t0.int_key 5162FROM t0 5163WHERE t0.varchar_nokey IN ( 5164SELECT t1_1 .varchar_key 5165FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key 5166); 5167int_key 51689 51697 5170EXPLAIN 5171SELECT t0.int_key 5172FROM t0 5173WHERE t0.varchar_nokey IN ( 5174SELECT t1_1 .varchar_key 5175FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key 5176); 5177id select_type table type possible_keys key key_len ref rows Extra 51781 PRIMARY t0 ALL NULL NULL NULL NULL 20 Using where 51792 SUBQUERY t1_1 index varchar_key varchar_key 9 NULL 2 Using where; Using index 51802 SUBQUERY t1_2 index NULL int_key 5 NULL 2 Using index; Using join buffer (Block Nested Loop) 5181SELECT t0.int_key 5182FROM t0, t2 5183WHERE t0.varchar_nokey IN ( 5184SELECT t1_1 .varchar_key 5185FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key 5186); 5187int_key 51889 51897 5190EXPLAIN 5191SELECT t0.int_key 5192FROM t0, t2 5193WHERE t0.varchar_nokey IN ( 5194SELECT t1_1 .varchar_key 5195FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key 5196); 5197id select_type table type possible_keys key key_len ref rows Extra 51981 PRIMARY t2 system NULL NULL NULL NULL 1 NULL 51991 PRIMARY t0 ALL NULL NULL NULL NULL 20 Using where 52002 SUBQUERY t1_1 index varchar_key varchar_key 9 NULL 2 Using where; Using index 52012 SUBQUERY t1_2 index NULL int_key 5 NULL 2 Using index; Using join buffer (Block Nested Loop) 5202DROP TABLE t0, t1, t2; 5203# End of bug#46550 5204 5205Bug #48073 Subquery on char columns from view crashes Mysql 5206 5207DROP TABLE IF EXISTS t1, t2; 5208DROP VIEW IF EXISTS v1; 5209CREATE TABLE t1 ( 5210city VARCHAR(50) NOT NULL, 5211country_id SMALLINT UNSIGNED NOT NULL 5212); 5213INSERT INTO t1 VALUES 5214('Batna',2), 5215('Bchar',2), 5216('Skikda',2), 5217('Tafuna',3), 5218('Algeria',2) ; 5219CREATE TABLE t2 ( 5220country_id SMALLINT UNSIGNED NOT NULL, 5221country VARCHAR(50) NOT NULL 5222); 5223INSERT INTO t2 VALUES 5224(2,'Algeria'), 5225(3,'American Samoa') ; 5226CREATE VIEW v1 AS 5227SELECT country_id, country 5228FROM t2 5229WHERE LEFT(country,1) = "A" 5230; 5231SELECT city, country_id 5232FROM t1 5233WHERE city IN ( 5234SELECT country 5235FROM t2 5236WHERE LEFT(country, 1) = "A" 5237); 5238city country_id 5239Algeria 2 5240SELECT city, country_id 5241FROM t1 5242WHERE city IN ( 5243SELECT country 5244FROM v1 5245); 5246city country_id 5247Algeria 2 5248drop table t1, t2; 5249drop view v1; 5250# End of bug#48073 5251 5252Bug#49097 subquery with view generates wrong result with 5253non-prepared statement 5254 5255DROP TABLE IF EXISTS t1, t2; 5256DROP VIEW IF EXISTS v1; 5257CREATE TABLE t1 ( 5258city VARCHAR(50) NOT NULL, 5259country_id SMALLINT UNSIGNED NOT NULL 5260); 5261INSERT INTO t1 VALUES 5262('Batna',2), 5263('Bchar',2), 5264('Skikda',2), 5265('Tafuna',3), 5266('Algeria',2) ; 5267CREATE TABLE t2 ( 5268country_id SMALLINT UNSIGNED NOT NULL, 5269country VARCHAR(50) NOT NULL 5270); 5271INSERT INTO t2 VALUES 5272(2,'Algeria'), 5273(3,'XAmerican Samoa') ; 5274CREATE VIEW v1 AS 5275SELECT country_id, country 5276FROM t2 5277WHERE LEFT(country,1) = "A" 5278; 5279SELECT city, country_id 5280FROM t1 5281WHERE country_id IN ( 5282SELECT country_id 5283FROM t2 5284WHERE LEFT(country,1) = "A" 5285); 5286city country_id 5287Batna 2 5288Bchar 2 5289Skikda 2 5290Algeria 2 5291SELECT city, country_id 5292FROM t1 5293WHERE country_id IN ( 5294SELECT country_id 5295FROM v1 5296); 5297city country_id 5298Batna 2 5299Bchar 2 5300Skikda 2 5301Algeria 2 5302PREPARE stmt FROM 5303" 5304SELECT city, country_id 5305FROM t1 5306WHERE country_id IN ( 5307 SELECT country_id 5308 FROM v1 5309); 5310"; 5311execute stmt; 5312city country_id 5313Batna 2 5314Bchar 2 5315Skikda 2 5316Algeria 2 5317deallocate prepare stmt; 5318drop table t1, t2; 5319drop view v1; 5320# End of Bug#49097 5321# 5322# Bug#49198 Wrong result for second call of procedure 5323# with view in subselect. 5324# 5325CREATE TABLE t1 (t1field integer, primary key (t1field)); 5326CREATE TABLE t2 (t2field integer, primary key (t2field)); 5327CREATE TABLE t3 (t3field integer, primary key (t3field)); 5328CREATE VIEW v2 AS SELECT * FROM t2; 5329CREATE VIEW v3 AS SELECT * FROM t3; 5330INSERT INTO t1 VALUES(1),(2); 5331INSERT INTO t2 VALUES(1),(2); 5332INSERT INTO t3 VALUES(1),(2); 5333PREPARE stmt FROM 5334" 5335SELECT t1field 5336FROM t1 5337WHERE t1field IN (SELECT * FROM v2); 5338"; 5339EXECUTE stmt; 5340t1field 53411 53422 5343EXECUTE stmt; 5344t1field 53451 53462 5347PREPARE stmt FROM 5348" 5349EXPLAIN 5350SELECT t1field 5351FROM t1 5352WHERE t1field IN (SELECT * FROM v2) 5353 AND t1field IN (SELECT * FROM v3) 5354"; 5355EXECUTE stmt; 5356id select_type table type possible_keys key key_len ref rows Extra 53571 PRIMARY t1 index NULL PRIMARY 4 NULL 2 Using where; Using index 53583 SUBQUERY t3 index PRIMARY PRIMARY 4 NULL 2 Using index 53592 SUBQUERY t2 index PRIMARY PRIMARY 4 NULL 2 Using index 5360EXECUTE stmt; 5361id select_type table type possible_keys key key_len ref rows Extra 53621 PRIMARY t1 index NULL PRIMARY 4 NULL 2 Using where; Using index 53633 SUBQUERY t3 index PRIMARY PRIMARY 4 NULL 2 Using index 53642 SUBQUERY t2 index PRIMARY PRIMARY 4 NULL 2 Using index 5365DROP TABLE t1, t2, t3; 5366DROP VIEW v2, v3; 5367# End of Bug#49198 5368# 5369# Bug#48623 Multiple subqueries are optimized incorrectly 5370# 5371CREATE TABLE ot(val VARCHAR(10)); 5372CREATE TABLE it1(val VARCHAR(10)); 5373CREATE TABLE it2(val VARCHAR(10)); 5374INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); 5375INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); 5376INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); 5377EXPLAIN 5378SELECT * 5379FROM ot 5380WHERE ot.val IN (SELECT it1.val FROM it1 5381WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') 5382AND ot.val IN (SELECT it2.val FROM it2 5383WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); 5384id select_type table type possible_keys key key_len ref rows Extra 53851 PRIMARY ot ALL NULL NULL NULL NULL 5 Using where 53863 SUBQUERY it2 ALL NULL NULL NULL NULL 5 Using where 53872 SUBQUERY it1 ALL NULL NULL NULL NULL 6 Using where 5388SELECT * 5389FROM ot 5390WHERE ot.val IN (SELECT it1.val FROM it1 5391WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') 5392AND ot.val IN (SELECT it2.val FROM it2 5393WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); 5394val 5395aaa 5396eee 5397DROP TABLE ot; 5398DROP TABLE it1; 5399DROP TABLE it2; 5400# End of Bug#48623 5401# 5402# Bug #51487 Assertion failure when semi-join flattening occurs 5403# for a subquery in HAVING 5404# 5405CREATE TABLE t1 (a INT, b INT); 5406INSERT INTO t1 VALUES (1,10),(2,11),(1,13); 5407CREATE TABLE t2 AS SELECT * FROM t1; 5408CREATE TABLE t3 AS SELECT * FROM t1; 5409SELECT COUNT(*) FROM t1 5410GROUP BY t1.a 5411HAVING t1.a IN (SELECT t3.a FROM t3 5412WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); 5413COUNT(*) 54142 54151 5416DROP TABLE t1, t2, t3; 5417# End of Bug#51487 5418# 5419# BUG#38075: Wrong result: rows matching a subquery with outer join not returned 5420# 5421DROP TABLE IF EXISTS ot1, it1, it2; 5422CREATE TABLE it2 ( 5423int_key int(11) NOT NULL, 5424datetime_key datetime NOT NULL, 5425KEY int_key (int_key), 5426KEY datetime_key (datetime_key) 5427); 5428INSERT INTO it2 VALUES 5429(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), 5430(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), 5431(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), 5432(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), 5433(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), 5434(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), 5435(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), 5436(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), 5437(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), 5438(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); 5439CREATE TABLE ot1 ( 5440int_nokey int(11) NOT NULL, 5441int_key int(11) NOT NULL, 5442KEY int_key (int_key) 5443); 5444INSERT INTO ot1 VALUES 5445(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), 5446(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); 5447CREATE TABLE it1 ( 5448int_nokey int(11) NOT NULL, 5449int_key int(11) NOT NULL, 5450KEY int_key (int_key) 5451); 5452INSERT INTO it1 VALUES 5453(9,5), (0,4); 5454SELECT int_key FROM ot1 5455WHERE int_nokey IN (SELECT it2.int_key 5456FROM it1 LEFT JOIN it2 ON it2.datetime_key); 5457int_key 54580 54590 54600 54610 54620 54630 54642 54652 54663 54675 54685 54697 54707 54717 54728 54739 54749 5475EXPLAIN 5476SELECT int_key FROM ot1 5477WHERE int_nokey IN (SELECT it2.int_key 5478FROM it1 LEFT JOIN it2 ON it2.datetime_key); 5479id select_type table type possible_keys key key_len ref rows Extra 54801 PRIMARY ot1 ALL NULL NULL NULL NULL 20 Using where 54812 SUBQUERY it1 index NULL int_key 4 NULL 2 Using index 54822 SUBQUERY it2 ALL int_key NULL NULL NULL 20 Using where; Using join buffer (Block Nested Loop) 5483DROP TABLE ot1, it1, it2; 5484# End of BUG#38075 5485# 5486# BUG#50089: Second call of procedure with view in subselect crashes server 5487# 5488CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); 5489CREATE VIEW v1 AS 5490SELECT t1field AS v1field 5491FROM t1 a 5492WHERE a.t1field IN (SELECT t1field FROM t1); 5493INSERT INTO t1 VALUES(1),(2); 5494SELECT t1field 5495FROM t1 5496WHERE t1field IN (SELECT v1field FROM v1); 5497t1field 54981 54992 5500EXPLAIN 5501SELECT t1field 5502FROM t1 5503WHERE t1field IN (SELECT v1field FROM v1); 5504id select_type table type possible_keys key key_len ref rows Extra 55051 PRIMARY t1 index NULL PRIMARY 4 NULL 2 Using where; Using index 55062 SUBQUERY a index PRIMARY PRIMARY 4 NULL 2 Using where; Using index 55074 SUBQUERY t1 index PRIMARY PRIMARY 4 NULL 2 Using index 5508SELECT t1.t1field 5509FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); 5510t1field 55111 55121 55132 55142 5515EXPLAIN 5516SELECT t1field 5517FROM t1 5518WHERE t1field IN (SELECT v1field FROM v1); 5519id select_type table type possible_keys key key_len ref rows Extra 55201 PRIMARY t1 index NULL PRIMARY 4 NULL 2 Using where; Using index 55212 SUBQUERY a index PRIMARY PRIMARY 4 NULL 2 Using where; Using index 55224 SUBQUERY t1 index PRIMARY PRIMARY 4 NULL 2 Using index 5523CREATE PROCEDURE p1() 5524BEGIN 5525SELECT t1field 5526FROM t1 5527WHERE t1field IN (SELECT v1field FROM v1); 5528END| 5529CALL p1; 5530t1field 55311 55322 5533CALL p1; 5534t1field 55351 55362 5537PREPARE stmt FROM 5538" 5539SELECT t1field 5540FROM t1 5541WHERE t1field IN (SELECT v1field FROM v1); 5542"; 5543EXECUTE stmt; 5544t1field 55451 55462 5547EXECUTE stmt; 5548t1field 55491 55502 5551DROP PROCEDURE p1; 5552DROP VIEW v1; 5553DROP TABLE t1; 5554# End of BUG#50089 5555# 5556# Bug#45191: Incorrectly initialized semi-join led to a wrong result. 5557# 5558CREATE TABLE STAFF (EMPNUM CHAR(3) NOT NULL, 5559EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)); 5560CREATE TABLE PROJ (PNUM CHAR(3) NOT NULL, 5561PNAME CHAR(20), PTYPE CHAR(6), 5562BUDGET DECIMAL(9), 5563CITY CHAR(15)); 5564CREATE TABLE WORKS (EMPNUM CHAR(3) NOT NULL, 5565PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)); 5566INSERT INTO STAFF VALUES ('E1','Alice',12,'Deale'); 5567INSERT INTO STAFF VALUES ('E2','Betty',10,'Vienna'); 5568INSERT INTO STAFF VALUES ('E3','Carmen',13,'Vienna'); 5569INSERT INTO STAFF VALUES ('E4','Don',12,'Deale'); 5570INSERT INTO STAFF VALUES ('E5','Ed',13,'Akron'); 5571INSERT INTO PROJ VALUES ('P1','MXSS','Design',10000,'Deale'); 5572INSERT INTO PROJ VALUES ('P2','CALM','Code',30000,'Vienna'); 5573INSERT INTO PROJ VALUES ('P3','SDP','Test',30000,'Tampa'); 5574INSERT INTO PROJ VALUES ('P4','SDP','Design',20000,'Deale'); 5575INSERT INTO PROJ VALUES ('P5','IRM','Test',10000,'Vienna'); 5576INSERT INTO PROJ VALUES ('P6','PAYR','Design',50000,'Deale'); 5577INSERT INTO WORKS VALUES ('E1','P1',40); 5578INSERT INTO WORKS VALUES ('E1','P2',20); 5579INSERT INTO WORKS VALUES ('E1','P3',80); 5580INSERT INTO WORKS VALUES ('E1','P4',20); 5581INSERT INTO WORKS VALUES ('E1','P5',12); 5582INSERT INTO WORKS VALUES ('E1','P6',12); 5583INSERT INTO WORKS VALUES ('E2','P1',40); 5584INSERT INTO WORKS VALUES ('E2','P2',80); 5585INSERT INTO WORKS VALUES ('E3','P2',20); 5586INSERT INTO WORKS VALUES ('E4','P2',20); 5587INSERT INTO WORKS VALUES ('E4','P4',40); 5588INSERT INTO WORKS VALUES ('E4','P5',80); 5589explain SELECT EMPNUM, EMPNAME 5590FROM STAFF 5591WHERE EMPNUM IN 5592(SELECT EMPNUM FROM WORKS 5593WHERE PNUM IN 5594(SELECT PNUM FROM PROJ)); 5595id select_type table type possible_keys key key_len ref rows Extra 55961 PRIMARY STAFF ALL NULL NULL NULL NULL 5 Using where 55972 SUBQUERY WORKS ALL NULL NULL NULL NULL 12 Using where 55983 SUBQUERY PROJ ALL NULL NULL NULL NULL 6 NULL 5599SELECT EMPNUM, EMPNAME 5600FROM STAFF 5601WHERE EMPNUM IN 5602(SELECT EMPNUM FROM WORKS 5603WHERE PNUM IN 5604(SELECT PNUM FROM PROJ)); 5605EMPNUM EMPNAME 5606E1 Alice 5607E2 Betty 5608E3 Carmen 5609E4 Don 5610drop table STAFF,WORKS,PROJ; 5611# End of bug#45191 5612# 5613# BUG#36896: Server crash on SELECT FROM DUAL 5614# 5615create table t1 (a int); 5616select 1 as res from dual where (1) in (select * from t1); 5617res 5618drop table t1; 5619 5620BUG#40118 Crash when running Batched Key Access and requiring one match for each key 5621 5622create table t0(a int); 5623insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 5624create table t1 (a int, key(a)); 5625insert into t1 select * from t0; 5626alter table t1 add b int not null, add filler char(200); 5627insert into t1 select * from t1; 5628insert into t1 select * from t1; 5629select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); 5630a 56310 56321 56332 56343 56354 56365 56376 56387 56398 56409 5641drop table t0, t1; 5642# 5643# BUG#32665 Query with dependent subquery is too slow 5644# 5645create table t1 ( 5646idIndividual int primary key 5647); 5648insert into t1 values (1),(2); 5649create table t2 ( 5650idContact int primary key, 5651contactType int, 5652idObj int 5653); 5654insert into t2 values (1,1,1),(2,2,2),(3,3,3); 5655create table t3 ( 5656idAddress int primary key, 5657idContact int, 5658postalStripped varchar(100) 5659); 5660insert into t3 values (1,1, 'foo'), (2,2,'bar'); 5661The following must be converted to a semi-join: 5662explain extended SELECT a.idIndividual FROM t1 a 5663WHERE a.idIndividual IN 5664( SELECT c.idObj FROM t3 cona 5665INNER JOIN t2 c ON c.idContact=cona.idContact 5666WHERE cona.postalStripped='T2H3B2' 5667 ); 5668id select_type table type possible_keys key key_len ref rows filtered Extra 56691 PRIMARY a index NULL PRIMARY 4 NULL 2 100.00 Using where; Using index 56702 SUBQUERY cona ALL NULL NULL NULL NULL 2 100.00 Using where 56712 SUBQUERY c eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 NULL 5672Warnings: 5673Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` where <in_optimizer>(`test`.`a`.`idIndividual`,`test`.`a`.`idIndividual` in ( <materialize> (/* select#2 */ select `test`.`c`.`idObj` from `test`.`t3` `cona` join `test`.`t2` `c` where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) ), <primary_index_lookup>(`test`.`a`.`idIndividual` in <temporary table> on <auto_key> where ((`test`.`a`.`idIndividual` = `materialized-subquery`.`idObj`))))) 5674drop table t1,t2,t3; 5675CREATE TABLE t1 (one int, two int, flag char(1)); 5676CREATE TABLE t2 (one int, two int, flag char(1)); 5677INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); 5678INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); 5679SELECT * FROM t1 5680WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); 5681one two flag 56825 6 N 56837 8 N 5684SELECT * FROM t1 5685WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); 5686one two flag 56875 6 N 56887 8 N 5689insert into t2 values (null,null,'N'); 5690insert into t2 values (null,3,'0'); 5691insert into t2 values (null,5,'0'); 5692insert into t2 values (10,null,'0'); 5693insert into t1 values (10,3,'0'); 5694insert into t1 values (10,5,'0'); 5695insert into t1 values (10,10,'0'); 5696SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; 5697one two test 56981 2 NULL 56992 3 NULL 57003 4 NULL 57015 6 1 57027 8 1 570310 3 NULL 570410 5 NULL 570510 10 NULL 5706SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); 5707one two 57085 6 57097 8 5710SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; 5711one two test 57121 2 NULL 57132 3 NULL 57143 4 NULL 57155 6 1 57167 8 1 571710 3 NULL 571810 5 NULL 571910 10 NULL 5720SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; 5721one two test 57221 2 0 57232 3 NULL 57243 4 0 57255 6 0 57267 8 0 572710 3 NULL 572810 5 NULL 572910 10 NULL 5730SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; 5731one two test 57321 2 0 57332 3 NULL 57343 4 0 57355 6 0 57367 8 0 573710 3 NULL 573810 5 NULL 573910 10 NULL 5740explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; 5741id select_type table type possible_keys key key_len ref rows filtered Extra 57421 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 NULL 57432 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where 5744Warnings: 5745Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(/* select#2 */ select 1,1 from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and <if>(outer_field_is_not_null, ((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`)), true) and <if>(outer_field_is_not_null, ((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`)), true)) having (<if>(outer_field_is_not_null, <is_not_null_test>(`test`.`t2`.`one`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` 5746explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); 5747id select_type table type possible_keys key key_len ref rows filtered Extra 57481 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 Using where 57492 SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where 5750Warnings: 5751Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),(`test`.`t1`.`one`,`test`.`t1`.`two`) in ( <materialize> (/* select#2 */ select `test`.`t2`.`one`,`test`.`t2`.`two` from `test`.`t2` where (`test`.`t2`.`flag` = 'N') ), <primary_index_lookup>(`test`.`t1`.`one` in <temporary table> on <auto_key> where ((`test`.`t1`.`one` = `materialized-subquery`.`one`) and (`test`.`t1`.`two` = `materialized-subquery`.`two`))))) 5752explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; 5753id select_type table type possible_keys key key_len ref rows filtered Extra 57541 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 NULL 57552 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where 5756Warnings: 5757Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(/* select#2 */ select 1,1 from `test`.`t2` where ((`test`.`t2`.`flag` = '0') and <if>(outer_field_is_not_null, ((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`)), true) and <if>(outer_field_is_not_null, ((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`)), true)) having (<if>(outer_field_is_not_null, <is_not_null_test>(`test`.`t2`.`one`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`test`.`t2`.`two`), true)))) AS `test` from `test`.`t1` 5758DROP TABLE t1,t2; 5759CREATE TABLE t1 (a char(5), b char(5)); 5760INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); 5761SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); 5762a b 5763aaa aaa 5764DROP TABLE t1; 5765CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)); 5766INSERT INTO t1 VALUES ('a', 'aa'); 5767INSERT INTO t1 VALUES ('a', 'aaa'); 5768SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); 5769a b 5770CREATE INDEX I1 ON t1 (a); 5771CREATE INDEX I2 ON t1 (b); 5772EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); 5773id select_type table type possible_keys key key_len ref rows Extra 57741 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 57752 SUBQUERY t1 index I1 I1 2 NULL 2 Using index 5776SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); 5777a b 5778CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)); 5779INSERT INTO t2 SELECT * FROM t1; 5780CREATE INDEX I1 ON t2 (a); 5781CREATE INDEX I2 ON t2 (b); 5782EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); 5783id select_type table type possible_keys key key_len ref rows Extra 57841 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where 57852 SUBQUERY t2 index I1 I1 4 NULL 2 Using index 5786SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); 5787a b 5788EXPLAIN 5789SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); 5790id select_type table type possible_keys key key_len ref rows Extra 57911 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 57922 SUBQUERY t1 index I1 I1 2 NULL 2 Using where; Using index 5793SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); 5794a b 5795DROP TABLE t1,t2; 5796# 5797# BUG#45928 "Differing query results depending on MRR and 5798# engine_condition_pushdown settings" 5799# 5800CREATE TABLE `t1` ( 5801`pk` int(11) NOT NULL AUTO_INCREMENT, 5802`time_nokey` time NOT NULL, 5803`varchar_key` varchar(1) NOT NULL, 5804`varchar_nokey` varchar(1) NOT NULL, 5805PRIMARY KEY (`pk`), 5806KEY `varchar_key` (`varchar_key`) 5807) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; 5808INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); 5809SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( 5810SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER 5811BY `pk` ; 5812G1 5813DROP TABLE t1; 5814# 5815# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), 5816# file item.cc, line 4448" 5817# 5818DROP TABLE IF EXISTS C, BB; 5819CREATE TABLE C ( 5820varchar_nokey varchar(1) NOT NULL 5821); 5822INSERT INTO C VALUES 5823('k'),('a'),(''),('u'),('e'),('v'),('i'), 5824('t'),('u'),('f'),('u'),('m'),('j'),('f'), 5825('v'),('j'),('g'),('e'),('h'),('z'); 5826CREATE TABLE BB ( 5827varchar_nokey varchar(1) NOT NULL 5828); 5829INSERT INTO BB VALUES ('i'),('t'); 5830SELECT varchar_nokey FROM C 5831WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey 5832FROM BB); 5833ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' 5834SELECT varchar_nokey FROM C 5835WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey 5836FROM BB); 5837ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' 5838DROP TABLE C,BB; 5839# 5840# During work with BUG#45863 I had problems with a query that was 5841# optimized differently in regular and prepared mode. 5842# Because there was a bug in one of the selected strategies, I became 5843# aware of the problem. Adding an EXPLAIN query to catch this. 5844DROP TABLE IF EXISTS t1, t2, t3; 5845CREATE TABLE t1 5846(EMPNUM CHAR(3) NOT NULL, 5847EMPNAME CHAR(20), 5848GRADE DECIMAL(4), 5849CITY CHAR(15)); 5850CREATE TABLE t2 5851(PNUM CHAR(3) NOT NULL, 5852PNAME CHAR(20), 5853PTYPE CHAR(6), 5854BUDGET DECIMAL(9), 5855CITY CHAR(15)); 5856CREATE TABLE t3 5857(EMPNUM CHAR(3) NOT NULL, 5858PNUM CHAR(3) NOT NULL, 5859HOURS DECIMAL(5)); 5860INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); 5861INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); 5862INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); 5863INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); 5864INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); 5865INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); 5866INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); 5867INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); 5868INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); 5869INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); 5870INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); 5871INSERT INTO t3 VALUES ('E1','P1',40); 5872INSERT INTO t3 VALUES ('E1','P2',20); 5873INSERT INTO t3 VALUES ('E1','P3',80); 5874INSERT INTO t3 VALUES ('E1','P4',20); 5875INSERT INTO t3 VALUES ('E1','P5',12); 5876INSERT INTO t3 VALUES ('E1','P6',12); 5877INSERT INTO t3 VALUES ('E2','P1',40); 5878INSERT INTO t3 VALUES ('E2','P2',80); 5879INSERT INTO t3 VALUES ('E3','P2',20); 5880INSERT INTO t3 VALUES ('E4','P2',20); 5881INSERT INTO t3 VALUES ('E4','P4',40); 5882INSERT INTO t3 VALUES ('E4','P5',80); 5883CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); 5884EXPLAIN SELECT EMPNAME 5885FROM t1 5886WHERE EMPNUM IN 5887(SELECT EMPNUM 5888FROM t3 5889WHERE PNUM IN 5890(SELECT PNUM 5891FROM t2 5892WHERE PTYPE = 'Design')); 5893id select_type table type possible_keys key key_len ref rows Extra 58941 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where 58952 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where 58963 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where 5897PREPARE stmt FROM "EXPLAIN SELECT EMPNAME 5898FROM t1 5899WHERE EMPNUM IN 5900 (SELECT EMPNUM 5901 FROM t3 5902 WHERE PNUM IN 5903 (SELECT PNUM 5904 FROM t2 5905 WHERE PTYPE = 'Design'))"; 5906EXECUTE stmt; 5907id select_type table type possible_keys key key_len ref rows Extra 59081 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where 59092 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where 59103 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where 5911EXECUTE stmt; 5912id select_type table type possible_keys key key_len ref rows Extra 59131 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where 59142 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where 59153 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where 5916DEALLOCATE PREPARE stmt; 5917DROP INDEX t1_IDX ON t1; 5918CREATE INDEX t1_IDX ON t1(EMPNUM); 5919EXPLAIN SELECT EMPNAME 5920FROM t1 5921WHERE EMPNUM IN 5922(SELECT EMPNUM 5923FROM t3 5924WHERE PNUM IN 5925(SELECT PNUM 5926FROM t2 5927WHERE PTYPE = 'Design')); 5928id select_type table type possible_keys key key_len ref rows Extra 59291 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where 59302 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where 59313 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where 5932PREPARE stmt FROM "EXPLAIN SELECT EMPNAME 5933FROM t1 5934WHERE EMPNUM IN 5935 (SELECT EMPNUM 5936 FROM t3 5937 WHERE PNUM IN 5938 (SELECT PNUM 5939 FROM t2 5940 WHERE PTYPE = 'Design'))"; 5941EXECUTE stmt; 5942id select_type table type possible_keys key key_len ref rows Extra 59431 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where 59442 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where 59453 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where 5946EXECUTE stmt; 5947id select_type table type possible_keys key key_len ref rows Extra 59481 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where 59492 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where 59503 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where 5951DEALLOCATE PREPARE stmt; 5952DROP INDEX t1_IDX ON t1; 5953EXPLAIN SELECT EMPNAME 5954FROM t1 5955WHERE EMPNUM IN 5956(SELECT EMPNUM 5957FROM t3 5958WHERE PNUM IN 5959(SELECT PNUM 5960FROM t2 5961WHERE PTYPE = 'Design')); 5962id select_type table type possible_keys key key_len ref rows Extra 59631 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where 59642 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where 59653 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where 5966PREPARE stmt FROM "EXPLAIN SELECT EMPNAME 5967FROM t1 5968WHERE EMPNUM IN 5969 (SELECT EMPNUM 5970 FROM t3 5971 WHERE PNUM IN 5972 (SELECT PNUM 5973 FROM t2 5974 WHERE PTYPE = 'Design'))"; 5975EXECUTE stmt; 5976id select_type table type possible_keys key key_len ref rows Extra 59771 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where 59782 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where 59793 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where 5980EXECUTE stmt; 5981id select_type table type possible_keys key key_len ref rows Extra 59821 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where 59832 SUBQUERY t3 ALL NULL NULL NULL NULL 12 Using where 59843 SUBQUERY t2 ALL NULL NULL NULL NULL 6 Using where 5985DEALLOCATE PREPARE stmt; 5986DROP TABLE t1, t2, t3; 5987# 5988# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing 5989# 5990CREATE TABLE t1 ( 5991i1_key INT, 5992i2 INT, 5993i3 INT, 5994KEY i1_index (i1_key) 5995); 5996INSERT INTO t1 VALUES (9,1,2), (9,2,1); 5997CREATE TABLE t2 ( 5998pk INT NOT NULL, 5999i1 INT, 6000PRIMARY KEY (pk) 6001); 6002INSERT INTO t2 VALUES (9,1); 6003SELECT pk 6004FROM t2 6005WHERE 6006pk IN ( 6007SELECT i1_key 6008FROM t1 6009WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 6010ORDER BY t1.i2 desc); 6011pk 60129 6013DROP TABLE t1,t2; 6014# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result 6015# 6016CREATE TABLE t1( 6017id INTEGER 6018); 6019INSERT INTO t1 VALUES(10),(20); 6020create table t2 select * from t1; 6021create table t3 select * from t1; 6022SELECT * 6023FROM t1 6024WHERE 1 IN(SELECT 1 6025FROM t2 6026WHERE 1 IN(SELECT 1 6027FROM t3)); 6028id 602910 603020 6031explain extended SELECT * 6032FROM t1 6033WHERE 1 IN(SELECT 1 6034FROM t2 6035WHERE 1 IN(SELECT 1 6036FROM t3)); 6037id select_type table type possible_keys key key_len ref rows filtered Extra 60381 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 NULL 60392 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 NULL 60403 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 NULL 6041Warnings: 6042Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` where <in_optimizer>(1,<exists>(/* select#2 */ select 1 from `test`.`t2` where <in_optimizer>(1,<exists>(/* select#3 */ select 1 from `test`.`t3` where 1)))) 6043delete from t2; 6044delete from t3; 6045INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); 6046insert into t2 select * from t1; 6047insert into t3 select * from t1; 6048create table t4 select * from t1; 6049SELECT * 6050FROM t1 6051WHERE 1 IN(SELECT 1 6052FROM t2 6053WHERE 1 IN(SELECT 1 6054FROM t3 6055WHERE 1 IN(SELECT 1 6056FROM t4))); 6057id 605810 605920 606030 606140 606250 606360 606470 606580 606690 6067explain SELECT * 6068FROM t1 6069WHERE 1 IN(SELECT 1 6070FROM t2 6071WHERE 1 IN(SELECT 1 6072FROM t3 6073WHERE 1 IN(SELECT 1 6074FROM t4))); 6075id select_type table type possible_keys key key_len ref rows Extra 60761 PRIMARY t1 ALL NULL NULL NULL NULL 9 NULL 60772 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 NULL 60783 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 9 NULL 60794 DEPENDENT SUBQUERY t4 ALL NULL NULL NULL NULL 9 NULL 6080SELECT * 6081FROM t1 6082WHERE 1 IN(SELECT 1 6083FROM t1 6084WHERE 1 IN(SELECT 1 6085FROM t1 6086WHERE 1 IN(SELECT 1 6087FROM t1))); 6088id 608910 609020 609130 609240 609350 609460 609570 609680 609790 6098drop table t1,t2,t3,t4; 6099# 6100# Bug#53236 Segfault in DTCollation::set(DTCollation&) 6101# 6102CREATE TABLE t1 ( 6103pk INTEGER AUTO_INCREMENT, 6104col_varchar VARCHAR(1), 6105PRIMARY KEY (pk) 6106) 6107; 6108INSERT INTO t1 (col_varchar) 6109VALUES 6110('w'), 6111('m') 6112; 6113SELECT table1.pk 6114FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = 6115table2.col_varchar) ) 6116WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, 6117SUBQUERY1_t1.pk AS SUBQUERY1_field2 6118FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 6119ON (SUBQUERY1_t2.col_varchar = 6120SUBQUERY1_t1.col_varchar) ) ) 6121; 6122pk 6123drop table t1; 6124# 6125# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" 6126# 6127create table t1 (uid int, fid int); 6128insert into t1 values (1,1), (3,1); 6129create table t2 (uid int, name varchar(128)); 6130insert into t2 values (1, "A"), (2, "B"); 6131create table t3 (uid int, fid int, index(uid)); 6132insert into t3 values (1,3), (1,3); 6133create table t4 (uid int); 6134insert into t4 values (3); 6135explain select t2.uid from t2, t1 6136where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) 6137and t2.uid=t1.fid; 6138id select_type table type possible_keys key key_len ref rows Extra 61391 PRIMARY t2 ALL NULL NULL NULL NULL 2 NULL 61401 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 61412 SUBQUERY t4 system NULL NULL NULL NULL 1 NULL 61422 SUBQUERY t3 ref uid uid 5 const 1 Using where 6143select t2.uid from t2, t1 6144where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) 6145and t2.uid=t1.fid; 6146uid 61471 6148drop table t1,t2,t3,t4; 6149CREATE TABLE t1 ( 6150pk int, 6151a varchar(1), 6152b varchar(4), 6153c varchar(4), 6154d varchar(4), 6155PRIMARY KEY (pk) 6156); 6157INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); 6158CREATE TABLE t2 LIKE t1; 6159INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); 6160EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); 6161id select_type table type possible_keys key key_len ref rows Extra 61621 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 61632 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 Using where 6164SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); 6165pk 61662 6167SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); 6168pk 61692 6170DROP TABLE t1, t2; 6171CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; 6172INSERT INTO t1 (f1, f2) VALUES (1, 1.789); 6173INSERT INTO t1 (f1, f2) VALUES (13, 1.454); 6174INSERT INTO t1 (f1, f2) VALUES (10, 1.668); 6175CREATE TABLE t2 LIKE t1; 6176INSERT INTO t2 VALUES (1, 1.789); 6177INSERT INTO t2 VALUES (13, 1.454); 6178EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); 6179id select_type table type possible_keys key key_len ref rows Extra 61801 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where 61812 SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 6182SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); 6183COUNT(*) 61842 6185DROP TABLE t1, t2; 6186CREATE TABLE t1 ( 6187ID int(11) NOT NULL auto_increment, 6188Name char(35) NOT NULL default '', 6189Country char(3) NOT NULL default '', 6190Population int(11) NOT NULL default '0', 6191PRIMARY KEY (ID), 6192INDEX (Population), 6193INDEX (Country) 6194); 6195CREATE TABLE t2 ( 6196Code char(3) NOT NULL default '', 6197Name char(52) NOT NULL default '', 6198SurfaceArea float(10,2) NOT NULL default '0.00', 6199Population int(11) NOT NULL default '0', 6200Capital int(11) default NULL, 6201PRIMARY KEY (Code), 6202UNIQUE INDEX (Name), 6203INDEX (Population) 6204); 6205CREATE TABLE t3 ( 6206Country char(3) NOT NULL default '', 6207Language char(30) NOT NULL default '', 6208Percentage float(3,1) NOT NULL default '0.0', 6209PRIMARY KEY (Country, Language), 6210INDEX (Percentage) 6211); 6212EXPLAIN SELECT Name FROM t2 6213WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) 6214AND 6215t2.Code IN (SELECT Country FROM t3 6216WHERE Language='English' AND Percentage > 10 AND 6217t2.Population > 100000); 6218id select_type table type possible_keys key key_len ref rows Extra 62191 PRIMARY t2 ALL NULL NULL NULL NULL 16 Using where 62203 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,Percentage PRIMARY 33 func,const 1 Using where 62212 SUBQUERY t1 range Population,Country Population 4 NULL 1 Using where 6222EXPLAIN FORMAT=JSON SELECT Name FROM t2 6223WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) 6224AND 6225t2.Code IN (SELECT Country FROM t3 6226WHERE Language='English' AND Percentage > 10 AND 6227t2.Population > 100000); 6228EXPLAIN 6229{ 6230 "query_block": { 6231 "select_id": 1, 6232 "table": { 6233 "table_name": "t2", 6234 "access_type": "ALL", 6235 "rows": 16, 6236 "filtered": 100, 6237 "attached_condition": "(<in_optimizer>(`test`.`t2`.`Code`,`test`.`t2`.`Code` in ( <materialize> (/* select#2 */ select `test`.`t1`.`Country` from `test`.`t1` where (`test`.`t1`.`Population` > 5000000) ), <primary_index_lookup>(`test`.`t2`.`Code` in <temporary table> on <auto_key> where ((`test`.`t2`.`Code` = `materialized-subquery`.`Country`))))) and <in_optimizer>(`test`.`t2`.`Code`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`Code`) in t3 on PRIMARY where ((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (<cache>(`test`.`t2`.`Code`) = `test`.`t3`.`Country`))))))", 6238 "attached_subqueries": [ 6239 { 6240 "dependent": true, 6241 "cacheable": false, 6242 "query_block": { 6243 "select_id": 3, 6244 "table": { 6245 "table_name": "t3", 6246 "access_type": "unique_subquery", 6247 "possible_keys": [ 6248 "PRIMARY", 6249 "Percentage" 6250 ], 6251 "key": "PRIMARY", 6252 "used_key_parts": [ 6253 "Country", 6254 "Language" 6255 ], 6256 "key_length": "33", 6257 "ref": [ 6258 "func", 6259 "const" 6260 ], 6261 "rows": 1, 6262 "filtered": 100, 6263 "attached_condition": "((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000))" 6264 } 6265 } 6266 }, 6267 { 6268 "table": { 6269 "table_name": "<materialized_subquery>", 6270 "access_type": "eq_ref", 6271 "key": "<auto_key>", 6272 "key_length": "3", 6273 "rows": 1, 6274 "materialized_from_subquery": { 6275 "using_temporary_table": true, 6276 "dependent": true, 6277 "cacheable": false, 6278 "query_block": { 6279 "select_id": 2, 6280 "table": { 6281 "table_name": "t1", 6282 "access_type": "range", 6283 "possible_keys": [ 6284 "Population", 6285 "Country" 6286 ], 6287 "key": "Population", 6288 "used_key_parts": [ 6289 "Population" 6290 ], 6291 "key_length": "4", 6292 "rows": 1, 6293 "filtered": 100, 6294 "attached_condition": "(`test`.`t1`.`Population` > 5000000)" 6295 } 6296 } 6297 } 6298 } 6299 } 6300 ] 6301 } 6302 } 6303} 6304Warnings: 6305Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 6306Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t2` where (<in_optimizer>(`test`.`t2`.`Code`,`test`.`t2`.`Code` in ( <materialize> (/* select#2 */ select `test`.`t1`.`Country` from `test`.`t1` where (`test`.`t1`.`Population` > 5000000) ), <primary_index_lookup>(`test`.`t2`.`Code` in <temporary table> on <auto_key> where ((`test`.`t2`.`Code` = `materialized-subquery`.`Country`))))) and <in_optimizer>(`test`.`t2`.`Code`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`Code`) in t3 on PRIMARY where ((`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (<cache>(`test`.`t2`.`Code`) = `test`.`t3`.`Country`)))))) 6307DROP TABLE t1,t2,t3; 6308CREATE TABLE t1 ( 6309Code char(3) NOT NULL DEFAULT '', 6310Name char(52) NOT NULL DEFAULT '', 6311Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', 6312Region char(26) NOT NULL DEFAULT '', 6313SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', 6314IndepYear smallint(6) DEFAULT NULL, 6315Population int(11) NOT NULL DEFAULT '0', 6316LifeExpectancy float(3,1) DEFAULT NULL, 6317GNP float(10,2) DEFAULT NULL, 6318GNPOld float(10,2) DEFAULT NULL, 6319LocalName char(45) NOT NULL DEFAULT '', 6320GovernmentForm char(45) NOT NULL DEFAULT '', 6321HeadOfState char(60) DEFAULT NULL, 6322Capital int(11) DEFAULT NULL, 6323Code2 char(2) NOT NULL DEFAULT '', 6324PRIMARY KEY (Code) 6325); 6326CREATE TABLE t2 ( 6327ID int(11) NOT NULL AUTO_INCREMENT, 6328Name char(35) NOT NULL DEFAULT '', 6329CountryCode char(3) NOT NULL DEFAULT '', 6330District char(20) NOT NULL DEFAULT '', 6331Population int(11) NOT NULL DEFAULT '0', 6332PRIMARY KEY (ID), 6333KEY CountryCode (CountryCode) 6334); 6335Fill the table with test data 6336This must not use LooseScan: 6337EXPLAIN SELECT Name FROM t1 6338WHERE t1.Code IN ( 6339SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); 6340id select_type table type possible_keys key key_len ref rows Extra 63411 PRIMARY t1 ALL NULL NULL NULL NULL 31 Using where 63422 SUBQUERY t2 ALL CountryCode NULL NULL NULL 545 Using where 6343SELECT Name FROM t1 6344WHERE t1.Code IN ( 6345SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); 6346Name 6347Austria 6348Canada 6349China 6350Czech Republic 6351drop table t1, t2; 6352create table t0 (a int); 6353insert into t0 values (0),(1),(2),(3),(4); 6354create table t1 (a int, b int, key(a)); 6355insert into t1 select a,a from t0; 6356create table t2 (a int, b int, primary key(a)); 6357insert into t2 select * from t1; 6358Table t2, unlike table t1, should be displayed as pulled out 6359explain extended select * from t0 6360where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and 6361t1.b=t2.b); 6362id select_type table type possible_keys key key_len ref rows filtered Extra 63631 PRIMARY t0 ALL NULL NULL NULL NULL 5 100.00 Using where 63642 DEPENDENT SUBQUERY t1 ref a a 5 func 1 100.00 NULL 63652 DEPENDENT SUBQUERY t2 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 100.00 Using where 6366Warnings: 6367Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 6368Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` where <in_optimizer>(`test`.`t0`.`a`,<exists>(/* select#2 */ select 1 from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t0`.`a`) and (<cache>(`test`.`t0`.`a`) = `test`.`t1`.`a`)))) 6369update t1 set a=3, b=11 where a=4; 6370update t2 set b=11 where a=3; 6371create temporary table tmp select * from t0 where t0.a in 6372(select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); 6373create temporary table tmp_as_ref (a int); 6374insert into tmp_as_ref values(0),(1),(2),(3); 6375select * from tmp; 6376a 63770 63781 63792 63803 6381drop table t0, t1, t2, tmp, tmp_as_ref; 6382CREATE TABLE t1 ( 6383id int(11) NOT NULL, 6384PRIMARY KEY (id)); 6385CREATE TABLE t2 ( 6386id int(11) NOT NULL, 6387fid int(11) NOT NULL, 6388PRIMARY KEY (id)); 6389insert into t1 values(1); 6390insert into t2 values(1,7503),(2,1); 6391explain select count(*) 6392from t1 6393where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); 6394ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' 6395drop table t1, t2; 6396create table t1 (a int, b int, key (a), key (b)); 6397insert into t1 values (2,4),(2,4),(2,4); 6398select t1.a from t1 6399where 6400t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); 6401a 6402drop table t1; 6403create table t1(a int,b int,key(a),key(b)); 6404insert into t1 values (1,1),(2,2),(3,3); 6405select 1 from t1 6406where t1.a not in (select 1 from t1 6407where t1.a in (select 1 from t1) 6408group by t1.b); 64091 64101 64111 6412drop table t1; 6413CREATE TABLE t1 6414(EMPNUM CHAR(3) NOT NULL, 6415EMPNAME CHAR(20), 6416GRADE DECIMAL(4), 6417CITY CHAR(15)); 6418CREATE TABLE t2 6419(PNUM CHAR(3) NOT NULL, 6420PNAME CHAR(20), 6421PTYPE CHAR(6), 6422BUDGET DECIMAL(9), 6423CITY CHAR(15)); 6424CREATE TABLE t3 6425(EMPNUM CHAR(3) NOT NULL, 6426PNUM CHAR(3) NOT NULL, 6427HOURS DECIMAL(5)); 6428INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); 6429INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); 6430INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); 6431INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); 6432INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); 6433INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); 6434INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); 6435INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); 6436INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); 6437INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); 6438INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); 6439INSERT INTO t3 VALUES ('E1','P1',40); 6440INSERT INTO t3 VALUES ('E1','P2',20); 6441INSERT INTO t3 VALUES ('E1','P3',80); 6442INSERT INTO t3 VALUES ('E1','P4',20); 6443INSERT INTO t3 VALUES ('E1','P5',12); 6444INSERT INTO t3 VALUES ('E1','P6',12); 6445INSERT INTO t3 VALUES ('E2','P1',40); 6446INSERT INTO t3 VALUES ('E2','P2',80); 6447INSERT INTO t3 VALUES ('E3','P2',20); 6448INSERT INTO t3 VALUES ('E4','P2',20); 6449INSERT INTO t3 VALUES ('E4','P4',40); 6450INSERT INTO t3 VALUES ('E4','P5',80); 6451SELECT * FROM t1; 6452EMPNUM EMPNAME GRADE CITY 6453E1 Alice 12 Deale 6454E2 Betty 10 Vienna 6455E3 Carmen 13 Vienna 6456E4 Don 12 Deale 6457E5 Ed 13 Akron 6458CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); 6459SELECT EMPNAME 6460FROM t1 6461WHERE EMPNUM IN 6462(SELECT EMPNUM 6463FROM t3 6464WHERE PNUM IN 6465(SELECT PNUM 6466FROM t2 6467WHERE PTYPE = 'Design')); 6468EMPNAME 6469Alice 6470Betty 6471Don 6472DROP INDEX t1_IDX ON t1; 6473CREATE INDEX t1_IDX ON t1(EMPNUM); 6474SELECT EMPNAME 6475FROM t1 6476WHERE EMPNUM IN 6477(SELECT EMPNUM 6478FROM t3 6479WHERE PNUM IN 6480(SELECT PNUM 6481FROM t2 6482WHERE PTYPE = 'Design')); 6483EMPNAME 6484Alice 6485Betty 6486Don 6487DROP INDEX t1_IDX ON t1; 6488SELECT EMPNAME 6489FROM t1 6490WHERE EMPNUM IN 6491(SELECT EMPNUM 6492FROM t3 6493WHERE PNUM IN 6494(SELECT PNUM 6495FROM t2 6496WHERE PTYPE = 'Design')); 6497EMPNAME 6498Alice 6499Betty 6500Don 6501DROP TABLE t1, t2, t3; 6502CREATE TABLE t1 (f1 INT NOT NULL); 6503CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; 6504SELECT * FROM v1; 6505a 6506drop view v1; 6507drop table t1; 6508create table t0 (a int); 6509insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 6510create table t1(a int, b int); 6511insert into t1 values (0,0),(1,1),(2,2); 6512create table t2 as select * from t1; 6513create table t3 (pk int, a int, primary key(pk)); 6514insert into t3 select a,a from t0; 6515explain 6516select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); 6517id select_type table type possible_keys key key_len ref rows Extra 65181 PRIMARY t1 ALL NULL NULL NULL NULL 3 NULL 65191 PRIMARY t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (Block Nested Loop) 65202 SUBQUERY t3 index PRIMARY PRIMARY 4 NULL 10 Using index 6521drop table t0, t1, t2, t3; 6522create table t0 (a int); 6523insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 6524create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; 6525create table t2 (id int, a int, primary key(id), key(a)) as select a as id, a as a from t1; 6526show create table t2; 6527Table Create Table 6528t2 CREATE TABLE `t2` ( 6529 `id` int(11) NOT NULL DEFAULT '0', 6530 `a` int(11) DEFAULT NULL, 6531 PRIMARY KEY (`id`), 6532 KEY `a` (`a`) 6533) ENGINE=MyISAM DEFAULT CHARSET=latin1 6534set @a=0; 6535create table t3 as select * from t2 limit 0; 6536insert into t3 select @a:=@a+1, t2.a from t2, t0; 6537insert into t3 select @a:=@a+1, t2.a from t2, t0; 6538insert into t3 select @a:=@a+1, t2.a from t2, t0; 6539alter table t3 add primary key(id), add key(a); 6540The following must use loose index scan over t3, key a: 6541explain select count(a) from t2 where a in ( SELECT a FROM t3); 6542id select_type table type possible_keys key key_len ref rows Extra 65431 PRIMARY t2 index NULL a 5 NULL 1000 Using where; Using index 65442 SUBQUERY t3 index a a 5 NULL 30000 Using index 6545select count(a) from t2 where a in ( SELECT a FROM t3); 6546count(a) 65471000 6548drop table t0,t1,t2,t3; 6549# 6550# Bug#33062: subquery in stored routine cause crash 6551# 6552CREATE TABLE t1(a INT); 6553CREATE TABLE t2(c INT); 6554CREATE PROCEDURE p1(v1 int) 6555BEGIN 6556SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); 6557END 6558// 6559CREATE PROCEDURE p2(v1 int) 6560BEGIN 6561SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); 6562END 6563// 6564CREATE PROCEDURE p3(v1 int) 6565BEGIN 6566SELECT 1 6567FROM 6568t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, 6569t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, 6570t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, 6571t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, 6572t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, 6573t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, 6574t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, 6575t1 t57,t1 t58,t1 t59,t1 t60 6576WHERE t01.a IN (SELECT c FROM t2); 6577END 6578// 6579CREATE PROCEDURE p4(v1 int) 6580BEGIN 6581SELECT 1 6582FROM 6583t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, 6584t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, 6585t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, 6586t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, 6587t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, 6588t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, 6589t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, 6590t1 t57,t1 t58,t1 t59,t1 t60 6591WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); 6592END 6593// 6594CALL p1(1); 65951 6596CALL p2(1); 65971 6598CALL p3(1); 65991 6600CALL p4(1); 66011 6602DROP TABLE t1, t2; 6603DROP PROCEDURE p1; 6604DROP PROCEDURE p2; 6605DROP PROCEDURE p3; 6606DROP PROCEDURE p4; 6607# 6608# Bug#48213 Materialized subselect crashes if using GEOMETRY type 6609# 6610CREATE TABLE t1 ( 6611pk int, 6612a varchar(1), 6613b varchar(4), 6614c tinyblob, 6615d blob, 6616e mediumblob, 6617f longblob, 6618g tinytext, 6619h text, 6620i mediumtext, 6621j longtext, 6622k geometry, 6623PRIMARY KEY (pk) 6624); 6625INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); 6626CREATE TABLE t2 LIKE t1; 6627INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); 6628EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); 6629id select_type table type possible_keys key key_len ref rows filtered Extra 66301 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where 66312 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using where 6632Warnings: 6633Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`a`,`test`.`t1`.`b`),(`test`.`t1`.`a`,`test`.`t1`.`b`) in ( <materialize> (/* select#2 */ select `test`.`t2`.`a`,`test`.`t2`.`b` from `test`.`t2` where (`test`.`t2`.`pk` > 0) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on <auto_key> where ((`test`.`t1`.`a` = `materialized-subquery`.`a`) and (`test`.`t1`.`b` = `materialized-subquery`.`b`))))) 6634SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); 6635pk 66362 6637EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); 6638id select_type table type possible_keys key key_len ref rows filtered Extra 66391 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where 66402 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using where 6641Warnings: 6642Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`b`,`test`.`t1`.`c`),<exists>(/* select#2 */ select 1,1 from `test`.`t2` where ((`test`.`t2`.`pk` > 0) and (<cache>(`test`.`t1`.`b`) = `test`.`t2`.`b`) and (<cache>(`test`.`t1`.`c`) = `test`.`t2`.`c`)))) 6643SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); 6644pk 66451 66462 6647EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); 6648id select_type table type possible_keys key key_len ref rows filtered Extra 66491 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where 66502 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using where 6651Warnings: 6652Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`b`,`test`.`t1`.`d`),<exists>(/* select#2 */ select 1,1 from `test`.`t2` where ((`test`.`t2`.`pk` > 0) and (<cache>(`test`.`t1`.`b`) = `test`.`t2`.`b`) and (<cache>(`test`.`t1`.`d`) = `test`.`t2`.`d`)))) 6653SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); 6654pk 66552 6656EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); 6657id select_type table type possible_keys key key_len ref rows filtered Extra 66581 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where 66592 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using where 6660Warnings: 6661Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`b`,`test`.`t1`.`e`),<exists>(/* select#2 */ select 1,1 from `test`.`t2` where ((`test`.`t2`.`pk` > 0) and (<cache>(`test`.`t1`.`b`) = `test`.`t2`.`b`) and (<cache>(`test`.`t1`.`e`) = `test`.`t2`.`e`)))) 6662SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); 6663pk 66641 66652 6666EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); 6667id select_type table type possible_keys key key_len ref rows filtered Extra 66681 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where 66692 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using where 6670Warnings: 6671Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`b`,`test`.`t1`.`f`),<exists>(/* select#2 */ select 1,1 from `test`.`t2` where ((`test`.`t2`.`pk` > 0) and (<cache>(`test`.`t1`.`b`) = `test`.`t2`.`b`) and (<cache>(`test`.`t1`.`f`) = `test`.`t2`.`f`)))) 6672SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); 6673pk 66741 66752 6676EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); 6677id select_type table type possible_keys key key_len ref rows filtered Extra 66781 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where 66792 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using where 6680Warnings: 6681Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`b`,`test`.`t1`.`g`),<exists>(/* select#2 */ select 1,1 from `test`.`t2` where ((`test`.`t2`.`pk` > 0) and (<cache>(`test`.`t1`.`b`) = `test`.`t2`.`b`) and (<cache>(`test`.`t1`.`g`) = `test`.`t2`.`g`)))) 6682SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); 6683pk 66841 66852 6686EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); 6687id select_type table type possible_keys key key_len ref rows filtered Extra 66881 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where 66892 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using where 6690Warnings: 6691Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`b`,`test`.`t1`.`h`),<exists>(/* select#2 */ select 1,1 from `test`.`t2` where ((`test`.`t2`.`pk` > 0) and (<cache>(`test`.`t1`.`b`) = `test`.`t2`.`b`) and (<cache>(`test`.`t1`.`h`) = `test`.`t2`.`h`)))) 6692SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); 6693pk 66941 66952 6696EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); 6697id select_type table type possible_keys key key_len ref rows filtered Extra 66981 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where 66992 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using where 6700Warnings: 6701Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`b`,`test`.`t1`.`i`),<exists>(/* select#2 */ select 1,1 from `test`.`t2` where ((`test`.`t2`.`pk` > 0) and (<cache>(`test`.`t1`.`b`) = `test`.`t2`.`b`) and (<cache>(`test`.`t1`.`i`) = `test`.`t2`.`i`)))) 6702SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); 6703pk 67041 67052 6706EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); 6707id select_type table type possible_keys key key_len ref rows filtered Extra 67081 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where 67092 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using where 6710Warnings: 6711Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`b`,`test`.`t1`.`j`),<exists>(/* select#2 */ select 1,1 from `test`.`t2` where ((`test`.`t2`.`pk` > 0) and (<cache>(`test`.`t1`.`b`) = `test`.`t2`.`b`) and (<cache>(`test`.`t1`.`j`) = `test`.`t2`.`j`)))) 6712SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); 6713pk 67141 67152 6716EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); 6717id select_type table type possible_keys key key_len ref rows filtered Extra 67181 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where 67192 DEPENDENT SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using where 6720Warnings: 6721Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`b`,`test`.`t1`.`k`),<exists>(/* select#2 */ select 1,1 from `test`.`t2` where ((`test`.`t2`.`pk` > 0) and (<cache>(`test`.`t1`.`b`) = `test`.`t2`.`b`) and (<cache>(`test`.`t1`.`k`) = `test`.`t2`.`k`)))) 6722SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); 6723pk 67241 67252 6726DROP TABLE t1, t2; 6727# End of Bug#48213 6728# 6729# BUG#53060: LooseScan semijoin strategy does not return all rows 6730# 6731CREATE TABLE t1 (i INTEGER); 6732INSERT INTO t1 VALUES (1), (2), (3), (4), (5); 6733CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); 6734INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); 6735EXPLAIN 6736SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); 6737id select_type table type possible_keys key key_len ref rows Extra 67381 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where 67392 SUBQUERY t2 index k k 10 NULL 4 Using where; Using index 6740SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); 6741i 67421 67432 6744DROP TABLE t1, t2; 6745# End of BUG#53060 6746# 6747# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" 6748# 6749create table t1 (uid int, fid int, index(uid)); 6750insert into t1 values 6751(1,1), (1,2), (1,3), (1,4), 6752(2,5), (2,6), (2,7), (2,8), 6753(3,1), (3,2), (3,9); 6754create table t2 (uid int primary key, name varchar(128), index(name)); 6755insert into t2 values 6756(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), 6757(6, "F"), (7, "G"), (8, "H"), (9, "I"); 6758create table t3 (uid int, fid int, index(uid)); 6759insert into t3 values 6760(1,1), (1,2), (1,3),(1,4), 6761(2,5), (2,6), (2,7), (2,8), 6762(3,1), (3,2), (3,9); 6763create table t4 (uid int primary key, name varchar(128), index(name)); 6764insert into t4 values 6765(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), 6766(6, "F"), (7, "G"), (8, "H"), (9, "I"); 6767explain select name from t2, t1 6768where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) 6769and t2.uid=t1.fid; 6770id select_type table type possible_keys key key_len ref rows Extra 67711 PRIMARY t1 ALL NULL NULL NULL NULL 11 Using where 67721 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 NULL 67732 SUBQUERY t3 ref uid uid 5 const 4 Using where 67742 SUBQUERY t4 eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 Using index 6775select name from t2, t1 6776where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) 6777and t2.uid=t1.fid; 6778name 6779A 6780A 6781B 6782B 6783C 6784D 6785E 6786F 6787G 6788H 6789I 6790drop table t1,t2,t3,t4; 6791# 6792# Bug#43768 Prepared query with nested subqueries core dump on second execution 6793# 6794CREATE TABLE t1 ( 6795id INT PRIMARY KEY, 6796partner_id VARCHAR(35) 6797); 6798INSERT INTO t1 VALUES 6799(1, 'partner1'), (2, 'partner2'), 6800(3, 'partner3'), (4, 'partner4'); 6801CREATE TABLE t2 ( 6802id INT NOT NULL, 6803t1_line_id INT, 6804article_id VARCHAR(20), 6805PRIMARY KEY(id, t1_line_id) 6806); 6807INSERT INTO t2 VALUES 6808(1, 1, 'sup'), (2, 1, 'sup'), 6809(2, 2, 'sup'), (2, 3, 'sup'), 6810(2, 4, 'imp'), (3, 1, 'sup'), 6811(4, 1, 'sup'); 6812CREATE TABLE t3 ( 6813user_id VARCHAR(50), 6814article_id VARCHAR(20) NOT NULL, 6815PRIMARY KEY(user_id) 6816); 6817INSERT INTO t3 VALUES('nicke', 'imp'); 6818EXPLAIN 6819SELECT t1.partner_id 6820FROM t1 6821WHERE t1.id IN ( 6822SELECT t2.id 6823FROM t2 6824WHERE article_id IN ( 6825SELECT article_id FROM t3 6826WHERE user_id = 'nicke' 6827 ) 6828); 6829id select_type table type possible_keys key key_len ref rows Extra 68301 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where 68312 SUBQUERY t2 ALL PRIMARY NULL NULL NULL 7 Using where 68323 SUBQUERY t3 system PRIMARY NULL NULL NULL 1 NULL 6833SELECT t1.partner_id 6834FROM t1 6835WHERE t1.id IN ( 6836SELECT t2.id 6837FROM t2 6838WHERE article_id IN ( 6839SELECT article_id FROM t3 6840WHERE user_id = 'nicke' 6841 ) 6842); 6843partner_id 6844partner2 6845PREPARE stmt FROM 6846'EXPLAIN SELECT t1.partner_id 6847FROM t1 6848WHERE t1.id IN ( 6849 SELECT t2.id 6850 FROM t2 6851 WHERE article_id IN ( 6852 SELECT article_id FROM t3 6853 WHERE user_id = \'nicke\' 6854 ) 6855 )'; 6856EXECUTE stmt; 6857id select_type table type possible_keys key key_len ref rows Extra 68581 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where 68592 SUBQUERY t2 ALL PRIMARY NULL NULL NULL 7 Using where 68603 SUBQUERY t3 system PRIMARY NULL NULL NULL 1 NULL 6861EXECUTE stmt; 6862id select_type table type possible_keys key key_len ref rows Extra 68631 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where 68642 SUBQUERY t2 ALL PRIMARY NULL NULL NULL 7 Using where 68653 SUBQUERY t3 system PRIMARY NULL NULL NULL 1 NULL 6866PREPARE stmt FROM 6867'SELECT t1.partner_id 6868FROM t1 6869WHERE t1.id IN ( 6870 SELECT t2.id 6871 FROM t2 6872 WHERE article_id IN ( 6873 SELECT article_id FROM t3 6874 WHERE user_id = \'nicke\' 6875 ) 6876 )'; 6877EXECUTE stmt; 6878partner_id 6879partner2 6880EXECUTE stmt; 6881partner_id 6882partner2 6883DROP TABLE t1,t2,t3; 6884# End of Bug#43768 6885# 6886# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result 6887# 6888CREATE TABLE t1 (i INTEGER); 6889CREATE TABLE t2 (i INTEGER); 6890CREATE TABLE t3 (i INTEGER); 6891INSERT INTO t1 VALUES (1), (2); 6892INSERT INTO t2 VALUES (6); 6893INSERT INTO t3 VALUES (1), (2); 6894explain extended SELECT * FROM t1 WHERE (t1.i) IN 6895(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); 6896id select_type table type possible_keys key key_len ref rows filtered Extra 68971 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where 68982 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 NULL 68992 SUBQUERY t2 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (Block Nested Loop) 6900Warnings: 6901Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`i`,`test`.`t1`.`i` in ( <materialize> (/* select#2 */ select `test`.`t3`.`i` from `test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`)) where 1 ), <primary_index_lookup>(`test`.`t1`.`i` in <temporary table> on <auto_key> where ((`test`.`t1`.`i` = `materialized-subquery`.`i`))))) 6902SELECT * FROM t1 WHERE (t1.i) IN 6903(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); 6904i 69051 69062 6907drop table t1,t2,t3; 6908# 6909# BUG#49453: re-execution of prepared statement with view 6910# and semijoin crashes 6911# 6912CREATE TABLE t1 (city VARCHAR(50), country_id INT); 6913CREATE TABLE t2 (country_id INT, country VARCHAR(50)); 6914INSERT INTO t1 VALUES 6915('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; 6916INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); 6917CREATE VIEW v1 AS 6918SELECT country_id as vf_country_id 6919FROM t2 6920WHERE LEFT(country,1) = "A"; 6921PREPARE stmt FROM " 6922SELECT city, country_id 6923FROM t1 6924WHERE country_id IN (SELECT vf_country_id FROM v1); 6925"; 6926 6927EXECUTE stmt; 6928city country_id 6929Batna 2 6930Bchar 2 6931Skikda 2 6932Algeria 2 6933EXECUTE stmt; 6934city country_id 6935Batna 2 6936Bchar 2 6937Skikda 2 6938Algeria 2 6939DROP TABLE t1,t2; 6940DROP VIEW v1; 6941# 6942# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch 6943# and duplicates weedout) 6944# 6945create table t1 (a int); 6946create table t2 (a int); 6947create table t3 (a int); 6948insert into t1 values(1),(1); 6949insert into t2 values(1),(1),(1),(1); 6950insert into t3 values(2),(2); 6951explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); 6952id select_type table type possible_keys key key_len ref rows Extra 69531 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 69542 SUBQUERY t2 ALL NULL NULL NULL NULL 4 NULL 69552 SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 6956select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); 6957a 69581 69591 6960drop table t1,t2,t3; 6961# 6962# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) 6963# 6964CREATE TABLE t1 (a INT); 6965CREATE TABLE t2 (a INT); 6966CREATE TABLE t3 (a INT); 6967INSERT INTO t1 VALUES(1),(1); 6968INSERT INTO t2 VALUES(1),(1); 6969INSERT INTO t3 VALUES(2),(2); 6970explain SELECT * FROM t1 6971WHERE t1.a IN (SELECT t2.a 6972FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); 6973id select_type table type possible_keys key key_len ref rows Extra 69741 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 69752 SUBQUERY t2 ALL NULL NULL NULL NULL 2 NULL 69762 SUBQUERY t2inner ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop) 69772 SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 6978SELECT * FROM t1 6979WHERE t1.a IN (SELECT t2.a 6980FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); 6981a 69821 69831 6984DROP TABLE t1,t2,t3; 6985# 6986# BUG#52329 - Wrong result: subquery materialization, IN, 6987# non-null field followed by nullable 6988# 6989CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); 6990CREATE TABLE t2a (b1 char(8), b2 char(8)); 6991CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); 6992CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); 6993INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); 6994INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), 6995('1 - 11', '2 - 21'), 6996('1 - 12', '2 - 22'), 6997('1 - 12', '2 - 22'), 6998('1 - 13', '2 - 23'); 6999INSERT INTO t2b SELECT * FROM t2a; 7000INSERT INTO t2c SELECT * FROM t2a; 7001SELECT * FROM t1 7002WHERE (a1, a2) IN ( 7003SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); 7004a1 a2 70051 - 12 2 - 22 7006SELECT * FROM t1 7007WHERE (a1, a2) IN ( 7008SELECT b1, b2 FROM t2a WHERE b1 > '0'); 7009a1 a2 70101 - 12 2 - 22 7011SELECT * FROM t1 7012WHERE (a1, a2) IN ( 7013SELECT b1, b2 FROM t2b WHERE b1 > '0'); 7014a1 a2 70151 - 12 2 - 22 7016SELECT * FROM t1 7017WHERE (a1, a2) IN ( 7018SELECT b1, b2 FROM t2c WHERE b1 > '0'); 7019a1 a2 70201 - 12 2 - 22 7021DROP TABLE t1,t2a,t2b,t2c; 7022# End BUG#52329 7023# 7024# Bug#45174: Incorrectly applied equality propagation caused wrong 7025# result on a query with a materialized semi-join. 7026# 7027CREATE TABLE t1 ( 7028varchar_nokey varchar(1) NOT NULL 7029); 7030INSERT INTO t1 VALUES 7031('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), 7032('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); 7033CREATE TABLE t2 ( 7034pk int NOT NULL, 7035varchar_key varchar(1) NOT NULL, 7036varchar_nokey varchar(1) NOT NULL, 7037PRIMARY KEY(pk), 7038KEY varchar_key(varchar_key) 7039); 7040INSERT INTO t2 VALUES 7041(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), 7042(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), 7043(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); 7044SELECT varchar_nokey 7045FROM t1 7046WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey 7047FROM t2 7048WHERE varchar_nokey < 'n' XOR pk); 7049varchar_nokey 7050explain SELECT varchar_nokey 7051FROM t1 7052WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey 7053FROM t2 7054WHERE varchar_nokey < 'n' XOR pk); 7055id select_type table type possible_keys key key_len ref rows Extra 70561 PRIMARY t1 ALL NULL NULL NULL NULL 18 Using where 70572 SUBQUERY t2 ALL varchar_key NULL NULL NULL 15 Using where 7058DROP TABLE t1, t2; 7059# End of the test for bug#45174. 7060# 7061# Bug#50019: Wrong result for IN-query with materialization 7062# 7063CREATE TABLE t1(i INT); 7064INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); 7065CREATE TABLE t2(i INT); 7066INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); 7067CREATE TABLE t3(i INT); 7068INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); 7069SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i 7070FROM t2 JOIN t3 7071WHERE t2.i + t3.i = 5); 7072i 70731 70742 70753 70764 7077explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i 7078FROM t2 JOIN t3 7079WHERE t2.i + t3.i = 5); 7080id select_type table type possible_keys key key_len ref rows Extra 70811 PRIMARY t1 ALL NULL NULL NULL NULL 10 Using where 70822 SUBQUERY t2 ALL NULL NULL NULL NULL 10 NULL 70832 SUBQUERY t3 ALL NULL NULL NULL NULL 10 Using where; Using join buffer (Block Nested Loop) 7084DROP TABLE t1,t2,t3; 7085# End of the test for bug#50019. 7086# 7087# Bug#52068: Optimizer generates invalid semijoin materialization plan 7088# 7089CREATE TABLE ot1(a INTEGER); 7090INSERT INTO ot1 VALUES(5), (8); 7091CREATE TABLE it2(a INTEGER); 7092INSERT INTO it2 VALUES(9), (5), (1), (8); 7093CREATE TABLE it3(a INTEGER); 7094INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); 7095CREATE TABLE ot4(a INTEGER); 7096INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); 7097SELECT * FROM ot1,ot4 7098WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a 7099FROM it2,it3); 7100a a 71015 1 71028 1 71035 5 71048 5 71055 7 71068 7 71075 7 71088 7 71095 1 71108 1 7111explain SELECT * FROM ot1,ot4 7112WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a 7113FROM it2,it3); 7114id select_type table type possible_keys key key_len ref rows Extra 71151 PRIMARY ot1 ALL NULL NULL NULL NULL 2 NULL 71161 PRIMARY ot4 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop) 71172 SUBQUERY it2 ALL NULL NULL NULL NULL 4 NULL 71182 SUBQUERY it3 ALL NULL NULL NULL NULL 6 Using join buffer (Block Nested Loop) 7119DROP TABLE IF EXISTS ot1, ot4, it2, it3; 7120# End of the test for bug#52068. 7121# 7122# Bug#57623: subquery within before insert trigger causes crash (sj=on) 7123# 7124CREATE TABLE ot1(a INT); 7125CREATE TABLE ot2(a INT); 7126CREATE TABLE ot3(a INT); 7127CREATE TABLE it1(a INT); 7128INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); 7129INSERT INTO ot2 VALUES(0),(2),(4),(6); 7130INSERT INTO ot3 VALUES(0),(3),(6); 7131INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); 7132explain SELECT * 7133FROM ot1 7134LEFT JOIN 7135(ot2 JOIN ot3 on ot2.a=ot3.a) 7136ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); 7137id select_type table type possible_keys key key_len ref rows Extra 71381 PRIMARY ot1 ALL NULL NULL NULL NULL 8 NULL 71391 PRIMARY ot3 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (Block Nested Loop) 71401 PRIMARY ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop) 71412 SUBQUERY it1 ALL NULL NULL NULL NULL 8 NULL 7142SELECT * 7143FROM ot1 7144LEFT JOIN 7145(ot2 JOIN ot3 on ot2.a=ot3.a) 7146ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); 7147a a a 71480 0 0 71491 NULL NULL 71502 NULL NULL 71513 NULL NULL 71524 NULL NULL 71535 NULL NULL 71546 6 6 71557 NULL NULL 7156prepare s from 'SELECT * 7157FROM ot1 7158LEFT JOIN 7159(ot2 JOIN ot3 on ot2.a=ot3.a) 7160ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; 7161execute s; 7162a a a 71630 0 0 71641 NULL NULL 71652 NULL NULL 71663 NULL NULL 71674 NULL NULL 71685 NULL NULL 71696 6 6 71707 NULL NULL 7171execute s; 7172a a a 71730 0 0 71741 NULL NULL 71752 NULL NULL 71763 NULL NULL 71774 NULL NULL 71785 NULL NULL 71796 6 6 71807 NULL NULL 7181deallocate prepare s; 7182DROP TABLE ot1, ot2, ot3, it1; 7183# End of the test for bug#57623. 7184# 7185# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on 7186# 7187CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; 7188CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; 7189INSERT INTO t1 VALUES (1); 7190INSERT INTO t2 VALUES (1,1), (2,1); 7191EXPLAIN SELECT * FROM t2 7192WHERE f2 IN (SELECT t1.f1 7193FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); 7194id select_type table type possible_keys key key_len ref rows Extra 71951 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where 71962 SUBQUERY t1 system NULL NULL NULL NULL 1 NULL 71972 SUBQUERY b1 ALL NULL NULL NULL NULL 2 Using where 71982 SUBQUERY b2 ALL NULL NULL NULL NULL 2 NULL 7199SELECT * FROM t2 7200WHERE f2 IN (SELECT t1.f1 7201FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); 7202f1 f2 72031 1 72042 1 7205DROP TABLE t1, t2; 7206# End of the test for bug#11766739. 7207# 7208# Bug#11766642: crash in Item_field::register_field_in_read_map with view 7209# 7210CREATE TABLE t1(a INT); 7211CREATE VIEW v1 AS SELECT a FROM t1; 7212INSERT INTO t1 VALUES (0),(1),(2); 7213SELECT a FROM t1 WHERE a IN 7214(SELECT a XOR a FROM v1) 7215ORDER BY a; 7216a 72170 7218DROP TABLE t1; 7219DROP VIEW v1; 7220# 7221# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 7222# 7223CREATE TABLE t1 ( 7224f2 varchar(1024) 7225); 7226INSERT INTO t1 VALUES ('v'),('we'); 7227CREATE TABLE t2 ( 7228col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, 7229col_int_key int, 7230col_int int 7231); 7232INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); 7233CREATE TABLE t3 ( 7234col_int_key int, 7235col_int int 7236); 7237INSERT INTO t3 VALUES (4,4); 7238SELECT * 7239FROM t1 7240WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 7241FROM t2 AS a1 LEFT JOIN t3 AS a2 7242ON a1.col_int_key = a2.col_int_key 7243WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); 7244f2 7245v 7246we 7247DROP TABLE t1,t2,t3; 7248# 7249# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT 7250# OF ROWS WHEN JCL>=3 7251# 7252CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); 7253INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); 7254CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); 7255INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); 7256CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); 7257INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); 7258SELECT table2.col_int_key 7259from t3 as table1 join t1 as table2 on table2.col_int_nokey 7260where table1.col_int_nokey in 7261( 7262select subquery2_t2.col_int_nokey 7263from t3 as subquery2_t1 7264right join 7265t2 as subquery2_t2 7266join t1 as subquery2_t3 7267on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey 7268on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey 7269where subquery2_t1.col_varchar_key != table1.col_varchar_key 7270or subquery2_t2.pk <= table1.pk 7271); 7272col_int_key 72736 72746 7275DROP TABLE t1,t2,t3; 7276# 7277# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE 7278# 7279CREATE TABLE t1 (i1 int); 7280INSERT INTO t1 VALUES (1); 7281CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; 7282INSERT INTO t2 VALUES (1, 2),(7, 3); 7283SELECT GRANDPARENT1.i1 7284FROM t2 AS GRANDPARENT1 7285WHERE GRANDPARENT1.i2 7286IN ( SELECT PARENT1.i2 7287FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) 7288WHERE 7289GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) 7290ORDER BY PARENT1.i1) 7291ORDER BY GRANDPARENT1.i2 ; 7292i1 72931 7294DROP TABLE t1,t2; 7295# 7296# Bug#12640083: Same query executed as WHERE subquery gives different 7297# results on IN() compare 7298# 7299CREATE TABLE t1 ( 7300pk int NOT NULL, 7301col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, 7302col_varchar_10_latin1_key varchar(10) DEFAULT NULL, 7303PRIMARY KEY (pk), 7304KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), 7305KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) 7306); 7307INSERT INTO t1 VALUES 7308(1, 'a', 'a'), 7309(2, 'ab', 'ab'), 7310(3, 'abc', 'abc'), 7311(4, 'abcd', 'abcd'); 7312CREATE TABLE t2 ( 7313pk int NOT NULL AUTO_INCREMENT, 7314PRIMARY KEY (pk) 7315) ENGINE=Innodb; 7316CREATE TABLE t3 7317SELECT alias1.col_varchar_10_latin1_key 7318FROM t1 AS alias1 7319LEFT JOIN t1 AS alias2 7320JOIN t2 AS alias3 7321ON alias2.col_varchar_10_latin1_key 7322ON alias1.col_varchar_1024_utf8_key 7323WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; 7324EXPLAIN SELECT * 7325FROM t3 7326WHERE col_varchar_10_latin1_key IN ( 7327SELECT alias1.col_varchar_10_latin1_key 7328FROM t1 AS alias1 7329LEFT JOIN t1 AS alias2 7330JOIN t2 AS alias3 7331ON alias2.col_varchar_10_latin1_key 7332ON alias1.col_varchar_1024_utf8_key 7333WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); 7334id select_type table type possible_keys key key_len ref rows Extra 73351 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where 73362 SUBQUERY alias1 ALL PRIMARY,col_varchar_10_latin1_key NULL NULL NULL 4 Using where 73372 SUBQUERY alias3 index NULL PRIMARY 4 NULL 1 Using where; Using index; Using join buffer (Block Nested Loop) 73382 SUBQUERY alias2 index NULL col_varchar_10_latin1_key 13 NULL 4 Using where; Using index; Using join buffer (Block Nested Loop) 7339SELECT * 7340FROM t3 7341WHERE col_varchar_10_latin1_key IN ( 7342SELECT alias1.col_varchar_10_latin1_key 7343FROM t1 AS alias1 7344LEFT JOIN t1 AS alias2 7345JOIN t2 AS alias3 7346ON alias2.col_varchar_10_latin1_key 7347ON alias1.col_varchar_1024_utf8_key 7348WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); 7349col_varchar_10_latin1_key 7350a 7351ab 7352DROP TABLE t1, t2, t3; 7353# End of the test for bug#12640083. 7354# 7355# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output 7356# 7357CREATE TABLE t1 ( 7358pk int NOT NULL, 7359col_int_key int NOT NULL, 7360col_varchar_nokey varchar(1) NOT NULL, 7361col_varchar_key varchar(1) NOT NULL, 7362PRIMARY KEY(pk), 7363KEY col_int_key(col_int_key), 7364KEY col_varchar_key(col_varchar_key, col_int_key) 7365) engine=innodb; 7366INSERT INTO t1 VALUES 7367(1,7,'a','a'), 7368(2,0,'v','v'), 7369(3,9,'c','c'), 7370(4,3,'m','m'), 7371(5,2,'a','a'), 7372(6,1,'d','d'), 7373(7,8,'y','y'), 7374(8,6,'t','t'), 7375(11,7,'a','x'), 7376(12,0,'v','v'), 7377(13,9,'c','c'), 7378(14,3,'m','m'), 7379(15,2,'a','x'), 7380(16,1,'d','d'), 7381(17,8,'y','y'), 7382(18,6,'t','u'); 7383CREATE TABLE t2 ( 7384pk int NOT NULL, 7385col_int_key int NOT NULL, 7386col_varchar_key varchar(1) NOT NULL, 7387PRIMARY KEY(pk), 7388KEY col_varchar_key(col_varchar_key, col_int_key) 7389) engine=innodb; 7390INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES 7391(8,7,'c'), 7392(11,4,'l'), 7393(12,7,'b'), 7394(13,0,'c'), 7395(14,2,'i'), 7396(15,9,'h'), 7397(16,4,'q'), 7398(17,1,'m'), 7399(18,9,'b'), 7400(19,2,'e'), 7401(20,1,'c'), 7402(21,7,'z'), 7403(22,4,'l'), 7404(23,7,'z'), 7405(24,0,'c'), 7406(25,2,'i'), 7407(26,9,'h'), 7408(27,4,'q'), 7409(28,0,'a'), 7410(29,1,'d'); 7411EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y 7412FROM t1 AS outr 7413WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key 7414FROM t2 AS innr 7415WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) 7416AND outr.col_varchar_nokey < 't' 7417ORDER BY outr.col_varchar_key, outr.pk; 7418id select_type table type possible_keys key key_len ref rows Extra 74191 PRIMARY outr ALL NULL NULL NULL NULL 16 Using where; Using filesort 74202 SUBQUERY innr index_merge PRIMARY,col_varchar_key col_varchar_key,PRIMARY 3,4 NULL 2 Using sort_union(col_varchar_key,PRIMARY); Using where 7421SELECT outr.col_varchar_key AS x, outr.pk AS y 7422FROM t1 AS outr 7423WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key 7424FROM t2 AS innr 7425WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) 7426AND outr.col_varchar_nokey < 't' 7427ORDER BY outr.col_varchar_key, outr.pk; 7428x y 7429a 1 7430a 5 7431c 3 7432c 13 7433DROP TABLE t1, t2; 7434# End of bug#12603200 7435# 7436# Bug#12603183: Segfault in hp_movelink 7437# 7438CREATE TABLE t1 ( 7439col_varchar_key varchar(1) , 7440col_varchar_nokey varchar(1) , 7441KEY col_varchar_key(col_varchar_key) 7442); 7443INSERT INTO t1 VALUES 7444('i','i'), 7445('h','h'), 7446('q','q'), 7447('a','a'), 7448('v','v'), 7449('u','u'), 7450('s','s'), 7451('y','y'), 7452('z','z'), 7453('h','h'), 7454('p','p'), 7455('e','e'), 7456('i','i'), 7457('y','y'), 7458('w','w'); 7459CREATE TABLE t2 ( 7460col_varchar_nokey varchar(1) 7461); 7462INSERT INTO t2 VALUES 7463('b'); 7464EXPLAIN SELECT grandparent1.col_varchar_nokey 7465FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) 7466WHERE (grandparent1.col_varchar_key) IN 7467(SELECT parent1.col_varchar_nokey 7468FROM t1 AS parent1 7469WHERE parent1.col_varchar_key IN 7470(SELECT child1.col_varchar_nokey AS c1 7471FROM t1 AS child1 LEFT JOIN t2 AS child2 7472ON (child1.col_varchar_key > child2.col_varchar_nokey))); 7473id select_type table type possible_keys key key_len ref rows Extra 74741 PRIMARY grandparent1 ALL NULL NULL NULL NULL 15 Using where 74751 PRIMARY grandparent2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 74762 SUBQUERY parent1 ALL NULL NULL NULL NULL 15 Using where 74773 SUBQUERY child1 ALL NULL NULL NULL NULL 15 NULL 74783 SUBQUERY child2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 7479SELECT grandparent1.col_varchar_nokey 7480FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) 7481WHERE (grandparent1.col_varchar_key) IN 7482(SELECT parent1.col_varchar_nokey 7483FROM t1 AS parent1 7484WHERE parent1.col_varchar_key IN 7485(SELECT child1.col_varchar_nokey AS c1 7486FROM t1 AS child1 LEFT JOIN t2 AS child2 7487ON (child1.col_varchar_key > child2.col_varchar_nokey))); 7488col_varchar_nokey 7489a 7490e 7491h 7492h 7493i 7494i 7495p 7496q 7497s 7498u 7499v 7500w 7501y 7502y 7503z 7504DROP TABLE t1, t2; 7505# End of test for bug#12603183. 7506# 7507# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery 7508# 7509CREATE TABLE t1 ( 7510col_int_key INT NOT NULL, 7511col_datetime_key DATETIME NOT NULL, 7512col_varchar_key VARCHAR(1) NOT NULL, 7513KEY col_int_key (col_int_key), 7514KEY col_datetime_key(col_datetime_key), 7515KEY col_varchar_key (col_varchar_key,col_int_key) 7516) ENGINE=InnoDB; 7517INSERT INTO t1 VALUES 7518(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), 7519(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), 7520(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), 7521(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), 7522(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), 7523(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), 7524(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), 7525(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), 7526(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), 7527(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); 7528CREATE TABLE t2 ( 7529col_varchar_nokey VARCHAR(1) NOT NULL 7530) ENGINE=InnoDB; 7531INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); 7532explain SELECT col_varchar_key 7533FROM t1 7534WHERE col_varchar_key IN (SELECT col_varchar_nokey 7535FROM t2) 7536ORDER BY col_datetime_key LIMIT 4; 7537id select_type table type possible_keys key key_len ref rows Extra 75381 PRIMARY t1 ALL NULL NULL NULL NULL 20 Using where; Using filesort 75392 SUBQUERY t2 ALL NULL NULL NULL NULL 6 NULL 7540SELECT col_varchar_key 7541FROM t1 7542WHERE col_varchar_key IN (SELECT col_varchar_nokey 7543FROM t2) 7544ORDER BY col_datetime_key LIMIT 4; 7545col_varchar_key 7546v 7547y 7548v 7549y 7550DROP TABLE t1, t2; 7551# End of test for bug#12818569. 7552# 7553# Bug#12803439: Assert in replace_subcondition() on update query 7554# 7555CREATE TABLE t1(a INTEGER); 7556INSERT INTO t1 values(1), (2); 7557CREATE TABLE t2(a INTEGER); 7558INSERT INTO t2 VALUES(1), (3); 7559SELECT * 7560FROM t1 7561WHERE a IN (SELECT a 7562FROM t2 7563HAVING a IN (SELECT a 7564FROM t2) 7565) 7566HAVING a IN (SELECT a 7567FROM t2); 7568a 75691 7570DROP TABLE t1, t2; 7571# End of test for bug#12803439. 7572# 7573# Bug#12797534: Segfault in hp_movelink still exists 7574# 7575CREATE TABLE t1 ( 7576g1 VARCHAR(1) NOT NULL 7577) ENGINE=InnoDB; 7578INSERT INTO t1 VALUES ('d'), ('s'); 7579CREATE TABLE t2 ( 7580pk INT NOT NULL, 7581col_int_key INT NOT NULL, 7582col_varchar_key VARCHAR(1) NOT NULL, 7583col_varchar_nokey VARCHAR(1) NOT NULL, 7584PRIMARY KEY (pk), 7585KEY col_varchar_key(col_varchar_key, col_int_key) 7586) ENGINE=InnoDB; 7587INSERT INTO t2 VALUES 7588(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), 7589(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), 7590(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), 7591(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), 7592(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); 7593CREATE TABLE t3 ( 7594pk INTEGER NOT NULL, 7595PRIMARY KEY (pk) 7596) ENGINE=InnoDB; 7597INSERT INTO t3 VALUES (10); 7598EXPLAIN SELECT * 7599FROM t1 7600WHERE g1 NOT IN 7601(SELECT grandparent1.col_varchar_nokey AS g1 7602FROM t2 AS grandparent1 7603WHERE grandparent1.col_varchar_key IN 7604(SELECT parent1.col_varchar_nokey AS p1 7605FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) 7606) 7607AND grandparent1.col_varchar_key IS NOT NULL 7608); 7609id select_type table type possible_keys key key_len ref rows Extra 76101 PRIMARY t1 ALL NULL NULL NULL NULL ROWS Using where 76112 SUBQUERY grandparent1 ALL col_varchar_key NULL NULL NULL ROWS Using where 76123 SUBQUERY parent1 ALL NULL NULL NULL NULL ROWS NULL 76133 SUBQUERY parent2 eq_ref PRIMARY PRIMARY 4 test.parent1.pk ROWS Using index 7614SELECT * 7615FROM t1 7616WHERE g1 NOT IN 7617(SELECT grandparent1.col_varchar_nokey AS g1 7618FROM t2 AS grandparent1 7619WHERE grandparent1.col_varchar_key IN 7620(SELECT parent1.col_varchar_nokey AS p1 7621FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) 7622) 7623AND grandparent1.col_varchar_key IS NOT NULL 7624); 7625g1 7626DROP TABLE t1, t2, t3; 7627CREATE TABLE t1 ( 7628pk INTEGER AUTO_INCREMENT, 7629col_int_key INTEGER , 7630col_varchar_key VARCHAR(1) , 7631col_varchar_nokey VARCHAR(1) , 7632PRIMARY KEY (pk), 7633KEY (col_varchar_key,col_int_key) 7634) ENGINE=INNODB; 7635INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES 7636(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); 7637CREATE TABLE t2 ( 7638pk INTEGER AUTO_INCREMENT, 7639col_int_key INTEGER , 7640col_varchar_key VARCHAR(1) , 7641col_varchar_nokey VARCHAR(1) , 7642PRIMARY KEY (pk), 7643KEY (col_int_key), 7644KEY (col_varchar_key,col_int_key) 7645) AUTO_INCREMENT=10 ENGINE=INNODB; 7646INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES 7647(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); 7648CREATE TABLE t3 7649SELECT outr.col_varchar_nokey AS x 7650FROM t1 AS outr 7651WHERE outr.col_varchar_nokey IN 7652(SELECT innr.col_varchar_nokey AS y 7653FROM t2 AS innr 7654WHERE innr.col_int_key IS NULL) 7655AND outr.col_varchar_nokey IS NOT NULL 7656AND NOT col_varchar_key IS NULL; 7657SELECT * 7658FROM t3 7659WHERE x NOT IN 7660(SELECT outr.col_varchar_nokey AS x 7661FROM t1 AS outr 7662WHERE outr.col_varchar_nokey IN 7663(SELECT innr.col_varchar_nokey AS y 7664FROM t2 AS innr 7665WHERE innr.col_int_key IS NULL) 7666AND outr.col_varchar_nokey IS NOT NULL 7667AND NOT col_varchar_key IS NULL); 7668x 7669DROP TABLE t1, t2, t3; 7670# End of test for bug#12797534. 7671# 7672# Bug#12714094: Assert in optimize_semijoin_nests() 7673# 7674CREATE TABLE it ( 7675pk int NOT NULL, 7676col_varchar VARCHAR(10) DEFAULT NULL, 7677PRIMARY KEY (pk) 7678) ENGINE=MyISAM; 7679INSERT INTO it VALUES (1, 'g'); 7680CREATE TABLE ot 7681SELECT alias1.pk AS field1 7682FROM it AS alias1 7683LEFT JOIN it AS alias2 7684ON alias1.col_varchar = alias2.col_varchar 7685; 7686SELECT * 7687FROM ot 7688WHERE field1 IN ( 7689SELECT alias1.pk 7690FROM it AS alias1 7691LEFT JOIN it AS alias2 7692ON alias1.col_varchar = alias2.col_varchar 7693); 7694field1 76951 7696DROP TABLE it, ot; 7697# End of test for bug#12714094 7698# 7699# Bug#12867557: Valgrind: conditional jump/move at key_cmp 7700# 7701CREATE TABLE t1 ( 7702pk INTEGER AUTO_INCREMENT, 7703col_int_key INTEGER, 7704PRIMARY KEY (pk), 7705KEY (col_int_key) 7706) AUTO_INCREMENT=10; 7707INSERT INTO t1 (col_int_key) VALUES (8); 7708CREATE TABLE t2 ( 7709pk INTEGER AUTO_INCREMENT, 7710col_int_key INTEGER, 7711col_time_key TIME, 7712PRIMARY KEY (pk), 7713KEY (col_int_key), 7714KEY (col_time_key) 7715) AUTO_INCREMENT=10; 7716INSERT INTO t2 (col_int_key, col_time_key) 7717VALUES 7718(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), 7719(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), 7720(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), 7721(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), 7722(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), 7723(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), 7724(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); 7725CREATE TABLE t0 7726SELECT DISTINCT grandparent1.col_time_key AS g1 7727FROM t2 AS grandparent1 7728WHERE grandparent1.col_int_key IN 7729(SELECT parent1.col_int_key AS p1 7730FROM t1 AS parent1) 7731AND grandparent1.pk > 9; 7732UPDATE t0 7733SET g1 = g1 7734WHERE g1 IN 7735(SELECT grandparent1.col_time_key AS g1 7736FROM t2 AS grandparent1 7737WHERE grandparent1.col_int_key IN 7738(SELECT parent1.col_int_key AS p1 7739FROM t1 AS parent1) 7740AND grandparent1.pk > 9); 7741DROP TABLE t0, t1, t2; 7742# End of test for bug#12867557 7743# 7744# Bug#12711441: crash in fix_after_pullout 7745# 7746CREATE TABLE t1 ( 7747pk int NOT NULL, 7748col_int_nokey int DEFAULT NULL, 7749col_int_key int DEFAULT NULL, 7750col_time_key time DEFAULT NULL, 7751col_varchar_key varchar(1) DEFAULT NULL, 7752PRIMARY KEY (pk) 7753); 7754CREATE VIEW v1 AS SELECT * FROM t1; 7755CREATE TABLE t2 ( 7756col_int_key int DEFAULT NULL, 7757col_varchar_key varchar(1) DEFAULT NULL, 7758col_varchar_nokey varchar(1) DEFAULT NULL, 7759KEY col_varchar_key(col_varchar_key, col_int_key) 7760); 7761CREATE TABLE t3 ( 7762pk int NOT NULL, 7763col_int_key INT DEFAULT NULL, 7764PRIMARY KEY (pk) 7765); 7766CREATE TABLE t4 ( 7767col_int_nokey INT DEFAULT NULL, 7768col_varchar_key varchar(1) DEFAULT NULL, 7769col_varchar_nokey varchar(1) DEFAULT NULL, 7770KEY col_varchar_key(col_varchar_key) 7771); 7772CREATE TABLE ts 7773SELECT alias1.col_time_key AS field1 7774FROM v1 AS alias1 7775RIGHT JOIN t3 AS alias2 7776ON alias2.col_int_key = alias1.col_int_nokey 7777WHERE alias1.pk >= SOME( 7778SELECT SQ1_alias1.pk AS SQ1_field1 7779FROM t3 AS SQ1_alias1 7780INNER JOIN (t2 AS SQ1_alias2 7781INNER JOIN t4 AS SQ1_alias3 7782ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) 7783ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key 7784WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key 7785AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) 7786; 7787SELECT * FROM ts WHERE field1 IN ( 7788SELECT alias1.col_time_key AS field1 7789FROM v1 AS alias1 7790RIGHT JOIN t3 AS alias2 7791ON alias2.col_int_key = alias1.col_int_nokey 7792WHERE alias1.pk >= SOME( 7793SELECT SQ1_alias1.pk AS SQ1_field1 7794FROM t3 AS SQ1_alias1 7795INNER JOIN (t2 AS SQ1_alias2 7796INNER JOIN t4 AS SQ1_alias3 7797ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) 7798ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key 7799WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key 7800AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) 7801); 7802field1 7803DROP TABLE t1, t2, t3, t4, ts; 7804DROP VIEW v1; 7805# End of test for bug#12711441. 7806# 7807# Bug#12664936: Same query executed as where subquery ... 7808# 7809CREATE TABLE t1 ( 7810col_varchar_key VARCHAR(1), 7811KEY col_varchar_key (col_varchar_key) 7812); 7813INSERT INTO t1 VALUES 7814('o'), ('w'), ('m'), ('q'), 7815('f'), ('p'), ('j'), ('c'); 7816CREATE TABLE t2 ( 7817col_int_nokey INTEGER, 7818col_int_key INTEGER, 7819col_varchar_key varchar(1), 7820KEY col_int_key (col_int_key) 7821); 7822INSERT INTO t2 VALUES 7823(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), 7824(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); 7825CREATE TABLE t4 7826SELECT t2.col_int_nokey, t2.col_varchar_key 7827FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key 7828WHERE t2.col_int_key = 1; 7829EXPLAIN SELECT * 7830FROM t4 7831WHERE (col_int_nokey, col_varchar_key) IN 7832(SELECT t2.col_int_nokey, t2.col_varchar_key 7833FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key 7834WHERE t2.col_int_key = 1 7835); 7836id select_type table type possible_keys key key_len ref rows Extra 78371 PRIMARY t4 ALL NULL NULL NULL NULL 2 Using where 78382 SUBQUERY t2 ref col_int_key col_int_key 5 const 3 Using where 78392 SUBQUERY t1 ref col_varchar_key col_varchar_key 4 test.t2.col_varchar_key 2 Using index 7840SELECT * 7841FROM t4 7842WHERE (col_int_nokey, col_varchar_key) IN 7843(SELECT t2.col_int_nokey, t2.col_varchar_key 7844FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key 7845WHERE t2.col_int_key = 1 7846); 7847col_int_nokey col_varchar_key 78488 o 78492 q 7850DROP TABLE t1, t2, t4; 7851# End of test for bug#12664936. 7852# 7853# Bug#13340270: assertion table->sort.record_pointers == __null 7854# 7855CREATE TABLE t1 ( 7856pk int NOT NULL, 7857col_int_key int DEFAULT NULL, 7858col_varchar_key varchar(1) DEFAULT NULL, 7859col_varchar_nokey varchar(1) DEFAULT NULL, 7860PRIMARY KEY (pk), 7861KEY col_int_key (col_int_key), 7862KEY col_varchar_key (col_varchar_key, col_int_key) 7863) ENGINE=InnoDB; 7864INSERT INTO t1 VALUES 7865(10,8,'x','x'), 7866(11,7,'d','d'), 7867(12,1,'r','r'), 7868(13,7,'f','f'), 7869(14,9,'y','y'), 7870(15,NULL,'u','u'), 7871(16,1,'m','m'), 7872(17,9,NULL,NULL), 7873(18,2,'o','o'), 7874(19,9,'w','w'), 7875(20,2,'m','m'), 7876(21,4,'q','q'); 7877CREATE TABLE t2 7878SELECT alias1.col_varchar_nokey AS field1 7879FROM t1 AS alias1 JOIN t1 AS alias2 7880ON alias2.col_int_key = alias1.pk OR 7881alias2.col_int_key = alias1.col_int_key 7882WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' 7883 7884; 7885EXPLAIN SELECT * 7886FROM t2 7887WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 7888FROM t1 AS alias1 JOIN t1 AS alias2 7889ON alias2.col_int_key = alias1.pk OR 7890alias2.col_int_key = alias1.col_int_key 7891WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' 7892); 7893id select_type table type possible_keys key key_len ref rows Extra 78941 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where 78952 SUBQUERY alias1 index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 4,4 NULL 2 Using sort_union(col_varchar_key,PRIMARY); Using where 78962 SUBQUERY alias2 ALL col_int_key NULL NULL NULL 12 Range checked for each record (index map: 0x2) 7897SELECT * 7898FROM t2 7899WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 7900FROM t1 AS alias1 JOIN t1 AS alias2 7901ON alias2.col_int_key = alias1.pk OR 7902alias2.col_int_key = alias1.col_int_key 7903WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' 7904); 7905field1 7906o 7907o 7908DROP TABLE t1, t2; 7909# End of test for bug#13340270. 7910# 7911# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy 7912# 7913CREATE TABLE ot1(a INTEGER); 7914INSERT INTO ot1 VALUES(1), (2), (3); 7915CREATE TABLE ot2(a INTEGER); 7916INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); 7917CREATE TABLE it1(a INTEGER); 7918INSERT INTO it1 VALUES(1), (3), (5), (7); 7919CREATE TABLE it2(a INTEGER); 7920INSERT INTO it2 VALUES(1), (3), (5), (7), (9); 7921explain SELECT ot1.a, ot2.a 7922FROM ot1, ot2 7923WHERE ot1.a IN (SELECT a FROM it1) AND 7924ot2.a IN (SELECT a FROM it2); 7925id select_type table type possible_keys key key_len ref rows Extra 79261 PRIMARY ot1 ALL NULL NULL NULL NULL 3 Using where 79271 PRIMARY ot2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (Block Nested Loop) 79283 SUBQUERY it2 ALL NULL NULL NULL NULL 5 NULL 79292 SUBQUERY it1 ALL NULL NULL NULL NULL 4 NULL 7930SELECT ot1.a, ot2.a 7931FROM ot1, ot2 7932WHERE ot1.a IN (SELECT a FROM it1) AND 7933ot2.a IN (SELECT a FROM it2); 7934a a 79351 1 79363 1 7937DROP TABLE ot1, ot2, it1, it2; 7938# End of test for bug#13335319. 7939# 7940# Bug#13334882: Assertion keypart_map failed in MyIsam function 7941# 7942CREATE TABLE t1 ( 7943pk int NOT NULL, 7944col_int_nokey INT NOT NULL, 7945col_int_key INT NOT NULL, 7946PRIMARY KEY (pk), 7947KEY col_int_key (col_int_key) 7948) ENGINE=MyISAM; 7949INSERT INTO t1 VALUES 7950(1,4,0), 7951(2,6,8), 7952(3,3,1), 7953(7,2,6), 7954(8,9,1), 7955(9,3,6), 7956(10,8,2), 7957(11,1,4), 7958(12,8,8), 7959(13,8,4), 7960(14,5,4); 7961CREATE TABLE t2 ( 7962pk int NOT NULL, 7963col_int_nokey int NOT NULL, 7964col_int_key int NOT NULL, 7965PRIMARY KEY (pk), 7966KEY col_int_key (col_int_key) 7967) ENGINE=MyISAM; 7968INSERT INTO t2 VALUES 7969(10,8,7); 7970CREATE TABLE t3 7971SELECT grandparent1.col_int_nokey AS g1 7972FROM t1 AS grandparent1 7973WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN 7974(SELECT parent1.col_int_key AS p1, 7975parent1.col_int_key AS p2 7976FROM t1 AS parent1 7977LEFT JOIN t2 AS parent2 7978ON parent1.col_int_nokey = parent2.col_int_key 7979) 7980AND grandparent1.col_int_key <> 3 7981; 7982explain SELECT * FROM t3 7983WHERE g1 NOT IN 7984(SELECT grandparent1.col_int_nokey AS g1 7985FROM t1 AS grandparent1 7986WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN 7987(SELECT parent1.col_int_key AS p1, 7988parent1.col_int_key AS p2 7989FROM t1 AS parent1 7990LEFT JOIN t2 AS parent2 7991ON parent1.col_int_nokey = parent2.col_int_key 7992) 7993AND grandparent1.col_int_key <> 3 7994); 7995id select_type table type possible_keys key key_len ref rows Extra 79961 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 79972 DEPENDENT SUBQUERY grandparent1 ALL col_int_key NULL NULL NULL 11 Using where 79983 SUBQUERY parent1 ALL col_int_key NULL NULL NULL 11 NULL 79993 SUBQUERY parent2 index col_int_key col_int_key 4 NULL 1 Using where; Using index; Using join buffer (Block Nested Loop) 8000explain format=json SELECT * FROM t3 8001WHERE g1 NOT IN 8002(SELECT grandparent1.col_int_nokey AS g1 8003FROM t1 AS grandparent1 8004WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN 8005(SELECT parent1.col_int_key AS p1, 8006parent1.col_int_key AS p2 8007FROM t1 AS parent1 8008LEFT JOIN t2 AS parent2 8009ON parent1.col_int_nokey = parent2.col_int_key 8010) 8011AND grandparent1.col_int_key <> 3 8012); 8013EXPLAIN 8014{ 8015 "query_block": { 8016 "select_id": 1, 8017 "table": { 8018 "message": "Impossible WHERE noticed after reading const tables", 8019 "attached_subqueries": [ 8020 { 8021 "dependent": true, 8022 "cacheable": false, 8023 "query_block": { 8024 "select_id": 2, 8025 "table": { 8026 "table_name": "grandparent1", 8027 "access_type": "ALL", 8028 "possible_keys": [ 8029 "col_int_key" 8030 ], 8031 "rows": 11, 8032 "filtered": 100, 8033 "attached_condition": "(<in_optimizer>((`test`.`grandparent1`.`col_int_nokey`,`test`.`grandparent1`.`col_int_key`),(`test`.`grandparent1`.`col_int_nokey`,`test`.`grandparent1`.`col_int_key`) in ( <materialize> (/* select#3 */ select `test`.`parent1`.`col_int_key` AS `p1`,`test`.`parent1`.`col_int_key` AS `p2` from `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`)) where 1 ), <primary_index_lookup>(`test`.`grandparent1`.`col_int_nokey` in <temporary table> on <auto_key> where ((`test`.`grandparent1`.`col_int_nokey` = `materialized-subquery`.`p1`) and (`test`.`grandparent1`.`col_int_key` = `materialized-subquery`.`p2`))))) and (`test`.`grandparent1`.`col_int_key` <> 3) and (<cache>('8') = `test`.`grandparent1`.`col_int_nokey`))", 8034 "attached_subqueries": [ 8035 { 8036 "table": { 8037 "table_name": "<materialized_subquery>", 8038 "access_type": "eq_ref", 8039 "key": "<auto_key>", 8040 "key_length": "8", 8041 "rows": 1, 8042 "materialized_from_subquery": { 8043 "using_temporary_table": true, 8044 "dependent": true, 8045 "cacheable": false, 8046 "query_block": { 8047 "select_id": 3, 8048 "nested_loop": [ 8049 { 8050 "table": { 8051 "table_name": "parent1", 8052 "access_type": "ALL", 8053 "possible_keys": [ 8054 "col_int_key" 8055 ], 8056 "rows": 11, 8057 "filtered": 100 8058 } 8059 }, 8060 { 8061 "table": { 8062 "table_name": "parent2", 8063 "access_type": "index", 8064 "possible_keys": [ 8065 "col_int_key" 8066 ], 8067 "key": "col_int_key", 8068 "used_key_parts": [ 8069 "col_int_key" 8070 ], 8071 "key_length": "4", 8072 "rows": 1, 8073 "filtered": 100, 8074 "using_index": true, 8075 "using_join_buffer": "Block Nested Loop", 8076 "attached_condition": "<if>(is_not_null_compl(parent2), (`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`), true)" 8077 } 8078 } 8079 ] 8080 } 8081 } 8082 } 8083 } 8084 ] 8085 } 8086 } 8087 } 8088 ] 8089 } 8090 } 8091} 8092Warnings: 8093Note 1003 /* select#1 */ select '8' AS `g1` from dual where (not(<in_optimizer>('8',<exists>(/* select#2 */ select 1 from `test`.`t1` `grandparent1` where (<in_optimizer>((`test`.`grandparent1`.`col_int_nokey`,`test`.`grandparent1`.`col_int_key`),(`test`.`grandparent1`.`col_int_nokey`,`test`.`grandparent1`.`col_int_key`) in ( <materialize> (/* select#3 */ select `test`.`parent1`.`col_int_key` AS `p1`,`test`.`parent1`.`col_int_key` AS `p2` from `test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent2`.`col_int_key` = `test`.`parent1`.`col_int_nokey`)) where 1 ), <primary_index_lookup>(`test`.`grandparent1`.`col_int_nokey` in <temporary table> on <auto_key> where ((`test`.`grandparent1`.`col_int_nokey` = `materialized-subquery`.`p1`) and (`test`.`grandparent1`.`col_int_key` = `materialized-subquery`.`p2`))))) and (`test`.`grandparent1`.`col_int_key` <> 3) and (<cache>('8') = `test`.`grandparent1`.`col_int_nokey`)))))) 8094SELECT * FROM t3 8095WHERE g1 NOT IN 8096(SELECT grandparent1.col_int_nokey AS g1 8097FROM t1 AS grandparent1 8098WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN 8099(SELECT parent1.col_int_key AS p1, 8100parent1.col_int_key AS p2 8101FROM t1 AS parent1 8102LEFT JOIN t2 AS parent2 8103ON parent1.col_int_nokey = parent2.col_int_key 8104) 8105AND grandparent1.col_int_key <> 3 8106); 8107g1 8108DROP TABLE t1, t2, t3; 8109# End of test for bug#13334882. 8110# 8111# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution 8112# 8113CREATE TABLE t1 ( 8114col_int_nokey INT, 8115col_varchar_nokey VARCHAR(1) 8116); 8117INSERT INTO t1 VALUES 8118(1,'o'), 8119(2,'t'); 8120CREATE TABLE t2 LIKE t1; 8121INSERT INTO t2 VALUES 8122(1,'o'), 8123(4,'f'); 8124CREATE VIEW v_t2 AS SELECT * FROM t2; 8125CREATE TABLE t3 LIKE t1; 8126INSERT INTO t3 VALUES 8127(1,'o'), 8128(4,'f'); 8129explain SELECT alias1.col_varchar_nokey 8130FROM t1 AS alias1 8131INNER JOIN v_t2 AS alias2 8132ON alias2.col_int_nokey = alias1.col_int_nokey AND 8133'o' IN (SELECT col_varchar_nokey 8134FROM t3); 8135id select_type table type possible_keys key key_len ref rows Extra 81361 PRIMARY alias1 ALL NULL NULL NULL NULL 2 NULL 81371 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 81382 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where 8139SELECT alias1.col_varchar_nokey 8140FROM t1 AS alias1 8141INNER JOIN v_t2 AS alias2 8142ON alias2.col_int_nokey = alias1.col_int_nokey AND 8143'o' IN (SELECT col_varchar_nokey 8144FROM t3); 8145col_varchar_nokey 8146o 8147PREPARE stmt FROM "SELECT alias1.col_varchar_nokey 8148FROM t1 AS alias1 8149INNER JOIN v_t2 AS alias2 8150ON alias2.col_int_nokey = alias1.col_int_nokey AND 8151'o' IN (SELECT col_varchar_nokey 8152FROM t3)"; 8153EXECUTE stmt; 8154col_varchar_nokey 8155o 8156DROP VIEW v_t2; 8157DROP TABLE t1, t2, t3; 8158# End of test for bug#13339643. 8159# 8160# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses 8161# 8162CREATE TABLE t1 ( 8163pk int NOT NULL, 8164col_int_nokey int NOT NULL, 8165col_int_key int NOT NULL, 8166PRIMARY KEY (pk), 8167KEY col_int_key (col_int_key) 8168) ENGINE=MyIsam; 8169INSERT INTO t1 VALUES 8170(10,1,7), (13,7,3), (18,0,1), (23,8,1); 8171CREATE TABLE t2 ( 8172pk int NOT NULL, 8173col_int_key int NOT NULL, 8174PRIMARY KEY (pk), 8175KEY col_int_key (col_int_key) 8176) ENGINE=MyIsam; 8177INSERT INTO t2 VALUES (1,7); 8178EXPLAIN SELECT t1a.* 8179FROM t1 AS t1a 8180JOIN t1 AS t1b USING ( col_int_nokey ) 8181WHERE t1a.col_int_key IN ( 8182SELECT pk 8183FROM t2 8184WHERE col_int_key IN ( 8185SELECT col_int_nokey 8186FROM t1 8187) 8188); 8189id select_type table type possible_keys key key_len ref rows Extra 81901 PRIMARY t1a ALL NULL NULL NULL NULL 4 Using where 81911 PRIMARY t1b ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop) 81922 SUBQUERY t2 system PRIMARY NULL NULL NULL 1 NULL 81933 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 4 Using where 8194SELECT t1a.* 8195FROM t1 AS t1a 8196JOIN t1 AS t1b USING ( col_int_nokey ) 8197WHERE t1a.col_int_key IN ( 8198SELECT pk 8199FROM t2 8200WHERE col_int_key IN ( 8201SELECT col_int_nokey 8202FROM t1 8203) 8204); 8205pk col_int_nokey col_int_key 820618 0 1 820723 8 1 8208ALTER TABLE t1 ENGINE=Innodb; 8209ALTER TABLE t2 ENGINE=Innodb; 8210SELECT t1a.* 8211FROM t1 AS t1a 8212JOIN t1 AS t1b USING ( col_int_nokey ) 8213WHERE t1a.col_int_key IN ( 8214SELECT pk 8215FROM t2 8216WHERE col_int_key IN ( 8217SELECT col_int_nokey 8218FROM t1 8219) 8220); 8221pk col_int_nokey col_int_key 822218 0 1 822323 8 1 8224DROP TABLE t1, t2; 8225# End of test for bug#13424134. 8226# 8227# Bug#13414014: Extra rows in result on semijoin query with where ... 8228# 8229CREATE TABLE t1 ( 8230c INT, 8231d INT, 8232a VARCHAR(1), 8233b VARCHAR(1), 8234KEY a (a) 8235); 8236INSERT INTO t1 VALUES 8237(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); 8238CREATE TABLE t2 ( 8239a VARCHAR(1), 8240KEY a (a) 8241); 8242INSERT INTO t2 VALUES 8243('c'), (NULL), ('x'), ('q'); 8244explain SELECT * 8245FROM t2 AS ot 8246WHERE (a, a) IN 8247(SELECT a, b 8248FROM t1 AS it 8249WHERE it.a = 'x' OR it.c > it.d 8250) 8251; 8252id select_type table type possible_keys key key_len ref rows Extra 82531 PRIMARY ot index NULL a 4 NULL 4 Using where; Using index 82542 SUBQUERY it ALL a NULL NULL NULL 3 Using where 8255SELECT * 8256FROM t2 AS ot 8257WHERE (a, a) IN 8258(SELECT a, b 8259FROM t1 AS it 8260WHERE it.a = 'x' OR it.c > it.d 8261) 8262; 8263a 8264q 8265x 8266DROP TABLE t1, t2; 8267# End of test for bug#13414014. 8268# 8269# Bug#13545215: Missing rows on nested in-subquery with materialization 8270# 8271CREATE TABLE t1 ( 8272col_int_key int, 8273col_varchar_key varchar(1), 8274col_varchar_nokey varchar(1), 8275KEY col_int_key (col_int_key), 8276KEY col_varchar_key (col_varchar_key,col_int_key) 8277) ; 8278INSERT INTO t1 VALUES 8279(8,'x','x'), (0,'p','p'), (8,'c','c'); 8280CREATE TABLE t2 ( 8281pk int NOT NULL, 8282col_varchar_key varchar(1), 8283col_varchar_nokey varchar(1), 8284PRIMARY KEY (pk), 8285KEY col_varchar_key (col_varchar_key) 8286); 8287INSERT INTO t2 VALUES 8288(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), 8289(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); 8290CREATE TABLE t3 ( 8291col_int_nokey int 8292); 8293INSERT INTO t3 VALUES (7); 8294explain SELECT grandparent1.col_varchar_nokey 8295FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) 8296WHERE grandparent1.col_varchar_key IN ( 8297SELECT col_varchar_nokey 8298FROM t2 AS parent1 8299WHERE col_varchar_key IN ( 8300SELECT child1.col_varchar_nokey 8301FROM t2 AS child1 LEFT JOIN t3 AS child2 8302ON child1.pk < child2.col_int_nokey 8303) 8304); 8305id select_type table type possible_keys key key_len ref rows Extra 83061 PRIMARY grandparent1 ALL col_int_key NULL NULL NULL 3 Using where 83071 PRIMARY grandparent2 index col_int_key col_int_key 5 NULL 3 Using where; Using index; Using join buffer (Block Nested Loop) 83082 SUBQUERY parent1 ALL NULL NULL NULL NULL 8 Using where 83093 SUBQUERY child1 ALL NULL NULL NULL NULL 8 NULL 83103 SUBQUERY child2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 8311SELECT grandparent1.col_varchar_nokey 8312FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) 8313WHERE grandparent1.col_varchar_key IN ( 8314SELECT col_varchar_nokey 8315FROM t2 AS parent1 8316WHERE col_varchar_key IN ( 8317SELECT child1.col_varchar_nokey 8318FROM t2 AS child1 LEFT JOIN t3 AS child2 8319ON child1.pk < child2.col_int_nokey 8320) 8321); 8322col_varchar_nokey 8323c 8324c 8325p 8326x 8327x 8328DROP TABLE t1, t2, t3; 8329# End of test for bug#13545215. 8330# 8331# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND 8332# MATERIALIZATION + SEMIJOIN ON 8333# 8334CREATE TABLE t1 ( 8335col_int_key int(11) DEFAULT NULL, 8336col_varchar_key varchar(1) DEFAULT NULL, 8337col_varchar_nokey varchar(1) DEFAULT NULL, 8338KEY col_int_key (col_int_key), 8339KEY col_varchar_key (col_varchar_key,col_int_key) 8340); 8341INSERT INTO t1 VALUES (4,'v','v'); 8342INSERT INTO t1 VALUES (62,'v','v'); 8343INSERT INTO t1 VALUES (7,'c','c'); 8344INSERT INTO t1 VALUES (1,NULL,NULL); 8345EXPLAIN SELECT 8346alias1.col_varchar_nokey AS a1_nokey, 8347alias1.col_varchar_key AS a1_key, 8348alias2.col_varchar_nokey AS a2_nokey 8349FROM 8350t1 AS alias1, t1 AS alias2 8351WHERE 8352(alias1.col_varchar_nokey,alias2.col_varchar_nokey) 8353IN 8354( 8355SELECT 8356SQ2_alias2.col_varchar_nokey, SQ2_alias1.col_varchar_key 8357FROM 8358t1 AS SQ2_alias1, t1 AS SQ2_alias2 8359) 8360; 8361id select_type table type possible_keys key key_len ref rows Extra 83621 PRIMARY alias1 ALL NULL NULL NULL NULL 4 NULL 83631 PRIMARY alias2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop) 83642 SUBQUERY SQ2_alias1 index col_varchar_key col_varchar_key 9 NULL 4 Using index 83652 SUBQUERY SQ2_alias2 ALL NULL NULL NULL NULL 4 Using join buffer (Block Nested Loop) 8366SELECT 8367alias1.col_varchar_nokey AS a1_nokey, 8368alias1.col_varchar_key AS a1_key, 8369alias2.col_varchar_nokey AS a2_nokey 8370FROM 8371t1 AS alias1, t1 AS alias2 8372WHERE 8373(alias1.col_varchar_nokey,alias2.col_varchar_nokey) 8374IN 8375( 8376SELECT 8377SQ2_alias2.col_varchar_nokey, SQ2_alias1.col_varchar_key 8378FROM 8379t1 AS SQ2_alias1, t1 AS SQ2_alias2 8380) 8381; 8382a1_nokey a1_key a2_nokey 8383c c c 8384c c v 8385c c v 8386v v c 8387v v c 8388v v v 8389v v v 8390v v v 8391v v v 8392DROP TABLE t1; 8393# 8394# Bug#13541406: Wrong result with loosescan on select .. where .. in 8395# 8396CREATE TABLE t1 ( 8397col_int_key INT NOT NULL, 8398col_varchar_nokey VARCHAR(1) NOT NULL, 8399KEY col_int_key (col_int_key) 8400) ENGINE=InnoDB; 8401INSERT INTO t1 VALUES 8402(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), 8403(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), 8404(9,'e'), (5,'i'), (0,'y'), (3,'w'); 8405CREATE TABLE t2 ( 8406pk INT NOT NULL, 8407col_int_key INT NOT NULL, 8408col_varchar_key VARCHAR(1) NOT NULL, 8409col_varchar_nokey VARCHAR(1) NOT NULL, 8410PRIMARY KEY (pk), 8411KEY col_int_key (col_int_key), 8412KEY col_varchar_key (col_varchar_key,col_int_key) 8413) ENGINE=InnoDB; 8414INSERT INTO t2 VALUES 8415(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), 8416(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), 8417(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), 8418(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), 8419(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); 8420# This query should never use a LooseScan strategy 8421explain SELECT ot1.col_int_key AS field1 8422FROM t2 AS ot1, t2 AS ot2 8423WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( 8424SELECT it2.col_varchar_nokey, it1.col_varchar_key 8425FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); 8426id select_type table type possible_keys key key_len ref rows Extra 84271 PRIMARY ot1 index NULL col_varchar_key 7 NULL 20 Using index 84281 PRIMARY ot2 ALL NULL NULL NULL NULL 20 Using where; Using join buffer (Block Nested Loop) 84292 SUBQUERY it1 index PRIMARY,col_varchar_key col_varchar_key 7 NULL 20 Using index 84302 SUBQUERY it2 ref col_int_key col_int_key 4 test.it1.pk 1 NULL 8431SELECT ot1.col_int_key AS field1 8432FROM t2 AS ot1, t2 AS ot2 8433WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( 8434SELECT it2.col_varchar_nokey, it1.col_varchar_key 8435FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); 8436field1 84371 84381 84391 84402 84416 84426 84436 84446 84456 84468 84478 84488 84498 84508 84518 84529 8453DROP TABLE t1, t2; 8454# End of test for bug#13541406. 8455# 8456# Bug#13576391: Missing rows on select with in-subquery and 8457# batched-key-access=on and semijoin 8458# 8459CREATE TABLE t1 ( 8460col_int_nokey int NOT NULL, 8461col_varchar_key varchar(1) NOT NULL, 8462KEY col_varchar_key (col_varchar_key) 8463) engine=InnoDB; 8464INSERT INTO t1 VALUES 8465(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), 8466(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), 8467(6,'e'), (3,'i'), (6,'y'), (6,'w'); 8468CREATE TABLE t2 ( 8469col_int_nokey int NOT NULL, 8470col_varchar_nokey varchar(1) NOT NULL 8471) engine=InnoDB; 8472INSERT INTO t2 VALUES 8473(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), 8474(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), 8475(1,'q'), (6,'w'), (2,'d'), (9,'e'); 8476explain SELECT col_varchar_nokey 8477FROM t2 AS ot 8478WHERE col_varchar_nokey IN ( 8479SELECT col_varchar_key 8480FROM t1 AS it 8481WHERE it.col_int_nokey <= it.col_int_nokey 8482AND NOT ot.col_int_nokey < 2 8483) 8484ORDER BY col_varchar_nokey; 8485id select_type table type possible_keys key key_len ref rows Extra 84861 PRIMARY ot ALL NULL NULL NULL NULL 20 Using where; Using filesort 84872 DEPENDENT SUBQUERY it index_subquery col_varchar_key col_varchar_key 3 func 1 Using where 8488SELECT col_varchar_nokey 8489FROM t2 AS ot 8490WHERE col_varchar_nokey IN ( 8491SELECT col_varchar_key 8492FROM t1 AS it 8493WHERE it.col_int_nokey <= it.col_int_nokey 8494AND NOT ot.col_int_nokey < 2 8495) 8496ORDER BY col_varchar_nokey; 8497col_varchar_nokey 8498c 8499e 8500p 8501s 8502v 8503w 8504y 8505ALTER TABLE t1 ENGINE=MyISAM; 8506ALTER TABLE t2 ENGINE=MyISAM; 8507explain SELECT col_varchar_nokey 8508FROM t2 AS ot 8509WHERE col_varchar_nokey IN ( 8510SELECT col_varchar_key 8511FROM t1 AS it 8512WHERE it.col_int_nokey <= it.col_int_nokey 8513AND NOT ot.col_int_nokey < 2 8514) 8515ORDER BY col_varchar_nokey; 8516id select_type table type possible_keys key key_len ref rows Extra 85171 PRIMARY ot ALL NULL NULL NULL NULL 20 Using where; Using filesort 85182 DEPENDENT SUBQUERY it index_subquery col_varchar_key col_varchar_key 3 func 2 Using where 8519SELECT col_varchar_nokey 8520FROM t2 AS ot 8521WHERE col_varchar_nokey IN ( 8522SELECT col_varchar_key 8523FROM t1 AS it 8524WHERE it.col_int_nokey <= it.col_int_nokey 8525AND NOT ot.col_int_nokey < 2 8526) 8527ORDER BY col_varchar_nokey; 8528col_varchar_nokey 8529c 8530e 8531p 8532s 8533v 8534w 8535y 8536ALTER TABLE t1 ENGINE=Memory; 8537ALTER TABLE t2 ENGINE=Memory; 8538explain SELECT col_varchar_nokey 8539FROM t2 AS ot 8540WHERE col_varchar_nokey IN ( 8541SELECT col_varchar_key 8542FROM t1 AS it 8543WHERE it.col_int_nokey <= it.col_int_nokey 8544AND NOT ot.col_int_nokey < 2 8545) 8546ORDER BY col_varchar_nokey; 8547id select_type table type possible_keys key key_len ref rows Extra 85481 PRIMARY ot ALL NULL NULL NULL NULL 20 Using where; Using filesort 85492 DEPENDENT SUBQUERY it index_subquery col_varchar_key col_varchar_key 3 func 2 Using where 8550SELECT col_varchar_nokey 8551FROM t2 AS ot 8552WHERE col_varchar_nokey IN ( 8553SELECT col_varchar_key 8554FROM t1 AS it 8555WHERE it.col_int_nokey <= it.col_int_nokey 8556AND NOT ot.col_int_nokey < 2 8557) 8558ORDER BY col_varchar_nokey; 8559col_varchar_nokey 8560c 8561e 8562p 8563s 8564v 8565w 8566y 8567DROP TABLE t1, t2; 8568# End of test for bug#13576391. 8569# 8570# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" 8571# 8572CREATE TABLE t1 ( 8573id INT, 8574col_varchar_key VARCHAR(1), 8575col_varchar_nokey VARCHAR(1), 8576KEY (col_varchar_key) 8577); 8578INSERT INTO t1 VALUES (100,'m','m'), 8579(200,'b','b'), (300,'x','x'); 8580CREATE TABLE t2 ( 8581col_varchar_key VARCHAR(1), 8582col_varchar_nokey VARCHAR(1), 8583KEY (col_varchar_key) 8584); 8585INSERT INTO t2 VALUES ('b','b'); 8586CREATE TABLE t3 ( 8587col_varchar_key VARCHAR(1), 8588col_varchar_nokey VARCHAR(1), 8589KEY (col_varchar_key) 8590); 8591INSERT INTO t3 VALUES ('k','k'); 8592EXPLAIN SELECT GP1.id 8593FROM t1 AS GP1 JOIN t3 AS GP2 8594ON GP2.col_varchar_key <> GP1.col_varchar_nokey 8595WHERE (GP1.col_varchar_nokey, GP1.col_varchar_nokey) 8596IN ( 8597SELECT col_varchar_nokey, col_varchar_nokey 8598FROM t1 8599WHERE col_varchar_nokey 8600IN ( SELECT col_varchar_key 8601FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) 8602) 8603; 8604id select_type table type possible_keys key key_len ref rows Extra 86051 PRIMARY GP2 system NULL NULL NULL NULL 1 NULL 86061 PRIMARY GP1 ALL NULL NULL NULL NULL 3 Using where 86072 SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using where 86083 SUBQUERY t2 system col_varchar_key NULL NULL NULL 1 NULL 86093 SUBQUERY t3 system col_varchar_key NULL NULL NULL 1 NULL 8610SELECT GP1.id 8611FROM t1 AS GP1 JOIN t3 AS GP2 8612ON GP2.col_varchar_key <> GP1.col_varchar_nokey 8613WHERE (GP1.col_varchar_nokey, GP1.col_varchar_nokey) 8614IN ( 8615SELECT col_varchar_nokey, col_varchar_nokey 8616FROM t1 8617WHERE col_varchar_nokey 8618IN ( SELECT col_varchar_key 8619FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) 8620) 8621; 8622id 8623200 8624DROP TABLE t1,t2,t3; 8625# 8626# Bug #13596176: Missing row on select with nested in clause when 8627# matr=on and bnl=off + MyISAM 8628# 8629CREATE TABLE t1 ( 8630int_key int DEFAULT NULL, 8631vc_key varchar(1) DEFAULT NULL, 8632vc_nokey varchar(1) DEFAULT NULL, 8633KEY int_key (int_key), 8634KEY vc_key (vc_key, int_key) 8635) ENGINE=MyISAM; 8636INSERT INTO t1 VALUES 8637(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), 8638(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), 8639(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), 8640(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), 8641(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); 8642CREATE TABLE t2 ( 8643int_key int DEFAULT NULL, 8644vc_key varchar(1) DEFAULT NULL, 8645KEY int_key (int_key), 8646KEY vc_key (vc_key, int_key) 8647) ENGINE=MyISAM; 8648INSERT INTO t2 VALUES (8,'g'); 8649explain SELECT vc_key 8650FROM t1 as outr 8651WHERE (vc_nokey, vc_key ) IN 8652(SELECT vc_nokey, vc_nokey 8653FROM t1 middle 8654WHERE vc_nokey IN 8655(SELECT child1.vc_key 8656FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) 8657) 8658); 8659id select_type table type possible_keys key key_len ref rows Extra 86601 PRIMARY outr ALL NULL NULL NULL NULL 20 Using where 86612 SUBQUERY middle ALL NULL NULL NULL NULL 20 Using where 86623 SUBQUERY child1 system int_key,vc_key NULL NULL NULL 1 NULL 86633 SUBQUERY child2 ref int_key int_key 5 const 3 Using index 8664SELECT vc_key 8665FROM t1 as outr 8666WHERE (vc_nokey, vc_key ) IN 8667(SELECT vc_nokey, vc_nokey 8668FROM t1 middle 8669WHERE vc_nokey IN 8670(SELECT child1.vc_key 8671FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) 8672) 8673); 8674vc_key 8675g 8676DROP TABLE t1, t2; 8677# End of test for bug#13596176. 8678# 8679# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS 8680# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO 8681# ROWS + INDEX DOES NOT RETURN NULL 8682# 8683CREATE TABLE t1 ( 8684pk int(11) PRIMARY KEY, 8685int_key int(11), 8686KEY int_key (int_key) 8687); 8688INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); 8689SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); 8690MIN(int_key) 8691NULL 8692SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); 8693MIN(int_key) 86940 8695SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; 8696MIN(pk) 8697NULL 8698DROP TABLE t1; 8699# BUG#13726217: Crash in Item_ident::fix_after_pullout() 8700CREATE TABLE t1(a INTEGER) engine=innodb; 8701INSERT INTO t1 VALUES (0); 8702SELECT 0 8703FROM t1 8704WHERE 0 IN 8705(SELECT 0 8706FROM t1 8707WHERE 0 LIKE 8708(SELECT elt(a, 0) AS b 8709FROM t1 8710GROUP BY a 8711HAVING b 8712) 8713); 87140 8715DROP TABLE t1; 8716# End of test for bug#13726217. 8717# BUG#13773979: Missing rows on second execution of prepared statement 8718CREATE TABLE t1 ( 8719col_int_nokey INT, 8720col_int_key INT, 8721col_varchar_key VARCHAR(1) 8722); 8723INSERT INTO t1 VALUES 8724(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), 8725(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); 8726CREATE VIEW v1 AS SELECT * FROM t1; 8727SELECT * 8728FROM t1 8729WHERE col_int_key IN ( 8730SELECT alias1.col_int_nokey AS field1 8731FROM v1 AS alias1 8732WHERE alias1.col_varchar_key < 'v' 8733); 8734col_int_nokey col_int_key col_varchar_key 87351 7 v 87367 0 s 87374 9 l 87382 2 i 8739prepare stmt FROM "SELECT * 8740FROM t1 8741WHERE col_int_key IN ( 8742SELECT alias1.col_int_nokey AS field1 8743FROM v1 AS alias1 8744WHERE alias1.col_varchar_key < 'v' 8745)"; 8746execute stmt; 8747col_int_nokey col_int_key col_varchar_key 87481 7 v 87497 0 s 87504 9 l 87512 2 i 8752execute stmt; 8753col_int_nokey col_int_key col_varchar_key 87541 7 v 87557 0 s 87564 9 l 87572 2 i 8758DEALLOCATE PREPARE stmt; 8759DROP VIEW v1; 8760DROP TABLE t1; 8761# End of test for bug#13773979. 8762# 8763# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN 8764# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER 8765# 8766CREATE TABLE t1 ( 8767col_int_key INT(11) NOT NULL, 8768col_datetime_key DATETIME NOT NULL, 8769col_varchar_key VARCHAR(1) NOT NULL, 8770col_varchar_nokey VARCHAR(1) NOT NULL, 8771KEY col_int_key (col_int_key), 8772KEY col_datetime_key (col_datetime_key), 8773KEY col_varchar_key (col_varchar_key,col_int_key) 8774); 8775INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); 8776INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); 8777CREATE TABLE t2 ( 8778col_int_key INT(11) NOT NULL, 8779col_datetime_key DATETIME NOT NULL, 8780col_varchar_key VARCHAR(1) NOT NULL, 8781col_varchar_nokey VARCHAR(1) NOT NULL, 8782KEY col_int_key (col_int_key), 8783KEY col_datetime_key (col_datetime_key), 8784KEY col_varchar_key (col_varchar_key,col_int_key) 8785); 8786INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); 8787SET @old_depth=@@optimizer_search_depth; 8788SET optimizer_search_depth=4; 8789EXPLAIN SELECT col_datetime_key 8790FROM t1 as outr 8791WHERE col_datetime_key IN ( 8792SELECT alias1.col_datetime_key 8793FROM t1 AS alias1 8794LEFT JOIN t1 as alias3 8795STRAIGHT_JOIN ( t2 AS alias4 8796JOIN t1 AS alias5 8797ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) 8798ON alias5.col_int_key < alias4.col_int_key 8799ON alias5.col_varchar_key = alias4.col_varchar_key 8800); 8801id select_type table type possible_keys key key_len ref rows Extra 88021 PRIMARY outr index NULL col_datetime_key 5 NULL 2 Using where; Using index 88032 SUBQUERY alias1 index col_datetime_key col_datetime_key 5 NULL 2 Using index 88042 SUBQUERY alias4 ALL col_int_key,col_varchar_key NULL NULL NULL 1 Using where 88052 SUBQUERY alias5 ref col_int_key,col_varchar_key col_varchar_key 3 test.alias4.col_varchar_key 1 Using where; Using index 88062 SUBQUERY alias3 index NULL col_int_key 4 NULL 2 Using index 8807SELECT col_datetime_key 8808FROM t1 as outr 8809WHERE col_datetime_key IN ( 8810SELECT alias1.col_datetime_key 8811FROM t1 AS alias1 8812LEFT JOIN t1 as alias3 8813STRAIGHT_JOIN ( t2 AS alias4 8814JOIN t1 AS alias5 8815ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) 8816ON alias5.col_int_key < alias4.col_int_key 8817ON alias5.col_varchar_key = alias4.col_varchar_key 8818); 8819col_datetime_key 88202002-02-13 17:30:06 88212008-09-27 00:34:58 8822DROP TABLE t1,t2; 8823SET @@optimizer_search_depth=@old_depth; 8824# 8825# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 8826# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN 8827# 8828CREATE TABLE t1 ( 8829col_int_key INT, 8830col_varchar_key VARCHAR(1), 8831KEY col_int_key (col_int_key), 8832KEY col_varchar_key (col_varchar_key) 8833); 8834INSERT INTO t1 VALUES (8,'x'); 8835CREATE TABLE t2 ( 8836col_varchar_key VARCHAR(1), 8837KEY col_varchar_key (col_varchar_key) 8838); 8839INSERT INTO t2 VALUES ('x'), ('y'); 8840explain SELECT MIN(col_int_key) 8841FROM t1 as t1_outer 8842HAVING (1, 2) IN ( 8843SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) 8844FROM t1 as t1_inner JOIN t2 8845ON t2.col_varchar_key = t1_inner.col_varchar_key 8846); 8847id select_type table type possible_keys key key_len ref rows Extra 88481 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away 88492 SUBQUERY t1_inner system col_varchar_key NULL NULL NULL 1 NULL 88502 SUBQUERY t2 ref col_varchar_key col_varchar_key 4 const 1 Using index 8851SELECT MIN(col_int_key) 8852FROM t1 as t1_outer 8853HAVING (1, 2) IN ( 8854SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) 8855FROM t1 as t1_inner JOIN t2 8856ON t2.col_varchar_key = t1_inner.col_varchar_key 8857); 8858MIN(col_int_key) 8859DROP TABLE t1,t2; 8860# Bug#13838810: Segfault in evaluate_null_complemented_join_record 8861CREATE TABLE t1 ( 8862pk int NOT NULL, 8863col_int_nokey int DEFAULT NULL, 8864col_int_key int DEFAULT NULL, 8865col_varchar_key varchar(1) DEFAULT NULL, 8866PRIMARY KEY (pk), 8867KEY col_int_key (col_int_key), 8868KEY col_varchar_key (col_varchar_key,col_int_key) 8869) ENGINE=InnoDB; 8870INSERT INTO t1 VALUES (10,NULL,8,'x'); 8871CREATE TABLE t2 ( 8872pk int NOT NULL, 8873col_varchar_nokey varchar(1) DEFAULT NULL, 8874PRIMARY KEY (pk) 8875) ENGINE=InnoDB; 8876INSERT INTO t2 VALUES (1,'x'); 8877CREATE TABLE t3 ( 8878pk int NOT NULL, 8879col_varchar_key varchar(1) DEFAULT NULL, 8880col_varchar_nokey varchar(1) DEFAULT NULL, 8881PRIMARY KEY (pk), 8882KEY col_varchar_key (col_varchar_key) 8883) ENGINE=InnoDB; 8884INSERT INTO t3 VALUES 8885(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); 8886EXPLAIN SELECT table1.pk,table2.pk, table3.pk 8887FROM t2 AS table1 8888LEFT JOIN t1 AS table2 8889LEFT JOIN t1 AS table3 8890ON table3.col_int_key = table2.col_int_key 8891ON table3.pk = table2.col_int_nokey AND 8892table1.col_varchar_nokey IN ( 8893SELECT subquery3_t1.col_varchar_nokey 8894FROM t3 AS subquery3_t1 8895LEFT JOIN t1 AS subquery3_t2 8896ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key 8897WHERE subquery3_t2.col_int_nokey <> 9 8898) 8899; 8900id select_type table type possible_keys key key_len ref rows Extra 89011 PRIMARY table1 ALL NULL NULL NULL NULL 1 NULL 89021 PRIMARY table2 ALL col_int_key NULL NULL NULL 1 Using where 89031 PRIMARY table3 eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 Using where 89042 SUBQUERY subquery3_t2 ALL col_varchar_key NULL NULL NULL 1 Using where 89052 SUBQUERY subquery3_t1 ref col_varchar_key col_varchar_key 4 test.subquery3_t2.col_varchar_key 1 NULL 8906SELECT table1.pk,table2.pk, table3.pk 8907FROM t2 AS table1 8908LEFT JOIN t1 AS table2 8909LEFT JOIN t1 AS table3 8910ON table3.col_int_key = table2.col_int_key 8911ON table3.pk = table2.col_int_nokey AND 8912table1.col_varchar_nokey IN ( 8913SELECT subquery3_t1.col_varchar_nokey 8914FROM t3 AS subquery3_t1 8915LEFT JOIN t1 AS subquery3_t2 8916ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key 8917WHERE subquery3_t2.col_int_nokey <> 9 8918) 8919; 8920pk pk pk 89211 NULL NULL 8922DROP TABLE t1, t2, t3; 8923Extra test case for specific code coverage 8924CREATE TABLE t1(pk INTEGER); 8925INSERT INTO t1 VALUES(1), (2); 8926explain SELECT * 8927FROM t1 AS ot1 LEFT JOIN t1 AS ot2 8928ON ot1.pk=ot2.pk AND 8929ot2.pk IN 8930(SELECT it1.pk 8931FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); 8932id select_type table type possible_keys key key_len ref rows Extra 89331 PRIMARY ot1 ALL NULL NULL NULL NULL 2 NULL 89341 PRIMARY ot2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 89352 SUBQUERY it1 ALL NULL NULL NULL NULL 2 NULL 89362 SUBQUERY it2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 8937SELECT * 8938FROM t1 AS ot1 LEFT JOIN t1 AS ot2 8939ON ot1.pk=ot2.pk AND 8940ot2.pk IN 8941(SELECT it1.pk 8942FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); 8943pk pk 89441 1 89452 2 8946DROP TABLE t1; 8947# End of test for bug#13838810. 8948# 8949# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN 8950# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER 8951# 8952CREATE TABLE t1 ( 8953col_int_key INT(11) NOT NULL, 8954col_datetime_key DATETIME NOT NULL, 8955col_varchar_key VARCHAR(1) NOT NULL, 8956col_varchar_nokey VARCHAR(1) NOT NULL, 8957KEY col_int_key (col_int_key), 8958KEY col_datetime_key (col_datetime_key), 8959KEY col_varchar_key (col_varchar_key,col_int_key) 8960); 8961INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); 8962INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); 8963CREATE TABLE t2 ( 8964col_int_key INT(11) NOT NULL, 8965col_datetime_key DATETIME NOT NULL, 8966col_varchar_key VARCHAR(1) NOT NULL, 8967col_varchar_nokey VARCHAR(1) NOT NULL, 8968KEY col_int_key (col_int_key), 8969KEY col_datetime_key (col_datetime_key), 8970KEY col_varchar_key (col_varchar_key,col_int_key) 8971); 8972INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); 8973SET @old_depth=@@optimizer_search_depth; 8974SET optimizer_search_depth=4; 8975EXPLAIN SELECT col_datetime_key 8976FROM t1 as outr 8977WHERE col_datetime_key IN ( 8978SELECT alias1.col_datetime_key 8979FROM t1 AS alias1 8980LEFT JOIN t1 as alias3 8981STRAIGHT_JOIN ( t2 AS alias4 8982JOIN t1 AS alias5 8983ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) 8984ON alias5.col_int_key < alias4.col_int_key 8985ON alias5.col_varchar_key = alias4.col_varchar_key 8986); 8987id select_type table type possible_keys key key_len ref rows Extra 89881 PRIMARY outr index NULL col_datetime_key 5 NULL 2 Using where; Using index 89892 SUBQUERY alias1 index col_datetime_key col_datetime_key 5 NULL 2 Using index 89902 SUBQUERY alias4 ALL col_int_key,col_varchar_key NULL NULL NULL 1 Using where 89912 SUBQUERY alias5 ref col_int_key,col_varchar_key col_varchar_key 3 test.alias4.col_varchar_key 1 Using where; Using index 89922 SUBQUERY alias3 index NULL col_int_key 4 NULL 2 Using index 8993SELECT col_datetime_key 8994FROM t1 as outr 8995WHERE col_datetime_key IN ( 8996SELECT alias1.col_datetime_key 8997FROM t1 AS alias1 8998LEFT JOIN t1 as alias3 8999STRAIGHT_JOIN ( t2 AS alias4 9000JOIN t1 AS alias5 9001ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) 9002ON alias5.col_int_key < alias4.col_int_key 9003ON alias5.col_varchar_key = alias4.col_varchar_key 9004); 9005col_datetime_key 90062002-02-13 17:30:06 90072008-09-27 00:34:58 9008DROP TABLE t1,t2; 9009SET @@optimizer_search_depth=@old_depth; 9010# 9011# Bug#13845930: Segfault in st_join_table::and_with_condition 9012# 9013CREATE TABLE t1 ( 9014col_int INTEGER 9015); 9016CREATE TABLE t2 ( 9017col_varchar_1 VARCHAR(1), 9018col_varchar_2 VARCHAR(1) 9019); 9020INSERT INTO t2 VALUES ('x','x'), ('c','c'); 9021PREPARE stmt FROM ' 9022SELECT alias2.col_varchar_2 AS field1 9023FROM t2 AS alias1 9024 JOIN 9025 (t2 AS alias2 9026 LEFT JOIN t2 AS alias3 9027 ON (8, 92) IN 9028 (SELECT sq1_alias1.col_int, 9029 sq1_alias2.col_int 9030 FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 9031 ) 9032 ) 9033 ON alias3.col_varchar_1 = alias2.col_varchar_2 9034'; 9035EXECUTE stmt; 9036field1 9037EXECUTE stmt; 9038field1 9039DEALLOCATE prepare stmt; 9040DROP TABLE t1, t2; 9041# End of test for bug#13845930. 9042# 9043# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' 9044# in ha_innobase::index_read 9045# 9046CREATE TABLE t1 ( 9047pk INTEGER AUTO_INCREMENT, 9048col_int_nokey INT, 9049col_int_key INT, 9050col_varchar_key VARCHAR(1), 9051col_varchar_nokey VARCHAR(1), 9052PRIMARY KEY (pk), 9053KEY (col_varchar_key) 9054) ENGINE=INNODB; 9055INSERT INTO t1 ( 9056col_int_key, col_int_nokey, 9057col_varchar_key, col_varchar_nokey 9058) VALUES 9059(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), 9060(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), 9061(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), 9062(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), 9063(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); 9064CREATE TABLE t2 ( 9065pk INT AUTO_INCREMENT, 9066col_int_nokey INT, 9067col_int_key INT, 9068PRIMARY KEY (pk), 9069KEY (col_int_key) 9070) AUTO_INCREMENT=10 ENGINE=INNODB; 9071INSERT INTO t2 (col_int_key, col_int_nokey) VALUES 9072(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), 9073(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), 9074(NULL, 6), (0, 2), (NULL, 9), (8, 6); 9075CREATE TABLE t3 ( 9076pk INT AUTO_INCREMENT, 9077col_varchar_key VARCHAR(1), 9078PRIMARY KEY (pk), 9079KEY (col_varchar_key) 9080) ENGINE=INNODB; 9081INSERT INTO t3 (col_varchar_key) VALUES 9082('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), 9083('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); 9084CREATE VIEW v1 AS 9085SELECT table2.col_varchar_nokey AS field1 9086FROM t2 AS table1 9087INNER JOIN (t1 AS table2 9088STRAIGHT_JOIN t2 AS table3 9089ON table3.col_int_key = table2.pk AND 9090table3.col_int_nokey = ANY 9091(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 9092FROM t2 AS subquery1_t1 9093RIGHT OUTER JOIN t1 AS subquery1_t2 9094INNER JOIN t1 AS subquery1_t3 9095ON subquery1_t3.col_int_key = subquery1_t2.pk 9096ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey 9097WHERE subquery1_t1.pk > 1 9098) 9099) 9100ON table3.col_int_key IN 9101(SELECT subquery2_t1.col_int_key AS subquery2_field1 9102FROM t2 AS subquery2_t1 9103RIGHT OUTER JOIN t3 AS subquery2_t2 9104LEFT OUTER JOIN t1 AS subquery2_t3 9105ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key 9106ON subquery2_t3.pk = subquery2_t2.pk 9107) 9108; 9109explain SELECT * FROM v1; 9110id select_type table type possible_keys key key_len ref rows Extra 91111 PRIMARY table1 index NULL col_int_key 5 NULL 20 Using index 91121 PRIMARY table2 ALL PRIMARY NULL NULL NULL 20 Using where; Using join buffer (Block Nested Loop) 91131 PRIMARY table3 ref col_int_key col_int_key 5 test.table2.pk 1 Using where 91143 SUBQUERY subquery1_t2 ALL PRIMARY NULL NULL NULL 20 Using where 91153 SUBQUERY subquery1_t3 ref col_varchar_key col_varchar_key 4 test.subquery1_t2.col_varchar_nokey 1 Using where 91163 SUBQUERY subquery1_t1 index PRIMARY col_int_key 5 NULL 20 Using where; Using index; Using join buffer (Block Nested Loop) 91174 SUBQUERY subquery2_t3 index PRIMARY,col_varchar_key col_varchar_key 4 NULL 20 Using where; Using index 91184 SUBQUERY subquery2_t2 eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 Using where 91194 SUBQUERY subquery2_t1 index col_int_key col_int_key 5 NULL 20 Using index; Using join buffer (Block Nested Loop) 9120SELECT * FROM v1; 9121field1 9122v 9123v 9124v 9125v 9126v 9127v 9128v 9129v 9130v 9131v 9132v 9133v 9134v 9135v 9136v 9137v 9138v 9139v 9140v 9141v 9142DROP VIEW v1; 9143DROP TABLE t1,t2,t3; 9144# End of test for bug#13855925. 9145# 9146# Bug#13897959: Segfault in setup_semijoin_dups_elimination() 9147# 9148CREATE TABLE t1 ( 9149col_datetime_key DATETIME DEFAULT NULL, 9150KEY col_datetime_key (col_datetime_key) 9151) ENGINE=MyISAM; 9152INSERT INTO t1 VALUES 9153('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), 9154('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), 9155('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); 9156CREATE TABLE t2 ( 9157col_date_nokey date DEFAULT NULL, 9158col_time_key time DEFAULT NULL, 9159col_datetime_key datetime DEFAULT NULL, 9160col_varchar_key varchar(1) DEFAULT NULL, 9161col_varchar_nokey varchar(1) DEFAULT NULL, 9162KEY col_time_key (col_time_key), 9163KEY col_datetime_key (col_datetime_key), 9164KEY col_varchar_key(col_varchar_key) 9165) ENGINE=MyISAM; 9166INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); 9167SELECT grandparent1.col_varchar_nokey 9168FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) 9169WHERE grandparent1.col_varchar_nokey IN ( 9170SELECT col_varchar_nokey 9171FROM t2 AS parent1 9172WHERE parent1.col_time_key > grandparent1.col_date_nokey 9173); 9174col_varchar_nokey 9175DROP TABLE t1, t2; 9176# End of test for bug#13897959. 9177# 9178# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN 9179# BEST_EXTENSION_BY_LIMITED_SEARCH 9180# 9181CREATE TABLE t1 ( 9182pk int(11) NOT NULL, 9183col_int_nokey INT, 9184col_int_key INT, 9185col_varchar_key VARCHAR(1), 9186col_varchar_nokey VARCHAR(1), 9187PRIMARY KEY (pk), 9188KEY col_int_key (col_int_key), 9189KEY col_varchar_key (col_varchar_key,col_int_key) 9190); 9191INSERT INTO t1 VALUES (26,6,NULL,'f','f'); 9192INSERT INTO t1 VALUES (29,6,8,'c','c'); 9193CREATE TABLE t2 ( 9194pk INT NOT NULL, 9195col_int_nokey INT, 9196col_int_key INT, 9197col_varchar_key VARCHAR(1), 9198col_varchar_nokey VARCHAR(1), 9199PRIMARY KEY (pk), 9200KEY col_int_key (col_int_key), 9201KEY col_varchar_key (col_varchar_key,col_int_key) 9202); 9203INSERT INTO t2 VALUES (1,2,4,'v','v'); 9204INSERT INTO t2 VALUES (2,150,62,'v','v'); 9205INSERT INTO t2 VALUES (5,5,0,'x','x'); 9206INSERT INTO t2 VALUES (6,3,7,'i','i'); 9207INSERT INTO t2 VALUES (7,1,7,'e','e'); 9208CREATE VIEW view_c AS SELECT * FROM t2; 9209PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 9210FROM t1 AS alias1 9211RIGHT JOIN t2 AS alias2 9212INNER JOIN t1 AS alias3 9213ON (alias3.col_varchar_key = alias2.col_varchar_key ) 9214ON ( "v" ) IN ( 9215SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 9216FROM t1 AS sq1_alias1 9217) 9218WHERE alias3.pk IN ( 9219SELECT sq2_alias1.col_int_key AS sq2_field1 9220FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) 9221) 9222'; 9223EXECUTE prep_stmt_7430; 9224field1 9225NULL 9226EXECUTE prep_stmt_7430; 9227field1 9228NULL 9229EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 9230FROM t1 AS alias1 9231RIGHT JOIN t2 AS alias2 9232INNER JOIN t1 AS alias3 9233ON (alias3.col_varchar_key = alias2.col_varchar_key ) 9234ON ( "v" ) IN ( 9235SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 9236FROM t1 AS sq1_alias1 9237) 9238WHERE alias3.pk IN ( 9239SELECT sq2_alias1.col_int_key AS sq2_field1 9240FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) 9241) 9242; 9243id select_type table type possible_keys key key_len ref rows Extra 92441 PRIMARY alias3 ALL col_varchar_key NULL NULL NULL 2 Using where 92451 PRIMARY alias2 ref col_varchar_key col_varchar_key 4 test.alias3.col_varchar_key 1 Using index 92461 PRIMARY alias1 index NULL col_varchar_key 9 NULL 2 Using where; Using index; Using join buffer (Block Nested Loop) 92473 SUBQUERY sq2_alias2 index NULL PRIMARY 4 NULL 2 Using index 92483 SUBQUERY t2 index col_int_key col_int_key 5 NULL 5 Using index; Using join buffer (Block Nested Loop) 92492 SUBQUERY sq1_alias1 ALL NULL NULL NULL NULL 2 Using where 9250PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 9251FROM t1 AS alias1 9252RIGHT JOIN t2 AS alias2 9253INNER JOIN t1 AS alias3 9254ON (alias3.col_varchar_key = alias2.col_varchar_key ) 9255ON ( "v" ) IN ( 9256SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 9257FROM t1 AS sq1_alias1 9258) 9259WHERE alias3.pk IN ( 9260SELECT sq2_alias1.col_int_key AS sq2_field1 9261FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) 9262WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key 9263AND sq2_alias1.col_varchar_key < "l" 9264 ) 9265'; 9266EXECUTE prep_stmt_7430; 9267field1 9268NULL 9269EXECUTE prep_stmt_7430; 9270field1 9271NULL 9272EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 9273FROM t1 AS alias1 9274RIGHT JOIN t2 AS alias2 9275INNER JOIN t1 AS alias3 9276ON (alias3.col_varchar_key = alias2.col_varchar_key ) 9277ON ( "v" ) IN ( 9278SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 9279FROM t1 AS sq1_alias1 9280) 9281WHERE alias3.pk IN ( 9282SELECT sq2_alias1.col_int_key AS sq2_field1 9283FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) 9284WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key 9285AND sq2_alias1.col_varchar_key < "l" 9286 ) 9287; 9288id select_type table type possible_keys key key_len ref rows Extra 92891 PRIMARY alias3 ALL col_varchar_key NULL NULL NULL 2 Using where 92901 PRIMARY alias2 ref col_varchar_key col_varchar_key 4 test.alias3.col_varchar_key 1 Using where; Using index 92911 PRIMARY alias1 index NULL col_varchar_key 9 NULL 2 Using where; Using index; Using join buffer (Block Nested Loop) 92923 DEPENDENT SUBQUERY t2 ref col_int_key,col_varchar_key col_int_key 5 func 2 Using where 92933 DEPENDENT SUBQUERY sq2_alias2 index NULL PRIMARY 4 NULL 2 Using index; Using join buffer (Block Nested Loop) 92942 SUBQUERY sq1_alias1 ALL NULL NULL NULL NULL 2 Using where 9295DROP TABLE t1,t2; 9296DROP VIEW view_c; 9297# 9298# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD 9299# ON SECOND EXEC OF PREP STMT 9300# 9301CREATE TABLE t1 ( 9302pk INT, 9303col_int_nokey INT, 9304col_int_key INT, 9305col_varchar_key VARCHAR(1), 9306col_varchar_nokey VARCHAR(1), 9307KEY col_varchar_key (col_varchar_key) 9308); 9309CREATE VIEW view_b AS SELECT * FROM t1; 9310PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 9311FROM t1 AS alias1 9312INNER JOIN t1 AS alias2 9313ON (alias1.col_varchar_key = alias2.col_varchar_nokey 9314AND ( alias1.col_int_key ) IN ( 9315SELECT t1.col_int_nokey 9316FROM t1 9317) 9318) 9319WHERE alias1.col_varchar_key IN ( 9320SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 9321FROM view_b AS sq2_alias1 9322INNER JOIN t1 AS sq2_alias2 9323ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) 9324WHERE sq2_alias1.pk > alias2.pk 9325) 9326'; 9327EXECUTE prep_stmt_20421; 9328field1 9329EXECUTE prep_stmt_20421; 9330field1 9331EXPLAIN SELECT alias2.col_varchar_nokey AS field1 9332FROM t1 AS alias1 9333INNER JOIN t1 AS alias2 9334ON (alias1.col_varchar_key = alias2.col_varchar_nokey 9335AND ( alias1.col_int_key ) IN ( 9336SELECT t1.col_int_nokey 9337FROM t1 9338) 9339) 9340WHERE alias1.col_varchar_key IN ( 9341SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 9342FROM view_b AS sq2_alias1 9343INNER JOIN t1 AS sq2_alias2 9344ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) 9345WHERE sq2_alias1.pk > alias2.pk 9346) 9347; 9348id select_type table type possible_keys key key_len ref rows Extra 93491 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 93503 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 93512 SUBQUERY t1 system NULL NULL NULL NULL 0 const row not found 9352ALTER TABLE t1 DROP INDEX col_varchar_key; 9353PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 9354FROM t1 AS alias1 9355INNER JOIN t1 AS alias2 9356ON (alias1.col_varchar_key = alias2.col_varchar_nokey 9357AND ( alias1.col_int_key ) IN ( 9358SELECT t1.col_int_nokey 9359FROM t1 9360) 9361) 9362WHERE alias1.col_varchar_key IN ( 9363SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 9364FROM view_b AS sq2_alias1 9365INNER JOIN t1 AS sq2_alias2 9366ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) 9367WHERE sq2_alias1.pk > alias2.pk 9368) 9369'; 9370EXECUTE prep_stmt_20421; 9371field1 9372EXECUTE prep_stmt_20421; 9373field1 9374EXPLAIN SELECT alias2.col_varchar_nokey AS field1 9375FROM t1 AS alias1 9376INNER JOIN t1 AS alias2 9377ON (alias1.col_varchar_key = alias2.col_varchar_nokey 9378AND ( alias1.col_int_key ) IN ( 9379SELECT t1.col_int_nokey 9380FROM t1 9381) 9382) 9383WHERE alias1.col_varchar_key IN ( 9384SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 9385FROM view_b AS sq2_alias1 9386INNER JOIN t1 AS sq2_alias2 9387ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) 9388WHERE sq2_alias1.pk > alias2.pk 9389) 9390; 9391id select_type table type possible_keys key key_len ref rows Extra 93921 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 93933 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 93942 SUBQUERY t1 system NULL NULL NULL NULL 0 const row not found 9395DROP TABLE t1; 9396DROP VIEW view_b; 9397# 9398# Bug#13907277: Segfault in evaluate_null_complemented_join_record 9399# 9400CREATE TABLE t1 ( 9401pk INTEGER, 9402col_varchar_nokey VARCHAR(1), 9403col_varchar_key VARCHAR(1), 9404PRIMARY KEY (pk) 9405); 9406INSERT INTO t1 VALUES (1, 'x', 'x'); 9407CREATE TABLE t2 ( 9408pk INTEGER, 9409PRIMARY KEY (pk) 9410); 9411INSERT INTO t2 VALUES (1); 9412CREATE TABLE t3 ( 9413pk INTEGER, 9414col_int_nokey INTEGER, 9415col_int_key INTEGER, 9416col_varchar_nokey VARCHAR(1), 9417PRIMARY KEY (pk) 9418); 9419INSERT INTO t3 VALUES (1, 6, 5, 'r'); 9420explain SELECT outer_t1.pk, outer_t2.pk 9421FROM t3 AS outer_t1 9422RIGHT JOIN t2 AS outer_t2 9423ON outer_t1.col_int_nokey IN 9424(SELECT inner_t1.col_int_nokey 9425FROM t3 AS inner_t1 9426LEFT JOIN t1 AS inner_t2 9427INNER JOIN t1 AS inner_t3 9428ON inner_t3.pk = inner_t2.pk 9429ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key 9430); 9431id select_type table type possible_keys key key_len ref rows Extra 94321 PRIMARY outer_t2 system NULL NULL NULL NULL 1 NULL 94331 PRIMARY outer_t1 system NULL NULL NULL NULL 1 NULL 94342 DEPENDENT SUBQUERY inner_t1 system NULL NULL NULL NULL 1 NULL 94352 DEPENDENT SUBQUERY inner_t2 ALL PRIMARY NULL NULL NULL 1 Using where 94362 DEPENDENT SUBQUERY inner_t3 eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 Using where 9437SELECT outer_t1.pk, outer_t2.pk 9438FROM t3 AS outer_t1 9439RIGHT JOIN t2 AS outer_t2 9440ON outer_t1.col_int_nokey IN 9441(SELECT inner_t1.col_int_nokey 9442FROM t3 AS inner_t1 9443LEFT JOIN t1 AS inner_t2 9444INNER JOIN t1 AS inner_t3 9445ON inner_t3.pk = inner_t2.pk 9446ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key 9447); 9448pk pk 94491 1 9450DROP TABLE t1, t2, t3; 9451# End of test for bug#13907277. 9452# 9453# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution 9454# 9455CREATE TABLE t1 ( 9456pk INTEGER, 9457col_varchar_key VARCHAR(1), 9458col_varchar_nokey VARCHAR(1) 9459); 9460PREPARE stmt FROM " 9461SELECT MIN(alias2.col_varchar_key) AS field1 9462FROM t1 AS alias1 9463 INNER JOIN (t1 AS alias2 9464 INNER JOIN t1 AS alias3 9465 ON 8 IN 9466 (SELECT sq1_alias1.pk AS sq1_field2 9467 FROM t1 AS sq1_alias1 9468 WHERE 9 IN 9469 (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 9470 FROM t1 AS t1_sq1_alias1 9471 ) 9472 ) 9473 ) 9474 ON alias3.col_varchar_nokey = alias2.col_varchar_key 9475WHERE EXISTS 9476 (SELECT sq2_alias1.pk AS sq2_field1 9477 FROM t1 AS sq2_alias1 9478 WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey 9479 ) 9480"; 9481EXECUTE stmt; 9482field1 9483NULL 9484EXECUTE stmt; 9485field1 9486NULL 9487DEALLOCATE PREPARE stmt; 9488DROP TABLE t1; 9489# End of test for bug#13955713. 9490# 9491# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() 9492# 9493CREATE TABLE t1 ( 9494pk INT, 9495col_varchar_key VARCHAR(1), 9496col_varchar_nokey VARCHAR(1) 9497); 9498CREATE TABLE t2 ( 9499pk INT, 9500col_varchar_key VARCHAR(1), 9501col_varchar_nokey VARCHAR(1) 9502); 9503INSERT INTO t2 VALUES 9504(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), 9505(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), 9506(18,'v','v'), (19,NULL,NULL), (20,'r','r'); 9507CREATE TABLE t3 ( 9508pk INT, 9509col_int_key INT, 9510col_varchar_key VARCHAR(1), 9511KEY col_int_key (col_int_key) 9512); 9513INSERT INTO t3 VALUES 9514(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), 9515(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), 9516(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), 9517(27,0,'p'), (28,NULL,'j'), (29,8,'c'); 9518CREATE VIEW view_inline_0 AS 9519SELECT t1.* 9520FROM t1 INNER JOIN t3 9521ON t1.pk = t3.pk; 9522CREATE VIEW view_inline_1 AS 9523SELECT sq2_alias2.col_varchar_key AS sq2_field1, 9524sq2_alias1.col_varchar_key AS sq2_field2 9525FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 9526ON sq2_alias1.pk = sq2_alias2.col_int_key; 9527CREATE VIEW view_inline_2 AS 9528SELECT 'p', 'p' UNION SELECT 'k', 's'; 9529explain SELECT SUM(alias1.col_varchar_nokey) AS field2 9530FROM t2 AS alias2 9531LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 9532ON alias2.col_varchar_key = alias1.col_varchar_key AND 9533(alias2.col_varchar_nokey, alias2.col_varchar_key) IN 9534(SELECT * FROM view_inline_1 9535) 9536WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN 9537(SELECT * FROM view_inline_2 9538); 9539id select_type table type possible_keys key key_len ref rows Extra 95401 PRIMARY alias2 ALL NULL NULL NULL NULL 11 Using where 95411 PRIMARY <derived2> ref <auto_key0> <auto_key0> 4 test.alias2.col_varchar_key 2 Using where 95424 SUBQUERY <derived7> ALL NULL NULL NULL NULL 2 NULL 95437 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used 95448 UNION NULL NULL NULL NULL NULL NULL NULL No tables used 9545NULL UNION RESULT <union7,8> ALL NULL NULL NULL NULL NULL Using temporary 95463 SUBQUERY sq2_alias1 ALL NULL NULL NULL NULL 15 NULL 95473 SUBQUERY sq2_alias2 ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 NULL 95482 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table 9549SELECT SUM(alias1.col_varchar_nokey) AS field2 9550FROM t2 AS alias2 9551LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 9552ON alias2.col_varchar_key = alias1.col_varchar_key AND 9553(alias2.col_varchar_nokey, alias2.col_varchar_key) IN 9554(SELECT * FROM view_inline_1 9555) 9556WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN 9557(SELECT * FROM view_inline_2 9558); 9559field2 9560NULL 9561DROP VIEW view_inline_0, view_inline_1, view_inline_2; 9562DROP TABLE t1, t2, t3; 9563# End of test for bug#13956813. 9564# 9565# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... 9566# 9567CREATE TABLE t1 ( 9568pk INTEGER AUTO_INCREMENT, 9569col_int_nokey INTEGER, 9570col_int_key INTEGER, 9571col_varchar_key VARCHAR(1), 9572col_varchar_nokey VARCHAR(1), 9573PRIMARY KEY (pk), 9574KEY (col_int_key), 9575KEY (col_varchar_key, col_int_key) 9576); 9577INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) 9578VALUES 9579(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), 9580(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), 9581(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), 9582(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), 9583(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); 9584CREATE TABLE t2 ( 9585pk INTEGER AUTO_INCREMENT, 9586col_int_nokey INTEGER NOT NULL, 9587col_time_key TIME NOT NULL, 9588col_time_nokey TIME NOT NULL, 9589PRIMARY KEY (pk), 9590KEY (col_time_key) 9591) ENGINE=InnoDB; 9592INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES 9593(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), 9594(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), 9595(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), 9596(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), 9597(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), 9598(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), 9599(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), 9600(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), 9601(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), 9602(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); 9603explain SELECT ot1.col_int_key AS x 9604FROM t1 AS ot2 9605LEFT JOIN t1 AS ot1 9606ON ot2.col_varchar_nokey > ot1.col_varchar_key 9607WHERE (ot1.col_int_nokey, ot1.pk) IN 9608(SELECT it1.pk AS x, 9609it1.col_int_nokey AS y 9610FROM t2 AS it2 9611LEFT JOIN t2 AS it1 9612ON it2.col_time_nokey = it1.col_time_key 9613) AND ot1.pk IS NULL 9614; 9615id select_type table type possible_keys key key_len ref rows Extra 96161 PRIMARY ot1 const PRIMARY,col_varchar_key PRIMARY 4 const 1 Using where 96171 PRIMARY ot2 ALL NULL NULL NULL NULL 20 Using where; Using join buffer (Block Nested Loop) 96182 SUBQUERY it2 ALL NULL NULL NULL NULL 20 NULL 96192 SUBQUERY it1 ref PRIMARY,col_time_key col_time_key 3 test.it2.col_time_nokey 1 NULL 9620SELECT ot1.col_int_key AS x 9621FROM t1 AS ot2 9622LEFT JOIN t1 AS ot1 9623ON ot2.col_varchar_nokey > ot1.col_varchar_key 9624WHERE (ot1.col_int_nokey, ot1.pk) IN 9625(SELECT it1.pk AS x, 9626it1.col_int_nokey AS y 9627FROM t2 AS it2 9628LEFT JOIN t2 AS it1 9629ON it2.col_time_nokey = it1.col_time_key 9630) AND ot1.pk IS NULL 9631; 9632x 9633DROP TABLE t1, t2; 9634# End of test for bug#13974177. 9635# 9636# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... 9637# 9638CREATE TABLE t1 ( 9639pk INT, 9640col_int_key INT, 9641col_varchar_key VARCHAR(1), 9642PRIMARY KEY (pk), 9643KEY col_varchar_key (col_varchar_key,col_int_key) 9644); 9645CREATE TABLE t2 ( 9646pk INT, 9647col_int_key INT, 9648col_varchar_key VARCHAR(1), 9649col_varchar_nokey VARCHAR(1), 9650PRIMARY KEY (pk) 9651) ENGINE=InnoDB; 9652CREATE TABLE t3 ( 9653i INT 9654); 9655explain SELECT table1.pk AS field1 9656FROM ( SELECT subquery1_t1. * 9657FROM t2 AS subquery1_t1 9658JOIN t2 AS subquery1_t2 9659ON subquery1_t2.pk = subquery1_t1.pk) AS table1 9660STRAIGHT_JOIN t2 AS table2 9661ON table1.col_int_key IN (SELECT 7 FROM t3) 9662WHERE table1.col_varchar_nokey IN 9663(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 9664FROM t1 AS subquery3_t1 9665) 9666; 9667id select_type table type possible_keys key key_len ref rows Extra 96681 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 Using where 96691 PRIMARY table2 index NULL PRIMARY 4 NULL 1 Using index; Using join buffer (Block Nested Loop) 96704 SUBQUERY subquery3_t1 system col_varchar_key NULL NULL NULL 0 const row not found 96713 SUBQUERY t3 system NULL NULL NULL NULL 0 const row not found 96722 DERIVED subquery1_t1 ALL PRIMARY NULL NULL NULL 1 NULL 96732 DERIVED subquery1_t2 eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 Using index 9674SELECT table1.pk AS field1 9675FROM ( SELECT subquery1_t1. * 9676FROM t2 AS subquery1_t1 9677JOIN t2 AS subquery1_t2 9678ON subquery1_t2.pk = subquery1_t1.pk) AS table1 9679STRAIGHT_JOIN t2 AS table2 9680ON table1.col_int_key IN (SELECT 7 FROM t3) 9681WHERE table1.col_varchar_nokey IN 9682(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 9683FROM t1 AS subquery3_t1 9684) 9685; 9686field1 9687DROP TABLE t1, t2, t3; 9688# End of test for bug#13971022. 9689# 9690# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH 9691# TIME/DATETIME COMPARE" - Subquery part of test. 9692# 9693SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); 9694CREATE TABLE t1 ( 9695pk INT NOT NULL, 9696col_int_nokey INT, 9697col_int_key INT NOT NULL, 9698PRIMARY KEY (pk), 9699KEY col_int_key (col_int_key) 9700) ENGINE=InnoDB; 9701INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), 9702(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), 9703(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), 9704(27,3,5), (28,6,0), (29,6,3); 9705CREATE TABLE t2 ( 9706col_int_nokey INT NOT NULL, 9707col_datetime_key DATETIME NOT NULL, 9708col_varchar_key VARCHAR(1) NOT NULL, 9709KEY col_datetime_key (col_datetime_key), 9710KEY col_varchar_key (col_varchar_key) 9711) ENGINE=InnoDB; 9712INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); 9713CREATE TABLE t3 ( 9714col_time_key TIME, 9715KEY col_time_key (col_time_key) 9716) ENGINE=InnoDB; 9717INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), 9718('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), 9719('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), 9720('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), 9721('02:59:24'), ('00:01:58'); 9722EXPLAIN EXTENDED SELECT outr.col_int_nokey 9723FROM t2 as outr 9724STRAIGHT_JOIN t3 AS outr2 9725ON outr2.col_time_key > outr.col_datetime_key 9726WHERE outr.col_int_nokey IN ( 9727SELECT col_int_key 9728FROM t1 AS innr 9729WHERE innr.pk >= innr.col_int_nokey 9730) AND ( 9731outr.col_int_nokey <= 6 9732OR 9733outr.col_varchar_key IS NULL 9734); 9735id select_type table type possible_keys key key_len ref rows filtered Extra 97361 PRIMARY outr ALL col_datetime_key NULL NULL NULL 1 100.00 Using where 97371 PRIMARY outr2 ALL col_time_key NULL NULL NULL 20 100.00 Range checked for each record (index map: 0x1) 97382 SUBQUERY innr ALL col_int_key NULL NULL NULL 20 100.00 Using where 9739Warnings: 9740Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` straight_join `test`.`t3` `outr2` where (<in_optimizer>(`test`.`outr`.`col_int_nokey`,`test`.`outr`.`col_int_nokey` in ( <materialize> (/* select#2 */ select `test`.`innr`.`col_int_key` from `test`.`t1` `innr` where (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) ), <primary_index_lookup>(`test`.`outr`.`col_int_nokey` in <temporary table> on <auto_key> where ((`test`.`outr`.`col_int_nokey` = `materialized-subquery`.`col_int_key`))))) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`outr2`.`col_time_key` > `test`.`outr`.`col_datetime_key`)) 9741SELECT outr.col_int_nokey 9742FROM t2 as outr 9743STRAIGHT_JOIN t3 AS outr2 9744ON outr2.col_time_key > outr.col_datetime_key 9745WHERE outr.col_int_nokey IN ( 9746SELECT col_int_key 9747FROM t1 AS innr 9748WHERE innr.pk >= innr.col_int_nokey 9749) AND ( 9750outr.col_int_nokey <= 6 9751OR 9752outr.col_varchar_key IS NULL 9753); 9754col_int_nokey 97551 97561 97571 97581 97591 97601 97611 97621 97631 97641 97651 97661 97671 97681 97691 97701 97711 97721 97731 97741 9775DROP TABLE t1,t2,t3; 9776SET TIMESTAMP = DEFAULT; 9777# End of test for bug#13623473. 9778# 9779# Bug#13980954: Missing data on left join + null value + where..in 9780# 9781CREATE TABLE t1 ( 9782ik INT, 9783vc varchar(1) 9784); 9785INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); 9786CREATE TABLE t2 ( 9787ik INT, 9788vc varchar(1) 9789); 9790INSERT INTO t2 VALUES 9791(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); 9792explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik 9793FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc 9794WHERE t2.vc IN (SELECT vc FROM t2 AS t3); 9795EXPLAIN 9796{ 9797 "query_block": { 9798 "select_id": 1, 9799 "nested_loop": [ 9800 { 9801 "table": { 9802 "table_name": "t2", 9803 "access_type": "ALL", 9804 "rows": 6, 9805 "filtered": 100, 9806 "attached_condition": "<in_optimizer>(`test`.`t2`.`vc`,`test`.`t2`.`vc` in ( <materialize> (/* select#2 */ select `test`.`t3`.`vc` from `test`.`t2` `t3` where 1 ), <primary_index_lookup>(`test`.`t2`.`vc` in <temporary table> on <auto_key> where ((`test`.`t2`.`vc` = `materialized-subquery`.`vc`)))))", 9807 "attached_subqueries": [ 9808 { 9809 "table": { 9810 "table_name": "<materialized_subquery>", 9811 "access_type": "eq_ref", 9812 "key": "<auto_key>", 9813 "key_length": "4", 9814 "rows": 1, 9815 "materialized_from_subquery": { 9816 "using_temporary_table": true, 9817 "dependent": true, 9818 "cacheable": false, 9819 "query_block": { 9820 "select_id": 2, 9821 "table": { 9822 "table_name": "t3", 9823 "access_type": "ALL", 9824 "rows": 6, 9825 "filtered": 100 9826 } 9827 } 9828 } 9829 } 9830 } 9831 ] 9832 } 9833 }, 9834 { 9835 "table": { 9836 "table_name": "t1", 9837 "access_type": "ALL", 9838 "rows": 2, 9839 "filtered": 100, 9840 "using_join_buffer": "Block Nested Loop", 9841 "attached_condition": "<if>(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" 9842 } 9843 } 9844 ] 9845 } 9846} 9847Warnings: 9848Note 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`)) where <in_optimizer>(`test`.`t2`.`vc`,`test`.`t2`.`vc` in ( <materialize> (/* select#2 */ select `test`.`t3`.`vc` from `test`.`t2` `t3` where 1 ), <primary_index_lookup>(`test`.`t2`.`vc` in <temporary table> on <auto_key> where ((`test`.`t2`.`vc` = `materialized-subquery`.`vc`))))) 9849SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik 9850FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc 9851WHERE t2.vc IN (SELECT vc FROM t2 AS t3); 9852vc t2_ik t1_ik 9853x 0 8 9854x 0 NULL 9855i 7 NULL 9856e 7 NULL 9857p 1 NULL 9858s 7 NULL 9859j 1 NULL 9860DROP TABLE t1, t2; 9861# End of test for bug#13980954. 9862# 9863# Bug#14048292: Segfault in Item_field::result_type on 2nd execution 9864# of prep stmt with join of view 9865# 9866CREATE TABLE t1 ( 9867col_int INT 9868); 9869INSERT INTO t1 VALUES (0), (1); 9870CREATE VIEW view_t1 AS SELECT * FROM t1; 9871explain SELECT alias1.col_int 9872FROM t1 AS alias1 9873LEFT JOIN view_t1 AS alias2 9874ON alias1.col_int IN 9875(SELECT sq1_alias1.col_int 9876FROM t1 AS sq1_alias1 9877); 9878id select_type table type possible_keys key key_len ref rows Extra 98791 PRIMARY alias1 ALL NULL NULL NULL NULL 2 NULL 98801 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 98812 SUBQUERY sq1_alias1 ALL NULL NULL NULL NULL 2 NULL 9882PREPARE stmt FROM "SELECT alias1.col_int 9883FROM t1 AS alias1 9884LEFT JOIN view_t1 AS alias2 9885ON alias1.col_int IN 9886(SELECT sq1_alias1.col_int 9887FROM t1 AS sq1_alias1 9888)"; 9889EXECUTE stmt; 9890col_int 98910 98921 98930 98941 9895EXECUTE stmt; 9896col_int 98970 98981 98990 99001 9901DEALLOCATE PREPARE stmt; 9902DROP VIEW view_t1; 9903DROP TABLE t1; 9904# End of test for bug#14048292. 9905# 9906# Bug#14064201: Missing data on join of derived table + WHERE .. IN 9907# with two operands 9908# 9909CREATE TABLE t1 ( 9910col_varchar_nokey VARCHAR(1) 9911); 9912INSERT INTO t1 VALUES 9913('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), 9914('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); 9915CREATE TABLE t2 ( 9916col_varchar_key VARCHAR(1), 9917col_varchar_nokey VARCHAR(1), 9918KEY col_varchar_key(col_varchar_key) 9919); 9920INSERT INTO t2 VALUES 9921('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); 9922explain format=json SELECT * 9923FROM (SELECT * FROM t2) AS derived1 9924LEFT JOIN t1 9925USING (col_varchar_nokey) 9926WHERE (col_varchar_nokey, col_varchar_nokey) IN 9927(SELECT col_varchar_nokey, col_varchar_key 9928FROM t2 AS derived2 9929); 9930EXPLAIN 9931{ 9932 "query_block": { 9933 "select_id": 1, 9934 "nested_loop": [ 9935 { 9936 "table": { 9937 "table_name": "derived1", 9938 "access_type": "ALL", 9939 "rows": 7, 9940 "filtered": 100, 9941 "attached_condition": "<in_optimizer>((`derived1`.`col_varchar_nokey`,`derived1`.`col_varchar_nokey`),(`derived1`.`col_varchar_nokey`,`derived1`.`col_varchar_nokey`) in ( <materialize> (/* select#3 */ select `test`.`derived2`.`col_varchar_nokey`,`test`.`derived2`.`col_varchar_key` from `test`.`t2` `derived2` where 1 ), <primary_index_lookup>(`derived1`.`col_varchar_nokey` in <temporary table> on <auto_key> where ((`derived1`.`col_varchar_nokey` = `materialized-subquery`.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = `materialized-subquery`.`col_varchar_key`)))))", 9942 "attached_subqueries": [ 9943 { 9944 "table": { 9945 "table_name": "<materialized_subquery>", 9946 "access_type": "eq_ref", 9947 "key": "<auto_key>", 9948 "key_length": "8", 9949 "rows": 1, 9950 "materialized_from_subquery": { 9951 "using_temporary_table": true, 9952 "dependent": true, 9953 "cacheable": false, 9954 "query_block": { 9955 "select_id": 3, 9956 "table": { 9957 "table_name": "derived2", 9958 "access_type": "ALL", 9959 "possible_keys": [ 9960 "col_varchar_key" 9961 ], 9962 "rows": 7, 9963 "filtered": 100 9964 } 9965 } 9966 } 9967 } 9968 } 9969 ], 9970 "materialized_from_subquery": { 9971 "using_temporary_table": true, 9972 "dependent": false, 9973 "cacheable": true, 9974 "query_block": { 9975 "select_id": 2, 9976 "table": { 9977 "table_name": "t2", 9978 "access_type": "ALL", 9979 "rows": 7, 9980 "filtered": 100 9981 } 9982 } 9983 } 9984 } 9985 }, 9986 { 9987 "table": { 9988 "table_name": "t1", 9989 "access_type": "ALL", 9990 "rows": 20, 9991 "filtered": 100, 9992 "using_join_buffer": "Block Nested Loop", 9993 "attached_condition": "<if>(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`), true)" 9994 } 9995 } 9996 ] 9997 } 9998} 9999Warnings: 10000Note 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`)) where <in_optimizer>((`derived1`.`col_varchar_nokey`,`derived1`.`col_varchar_nokey`),(`derived1`.`col_varchar_nokey`,`derived1`.`col_varchar_nokey`) in ( <materialize> (/* select#3 */ select `test`.`derived2`.`col_varchar_nokey`,`test`.`derived2`.`col_varchar_key` from `test`.`t2` `derived2` where 1 ), <primary_index_lookup>(`derived1`.`col_varchar_nokey` in <temporary table> on <auto_key> where ((`derived1`.`col_varchar_nokey` = `materialized-subquery`.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = `materialized-subquery`.`col_varchar_key`))))) 10001SELECT * 10002FROM (SELECT * FROM t2) AS derived1 10003LEFT JOIN t1 10004USING (col_varchar_nokey) 10005WHERE (col_varchar_nokey, col_varchar_nokey) IN 10006(SELECT col_varchar_nokey, col_varchar_key 10007FROM t2 AS derived2 10008); 10009col_varchar_nokey col_varchar_key 10010v v 10011y y 10012c c 10013v v 10014y y 10015y y 10016j j 10017m m 10018d d 10019d d 10020DROP TABLE t1, t2; 10021CREATE TABLE t1 ( 10022col_int_nokey int NOT NULL, 10023col_int_key int NOT NULL, 10024KEY col_int_key (col_int_key) 10025); 10026INSERT INTO t1 VALUES 10027(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), 10028(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); 10029CREATE TABLE t2 ( 10030col_int_nokey int NOT NULL, 10031col_int_key int NOT NULL, 10032KEY col_int_key (col_int_key) 10033); 10034INSERT INTO t2 VALUES 10035(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), 10036(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); 10037explain format=json SELECT grandparent1.* 10038FROM t1 AS grandparent1 10039LEFT JOIN t1 USING (col_int_nokey) 10040WHERE (col_int_nokey, col_int_nokey) IN 10041(SELECT col_int_nokey, col_int_key 10042FROM t2 10043); 10044EXPLAIN 10045{ 10046 "query_block": { 10047 "select_id": 1, 10048 "nested_loop": [ 10049 { 10050 "table": { 10051 "table_name": "grandparent1", 10052 "access_type": "ALL", 10053 "rows": 20, 10054 "filtered": 100, 10055 "attached_condition": "<in_optimizer>((`test`.`grandparent1`.`col_int_nokey`,`test`.`grandparent1`.`col_int_nokey`),(`test`.`grandparent1`.`col_int_nokey`,`test`.`grandparent1`.`col_int_nokey`) in ( <materialize> (/* select#2 */ select `test`.`t2`.`col_int_nokey`,`test`.`t2`.`col_int_key` from `test`.`t2` where 1 ), <primary_index_lookup>(`test`.`grandparent1`.`col_int_nokey` in <temporary table> on <auto_key> where ((`test`.`grandparent1`.`col_int_nokey` = `materialized-subquery`.`col_int_nokey`) and (`test`.`grandparent1`.`col_int_nokey` = `materialized-subquery`.`col_int_key`)))))", 10056 "attached_subqueries": [ 10057 { 10058 "table": { 10059 "table_name": "<materialized_subquery>", 10060 "access_type": "eq_ref", 10061 "key": "<auto_key>", 10062 "key_length": "8", 10063 "rows": 1, 10064 "materialized_from_subquery": { 10065 "using_temporary_table": true, 10066 "dependent": true, 10067 "cacheable": false, 10068 "query_block": { 10069 "select_id": 2, 10070 "table": { 10071 "table_name": "t2", 10072 "access_type": "ALL", 10073 "possible_keys": [ 10074 "col_int_key" 10075 ], 10076 "rows": 20, 10077 "filtered": 100 10078 } 10079 } 10080 } 10081 } 10082 } 10083 ] 10084 } 10085 }, 10086 { 10087 "table": { 10088 "table_name": "t1", 10089 "access_type": "ALL", 10090 "rows": 20, 10091 "filtered": 100, 10092 "using_join_buffer": "Block Nested Loop", 10093 "attached_condition": "<if>(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" 10094 } 10095 } 10096 ] 10097 } 10098} 10099Warnings: 10100Note 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`)) where <in_optimizer>((`test`.`grandparent1`.`col_int_nokey`,`test`.`grandparent1`.`col_int_nokey`),(`test`.`grandparent1`.`col_int_nokey`,`test`.`grandparent1`.`col_int_nokey`) in ( <materialize> (/* select#2 */ select `test`.`t2`.`col_int_nokey`,`test`.`t2`.`col_int_key` from `test`.`t2` where 1 ), <primary_index_lookup>(`test`.`grandparent1`.`col_int_nokey` in <temporary table> on <auto_key> where ((`test`.`grandparent1`.`col_int_nokey` = `materialized-subquery`.`col_int_nokey`) and (`test`.`grandparent1`.`col_int_nokey` = `materialized-subquery`.`col_int_key`))))) 10101SELECT grandparent1.* 10102FROM t1 AS grandparent1 10103LEFT JOIN t1 USING (col_int_nokey) 10104WHERE (col_int_nokey, col_int_nokey) IN 10105(SELECT col_int_nokey, col_int_key 10106FROM t2 10107); 10108col_int_nokey col_int_key 101091 7 101101 6 101117 0 101127 3 101137 0 101147 3 101151 7 101161 6 101178 5 101188 1 101198 5 101208 1 10121DROP TABLE t1, t2; 10122CREATE TABLE t1 ( 10123pk int, 10124col_int_key int, 10125col_datetime_key datetime, 10126col_varchar_key varchar(1), 10127col_varchar_nokey varchar(1), 10128PRIMARY KEY (pk), 10129KEY col_int_key (col_int_key), 10130KEY col_datetime_key (col_datetime_key), 10131KEY col_varchar_key (col_varchar_key,col_int_key) 10132) engine=MyISAM; 10133INSERT INTO t1 VALUES 10134(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), 10135(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), 10136(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), 10137(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), 10138(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), 10139(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), 10140(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), 10141(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), 10142(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), 10143(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); 10144CREATE TABLE t2 ( 10145pk int, 10146col_int_key int, 10147col_datetime_key datetime, 10148col_varchar_key varchar(1), 10149col_varchar_nokey varchar(1), 10150PRIMARY KEY (pk), 10151KEY col_int_key (col_int_key), 10152KEY col_datetime_key (col_datetime_key), 10153KEY col_varchar_key (col_varchar_key,col_int_key) 10154) engine=MyISAM; 10155INSERT INTO t2 VALUES 10156(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), 10157(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), 10158(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), 10159(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), 10160(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), 10161(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), 10162(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), 10163(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), 10164(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), 10165(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); 10166SELECT alias1.col_datetime_key 10167FROM t2 AS alias1 10168RIGHT JOIN t2 AS alias2 10169JOIN t2 AS alias3 10170ON alias3.pk = alias2.pk 10171ON alias3.col_varchar_nokey = alias2.col_varchar_key OR 10172alias2.col_varchar_nokey 10173WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN 10174(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey 10175FROM t1 AS sq2_alias1, t1 AS sq2_alias2 10176WHERE sq2_alias2.col_int_key < 2); 10177col_datetime_key 101781900-01-01 00:00:00 101791900-01-01 00:00:00 101801900-01-01 00:00:00 101811900-01-01 00:00:00 101821900-01-01 00:00:00 101831900-01-01 00:00:00 101841900-01-01 00:00:00 101851900-01-01 00:00:00 101861900-01-01 00:00:00 101871900-01-01 00:00:00 101882001-01-20 12:47:23 101892001-01-20 12:47:23 101902001-02-15 03:08:38 101912001-02-15 03:08:38 101922002-01-16 00:00:00 101932002-01-16 00:00:00 101942002-02-13 17:30:06 101952002-02-13 17:30:06 101962002-08-20 22:48:00 101972002-08-20 22:48:00 101982002-08-25 20:35:06 101992002-08-25 20:35:06 102002002-12-08 11:34:58 102012002-12-08 11:34:58 102022004-10-02 20:31:15 102032004-10-02 20:31:15 102042005-08-15 00:00:00 102052005-08-15 00:00:00 102062006-10-12 04:32:53 102072006-10-12 04:32:53 102082007-05-28 00:00:00 102092007-05-28 00:00:00 102102008-05-16 08:09:06 102112008-05-16 08:09:06 102122008-07-02 00:00:00 102132008-07-02 00:00:00 102142008-09-27 00:34:58 102152008-09-27 00:34:58 102162009-07-25 09:21:20 102172009-07-25 09:21:20 10218ALTER TABLE t1 DISABLE KEYS; 10219ALTER TABLE t2 DISABLE KEYS; 10220explain format=json SELECT alias1.col_datetime_key 10221FROM t2 AS alias1 10222RIGHT JOIN t2 AS alias2 10223JOIN t2 AS alias3 10224ON alias3.pk = alias2.pk 10225ON alias3.col_varchar_nokey = alias2.col_varchar_key OR 10226alias2.col_varchar_nokey 10227WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN 10228(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey 10229FROM t1 AS sq2_alias1, t1 AS sq2_alias2 10230WHERE sq2_alias2.col_int_key < 2); 10231EXPLAIN 10232{ 10233 "query_block": { 10234 "select_id": 1, 10235 "nested_loop": [ 10236 { 10237 "table": { 10238 "table_name": "alias2", 10239 "access_type": "ALL", 10240 "possible_keys": [ 10241 "PRIMARY" 10242 ], 10243 "rows": 20, 10244 "filtered": 100, 10245 "attached_condition": "<in_optimizer>((`test`.`alias2`.`col_varchar_key`,`test`.`alias2`.`col_varchar_key`),(`test`.`alias2`.`col_varchar_key`,`test`.`alias2`.`col_varchar_key`) in ( <materialize> (/* select#2 */ select `test`.`sq2_alias2`.`col_varchar_key`,`test`.`sq2_alias1`.`col_varchar_nokey` from `test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2` where (`test`.`sq2_alias2`.`col_int_key` < 2) ), <primary_index_lookup>(`test`.`alias2`.`col_varchar_key` in <temporary table> on <auto_key> where ((`test`.`alias2`.`col_varchar_key` = `materialized-subquery`.`col_varchar_key`) and (`test`.`alias2`.`col_varchar_key` = `materialized-subquery`.`col_varchar_nokey`)))))", 10246 "attached_subqueries": [ 10247 { 10248 "table": { 10249 "table_name": "<materialized_subquery>", 10250 "access_type": "eq_ref", 10251 "key": "<auto_key>", 10252 "key_length": "8", 10253 "rows": 1, 10254 "materialized_from_subquery": { 10255 "using_temporary_table": true, 10256 "dependent": true, 10257 "cacheable": false, 10258 "query_block": { 10259 "select_id": 2, 10260 "nested_loop": [ 10261 { 10262 "table": { 10263 "table_name": "sq2_alias1", 10264 "access_type": "ALL", 10265 "rows": 20, 10266 "filtered": 100 10267 } 10268 }, 10269 { 10270 "table": { 10271 "table_name": "sq2_alias2", 10272 "access_type": "ALL", 10273 "rows": 20, 10274 "filtered": 100, 10275 "using_join_buffer": "Block Nested Loop", 10276 "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" 10277 } 10278 } 10279 ] 10280 } 10281 } 10282 } 10283 } 10284 ] 10285 } 10286 }, 10287 { 10288 "table": { 10289 "table_name": "alias3", 10290 "access_type": "eq_ref", 10291 "possible_keys": [ 10292 "PRIMARY" 10293 ], 10294 "key": "PRIMARY", 10295 "used_key_parts": [ 10296 "pk" 10297 ], 10298 "key_length": "4", 10299 "ref": [ 10300 "test.alias2.pk" 10301 ], 10302 "rows": 1, 10303 "filtered": 100 10304 } 10305 }, 10306 { 10307 "table": { 10308 "table_name": "alias1", 10309 "access_type": "ALL", 10310 "rows": 20, 10311 "filtered": 100, 10312 "using_join_buffer": "Block Nested Loop", 10313 "attached_condition": "<if>(is_not_null_compl(alias1), ((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) or `test`.`alias2`.`col_varchar_nokey`), true)" 10314 } 10315 } 10316 ] 10317 } 10318} 10319Warnings: 10320Note 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`) or `test`.`alias2`.`col_varchar_nokey`)) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and <in_optimizer>((`test`.`alias2`.`col_varchar_key`,`test`.`alias2`.`col_varchar_key`),(`test`.`alias2`.`col_varchar_key`,`test`.`alias2`.`col_varchar_key`) in ( <materialize> (/* select#2 */ select `test`.`sq2_alias2`.`col_varchar_key`,`test`.`sq2_alias1`.`col_varchar_nokey` from `test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2` where (`test`.`sq2_alias2`.`col_int_key` < 2) ), <primary_index_lookup>(`test`.`alias2`.`col_varchar_key` in <temporary table> on <auto_key> where ((`test`.`alias2`.`col_varchar_key` = `materialized-subquery`.`col_varchar_key`) and (`test`.`alias2`.`col_varchar_key` = `materialized-subquery`.`col_varchar_nokey`)))))) 10321SELECT alias1.col_datetime_key 10322FROM t2 AS alias1 10323RIGHT JOIN t2 AS alias2 10324JOIN t2 AS alias3 10325ON alias3.pk = alias2.pk 10326ON alias3.col_varchar_nokey = alias2.col_varchar_key OR 10327alias2.col_varchar_nokey 10328WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN 10329(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey 10330FROM t1 AS sq2_alias1, t1 AS sq2_alias2 10331WHERE sq2_alias2.col_int_key < 2); 10332col_datetime_key 103332002-02-13 17:30:06 103342002-02-13 17:30:06 103352008-09-27 00:34:58 103362008-09-27 00:34:58 103372007-05-28 00:00:00 103382007-05-28 00:00:00 103392009-07-25 09:21:20 103402009-07-25 09:21:20 103412002-01-16 00:00:00 103422002-01-16 00:00:00 103432006-10-12 04:32:53 103442006-10-12 04:32:53 103452001-02-15 03:08:38 103462001-02-15 03:08:38 103472004-10-02 20:31:15 103482004-10-02 20:31:15 103492002-08-20 22:48:00 103502002-08-20 22:48:00 103511900-01-01 00:00:00 103521900-01-01 00:00:00 103532005-08-15 00:00:00 103542005-08-15 00:00:00 103551900-01-01 00:00:00 103561900-01-01 00:00:00 103572008-05-16 08:09:06 103582008-05-16 08:09:06 103592001-01-20 12:47:23 103602001-01-20 12:47:23 103612008-07-02 00:00:00 103622008-07-02 00:00:00 103631900-01-01 00:00:00 103641900-01-01 00:00:00 103652002-12-08 11:34:58 103662002-12-08 11:34:58 103671900-01-01 00:00:00 103681900-01-01 00:00:00 103691900-01-01 00:00:00 103701900-01-01 00:00:00 103712002-08-25 20:35:06 103722002-08-25 20:35:06 10373DROP TABLE t1, t2; 10374# End of test for bug#14064201. 10375# 10376# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 10377# && IDX < PARENT_JOIN->TABLES 10378# 10379CREATE TABLE b (d INT); 10380CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); 10381SELECT(SELECT 1 10382FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) 10383FROM b) IN (SELECT d FROM c)) as cc FROM b; 10384cc 10385INSERT INTO b VALUE(1); 10386INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); 10387SELECT(SELECT d FROM b WHERE(SELECT d IN 10388(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN 10389(SELECT d FROM c)) as cc FROM c; 10390cc 103911 103921 103931 10394DROP TABLE b,c; 10395# 10396# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN 10397# 10398CREATE TABLE b ( 10399d INT(11) 10400); 10401CREATE TABLE c ( 10402d BLOB 10403) ; 10404CREATE TABLE d ( 10405b INT(11) 10406); 10407INSERT INTO b VALUES(1),(2),(4); 10408INSERT INTO c VALUES(1),(2),(3); 10409SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; 104101 10411INSERT INTO d VALUES(2); 10412SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; 104131 104141 104151 104161 10417DROP TABLE b,c,d; 10418# 10419# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT 10420# 10421CREATE TABLE t1 ( 10422ID int(11) NOT NULL AUTO_INCREMENT, 10423id2 int(11) DEFAULT NULL, 10424id3 int(11) DEFAULT NULL, 10425id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, 10426id5 int(11) DEFAULT NULL, 10427PRIMARY KEY (ID), 10428KEY id2 (id2), 10429KEY id3 (id3), 10430KEY id5 (id5) 10431) ENGINE=InnoDB; 10432INSERT INTO t1 VALUES 10433(123,1,1,'1',NULL), 10434(124,1,1,'2',NULL), 10435(125,1,1,'4',NULL), 10436(126,1,1,'3',NULL), 10437(127,1,1,'6',NULL), 10438(128,1,1,'8',NULL); 10439CREATE TABLE t2 ( 10440id6 int(11) NOT NULL, 10441id7 int(11) NOT NULL, 10442PRIMARY KEY (id6,id7), 10443KEY id7 (id7) 10444) ENGINE=InnoDB; 10445INSERT INTO t2 VALUES (126,123),(130,123),(135,123); 10446SELECT ID 10447FROM t1 p0 10448WHERE p0.id3=1 10449AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 10450p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); 10451ID 10452126 10453DROP TABLE t1,t2; 10454# 10455# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT 10456# 10457CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); 10458INSERT INTO t1 VALUES 10459(1,1), (1,2), (1,3), (1,4), 10460(2,5), (2,6), (2,7), (2,8), 10461(3,1), (3,2), (3,9); 10462CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); 10463INSERT INTO t2 VALUES 10464(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), 10465(6, "F"), (7, "G"), (8, "H"), (9, "I"); 10466CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); 10467INSERT INTO t3 VALUES 10468(1,1), (1,2), (1,3),(1,4), 10469(2,5), (2,6), (2,7), (2,8), 10470(3,1), (3,2), (3,9); 10471CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); 10472INSERT INTO t4 VALUES 10473(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), 10474(6, "F"), (7, "G"), (8, "H"), (9, "I"); 10475ANALYZE TABLE t1,t2,t3,t4; 10476Table Op Msg_type Msg_text 10477test.t1 analyze status OK 10478test.t2 analyze status OK 10479test.t3 analyze status OK 10480test.t4 analyze status OK 10481EXPLAIN SELECT name FROM t2, t1 10482WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) 10483AND t2.uid=t1.fid; 10484id select_type table type possible_keys key key_len ref rows Extra 104851 PRIMARY t1 ALL NULL NULL NULL NULL 11 Using where 104861 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 NULL 104872 SUBQUERY t3 ref uid uid 5 const 4 Using where 104882 SUBQUERY t4 eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 Using index 10489FLUSH STATUS; 10490SELECT name FROM t2, t1 10491WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) 10492AND t2.uid=t1.fid; 10493name 10494A 10495B 10496C 10497D 10498E 10499F 10500G 10501H 10502A 10503B 10504I 10505SHOW STATUS LIKE '%handler_read%'; 10506Variable_name Value 10507Handler_read_first 0 10508Handler_read_key 19 10509Handler_read_last 0 10510Handler_read_next 4 10511Handler_read_prev 0 10512Handler_read_rnd 0 10513Handler_read_rnd_next 12 10514DROP TABLE t1,t2,t3,t4; 10515# End of test for Bug#18194196 10516# 10517# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT 10518# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() 10519# 10520CREATE TABLE t1 ( 10521col_int int(11), 10522pk int(11) NOT NULL, 10523col_int_key int(11) , 10524col_varchar varchar(1), 10525PRIMARY KEY (pk) 10526) ENGINE=MyISAM; 10527CREATE TABLE t2 ( 10528col_int int(11), 10529col_varchar varchar(1) 10530) ENGINE=MyISAM; 10531INSERT INTO t2 VALUES (19,'x'); 10532INSERT INTO t2 VALUES (20,'z'); 10533SELECT table1.col_varchar 10534FROM (t2 AS table1 RIGHT JOIN 10535((t2 STRAIGHT_JOIN t1 ON (t1.col_varchar = t2.col_varchar))) 10536ON (t1.pk = t2.col_int)) 10537WHERE (t1.pk IN (SELECT t1.col_int_key 10538FROM (t1 INNER JOIN t2 ON (t2.col_int = t1.col_int)))) 10539AND table1.col_varchar != 'q'; 10540col_varchar 10541DROP TABLE t1,t2; 10542# End of test for Bug#21184091 10543set @@optimizer_switch=@old_opt_switch; 10544# End of 5.6 tests 10545# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... 10546CREATE TABLE t1(a INTEGER) engine=innodb; 10547CREATE TABLE t2(b INTEGER) engine=innodb; 10548explain SELECT 1 10549FROM (SELECT 1 IN (SELECT 1 10550FROM t1 10551WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) 10552) 10553FROM t2 10554) AS z; 10555id select_type table type possible_keys key key_len ref rows Extra 105561 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 NULL 105572 DERIVED t2 ALL NULL NULL NULL NULL 1 NULL 105583 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 1 Using where 105595 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 1 Using where 105604 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 1 NULL 10561SELECT 1 10562FROM (SELECT 1 IN (SELECT 1 10563FROM t1 10564WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) 10565) 10566FROM t2 10567) AS z; 105681 10569DROP TABLE t1, t2; 10570CREATE TABLE t1(a INTEGER) engine=innodb; 10571explain SELECT (SELECT a 10572FROM t1 AS t2 10573WHERE a IN (SELECT t1.a+t2.a 10574FROM t1 AS t3)) 10575FROM t1 AS t1; 10576id select_type table type possible_keys key key_len ref rows Extra 105771 PRIMARY t1 ALL NULL NULL NULL NULL 1 NULL 105782 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 1 Using where 105793 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 1 Using where 10580SELECT (SELECT a 10581FROM t1 AS t2 10582WHERE a IN (SELECT t1.a+t2.a 10583FROM t1 AS t3)) 10584FROM t1 AS t1; 10585(SELECT a 10586FROM t1 AS t2 10587WHERE a IN (SELECT t1.a+t2.a 10588FROM t1 AS t3)) 10589DROP TABLE t1; 10590# End of test for Bug#21139722 10591# 10592# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE 10593# 10594CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); 10595CREATE TABLE t2 (c INT PRIMARY KEY); 10596EXPLAIN SELECT 1 10597FROM t1 10598WHERE 1 IN (SELECT (c IS NULL) IN (SELECT a 10599FROM t1 10600WHERE b) 10601FROM t2); 10602id select_type table type possible_keys key key_len ref rows Extra 106031 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 106042 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 106053 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 10606SELECT 1 10607FROM t1 10608WHERE 1 IN (SELECT (c IS NULL) IN (SELECT a 10609FROM t1 10610WHERE b) 10611FROM t2); 106121 10613DROP TABLE t1,t2; 10614# 10615# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT 10616# RESULTS IN 5.6 10617# 10618CREATE TABLE t(a INT,b INT); 10619INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); 10620EXPLAIN extended SELECT * 10621FROM t AS t1 10622WHERE t1.a IN (SELECT t2.a 10623FROM t AS t2 10624WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a 10625FROM t AS t3 10626WHERE t3.b=1)); 10627id select_type table type possible_keys key key_len ref rows filtered Extra 106281 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00 Using where 106292 SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where 106303 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 5 100.00 Using where 10631Warnings: 10632Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` where <in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (/* select#2 */ select `test`.`t2`.`a` from `test`.`t` `t2` where (not(<in_optimizer>(concat(`test`.`t2`.`a`,''),<exists>(/* select#3 */ select 1 from `test`.`t` `t3` where ((`test`.`t3`.`b` = 1) and <if>(outer_field_is_not_null, ((<cache>(concat(`test`.`t2`.`a`,'')) = `test`.`t3`.`a`) or isnull(`test`.`t3`.`a`)), true)) having <if>(outer_field_is_not_null, <is_not_null_test>(`test`.`t3`.`a`), true))))) ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on <auto_key> where ((`test`.`t1`.`a` = `materialized-subquery`.`a`))))) 10633SELECT * 10634FROM t AS t1 10635WHERE t1.a IN (SELECT t2.a 10636FROM t AS t2 10637WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a 10638FROM t AS t3 10639WHERE t3.b=1)); 10640a b 10641DROP TABLE t; 10642set optimizer_switch=default; 10643