1set optimizer_switch='batched_key_access=on,mrr_cost_based=off'; 2set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; 3set @old_opt_switch=@@optimizer_switch; 4set optimizer_switch='subquery_materialization_cost_based=off'; 5drop table if exists t0, t1, t2, t10, t11, t12; 6create table t1 (a int not null, b int, primary key (a)); 7create table t2 (a int not null, primary key (a)); 8create table t3 (a int not null, b int, primary key (a)); 9insert into t1 values (1,10), (2,20), (3,30), (4,40); 10insert into t2 values (2), (3), (4), (5); 11insert into t3 values (10,3), (20,4), (30,5); 12select * from t2 where t2.a in (select a from t1); 13a 142 153 164 17explain extended select * from t2 where t2.a in (select a from t1); 18id select_type table type possible_keys key key_len ref rows filtered Extra 191 SIMPLE t2 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index 201 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 4 75.00 Using where; Using index; Using join buffer (Block Nested Loop) 21Warnings: 22Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) 23select * from t2 where t2.a in (select a from t1 where t1.b <> 30); 24a 252 264 27explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); 28id select_type table type possible_keys key key_len ref rows filtered Extra 291 SIMPLE t2 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index 301 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 75.00 Using where; Using join buffer (Block Nested Loop) 31Warnings: 32Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) 33select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); 34a 352 363 37explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); 38id select_type table type possible_keys key key_len ref rows filtered Extra 391 SIMPLE t2 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index 401 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 75.00 Using where; Using join buffer (Block Nested Loop) 411 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index 42Warnings: 43Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`b`)) 44drop table t1, t2, t3; 45create table t1 (a int, b int, index a (a,b)); 46create table t2 (a int, index a (a)); 47create table t3 (a int, b int, index a (a)); 48insert into t1 values (1,10), (2,20), (3,30), (4,40); 49create table t0(a int); 50insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 51insert into t1 52select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; 53insert into t2 values (2), (3), (4), (5); 54insert into t3 values (10,3), (20,4), (30,5); 55select * from t2 where t2.a in (select a from t1); 56a 572 583 594 60explain extended select * from t2 where t2.a in (select a from t1); 61id select_type table type possible_keys key key_len ref rows filtered Extra 621 SIMPLE t2 index a a 5 NULL 4 100.00 Using where; Using index 631 SIMPLE t1 ref a a 5 test.t2.a 101 100.00 Using index; FirstMatch(t2) 64Warnings: 65Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`) 66select * from t2 where t2.a in (select a from t1 where t1.b <> 30); 67a 682 694 70explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); 71id select_type table type possible_keys key key_len ref rows filtered Extra 721 SIMPLE t2 index a a 5 NULL 4 100.00 Using where; Using index 731 SIMPLE t1 ref a a 5 test.t2.a 101 100.00 Using where; Using index; FirstMatch(t2) 74Warnings: 75Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) 76select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); 77a 782 793 80explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); 81id select_type table type possible_keys key key_len ref rows filtered Extra 821 SIMPLE t2 index a a 5 NULL 4 100.00 Using where; Using index 831 SIMPLE t3 index a a 5 NULL 3 100.00 Using where; Using index 841 SIMPLE t1 ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; FirstMatch(t2) 85Warnings: 86Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) 87insert into t1 values (3,31); 88select * from t2 where t2.a in (select a from t1 where t1.b <> 30); 89a 902 913 924 93select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); 94a 952 964 97explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); 98id select_type table type possible_keys key key_len ref rows filtered Extra 991 SIMPLE t2 index a a 5 NULL 4 100.00 Using where; Using index 1001 SIMPLE t1 ref a a 5 test.t2.a 101 100.00 Using where; Using index; FirstMatch(t2) 101Warnings: 102Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where ((`test`.`t1`.`a` = `test`.`t2`.`a`) and (`test`.`t1`.`b` <> 30)) 103drop table t0, t1, t2, t3; 104create table t0 (a int); 105insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 106create table t1(a int, b int); 107insert into t1 values (0,0),(1,1),(2,2); 108create table t2 as select * from t1; 109create table t11(a int, b int); 110create table t10 (pk int, a int, primary key(pk)); 111insert into t10 select a,a from t0; 112create table t12 like t10; 113insert into t12 select * from t10; 114Flattened because of dependency, t10=func(t1) 115explain select * from t1 where a in (select pk from t10); 116id select_type table type possible_keys key key_len ref rows Extra 1171 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where 1181 SIMPLE t10 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using index 119select * from t1 where a in (select pk from t10); 120a b 1210 0 1221 1 1232 2 124A confluent case of dependency 125explain select * from t1 where a in (select a from t10 where pk=12); 126id select_type table type possible_keys key key_len ref rows Extra 1271 SIMPLE 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 SIMPLE t10 const PRIMARY PRIMARY 4 const 1 NULL 1331 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where 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 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 1401 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (Block Nested Loop) 1412 MATERIALIZED t11 ALL NULL NULL NULL NULL 0 NULL 142select * from t1 where a in (select a from t11); 143a b 144explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); 145id select_type table type possible_keys key key_len ref rows Extra 1461 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where 1471 SIMPLE t10 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using index 1481 SIMPLE t10 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 Using index 149select * from t1 where a in (select pk from t10) and b in (select pk from t10); 150a b 1510 0 1521 1 1532 2 154flattening a nested subquery 155explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); 156id select_type table type possible_keys key key_len ref rows Extra 1571 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where 1581 SIMPLE t10 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using join buffer (Batched Key Access) 1591 SIMPLE t12 eq_ref PRIMARY PRIMARY 4 test.t10.a 1 Using index 160select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); 161a b 1620 0 1631 1 1642 2 165flattening subquery w/ several tables 166explain extended select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); 167id select_type table type possible_keys key key_len ref rows filtered Extra 1681 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where 1691 SIMPLE t10 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where; Using join buffer (Batched Key Access) 1701 SIMPLE t12 eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index 171Warnings: 172Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t12` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) 173subqueries within outer joins go into ON expr. 174explAin extended 175select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A And B.A in (select pk from t10)); 176id select_type tABle type possiBle_keys key key_len ref rows filtered ExtrA 1771 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 NULL 1781 SIMPLE A ALL NULL NULL NULL NULL 3 100.00 Using where 1791 SIMPLE B ALL NULL NULL NULL NULL 3 100.00 NULL 1801 SIMPLE t10 eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index 181Warnings: 182Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`A`.`A` = `test`.`t1`.`A`) And 1 And (`test`.`B`.`A` = `test`.`t10`.`pk`))) where 1 183t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" 184explAin extended 185select * from t1 left join t2 on (t2.A= t1.A And t2.A in (select pk from t10)); 186id select_type tABle type possiBle_keys key key_len ref rows filtered ExtrA 1871 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 NULL 1881 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where 1891 SIMPLE t10 eq_ref PRIMARY PRIMARY 4 test.t2.A 1 100.00 Using index 190Warnings: 191Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t2`.`A` = `test`.`t1`.`A`) And 1 And (`test`.`t2`.`A` = `test`.`t10`.`pk`))) where 1 192we shouldn't flatten if we're going to get a join of > MAX_TABLES. 193explain select * from 194t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, 195t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, 196t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, 197t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, 198t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 199where 200s00.a in ( 201select m00.a from 202t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, 203t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 204); 205id select_type table type possible_keys key key_len ref rows Extra 2061 PRIMARY s00 ALL NULL NULL NULL NULL 3 Using where 2071 PRIMARY s01 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2081 PRIMARY s02 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2091 PRIMARY s03 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2101 PRIMARY s04 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2111 PRIMARY s05 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2121 PRIMARY s06 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2131 PRIMARY s07 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2141 PRIMARY s08 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2151 PRIMARY s09 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2161 PRIMARY s10 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2171 PRIMARY s11 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2181 PRIMARY s12 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2191 PRIMARY s13 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2201 PRIMARY s14 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2211 PRIMARY s15 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2221 PRIMARY s16 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2231 PRIMARY s17 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2241 PRIMARY s18 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2251 PRIMARY s19 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2261 PRIMARY s20 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2271 PRIMARY s21 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2281 PRIMARY s22 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2291 PRIMARY s23 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2301 PRIMARY s24 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2311 PRIMARY s25 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2321 PRIMARY s26 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2331 PRIMARY s27 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2341 PRIMARY s28 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2351 PRIMARY s29 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2361 PRIMARY s30 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2371 PRIMARY s31 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2381 PRIMARY s32 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2391 PRIMARY s33 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2401 PRIMARY s34 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2411 PRIMARY s35 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2421 PRIMARY s36 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2431 PRIMARY s37 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2441 PRIMARY s38 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2451 PRIMARY s39 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2461 PRIMARY s40 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2471 PRIMARY s41 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2481 PRIMARY s42 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2491 PRIMARY s43 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2501 PRIMARY s44 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2511 PRIMARY s45 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2521 PRIMARY s46 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2531 PRIMARY s47 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2541 PRIMARY s48 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2551 PRIMARY s49 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2562 SUBQUERY m00 ALL NULL NULL NULL NULL 3 NULL 2572 SUBQUERY m01 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2582 SUBQUERY m02 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2592 SUBQUERY m03 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2602 SUBQUERY m04 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2612 SUBQUERY m05 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2622 SUBQUERY m06 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2632 SUBQUERY m07 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2642 SUBQUERY m08 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2652 SUBQUERY m09 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2662 SUBQUERY m10 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2672 SUBQUERY m11 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2682 SUBQUERY m12 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2692 SUBQUERY m13 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2702 SUBQUERY m14 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2712 SUBQUERY m15 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2722 SUBQUERY m16 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2732 SUBQUERY m17 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2742 SUBQUERY m18 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 2752 SUBQUERY m19 ALL NULL NULL NULL NULL 3 Using join buffer (Block Nested Loop) 276select * from 277t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) 278where t1.a < 5; 279a b a b 2800 0 0 0 2811 1 1 1 2822 2 2 2 283prepare s1 from 284' select * from 285 t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) 286 where t1.a < 5'; 287execute s1; 288a b a b 2890 0 0 0 2901 1 1 1 2912 2 2 2 292execute s1; 293a b a b 2940 0 0 0 2951 1 1 1 2962 2 2 2 297insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; 298explain extended select * from t1 where a in (select pk from t10 where pk<3); 299id select_type table type possible_keys key key_len ref rows filtered Extra 3001 SIMPLE t10 range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index 3011 SIMPLE t1 ALL NULL NULL NULL NULL 103 100.00 Using where; Using join buffer (Block Nested Loop) 302Warnings: 303Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t10`.`pk`) and (`test`.`t10`.`pk` < 3)) 304drop table t0, t1, t2; 305drop table t10, t11, t12; 306# 307# Check that subqueries with outer joins or straight_join work for 308# different permutations of const and non-const tables. (Ref. Bug#46692) 309# 310CREATE TABLE t1 (i INTEGER); 311CREATE TABLE t2 (i INTEGER); 312CREATE TABLE t3 (i INTEGER); 313SELECT (SELECT COUNT(*) from t1) AS c1, 314(SELECT COUNT(*) from t2) AS c2, 315(SELECT COUNT(*) from t3) AS c3; 316c1 c2 c3 3170 0 0 318EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 319(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 320id select_type table type possible_keys key key_len ref rows Extra 3211 SIMPLE 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 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 336SELECT * FROM t1 WHERE (t1.i) IN 337(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 338i 339PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 340(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 341EXECUTE stmt; 342i 343EXECUTE stmt; 344i 345DEALLOCATE PREPARE stmt; 346EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 347(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 348id select_type table type possible_keys key key_len ref rows Extra 3491 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 350SELECT * FROM t1 WHERE (t1.i) IN 351(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 352i 353EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 354(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 355id select_type table type possible_keys key key_len ref rows Extra 3561 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 357SELECT * FROM t1 WHERE (t1.i) IN 358(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 359i 360EXPLAIN SELECT * FROM t1 WHERE (11) IN 361(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 362id select_type table type possible_keys key key_len ref rows Extra 3631 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 364SELECT * FROM t1 WHERE (11) IN 365(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 366i 367EXPLAIN SELECT * FROM t1 WHERE (11) IN 368(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 369id select_type table type possible_keys key key_len ref rows Extra 3701 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 371SELECT * FROM t1 WHERE (11) IN 372(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 373i 374EXPLAIN SELECT * FROM t1 WHERE (11) IN 375(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 376id select_type table type possible_keys key key_len ref rows Extra 3771 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 378SELECT * FROM t1 WHERE (11) IN 379(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 380i 381EXPLAIN SELECT * FROM t1 WHERE (11) IN 382(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 383id select_type table type possible_keys key key_len ref rows Extra 3841 SIMPLE 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 STRAIGHT_JOIN t3); 387i 388INSERT INTO t3 VALUES (2); 389SELECT (SELECT COUNT(*) from t1) AS c1, 390(SELECT COUNT(*) from t2) AS c2, 391(SELECT COUNT(*) from t3) AS c3; 392c1 c2 c3 3930 0 1 394EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 395(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 396id select_type table type possible_keys key key_len ref rows Extra 3971 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 398SELECT * FROM t1 WHERE (t1.i) IN 399(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 400i 401PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 402(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 403EXECUTE stmt; 404i 405EXECUTE stmt; 406i 407DEALLOCATE PREPARE stmt; 408EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 409(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 410id select_type table type possible_keys key key_len ref rows Extra 4111 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 412SELECT * FROM t1 WHERE (t1.i) IN 413(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 414i 415PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 416(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 417EXECUTE stmt; 418i 419EXECUTE stmt; 420i 421DEALLOCATE PREPARE stmt; 422EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 423(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 424id select_type table type possible_keys key key_len ref rows Extra 4251 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 426SELECT * FROM t1 WHERE (t1.i) IN 427(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 428i 429EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 430(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 431id select_type table type possible_keys key key_len ref rows Extra 4321 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 433SELECT * FROM t1 WHERE (t1.i) IN 434(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 435i 436EXPLAIN SELECT * FROM t1 WHERE (11) IN 437(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 438id select_type table type possible_keys key key_len ref rows Extra 4391 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 440SELECT * FROM t1 WHERE (11) IN 441(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 442i 443EXPLAIN SELECT * FROM t1 WHERE (11) IN 444(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 445id select_type table type possible_keys key key_len ref rows Extra 4461 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 447SELECT * FROM t1 WHERE (11) IN 448(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 449i 450EXPLAIN SELECT * FROM t1 WHERE (11) IN 451(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 452id select_type table type possible_keys key key_len ref rows Extra 4531 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 454SELECT * FROM t1 WHERE (11) IN 455(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 456i 457EXPLAIN SELECT * FROM t1 WHERE (11) IN 458(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 459id select_type table type possible_keys key key_len ref rows Extra 4601 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 461SELECT * FROM t1 WHERE (11) IN 462(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 463i 464INSERT INTO t3 VALUES (1); 465SELECT (SELECT COUNT(*) from t1) AS c1, 466(SELECT COUNT(*) from t2) AS c2, 467(SELECT COUNT(*) from t3) AS c3; 468c1 c2 c3 4690 0 2 470EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 471(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 472id select_type table type possible_keys key key_len ref rows Extra 4731 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 474SELECT * FROM t1 WHERE (t1.i) IN 475(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 476i 477PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 478(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 479EXECUTE stmt; 480i 481EXECUTE stmt; 482i 483DEALLOCATE PREPARE stmt; 484EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 485(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 486id select_type table type possible_keys key key_len ref rows Extra 4871 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 488SELECT * FROM t1 WHERE (t1.i) IN 489(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 490i 491PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 492(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 493EXECUTE stmt; 494i 495EXECUTE stmt; 496i 497DEALLOCATE PREPARE stmt; 498EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 499(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 500id select_type table type possible_keys key key_len ref rows Extra 5011 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 502SELECT * FROM t1 WHERE (t1.i) IN 503(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 504i 505EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 506(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 507id select_type table type possible_keys key key_len ref rows Extra 5081 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 509SELECT * FROM t1 WHERE (t1.i) IN 510(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 511i 512EXPLAIN SELECT * FROM t1 WHERE (11) IN 513(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 514id select_type table type possible_keys key key_len ref rows Extra 5151 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 516SELECT * FROM t1 WHERE (11) IN 517(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 518i 519EXPLAIN SELECT * FROM t1 WHERE (11) IN 520(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 521id select_type table type possible_keys key key_len ref rows Extra 5221 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 523SELECT * FROM t1 WHERE (11) IN 524(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 525i 526EXPLAIN SELECT * FROM t1 WHERE (11) IN 527(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 528id select_type table type possible_keys key key_len ref rows Extra 5291 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 530SELECT * FROM t1 WHERE (11) IN 531(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 532i 533EXPLAIN SELECT * FROM t1 WHERE (11) IN 534(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 535id select_type table type possible_keys key key_len ref rows Extra 5361 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 537SELECT * FROM t1 WHERE (11) IN 538(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 539i 540INSERT INTO t3 VALUES (0); 541DELETE FROM t3; 542INSERT INTO t2 VALUES (2); 543SELECT (SELECT COUNT(*) from t1) AS c1, 544(SELECT COUNT(*) from t2) AS c2, 545(SELECT COUNT(*) from t3) AS c3; 546c1 c2 c3 5470 1 0 548EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 549(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 550id select_type table type possible_keys key key_len ref rows Extra 5511 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 552SELECT * FROM t1 WHERE (t1.i) IN 553(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 554i 555PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 556(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 557EXECUTE stmt; 558i 559EXECUTE stmt; 560i 561DEALLOCATE PREPARE stmt; 562EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 563(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 564id select_type table type possible_keys key key_len ref rows Extra 5651 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 566SELECT * FROM t1 WHERE (t1.i) IN 567(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 568i 569PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 570(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 571EXECUTE stmt; 572i 573EXECUTE stmt; 574i 575DEALLOCATE PREPARE stmt; 576EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 577(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 578id select_type table type possible_keys key key_len ref rows Extra 5791 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 580SELECT * FROM t1 WHERE (t1.i) IN 581(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 582i 583EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 584(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 585id select_type table type possible_keys key key_len ref rows Extra 5861 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 587SELECT * FROM t1 WHERE (t1.i) IN 588(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 589i 590EXPLAIN SELECT * FROM t1 WHERE (11) IN 591(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 592id select_type table type possible_keys key key_len ref rows Extra 5931 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 594SELECT * FROM t1 WHERE (11) IN 595(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 596i 597EXPLAIN SELECT * FROM t1 WHERE (11) IN 598(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 599id select_type table type possible_keys key key_len ref rows Extra 6001 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 601SELECT * FROM t1 WHERE (11) IN 602(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 603i 604EXPLAIN SELECT * FROM t1 WHERE (11) IN 605(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 606id select_type table type possible_keys key key_len ref rows Extra 6071 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 608SELECT * FROM t1 WHERE (11) IN 609(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 610i 611EXPLAIN SELECT * FROM t1 WHERE (11) IN 612(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 613id select_type table type possible_keys key key_len ref rows Extra 6141 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 615SELECT * FROM t1 WHERE (11) IN 616(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 617i 618INSERT INTO t3 VALUES (2); 619SELECT (SELECT COUNT(*) from t1) AS c1, 620(SELECT COUNT(*) from t2) AS c2, 621(SELECT COUNT(*) from t3) AS c3; 622c1 c2 c3 6230 1 1 624EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 625(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 626id select_type table type possible_keys key key_len ref rows Extra 6271 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 628SELECT * FROM t1 WHERE (t1.i) IN 629(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 630i 631PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 632(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 633EXECUTE stmt; 634i 635EXECUTE stmt; 636i 637DEALLOCATE PREPARE stmt; 638EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 639(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 640id select_type table type possible_keys key key_len ref rows Extra 6411 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 642SELECT * FROM t1 WHERE (t1.i) IN 643(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 644i 645PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 646(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 647EXECUTE stmt; 648i 649EXECUTE stmt; 650i 651DEALLOCATE PREPARE stmt; 652EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 653(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 654id select_type table type possible_keys key key_len ref rows Extra 6551 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 656SELECT * FROM t1 WHERE (t1.i) IN 657(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 658i 659EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 660(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 661id select_type table type possible_keys key key_len ref rows Extra 6621 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 663SELECT * FROM t1 WHERE (t1.i) IN 664(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 665i 666EXPLAIN SELECT * FROM t1 WHERE (11) IN 667(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 668id select_type table type possible_keys key key_len ref rows Extra 6691 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 670SELECT * FROM t1 WHERE (11) IN 671(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 672i 673EXPLAIN SELECT * FROM t1 WHERE (11) IN 674(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 675id select_type table type possible_keys key key_len ref rows Extra 6761 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 677SELECT * FROM t1 WHERE (11) IN 678(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 679i 680EXPLAIN SELECT * FROM t1 WHERE (11) IN 681(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 682id select_type table type possible_keys key key_len ref rows Extra 6831 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 684SELECT * FROM t1 WHERE (11) IN 685(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 686i 687EXPLAIN SELECT * FROM t1 WHERE (11) IN 688(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 689id select_type table type possible_keys key key_len ref rows Extra 6901 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 691SELECT * FROM t1 WHERE (11) IN 692(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 693i 694INSERT INTO t3 VALUES (1); 695SELECT (SELECT COUNT(*) from t1) AS c1, 696(SELECT COUNT(*) from t2) AS c2, 697(SELECT COUNT(*) from t3) AS c3; 698c1 c2 c3 6990 1 2 700EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 701(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 702id select_type table type possible_keys key key_len ref rows Extra 7031 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 704SELECT * FROM t1 WHERE (t1.i) IN 705(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 706i 707PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 708(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 709EXECUTE stmt; 710i 711EXECUTE stmt; 712i 713DEALLOCATE PREPARE stmt; 714EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 715(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 716id select_type table type possible_keys key key_len ref rows Extra 7171 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 718SELECT * FROM t1 WHERE (t1.i) IN 719(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 720i 721PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 722(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 723EXECUTE stmt; 724i 725EXECUTE stmt; 726i 727DEALLOCATE PREPARE stmt; 728EXPLAIN SELECT * FROM t1 WHERE (t1.i) 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 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 732SELECT * FROM t1 WHERE (t1.i) IN 733(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 734i 735EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 736(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 737id select_type table type possible_keys key key_len ref rows Extra 7381 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 739SELECT * FROM t1 WHERE (t1.i) IN 740(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 741i 742EXPLAIN SELECT * FROM t1 WHERE (11) IN 743(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 744id select_type table type possible_keys key key_len ref rows Extra 7451 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 746SELECT * FROM t1 WHERE (11) IN 747(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 748i 749EXPLAIN SELECT * FROM t1 WHERE (11) IN 750(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 751id select_type table type possible_keys key key_len ref rows Extra 7521 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 753SELECT * FROM t1 WHERE (11) IN 754(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 755i 756EXPLAIN SELECT * FROM t1 WHERE (11) IN 757(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 758id select_type table type possible_keys key key_len ref rows Extra 7591 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 760SELECT * FROM t1 WHERE (11) IN 761(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 762i 763EXPLAIN SELECT * FROM t1 WHERE (11) IN 764(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 765id select_type table type possible_keys key key_len ref rows Extra 7661 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 767SELECT * FROM t1 WHERE (11) IN 768(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 769i 770INSERT INTO t3 VALUES (0); 771DELETE FROM t3; 772INSERT INTO t2 VALUES (1); 773SELECT (SELECT COUNT(*) from t1) AS c1, 774(SELECT COUNT(*) from t2) AS c2, 775(SELECT COUNT(*) from t3) AS c3; 776c1 c2 c3 7770 2 0 778EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 779(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 780id select_type table type possible_keys key key_len ref rows Extra 7811 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 782SELECT * FROM t1 WHERE (t1.i) IN 783(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 784i 785PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 786(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 787EXECUTE stmt; 788i 789EXECUTE stmt; 790i 791DEALLOCATE PREPARE stmt; 792EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 793(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 794id select_type table type possible_keys key key_len ref rows Extra 7951 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 796SELECT * FROM t1 WHERE (t1.i) IN 797(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 798i 799PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 800(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 801EXECUTE stmt; 802i 803EXECUTE stmt; 804i 805DEALLOCATE PREPARE stmt; 806EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 807(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 808id select_type table type possible_keys key key_len ref rows Extra 8091 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 810SELECT * FROM t1 WHERE (t1.i) IN 811(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 812i 813EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 814(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 815id select_type table type possible_keys key key_len ref rows Extra 8161 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 817SELECT * FROM t1 WHERE (t1.i) IN 818(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 819i 820EXPLAIN SELECT * FROM t1 WHERE (11) IN 821(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 822id select_type table type possible_keys key key_len ref rows Extra 8231 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 824SELECT * FROM t1 WHERE (11) IN 825(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 826i 827EXPLAIN SELECT * FROM t1 WHERE (11) IN 828(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 829id select_type table type possible_keys key key_len ref rows Extra 8301 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 831SELECT * FROM t1 WHERE (11) IN 832(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 833i 834EXPLAIN SELECT * FROM t1 WHERE (11) IN 835(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 836id select_type table type possible_keys key key_len ref rows Extra 8371 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 838SELECT * FROM t1 WHERE (11) IN 839(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 840i 841EXPLAIN SELECT * FROM t1 WHERE (11) IN 842(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 843id select_type table type possible_keys key key_len ref rows Extra 8441 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 845SELECT * FROM t1 WHERE (11) IN 846(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 847i 848INSERT INTO t3 VALUES (2); 849SELECT (SELECT COUNT(*) from t1) AS c1, 850(SELECT COUNT(*) from t2) AS c2, 851(SELECT COUNT(*) from t3) AS c3; 852c1 c2 c3 8530 2 1 854EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 855(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 856id select_type table type possible_keys key key_len ref rows Extra 8571 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 858SELECT * FROM t1 WHERE (t1.i) IN 859(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 860i 861PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 862(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 863EXECUTE stmt; 864i 865EXECUTE stmt; 866i 867DEALLOCATE PREPARE stmt; 868EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 869(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 870id select_type table type possible_keys key key_len ref rows Extra 8711 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 872SELECT * FROM t1 WHERE (t1.i) IN 873(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 874i 875PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 876(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 877EXECUTE stmt; 878i 879EXECUTE stmt; 880i 881DEALLOCATE PREPARE stmt; 882EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 883(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 884id select_type table type possible_keys key key_len ref rows Extra 8851 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 886SELECT * FROM t1 WHERE (t1.i) IN 887(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 888i 889EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 890(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 891id select_type table type possible_keys key key_len ref rows Extra 8921 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 893SELECT * FROM t1 WHERE (t1.i) IN 894(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 895i 896EXPLAIN SELECT * FROM t1 WHERE (11) IN 897(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 898id select_type table type possible_keys key key_len ref rows Extra 8991 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 900SELECT * FROM t1 WHERE (11) IN 901(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 902i 903EXPLAIN SELECT * FROM t1 WHERE (11) IN 904(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 905id select_type table type possible_keys key key_len ref rows Extra 9061 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 907SELECT * FROM t1 WHERE (11) IN 908(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 909i 910EXPLAIN SELECT * FROM t1 WHERE (11) IN 911(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 912id select_type table type possible_keys key key_len ref rows Extra 9131 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 914SELECT * FROM t1 WHERE (11) IN 915(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 916i 917EXPLAIN SELECT * FROM t1 WHERE (11) IN 918(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 919id select_type table type possible_keys key key_len ref rows Extra 9201 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 921SELECT * FROM t1 WHERE (11) IN 922(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 923i 924INSERT INTO t3 VALUES (1); 925SELECT (SELECT COUNT(*) from t1) AS c1, 926(SELECT COUNT(*) from t2) AS c2, 927(SELECT COUNT(*) from t3) AS c3; 928c1 c2 c3 9290 2 2 930EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 931(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 932id select_type table type possible_keys key key_len ref rows Extra 9331 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 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 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 948SELECT * FROM t1 WHERE (t1.i) IN 949(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 950i 951PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 952(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 953EXECUTE stmt; 954i 955EXECUTE stmt; 956i 957DEALLOCATE PREPARE stmt; 958EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 959(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 960id select_type table type possible_keys key key_len ref rows Extra 9611 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 962SELECT * FROM t1 WHERE (t1.i) IN 963(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 964i 965EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 966(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 967id select_type table type possible_keys key key_len ref rows Extra 9681 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 969SELECT * FROM t1 WHERE (t1.i) IN 970(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 971i 972EXPLAIN SELECT * FROM t1 WHERE (11) IN 973(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 974id select_type table type possible_keys key key_len ref rows Extra 9751 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 976SELECT * FROM t1 WHERE (11) IN 977(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 978i 979EXPLAIN SELECT * FROM t1 WHERE (11) IN 980(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 981id select_type table type possible_keys key key_len ref rows Extra 9821 SIMPLE 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 WHERE t1.i); 985i 986EXPLAIN SELECT * FROM t1 WHERE (11) IN 987(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 988id select_type table type possible_keys key key_len ref rows Extra 9891 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 990SELECT * FROM t1 WHERE (11) IN 991(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 992i 993EXPLAIN SELECT * FROM t1 WHERE (11) IN 994(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 995id select_type table type possible_keys key key_len ref rows Extra 9961 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 997SELECT * FROM t1 WHERE (11) IN 998(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 999i 1000INSERT INTO t3 VALUES (0); 1001DELETE FROM t3; 1002INSERT INTO t2 VALUES (0); 1003DELETE FROM t2; 1004INSERT INTO t1 VALUES (2); 1005SELECT (SELECT COUNT(*) from t1) AS c1, 1006(SELECT COUNT(*) from t2) AS c2, 1007(SELECT COUNT(*) from t3) AS c3; 1008c1 c2 c3 10091 0 0 1010EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1011(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1012id select_type table type possible_keys key key_len ref rows Extra 10131 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 10141 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where 10151 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1) 1016SELECT * FROM t1 WHERE (t1.i) IN 1017(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1018i 1019PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1020(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1021EXECUTE stmt; 1022i 1023EXECUTE stmt; 1024i 1025DEALLOCATE PREPARE stmt; 1026EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1027(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1028id select_type table type possible_keys key key_len ref rows Extra 10291 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 10301 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where 10311 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1) 1032SELECT * FROM t1 WHERE (t1.i) IN 1033(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1034i 1035PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1036(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1037EXECUTE stmt; 1038i 1039EXECUTE stmt; 1040i 1041DEALLOCATE PREPARE stmt; 1042EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1043(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1044id select_type table type possible_keys key key_len ref rows Extra 10451 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 10461 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where 10471 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1) 1048SELECT * FROM t1 WHERE (t1.i) IN 1049(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1050i 1051EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1052(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1053id select_type table type possible_keys key key_len ref rows Extra 10541 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 10551 SIMPLE t2 ALL NULL NULL NULL NULL 0 NULL 10561 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1) 1057SELECT * FROM t1 WHERE (t1.i) IN 1058(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1059i 1060EXPLAIN SELECT * FROM t1 WHERE (11) IN 1061(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1062id select_type table type possible_keys key key_len ref rows Extra 10631 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 10641 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where 10651 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1) 1066SELECT * FROM t1 WHERE (11) IN 1067(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1068i 1069EXPLAIN SELECT * FROM t1 WHERE (11) IN 1070(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1071id select_type table type possible_keys key key_len ref rows Extra 10721 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 10731 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where 10741 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1) 1075SELECT * FROM t1 WHERE (11) IN 1076(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1077i 1078EXPLAIN SELECT * FROM t1 WHERE (11) IN 1079(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1080id select_type table type possible_keys key key_len ref rows Extra 10811 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 10821 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where 10831 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1) 1084SELECT * FROM t1 WHERE (11) IN 1085(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1086i 1087EXPLAIN SELECT * FROM t1 WHERE (11) IN 1088(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1089id select_type table type possible_keys key key_len ref rows Extra 10901 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 10911 SIMPLE t2 ALL NULL NULL NULL NULL 0 NULL 10921 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1) 1093SELECT * FROM t1 WHERE (11) IN 1094(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1095i 1096INSERT INTO t3 VALUES (2); 1097SELECT (SELECT COUNT(*) from t1) AS c1, 1098(SELECT COUNT(*) from t2) AS c2, 1099(SELECT COUNT(*) from t3) AS c3; 1100c1 c2 c3 11011 0 1 1102EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1103(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1104id select_type table type possible_keys key key_len ref rows Extra 11051 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 11061 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where 11071 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 1108SELECT * FROM t1 WHERE (t1.i) IN 1109(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1110i 1111PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1112(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1113EXECUTE stmt; 1114i 1115EXECUTE stmt; 1116i 1117DEALLOCATE PREPARE stmt; 1118EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1119(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1120id select_type table type possible_keys key key_len ref rows Extra 11211 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 11221 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where 11231 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 1124SELECT * FROM t1 WHERE (t1.i) IN 1125(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1126i 1127PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1128(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1129EXECUTE stmt; 1130i 1131EXECUTE stmt; 1132i 1133DEALLOCATE PREPARE stmt; 1134EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1135(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1136id select_type table type possible_keys key key_len ref rows Extra 11371 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 11381 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where 11391 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1) 1140SELECT * FROM t1 WHERE (t1.i) IN 1141(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1142i 11432 1144EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1145(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1146id select_type table type possible_keys key key_len ref rows Extra 11471 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 11481 SIMPLE t2 ALL NULL NULL NULL NULL 0 NULL 11491 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 1150SELECT * FROM t1 WHERE (t1.i) IN 1151(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1152i 1153EXPLAIN SELECT * FROM t1 WHERE (11) IN 1154(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1155id select_type table type possible_keys key key_len ref rows Extra 11561 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 11571 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where 11581 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 1159SELECT * FROM t1 WHERE (11) IN 1160(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1161i 1162EXPLAIN SELECT * FROM t1 WHERE (11) IN 1163(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1164id select_type table type possible_keys key key_len ref rows Extra 11651 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 11661 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where 11671 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 1168SELECT * FROM t1 WHERE (11) IN 1169(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1170i 1171EXPLAIN SELECT * FROM t1 WHERE (11) IN 1172(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1173id select_type table type possible_keys key key_len ref rows Extra 11741 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 11751 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where 11761 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1) 1177SELECT * FROM t1 WHERE (11) IN 1178(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1179i 1180EXPLAIN SELECT * FROM t1 WHERE (11) IN 1181(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1182id select_type table type possible_keys key key_len ref rows Extra 11831 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 11841 SIMPLE t2 ALL NULL NULL NULL NULL 0 NULL 11851 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 1186SELECT * FROM t1 WHERE (11) IN 1187(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1188i 1189INSERT INTO t3 VALUES (1); 1190SELECT (SELECT COUNT(*) from t1) AS c1, 1191(SELECT COUNT(*) from t2) AS c2, 1192(SELECT COUNT(*) from t3) AS c3; 1193c1 c2 c3 11941 0 2 1195EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1196(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1197id select_type table type possible_keys key key_len ref rows Extra 11981 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 11991 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where 12001 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 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 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 12151 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where 12161 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1217SELECT * FROM t1 WHERE (t1.i) IN 1218(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1219i 1220PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1221(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1222EXECUTE stmt; 1223i 1224EXECUTE stmt; 1225i 1226DEALLOCATE PREPARE stmt; 1227EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1228(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1229id select_type table type possible_keys key key_len ref rows Extra 12301 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 12311 SIMPLE <subquery2> const <auto_key> <auto_key> 5 const 1 NULL 12322 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using where 12332 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop) 1234SELECT * FROM t1 WHERE (t1.i) IN 1235(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1236i 12372 1238EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1239(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1240id select_type table type possible_keys key key_len ref rows Extra 12411 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 12421 SIMPLE t2 ALL NULL NULL NULL NULL 0 NULL 12431 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1244SELECT * FROM t1 WHERE (t1.i) IN 1245(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1246i 1247EXPLAIN SELECT * FROM t1 WHERE (11) IN 1248(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1249id select_type table type possible_keys key key_len ref rows Extra 12501 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 12511 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where 12521 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1253SELECT * FROM t1 WHERE (11) IN 1254(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1255i 1256EXPLAIN SELECT * FROM t1 WHERE (11) IN 1257(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1258id select_type table type possible_keys key key_len ref rows Extra 12591 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 12601 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where 12611 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1262SELECT * FROM t1 WHERE (11) IN 1263(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1264i 1265EXPLAIN SELECT * FROM t1 WHERE (11) IN 1266(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1267id select_type table type possible_keys key key_len ref rows Extra 12681 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 12691 SIMPLE <subquery2> const <auto_key> <auto_key> 5 const 1 NULL 12702 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using where 12712 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop) 1272SELECT * FROM t1 WHERE (11) IN 1273(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1274i 1275EXPLAIN SELECT * FROM t1 WHERE (11) IN 1276(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1277id select_type table type possible_keys key key_len ref rows Extra 12781 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 12791 SIMPLE t2 ALL NULL NULL NULL NULL 0 NULL 12801 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1281SELECT * FROM t1 WHERE (11) IN 1282(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1283i 1284INSERT INTO t3 VALUES (0); 1285DELETE FROM t3; 1286INSERT INTO t2 VALUES (2); 1287SELECT (SELECT COUNT(*) from t1) AS c1, 1288(SELECT COUNT(*) from t2) AS c2, 1289(SELECT COUNT(*) from t3) AS c3; 1290c1 c2 c3 12911 1 0 1292EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1293(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1294id select_type table type possible_keys key key_len ref rows Extra 12951 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 12961 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where 12971 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 1298SELECT * FROM t1 WHERE (t1.i) IN 1299(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1300i 1301PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1302(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1303EXECUTE stmt; 1304i 1305EXECUTE stmt; 1306i 1307DEALLOCATE PREPARE stmt; 1308EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1309(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1310id select_type table type possible_keys key key_len ref rows Extra 13111 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 13121 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where 13131 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 1314SELECT * FROM t1 WHERE (t1.i) IN 1315(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1316i 1317PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1318(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1319EXECUTE stmt; 1320i 1321EXECUTE stmt; 1322i 1323DEALLOCATE PREPARE stmt; 1324EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1325(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1326id select_type table type possible_keys key key_len ref rows Extra 13271 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 13281 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where 13291 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 1330SELECT * FROM t1 WHERE (t1.i) IN 1331(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1332i 1333EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1334(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1335id select_type table type possible_keys key key_len ref rows Extra 13361 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 13371 SIMPLE t2 ALL NULL NULL NULL NULL 1 NULL 13381 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1) 1339SELECT * FROM t1 WHERE (t1.i) IN 1340(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1341i 1342EXPLAIN SELECT * FROM t1 WHERE (11) IN 1343(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1344id select_type table type possible_keys key key_len ref rows Extra 13451 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 13461 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where 13471 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 1348SELECT * FROM t1 WHERE (11) IN 1349(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1350i 1351EXPLAIN SELECT * FROM t1 WHERE (11) IN 1352(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1353id select_type table type possible_keys key key_len ref rows Extra 13541 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 13551 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where 13561 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 1357SELECT * FROM t1 WHERE (11) IN 1358(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1359i 1360EXPLAIN SELECT * FROM t1 WHERE (11) IN 1361(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1362id select_type table type possible_keys key key_len ref rows Extra 13631 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 13641 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where 13651 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 1366SELECT * FROM t1 WHERE (11) IN 1367(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1368i 1369EXPLAIN SELECT * FROM t1 WHERE (11) IN 1370(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1371id select_type table type possible_keys key key_len ref rows Extra 13721 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 13731 SIMPLE t2 ALL NULL NULL NULL NULL 1 NULL 13741 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1) 1375SELECT * FROM t1 WHERE (11) IN 1376(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1377i 1378INSERT INTO t3 VALUES (2); 1379SELECT (SELECT COUNT(*) from t1) AS c1, 1380(SELECT COUNT(*) from t2) AS c2, 1381(SELECT COUNT(*) from t3) AS c3; 1382c1 c2 c3 13831 1 1 1384EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1385(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1386id select_type table type possible_keys key key_len ref rows Extra 13871 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 13881 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where 13891 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 1390SELECT * FROM t1 WHERE (t1.i) IN 1391(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1392i 13932 1394PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1395(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1396EXECUTE stmt; 1397i 13982 1399EXECUTE stmt; 1400i 14012 1402DEALLOCATE PREPARE stmt; 1403EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1404(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1405id select_type table type possible_keys key key_len ref rows Extra 14061 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 14071 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where 14081 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 1409SELECT * FROM t1 WHERE (t1.i) IN 1410(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1411i 14122 1413PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1414(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1415EXECUTE stmt; 1416i 14172 1418EXECUTE stmt; 1419i 14202 1421DEALLOCATE PREPARE stmt; 1422EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1423(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1424id select_type table type possible_keys key key_len ref rows Extra 14251 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 14261 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where 14271 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 1428SELECT * FROM t1 WHERE (t1.i) IN 1429(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1430i 14312 1432EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1433(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1434id select_type table type possible_keys key key_len ref rows Extra 14351 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 14361 SIMPLE t2 ALL NULL NULL NULL NULL 1 NULL 14371 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 1438SELECT * FROM t1 WHERE (t1.i) IN 1439(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1440i 14412 1442EXPLAIN SELECT * FROM t1 WHERE (11) IN 1443(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1444id select_type table type possible_keys key key_len ref rows Extra 14451 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 14461 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where 14471 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 1448SELECT * FROM t1 WHERE (11) IN 1449(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1450i 1451EXPLAIN SELECT * FROM t1 WHERE (11) IN 1452(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1453id select_type table type possible_keys key key_len ref rows Extra 14541 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 14551 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where 14561 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 1457SELECT * FROM t1 WHERE (11) IN 1458(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1459i 1460EXPLAIN SELECT * FROM t1 WHERE (11) IN 1461(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1462id select_type table type possible_keys key key_len ref rows Extra 14631 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 14641 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where 14651 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 1466SELECT * FROM t1 WHERE (11) IN 1467(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1468i 1469EXPLAIN SELECT * FROM t1 WHERE (11) IN 1470(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1471id select_type table type possible_keys key key_len ref rows Extra 14721 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 14731 SIMPLE t2 ALL NULL NULL NULL NULL 1 NULL 14741 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 1475SELECT * FROM t1 WHERE (11) IN 1476(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1477i 1478INSERT INTO t3 VALUES (1); 1479SELECT (SELECT COUNT(*) from t1) AS c1, 1480(SELECT COUNT(*) from t2) AS c2, 1481(SELECT COUNT(*) from t3) AS c3; 1482c1 c2 c3 14831 1 2 1484EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1485(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1486id select_type table type possible_keys key key_len ref rows Extra 14871 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 14881 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where 14891 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1490SELECT * FROM t1 WHERE (t1.i) IN 1491(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1492i 14932 1494PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1495(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1496EXECUTE stmt; 1497i 14982 1499EXECUTE stmt; 1500i 15012 1502DEALLOCATE PREPARE stmt; 1503EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1504(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1505id select_type table type possible_keys key key_len ref rows Extra 15061 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 15071 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where 15081 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1509SELECT * FROM t1 WHERE (t1.i) IN 1510(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1511i 15122 1513PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1514(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1515EXECUTE stmt; 1516i 15172 1518EXECUTE stmt; 1519i 15202 1521DEALLOCATE PREPARE stmt; 1522EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1523(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1524id select_type table type possible_keys key key_len ref rows Extra 15251 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 15261 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where 15271 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 1528SELECT * FROM t1 WHERE (t1.i) IN 1529(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1530i 15312 1532EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1533(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1534id select_type table type possible_keys key key_len ref rows Extra 15351 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 15361 SIMPLE t2 ALL NULL NULL NULL NULL 1 NULL 15371 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1538SELECT * FROM t1 WHERE (t1.i) IN 1539(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1540i 15412 1542EXPLAIN SELECT * FROM t1 WHERE (11) IN 1543(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1544id select_type table type possible_keys key key_len ref rows Extra 15451 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 15461 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where 15471 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1548SELECT * FROM t1 WHERE (11) IN 1549(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1550i 1551EXPLAIN SELECT * FROM t1 WHERE (11) IN 1552(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1553id select_type table type possible_keys key key_len ref rows Extra 15541 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 15551 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where 15561 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1557SELECT * FROM t1 WHERE (11) IN 1558(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1559i 1560EXPLAIN SELECT * FROM t1 WHERE (11) IN 1561(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1562id select_type table type possible_keys key key_len ref rows Extra 15631 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 15641 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where 15651 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 1566SELECT * FROM t1 WHERE (11) IN 1567(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1568i 1569EXPLAIN SELECT * FROM t1 WHERE (11) IN 1570(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1571id select_type table type possible_keys key key_len ref rows Extra 15721 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 15731 SIMPLE t2 ALL NULL NULL NULL NULL 1 NULL 15741 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1575SELECT * FROM t1 WHERE (11) IN 1576(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1577i 1578INSERT INTO t3 VALUES (0); 1579DELETE FROM t3; 1580INSERT INTO t2 VALUES (1); 1581SELECT (SELECT COUNT(*) from t1) AS c1, 1582(SELECT COUNT(*) from t2) AS c2, 1583(SELECT COUNT(*) from t3) AS c3; 1584c1 c2 c3 15851 2 0 1586EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1587(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1588id select_type table type possible_keys key key_len ref rows Extra 15891 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 15901 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where 15911 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1592SELECT * FROM t1 WHERE (t1.i) IN 1593(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1594i 1595PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1596(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1597EXECUTE stmt; 1598i 1599EXECUTE stmt; 1600i 1601DEALLOCATE PREPARE stmt; 1602EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1603(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1604id select_type table type possible_keys key key_len ref rows Extra 16051 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 16061 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where 16071 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1608SELECT * FROM t1 WHERE (t1.i) IN 1609(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1610i 1611PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1612(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1613EXECUTE stmt; 1614i 1615EXECUTE stmt; 1616i 1617DEALLOCATE PREPARE stmt; 1618EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1619(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1620id select_type table type possible_keys key key_len ref rows Extra 16211 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 16221 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where 16231 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1624SELECT * FROM t1 WHERE (t1.i) IN 1625(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1626i 1627EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1628(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1629id select_type table type possible_keys key key_len ref rows Extra 16301 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 16311 SIMPLE <subquery2> const <auto_key> <auto_key> 5 const 1 NULL 16322 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 NULL 16332 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop) 1634SELECT * FROM t1 WHERE (t1.i) IN 1635(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1636i 1637EXPLAIN SELECT * FROM t1 WHERE (11) IN 1638(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1639id select_type table type possible_keys key key_len ref rows Extra 16401 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 16411 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where 16421 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1643SELECT * FROM t1 WHERE (11) IN 1644(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1645i 1646EXPLAIN SELECT * FROM t1 WHERE (11) IN 1647(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1648id select_type table type possible_keys key key_len ref rows Extra 16491 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 16501 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where 16511 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1652SELECT * FROM t1 WHERE (11) IN 1653(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1654i 1655EXPLAIN SELECT * FROM t1 WHERE (11) IN 1656(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1657id select_type table type possible_keys key key_len ref rows Extra 16581 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 16591 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where 16601 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1661SELECT * FROM t1 WHERE (11) IN 1662(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1663i 1664EXPLAIN SELECT * FROM t1 WHERE (11) IN 1665(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1666id select_type table type possible_keys key key_len ref rows Extra 16671 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 16681 SIMPLE <subquery2> const <auto_key> <auto_key> 5 const 1 NULL 16692 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 NULL 16702 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop) 1671SELECT * FROM t1 WHERE (11) IN 1672(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1673i 1674INSERT INTO t3 VALUES (2); 1675SELECT (SELECT COUNT(*) from t1) AS c1, 1676(SELECT COUNT(*) from t2) AS c2, 1677(SELECT COUNT(*) from t3) AS c3; 1678c1 c2 c3 16791 2 1 1680EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1681(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1682id select_type table type possible_keys key key_len ref rows Extra 16831 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 16841 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where 16851 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1686SELECT * FROM t1 WHERE (t1.i) IN 1687(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1688i 16892 1690PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1691(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1692EXECUTE stmt; 1693i 16942 1695EXECUTE stmt; 1696i 16972 1698DEALLOCATE PREPARE stmt; 1699EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1700(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1701id select_type table type possible_keys key key_len ref rows Extra 17021 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 17031 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where 17041 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1705SELECT * FROM t1 WHERE (t1.i) IN 1706(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1707i 17082 1709PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1710(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1711EXECUTE stmt; 1712i 17132 1714EXECUTE stmt; 1715i 17162 1717DEALLOCATE PREPARE stmt; 1718EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1719(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1720id select_type table type possible_keys key key_len ref rows Extra 17211 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 17221 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where 17231 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1724SELECT * FROM t1 WHERE (t1.i) IN 1725(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1726i 17272 1728EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1729(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1730id select_type table type possible_keys key key_len ref rows Extra 17311 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 17321 SIMPLE t2 ALL NULL NULL NULL NULL 2 NULL 17331 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 1734SELECT * FROM t1 WHERE (t1.i) IN 1735(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1736i 17372 1738EXPLAIN SELECT * FROM t1 WHERE (11) IN 1739(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1740id select_type table type possible_keys key key_len ref rows Extra 17411 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 17421 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where 17431 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1744SELECT * FROM t1 WHERE (11) IN 1745(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1746i 1747EXPLAIN SELECT * FROM t1 WHERE (11) IN 1748(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1749id select_type table type possible_keys key key_len ref rows Extra 17501 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 17511 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where 17521 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1753SELECT * FROM t1 WHERE (11) IN 1754(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1755i 1756EXPLAIN SELECT * FROM t1 WHERE (11) IN 1757(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1758id select_type table type possible_keys key key_len ref rows Extra 17591 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 17601 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where 17611 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1762SELECT * FROM t1 WHERE (11) IN 1763(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1764i 1765EXPLAIN SELECT * FROM t1 WHERE (11) IN 1766(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1767id select_type table type possible_keys key key_len ref rows Extra 17681 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 17691 SIMPLE t2 ALL NULL NULL NULL NULL 2 NULL 17701 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 1771SELECT * FROM t1 WHERE (11) IN 1772(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1773i 1774INSERT INTO t3 VALUES (1); 1775SELECT (SELECT COUNT(*) from t1) AS c1, 1776(SELECT COUNT(*) from t2) AS c2, 1777(SELECT COUNT(*) from t3) AS c3; 1778c1 c2 c3 17791 2 2 1780EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1781(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1782id select_type table type possible_keys key key_len ref rows Extra 17831 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 17841 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where 17851 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1786SELECT * FROM t1 WHERE (t1.i) IN 1787(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1788i 17892 1790PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1791(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1792EXECUTE stmt; 1793i 17942 1795EXECUTE stmt; 1796i 17972 1798DEALLOCATE PREPARE stmt; 1799EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1800(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1801id select_type table type possible_keys key key_len ref rows Extra 18021 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 18031 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where 18041 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1805SELECT * FROM t1 WHERE (t1.i) IN 1806(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1807i 18082 1809PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1810(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1811EXECUTE stmt; 1812i 18132 1814EXECUTE stmt; 1815i 18162 1817DEALLOCATE PREPARE stmt; 1818EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1819(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1820id select_type table type possible_keys key key_len ref rows Extra 18211 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 18221 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where 18231 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1824SELECT * FROM t1 WHERE (t1.i) IN 1825(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1826i 18272 1828EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1829(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1830id select_type table type possible_keys key key_len ref rows Extra 18311 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 18321 SIMPLE t2 ALL NULL NULL NULL NULL 2 NULL 18331 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1834SELECT * FROM t1 WHERE (t1.i) IN 1835(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1836i 18372 1838EXPLAIN SELECT * FROM t1 WHERE (11) IN 1839(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1840id select_type table type possible_keys key key_len ref rows Extra 18411 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 18421 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where 18431 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1844SELECT * FROM t1 WHERE (11) IN 1845(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1846i 1847EXPLAIN SELECT * FROM t1 WHERE (11) IN 1848(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1849id select_type table type possible_keys key key_len ref rows Extra 18501 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 18511 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where 18521 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1853SELECT * FROM t1 WHERE (11) IN 1854(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1855i 1856EXPLAIN SELECT * FROM t1 WHERE (11) IN 1857(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1858id select_type table type possible_keys key key_len ref rows Extra 18591 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 18601 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where 18611 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1862SELECT * FROM t1 WHERE (11) IN 1863(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1864i 1865EXPLAIN SELECT * FROM t1 WHERE (11) IN 1866(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1867id select_type table type possible_keys key key_len ref rows Extra 18681 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 18691 SIMPLE t2 ALL NULL NULL NULL NULL 2 NULL 18701 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 1871SELECT * FROM t1 WHERE (11) IN 1872(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1873i 1874INSERT INTO t3 VALUES (0); 1875DELETE FROM t3; 1876INSERT INTO t2 VALUES (0); 1877DELETE FROM t2; 1878INSERT INTO t1 VALUES (1); 1879SELECT (SELECT COUNT(*) from t1) AS c1, 1880(SELECT COUNT(*) from t2) AS c2, 1881(SELECT COUNT(*) from t3) AS c3; 1882c1 c2 c3 18832 0 0 1884EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1885(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1886id select_type table type possible_keys key key_len ref rows Extra 18871 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 18881 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 18892 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 NULL 18902 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop) 1891SELECT * FROM t1 WHERE (t1.i) IN 1892(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1893i 1894PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1895(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1896EXECUTE stmt; 1897i 1898EXECUTE stmt; 1899i 1900DEALLOCATE PREPARE stmt; 1901EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1902(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1903id select_type table type possible_keys key key_len ref rows Extra 19041 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 19051 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 19062 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 NULL 19072 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop) 1908SELECT * FROM t1 WHERE (t1.i) IN 1909(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1910i 1911PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1912(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1913EXECUTE stmt; 1914i 1915EXECUTE stmt; 1916i 1917DEALLOCATE PREPARE stmt; 1918EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1919(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1920id select_type table type possible_keys key key_len ref rows Extra 19211 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 19221 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 19232 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 NULL 19242 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop) 1925SELECT * FROM t1 WHERE (t1.i) IN 1926(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1927i 1928EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1929(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1930id select_type table type possible_keys key key_len ref rows Extra 19311 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 19321 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 19332 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 NULL 19342 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 Using join buffer (Block Nested Loop) 1935SELECT * FROM t1 WHERE (t1.i) IN 1936(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1937i 1938EXPLAIN SELECT * FROM t1 WHERE (11) IN 1939(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1940id select_type table type possible_keys key key_len ref rows Extra 19411 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where; FirstMatch 19421 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL 19431 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1) 1944SELECT * FROM t1 WHERE (11) IN 1945(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1946i 1947EXPLAIN SELECT * FROM t1 WHERE (11) IN 1948(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1949id select_type table type possible_keys key key_len ref rows Extra 19501 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where; Start temporary 19511 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop) 19521 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop) 1953SELECT * FROM t1 WHERE (11) IN 1954(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1955i 1956EXPLAIN SELECT * FROM t1 WHERE (11) IN 1957(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1958id select_type table type possible_keys key key_len ref rows Extra 19591 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch 19601 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL 19611 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1) 1962SELECT * FROM t1 WHERE (11) IN 1963(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1964i 1965EXPLAIN SELECT * FROM t1 WHERE (11) IN 1966(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1967id select_type table type possible_keys key key_len ref rows Extra 19681 SIMPLE t2 ALL NULL NULL NULL NULL 0 FirstMatch 19691 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL 19701 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch(t1) 1971SELECT * FROM t1 WHERE (11) IN 1972(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1973i 1974INSERT INTO t3 VALUES (2); 1975SELECT (SELECT COUNT(*) from t1) AS c1, 1976(SELECT COUNT(*) from t2) AS c2, 1977(SELECT COUNT(*) from t3) AS c3; 1978c1 c2 c3 19792 0 1 1980EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1981(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1982id select_type table type possible_keys key key_len ref rows Extra 19831 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 19841 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 19852 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 NULL 19862 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 1987SELECT * FROM t1 WHERE (t1.i) IN 1988(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1989i 1990PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1991(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1992EXECUTE stmt; 1993i 1994EXECUTE stmt; 1995i 1996DEALLOCATE PREPARE stmt; 1997EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1998(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1999id select_type table type possible_keys key key_len ref rows Extra 20001 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 20011 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 20022 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 NULL 20032 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 2004SELECT * FROM t1 WHERE (t1.i) IN 2005(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2006i 2007PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2008(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 2009EXECUTE stmt; 2010i 2011EXECUTE stmt; 2012i 2013DEALLOCATE PREPARE stmt; 2014EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2015(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2016id select_type table type possible_keys key key_len ref rows Extra 20171 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 20181 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 20192 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 NULL 20202 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop) 2021SELECT * FROM t1 WHERE (t1.i) IN 2022(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2023i 20242 2025EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2026(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2027id select_type table type possible_keys key key_len ref rows Extra 20281 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 20291 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 20302 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 NULL 20312 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 Using join buffer (Block Nested Loop) 2032SELECT * FROM t1 WHERE (t1.i) IN 2033(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2034i 2035EXPLAIN SELECT * FROM t1 WHERE (11) IN 2036(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2037id select_type table type possible_keys key key_len ref rows Extra 20381 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where; FirstMatch 20391 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL 20401 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 2041SELECT * FROM t1 WHERE (11) IN 2042(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2043i 2044EXPLAIN SELECT * FROM t1 WHERE (11) IN 2045(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2046id select_type table type possible_keys key key_len ref rows Extra 20471 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where; Start temporary 20481 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 20491 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop) 2050SELECT * FROM t1 WHERE (11) IN 2051(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2052i 2053EXPLAIN SELECT * FROM t1 WHERE (11) 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 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where 20571 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where; FirstMatch 20581 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop) 2059SELECT * FROM t1 WHERE (11) IN 2060(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2061i 2062EXPLAIN SELECT * FROM t1 WHERE (11) IN 2063(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2064id select_type table type possible_keys key key_len ref rows Extra 20651 SIMPLE t2 ALL NULL NULL NULL NULL 0 FirstMatch 20661 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL 20671 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 2068SELECT * FROM t1 WHERE (11) IN 2069(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2070i 2071INSERT INTO t3 VALUES (1); 2072SELECT (SELECT COUNT(*) from t1) AS c1, 2073(SELECT COUNT(*) from t2) AS c2, 2074(SELECT COUNT(*) from t3) AS c3; 2075c1 c2 c3 20762 0 2 2077EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2078(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2079id select_type table type possible_keys key key_len ref rows Extra 20801 SIMPLE t2 ALL NULL NULL NULL NULL 0 Start temporary 20811 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 20821 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop) 2083SELECT * FROM t1 WHERE (t1.i) IN 2084(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2085i 2086PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2087(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 2088EXECUTE stmt; 2089i 2090EXECUTE stmt; 2091i 2092DEALLOCATE PREPARE stmt; 2093EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2094(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2095id select_type table type possible_keys key key_len ref rows Extra 20961 SIMPLE t2 ALL NULL NULL NULL NULL 0 Start temporary 20971 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 20981 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop) 2099SELECT * FROM t1 WHERE (t1.i) IN 2100(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2101i 2102PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2103(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 2104EXECUTE stmt; 2105i 2106EXECUTE stmt; 2107i 2108DEALLOCATE PREPARE stmt; 2109EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2110(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2111id select_type table type possible_keys key key_len ref rows Extra 21121 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 21131 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 21142 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 NULL 21152 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop) 2116SELECT * FROM t1 WHERE (t1.i) IN 2117(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2118i 21192 21201 2121EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2122(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2123id select_type table type possible_keys key key_len ref rows Extra 21241 SIMPLE t2 ALL NULL NULL NULL NULL 0 Start temporary 21251 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop) 21261 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop) 2127SELECT * FROM t1 WHERE (t1.i) IN 2128(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2129i 2130EXPLAIN SELECT * FROM t1 WHERE (11) IN 2131(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2132id select_type table type possible_keys key key_len ref rows Extra 21331 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where; FirstMatch 21341 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL 21351 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 2136SELECT * FROM t1 WHERE (11) IN 2137(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2138i 2139EXPLAIN SELECT * FROM t1 WHERE (11) IN 2140(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2141id select_type table type possible_keys key key_len ref rows Extra 21421 SIMPLE t2 ALL NULL NULL NULL NULL 0 Using where; Start temporary 21431 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 21441 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop) 2145SELECT * FROM t1 WHERE (11) IN 2146(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2147i 2148EXPLAIN SELECT * FROM t1 WHERE (11) IN 2149(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2150id select_type table type possible_keys key key_len ref rows Extra 21511 SIMPLE <subquery2> const <auto_key> <auto_key> 5 const 1 NULL 21521 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop) 21532 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using where 21542 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop) 2155SELECT * FROM t1 WHERE (11) IN 2156(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2157i 2158EXPLAIN SELECT * FROM t1 WHERE (11) IN 2159(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2160id select_type table type possible_keys key key_len ref rows Extra 21611 SIMPLE t2 ALL NULL NULL NULL NULL 0 FirstMatch 21621 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL 21631 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 2164SELECT * FROM t1 WHERE (11) IN 2165(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2166i 2167INSERT INTO t3 VALUES (0); 2168DELETE FROM t3; 2169INSERT INTO t2 VALUES (2); 2170SELECT (SELECT COUNT(*) from t1) AS c1, 2171(SELECT COUNT(*) from t2) AS c2, 2172(SELECT COUNT(*) from t3) AS c3; 2173c1 c2 c3 21742 1 0 2175EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2176(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2177id select_type table type possible_keys key key_len ref rows Extra 21781 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 21791 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 21802 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 NULL 21812 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 2182SELECT * FROM t1 WHERE (t1.i) IN 2183(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2184i 2185PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2186(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 2187EXECUTE stmt; 2188i 2189EXECUTE stmt; 2190i 2191DEALLOCATE PREPARE stmt; 2192EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2193(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2194id select_type table type possible_keys key key_len ref rows Extra 21951 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 21961 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 21972 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 NULL 21982 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 2199SELECT * FROM t1 WHERE (t1.i) IN 2200(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2201i 2202PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2203(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 2204EXECUTE stmt; 2205i 2206EXECUTE stmt; 2207i 2208DEALLOCATE PREPARE stmt; 2209EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2210(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2211id select_type table type possible_keys key key_len ref rows Extra 22121 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 22131 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 22142 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 NULL 22152 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 2216SELECT * FROM t1 WHERE (t1.i) IN 2217(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2218i 2219EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2220(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2221id select_type table type possible_keys key key_len ref rows Extra 22221 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 22231 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 22242 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 NULL 22252 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 Using join buffer (Block Nested Loop) 2226SELECT * FROM t1 WHERE (t1.i) IN 2227(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2228i 2229EXPLAIN SELECT * FROM t1 WHERE (11) IN 2230(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2231id select_type table type possible_keys key key_len ref rows Extra 22321 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch 22331 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL 22341 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 2235SELECT * FROM t1 WHERE (11) IN 2236(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2237i 2238EXPLAIN SELECT * FROM t1 WHERE (11) IN 2239(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2240id select_type table type possible_keys key key_len ref rows Extra 22411 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; Start temporary 22421 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 22431 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop) 2244SELECT * FROM t1 WHERE (11) IN 2245(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2246i 2247EXPLAIN SELECT * FROM t1 WHERE (11) IN 2248(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2249id select_type table type possible_keys key key_len ref rows Extra 22501 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch 22511 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL 22521 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t1) 2253SELECT * FROM t1 WHERE (11) IN 2254(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2255i 2256EXPLAIN SELECT * FROM t1 WHERE (11) IN 2257(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2258id select_type table type possible_keys key key_len ref rows Extra 22591 SIMPLE t2 ALL NULL NULL NULL NULL 1 NULL 22601 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch 22611 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop) 2262SELECT * FROM t1 WHERE (11) IN 2263(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2264i 2265INSERT INTO t3 VALUES (2); 2266SELECT (SELECT COUNT(*) from t1) AS c1, 2267(SELECT COUNT(*) from t2) AS c2, 2268(SELECT COUNT(*) from t3) AS c3; 2269c1 c2 c3 22702 1 1 2271EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2272(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2273id select_type table type possible_keys key key_len ref rows Extra 22741 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 22751 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 22762 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 NULL 22772 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 2278SELECT * FROM t1 WHERE (t1.i) IN 2279(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2280i 22812 2282PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2283(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 2284EXECUTE stmt; 2285i 22862 2287EXECUTE stmt; 2288i 22892 2290DEALLOCATE PREPARE stmt; 2291EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2292(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2293id select_type table type possible_keys key key_len ref rows Extra 22941 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 22951 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 22962 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 NULL 22972 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 2298SELECT * FROM t1 WHERE (t1.i) IN 2299(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2300i 23012 2302PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2303(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 2304EXECUTE stmt; 2305i 23062 2307EXECUTE stmt; 2308i 23092 2310DEALLOCATE PREPARE stmt; 2311EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2312(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2313id select_type table type possible_keys key key_len ref rows Extra 23141 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 23151 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 23162 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 NULL 23172 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 2318SELECT * FROM t1 WHERE (t1.i) IN 2319(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2320i 23212 2322EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2323(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2324id select_type table type possible_keys key key_len ref rows Extra 23251 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 23261 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 23272 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 NULL 23282 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 Using join buffer (Block Nested Loop) 2329SELECT * FROM t1 WHERE (t1.i) IN 2330(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2331i 23322 2333EXPLAIN SELECT * FROM t1 WHERE (11) IN 2334(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2335id select_type table type possible_keys key key_len ref rows Extra 23361 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where 23371 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch 23381 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop) 2339SELECT * FROM t1 WHERE (11) IN 2340(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2341i 2342EXPLAIN SELECT * FROM t1 WHERE (11) IN 2343(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2344id select_type table type possible_keys key key_len ref rows Extra 23451 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; Start temporary 23461 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 23471 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop) 2348SELECT * FROM t1 WHERE (11) IN 2349(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2350i 2351EXPLAIN SELECT * FROM t1 WHERE (11) IN 2352(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2353id select_type table type possible_keys key key_len ref rows Extra 23541 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where 23551 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch 23561 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop) 2357SELECT * FROM t1 WHERE (11) IN 2358(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2359i 2360EXPLAIN SELECT * FROM t1 WHERE (11) IN 2361(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2362id select_type table type possible_keys key key_len ref rows Extra 23631 SIMPLE t2 ALL NULL NULL NULL NULL 1 NULL 23641 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch 23651 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop) 2366SELECT * FROM t1 WHERE (11) IN 2367(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2368i 2369INSERT INTO t3 VALUES (1); 2370SELECT (SELECT COUNT(*) from t1) AS c1, 2371(SELECT COUNT(*) from t2) AS c2, 2372(SELECT COUNT(*) from t3) AS c3; 2373c1 c2 c3 23742 1 2 2375EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2376(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2377id select_type table type possible_keys key key_len ref rows Extra 23781 SIMPLE t2 ALL NULL NULL NULL NULL 1 Start temporary 23791 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 23801 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop) 2381SELECT * FROM t1 WHERE (t1.i) IN 2382(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2383i 23842 2385PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2386(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 2387EXECUTE stmt; 2388i 23892 2390EXECUTE stmt; 2391i 23922 2393DEALLOCATE PREPARE stmt; 2394EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2395(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2396id select_type table type possible_keys key key_len ref rows Extra 23971 SIMPLE t2 ALL NULL NULL NULL NULL 1 Start temporary 23981 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 23991 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop) 2400SELECT * FROM t1 WHERE (t1.i) IN 2401(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2402i 24032 2404PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2405(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 2406EXECUTE stmt; 2407i 24082 2409EXECUTE stmt; 2410i 24112 2412DEALLOCATE PREPARE stmt; 2413EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2414(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2415id select_type table type possible_keys key key_len ref rows Extra 24161 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 24171 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 24182 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 NULL 24192 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 2420SELECT * FROM t1 WHERE (t1.i) IN 2421(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2422i 24232 24241 2425EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2426(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2427id select_type table type possible_keys key key_len ref rows Extra 24281 SIMPLE t2 ALL NULL NULL NULL NULL 1 Start temporary 24291 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop) 24301 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop) 2431SELECT * FROM t1 WHERE (t1.i) IN 2432(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2433i 24342 24351 2436EXPLAIN SELECT * FROM t1 WHERE (11) IN 2437(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2438id select_type table type possible_keys key key_len ref rows Extra 24391 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where 24401 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch 24411 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop) 2442SELECT * FROM t1 WHERE (11) IN 2443(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2444i 2445EXPLAIN SELECT * FROM t1 WHERE (11) IN 2446(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2447id select_type table type possible_keys key key_len ref rows Extra 24481 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; Start temporary 24491 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 24501 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop) 2451SELECT * FROM t1 WHERE (11) IN 2452(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2453i 2454EXPLAIN SELECT * FROM t1 WHERE (11) IN 2455(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2456id select_type table type possible_keys key key_len ref rows Extra 24571 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where 24581 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch 24591 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop) 2460SELECT * FROM t1 WHERE (11) IN 2461(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2462i 2463EXPLAIN SELECT * FROM t1 WHERE (11) IN 2464(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2465id select_type table type possible_keys key key_len ref rows Extra 24661 SIMPLE t2 ALL NULL NULL NULL NULL 1 NULL 24671 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch 24681 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop) 2469SELECT * FROM t1 WHERE (11) IN 2470(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2471i 2472INSERT INTO t3 VALUES (0); 2473DELETE FROM t3; 2474INSERT INTO t2 VALUES (1); 2475SELECT (SELECT COUNT(*) from t1) AS c1, 2476(SELECT COUNT(*) from t2) AS c2, 2477(SELECT COUNT(*) from t3) AS c3; 2478c1 c2 c3 24792 2 0 2480EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2481(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2482id select_type table type possible_keys key key_len ref rows Extra 24831 SIMPLE t3 ALL NULL NULL NULL NULL 0 Start temporary 24841 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 24851 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop) 2486SELECT * FROM t1 WHERE (t1.i) IN 2487(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2488i 2489PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2490(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 2491EXECUTE stmt; 2492i 2493EXECUTE stmt; 2494i 2495DEALLOCATE PREPARE stmt; 2496EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2497(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2498id select_type table type possible_keys key key_len ref rows Extra 24991 SIMPLE t3 ALL NULL NULL NULL NULL 0 Start temporary 25001 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 25011 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop) 2502SELECT * FROM t1 WHERE (t1.i) IN 2503(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2504i 2505PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2506(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 2507EXECUTE stmt; 2508i 2509EXECUTE stmt; 2510i 2511DEALLOCATE PREPARE stmt; 2512EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2513(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2514id select_type table type possible_keys key key_len ref rows Extra 25151 SIMPLE t3 ALL NULL NULL NULL NULL 0 Start temporary 25161 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 25171 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop) 2518SELECT * FROM t1 WHERE (t1.i) IN 2519(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2520i 2521EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2522(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2523id select_type table type possible_keys key key_len ref rows Extra 25241 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 25251 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 25262 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 NULL 25272 MATERIALIZED 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 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch 25351 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL 25361 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 2537SELECT * FROM t1 WHERE (11) IN 2538(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2539i 2540EXPLAIN SELECT * FROM t1 WHERE (11) IN 2541(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2542id select_type table type possible_keys key key_len ref rows Extra 25431 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; Start temporary 25441 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 25451 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop) 2546SELECT * FROM t1 WHERE (11) IN 2547(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2548i 2549EXPLAIN SELECT * FROM t1 WHERE (11) IN 2550(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2551id select_type table type possible_keys key key_len ref rows Extra 25521 SIMPLE t3 ALL NULL NULL NULL NULL 0 Using where; FirstMatch 25531 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL 25541 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1) 2555SELECT * FROM t1 WHERE (11) IN 2556(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2557i 2558EXPLAIN SELECT * FROM t1 WHERE (11) IN 2559(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2560id select_type table type possible_keys key key_len ref rows Extra 25611 SIMPLE <subquery2> const <auto_key> <auto_key> 5 const 1 NULL 25621 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop) 25632 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 NULL 25642 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 Using where; Using join buffer (Block Nested Loop) 2565SELECT * FROM t1 WHERE (11) IN 2566(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2567i 2568INSERT INTO t3 VALUES (2); 2569SELECT (SELECT COUNT(*) from t1) AS c1, 2570(SELECT COUNT(*) from t2) AS c2, 2571(SELECT COUNT(*) from t3) AS c3; 2572c1 c2 c3 25732 2 1 2574EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2575(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2576id select_type table type possible_keys key key_len ref rows Extra 25771 SIMPLE t3 ALL NULL NULL NULL NULL 1 Start temporary 25781 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 25791 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop) 2580SELECT * FROM t1 WHERE (t1.i) IN 2581(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2582i 25832 2584PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2585(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 2586EXECUTE stmt; 2587i 25882 2589EXECUTE stmt; 2590i 25912 2592DEALLOCATE PREPARE stmt; 2593EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2594(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2595id select_type table type possible_keys key key_len ref rows Extra 25961 SIMPLE t3 ALL NULL NULL NULL NULL 1 Start temporary 25971 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 25981 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop) 2599SELECT * FROM t1 WHERE (t1.i) IN 2600(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2601i 26022 2603PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2604(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 2605EXECUTE stmt; 2606i 26072 2608EXECUTE stmt; 2609i 26102 2611DEALLOCATE PREPARE stmt; 2612EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2613(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2614id select_type table type possible_keys key key_len ref rows Extra 26151 SIMPLE t3 ALL NULL NULL NULL NULL 1 Start temporary 26161 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 26171 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop) 2618SELECT * FROM t1 WHERE (t1.i) IN 2619(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2620i 26212 2622EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2623(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2624id select_type table type possible_keys key key_len ref rows Extra 26251 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 26261 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 26272 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 NULL 26282 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 Using join buffer (Block Nested Loop) 2629SELECT * FROM t1 WHERE (t1.i) IN 2630(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2631i 26322 2633EXPLAIN SELECT * FROM t1 WHERE (11) IN 2634(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2635id select_type table type possible_keys key key_len ref rows Extra 26361 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where 26371 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch 26381 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop) 2639SELECT * FROM t1 WHERE (11) IN 2640(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2641i 2642EXPLAIN SELECT * FROM t1 WHERE (11) IN 2643(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2644id select_type table type possible_keys key key_len ref rows Extra 26451 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; Start temporary 26461 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 26471 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop) 2648SELECT * FROM t1 WHERE (11) IN 2649(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2650i 2651EXPLAIN SELECT * FROM t1 WHERE (11) IN 2652(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2653id select_type table type possible_keys key key_len ref rows Extra 26541 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where 26551 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch 26561 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop) 2657SELECT * FROM t1 WHERE (11) IN 2658(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2659i 2660EXPLAIN SELECT * FROM t1 WHERE (11) IN 2661(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2662id select_type table type possible_keys key key_len ref rows Extra 26631 SIMPLE t2 ALL NULL NULL NULL NULL 2 NULL 26641 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where; FirstMatch 26651 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop) 2666SELECT * FROM t1 WHERE (11) IN 2667(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2668i 2669INSERT INTO t3 VALUES (1); 2670SELECT (SELECT COUNT(*) from t1) AS c1, 2671(SELECT COUNT(*) from t2) AS c2, 2672(SELECT COUNT(*) from t3) AS c3; 2673c1 c2 c3 26742 2 2 2675EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2676(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2677id select_type table type possible_keys key key_len ref rows Extra 26781 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where 26791 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.t1.i 1 NULL 26802 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 NULL 26812 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 2682SELECT * FROM t1 WHERE (t1.i) IN 2683(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2684i 26852 26861 2687PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2688(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 2689EXECUTE stmt; 2690i 26912 26921 2693EXECUTE stmt; 2694i 26952 26961 2697DEALLOCATE PREPARE stmt; 2698EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2699(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2700id select_type table type possible_keys key key_len ref rows Extra 27011 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where 27021 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.t1.i 1 NULL 27032 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 NULL 27042 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 2705SELECT * FROM t1 WHERE (t1.i) IN 2706(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2707i 27082 27091 2710PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2711(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 2712EXECUTE stmt; 2713i 27142 27151 2716EXECUTE stmt; 2717i 27182 27191 2720DEALLOCATE PREPARE stmt; 2721EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2722(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2723id select_type table type possible_keys key key_len ref rows Extra 27241 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where 27251 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.t1.i 1 NULL 27262 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 NULL 27272 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 2728SELECT * FROM t1 WHERE (t1.i) IN 2729(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2730i 27312 27321 2733EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2734(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2735id select_type table type possible_keys key key_len ref rows Extra 27361 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where 27371 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.t1.i 1 NULL 27382 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 NULL 27392 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop) 2740SELECT * FROM t1 WHERE (t1.i) IN 2741(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2742i 27432 27441 2745EXPLAIN SELECT * FROM t1 WHERE (11) IN 2746(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2747id select_type table type possible_keys key key_len ref rows Extra 27481 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL 27491 SIMPLE <subquery2> const <auto_key> <auto_key> 5 const 1 NULL 27502 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Using where 27512 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 2752SELECT * FROM t1 WHERE (11) IN 2753(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2754i 2755EXPLAIN SELECT * FROM t1 WHERE (11) IN 2756(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2757id select_type table type possible_keys key key_len ref rows Extra 27581 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Start temporary 27591 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 27601 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop) 2761SELECT * FROM t1 WHERE (11) IN 2762(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2763i 2764EXPLAIN SELECT * FROM t1 WHERE (11) IN 2765(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2766id select_type table type possible_keys key key_len ref rows Extra 27671 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL 27681 SIMPLE <subquery2> const <auto_key> <auto_key> 5 const 1 NULL 27692 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using where 27702 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 2771SELECT * FROM t1 WHERE (11) IN 2772(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2773i 2774EXPLAIN SELECT * FROM t1 WHERE (11) IN 2775(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2776id select_type table type possible_keys key key_len ref rows Extra 27771 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL 27781 SIMPLE <subquery2> const <auto_key> <auto_key> 5 const 1 NULL 27792 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 NULL 27802 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 2781SELECT * FROM t1 WHERE (11) IN 2782(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2783i 2784INSERT INTO t3 VALUES (0); 2785DELETE FROM t3; 2786INSERT INTO t2 VALUES (0); 2787DELETE FROM t2; 2788INSERT INTO t1 VALUES (0); 2789DROP TABLE t1, t2, t3; 2790create table x1(k int primary key, d1 int, d2 int); 2791create table x2(k int primary key, d1 int, d2 int); 2792insert into x1 values 2793(10, 10, 10), 2794(20, 20, 20), 2795(21, 20, null), 2796(30, null, 30), 2797(40, 40, 40); 2798insert into x2 values 2799(10, 10, 10), 2800(20, 20, 20), 2801(21, 20, null), 2802(30, null, 30); 2803select * 2804from x1 2805where (d1, d2) in (select d1, d2 2806from x2); 2807k d1 d2 280810 10 10 280920 20 20 2810select * 2811from x1 2812where (d1, d2) in (select d1, d2 2813from x2) is true; 2814k d1 d2 281510 10 10 281620 20 20 2817select * 2818from x1 2819where (d1, d2) in (select d1, d2 2820from x2) is false; 2821k d1 d2 282240 40 40 2823select * 2824from x1 2825where (d1, d2) in (select d1, d2 2826from x2) is unknown; 2827k d1 d2 282821 20 NULL 282930 NULL 30 2830select * 2831from x1 2832where d1 in (select d1 2833from x2 2834where x1.d2=x2.d2); 2835k d1 d2 283610 10 10 283720 20 20 2838select * 2839from x1 2840where d1 in (select d1 2841from x2 2842where x1.d2=x2.d2) is true; 2843k d1 d2 284410 10 10 284520 20 20 2846select * 2847from x1 2848where d1 in (select d1 2849from x2 2850where x1.d2=x2.d2) is false; 2851k d1 d2 285221 20 NULL 285340 40 40 2854select * 2855from x1 2856where d1 in (select d1 2857from x2 2858where x1.d2=x2.d2) is unknown; 2859k d1 d2 286030 NULL 30 2861select * 2862from x1 2863where 1 in (select 1 2864from x2 2865where x1.d1=x2.d1 and x1.d2=x2.d2); 2866k d1 d2 286710 10 10 286820 20 20 2869select * 2870from x1 2871where 1 in (select 1 2872from x2 2873where x1.d1=x2.d1 and x1.d2=x2.d2) is true; 2874k d1 d2 287510 10 10 287620 20 20 2877select * 2878from x1 2879where 1 in (select 1 2880from x2 2881where x1.d1=x2.d1 and x1.d2=x2.d2) is false; 2882k d1 d2 288321 20 NULL 288430 NULL 30 288540 40 40 2886select * 2887from x1 2888where 1 in (select 1 2889from x2 2890where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; 2891k d1 d2 2892select * 2893from x1 2894where exists (select * 2895from x2 2896where x1.d1=x2.d1 and x1.d2=x2.d2); 2897k d1 d2 289810 10 10 289920 20 20 2900drop table x1; 2901drop table x2; 2902CREATE TABLE t1 ( 2903a int(11) NOT NULL, 2904b int(11) NOT NULL, 2905c datetime default NULL, 2906PRIMARY KEY (a), 2907KEY idx_bc (b,c) 2908); 2909INSERT INTO t1 VALUES 2910(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), 2911(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), 2912(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), 2913(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), 2914(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), 2915(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), 2916(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), 2917(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), 2918(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), 2919(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), 2920(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), 2921(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), 2922(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), 2923(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), 2924(154503,67,'2005-10-28 11:52:38'); 2925create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; 2926create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; 2927create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; 2928create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; 2929update t22 set c = '2005-12-08 15:58:27' where a = 255; 2930explain select t21.* from t21,t22 where t21.a = t22.a and 2931t22.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; 2932id select_type table type possible_keys key key_len ref rows Extra 29331 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL Using temporary; Using filesort 29341 SIMPLE t22 ALL NULL NULL NULL NULL 26 Using where; Using join buffer (Block Nested Loop) 29351 SIMPLE t21 ALL NULL NULL NULL NULL 26 Using where; Using join buffer (Block Nested Loop) 29362 MATERIALIZED t11 ALL NULL NULL NULL NULL 8 Using where 29372 MATERIALIZED t12 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop) 2938explain format=json select * from t1 where a in (select a from t11); 2939EXPLAIN 2940{ 2941 "query_block": { 2942 "select_id": 1, 2943 "nested_loop": [ 2944 { 2945 "table": { 2946 "table_name": "<subquery2>", 2947 "access_type": "ALL", 2948 "materialized_from_subquery": { 2949 "using_temporary_table": true, 2950 "query_block": { 2951 "table": { 2952 "table_name": "t11", 2953 "access_type": "ALL", 2954 "rows": 8, 2955 "filtered": 100 2956 } 2957 } 2958 } 2959 } 2960 }, 2961 { 2962 "table": { 2963 "table_name": "t1", 2964 "access_type": "eq_ref", 2965 "possible_keys": [ 2966 "PRIMARY" 2967 ], 2968 "key": "PRIMARY", 2969 "used_key_parts": [ 2970 "a" 2971 ], 2972 "key_length": "4", 2973 "ref": [ 2974 "<subquery2>.a" 2975 ], 2976 "rows": 1, 2977 "filtered": 100, 2978 "using_join_buffer": "Batched Key Access" 2979 } 2980 } 2981 ] 2982 } 2983} 2984Warnings: 2985Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `<subquery2>`.`a`) 2986select t21.* from t21,t22 where t21.a = t22.a and 2987t22.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; 2988a b c 2989256 67 NULL 2990drop table t1, t11, t12, t21, t22; 2991create table t1(a int); 2992insert into t1 values (0),(1); 2993explain 2994select (select max(Y.a) from t1 Y where a in (select a from t1 Z) and a < X.a) as subq from t1 X; 2995id select_type table type possible_keys key key_len ref rows Extra 29961 PRIMARY X ALL NULL NULL NULL NULL 2 NULL 29972 DEPENDENT SUBQUERY Y ALL NULL NULL NULL NULL 2 Using where 29982 DEPENDENT SUBQUERY Z ALL NULL NULL NULL NULL 2 Using where; FirstMatch(Y); Using join buffer (Block Nested Loop) 2999select (select max(Y.a) from t1 Y where a in (select a from t1 Z) and a < X.a) as subq from t1 X; 3000subq 3001NULL 30020 3003drop table t1; 3004create table t0 (a int); 3005insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 3006create table t1 as select * from t0; 3007insert into t1 select a+10 from t0; 3008insert into t0 values(2); 3009explain select * from t1 where 2 in (select a from t0); 3010id select_type table type possible_keys key key_len ref rows Extra 30111 SIMPLE t0 ALL NULL NULL NULL NULL 11 Using where; FirstMatch 30121 SIMPLE t1 ALL NULL NULL NULL NULL 20 Using join buffer (Block Nested Loop) 3013select * from t1 where 2 in (select a from t0); 3014a 30150 30161 30172 30183 30194 30205 30216 30227 30238 30249 302510 302611 302712 302813 302914 303015 303116 303217 303318 303419 3035explain select * from (select a from t0) x where a in (select a from t1); 3036id select_type table type possible_keys key key_len ref rows Extra 30371 PRIMARY <derived2> ALL NULL NULL NULL NULL 11 Using where 30381 PRIMARY <subquery3> eq_ref <auto_key> <auto_key> 5 x.a 1 NULL 30393 MATERIALIZED t1 ALL NULL NULL NULL NULL 20 NULL 30402 DERIVED t0 ALL NULL NULL NULL NULL 11 NULL 3041explain format=json select * from (select a from t0) x where a in (select a from t1); 3042EXPLAIN 3043{ 3044 "query_block": { 3045 "select_id": 3, 3046 "nested_loop": [ 3047 { 3048 "table": { 3049 "table_name": "x", 3050 "access_type": "ALL", 3051 "rows": 11, 3052 "filtered": 100, 3053 "attached_condition": "(`x`.`a` is not null)", 3054 "materialized_from_subquery": { 3055 "using_temporary_table": true, 3056 "dependent": false, 3057 "cacheable": true, 3058 "query_block": { 3059 "select_id": 2, 3060 "table": { 3061 "table_name": "t0", 3062 "access_type": "ALL", 3063 "rows": 11, 3064 "filtered": 100 3065 } 3066 } 3067 } 3068 } 3069 }, 3070 { 3071 "table": { 3072 "table_name": "<subquery3>", 3073 "access_type": "eq_ref", 3074 "key": "<auto_key>", 3075 "key_length": "5", 3076 "ref": [ 3077 "x.a" 3078 ], 3079 "rows": 1, 3080 "materialized_from_subquery": { 3081 "using_temporary_table": true, 3082 "query_block": { 3083 "table": { 3084 "table_name": "t1", 3085 "access_type": "ALL", 3086 "rows": 20, 3087 "filtered": 100 3088 } 3089 } 3090 } 3091 } 3092 } 3093 ] 3094 } 3095} 3096Warnings: 3097Note 1003 /* select#1 */ select `x`.`a` AS `a` from (/* select#2 */ select `test`.`t0`.`a` AS `a` from `test`.`t0`) `x` semi join (`test`.`t1`) where (`<subquery3>`.`a` = `x`.`a`) 3098drop table t0, t1; 3099create table t0 (a int); 3100insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 3101create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); 3102insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; 3103insert into t1 select * from t1 where kp1 < 20; 3104create table t3 (a int); 3105insert into t3 select A.a + 10*B.a from t0 A, t0 B; 3106explain select * from t3 where a in (select kp1 from t1 where kp1<20); 3107id select_type table type possible_keys key key_len ref rows Extra 31081 SIMPLE t3 ALL NULL NULL NULL NULL 100 Using where 31091 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.t3.a 1 NULL 31102 MATERIALIZED t1 range kp1 kp1 5 NULL 48 Using where; Using index 3111select * from t3 where a in (select kp1 from t1 where kp1<20); 3112a 31130 31141 31152 31163 31174 31185 31196 31207 31218 31229 312310 312411 312512 312613 312714 312815 312916 313017 313118 313219 3133explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; 3134id select_type table type possible_keys key key_len ref rows Extra 31351 SIMPLE t3 ALL NULL NULL NULL NULL 100 Using where 31361 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.t3.a 1 NULL 31372 MATERIALIZED t1 range kp1 kp1 5 NULL 48 Using where; Using index 3138select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; 3139a 31400 31411 31422 31433 31444 31455 31466 31477 31488 31499 315010 315111 315212 315313 315414 315515 315616 315717 315818 315919 3160create table t4 (pk int primary key); 3161insert into t4 select a from t3; 3162explain select * from t3 where a in 3163(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); 3164id select_type table type possible_keys key key_len ref rows Extra 31651 SIMPLE t3 ALL NULL NULL NULL NULL 100 Using where 31661 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.t3.a 1 NULL 31672 MATERIALIZED t1 range kp1 kp1 5 NULL 48 Using index condition; Using where; Using MRR 31682 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 Using index 3169select * from t3 where a in 3170(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); 3171a 31720 31731 31742 31753 31764 31775 31786 31797 31808 31819 318210 318311 318412 318513 318614 318715 318816 318917 319018 319119 3192drop table t1, t3, t4; 3193create table t1 (a int); 3194insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); 3195set @save_max_heap_table_size=@@max_heap_table_size; 3196set @@max_heap_table_size= 16384; 3197# Attempt to make one test that overflows the heap table when a 3198# non-duplicate row is inserted and one test that overflows the 3199# heap table when a duplicate record is inserted. Debugging showed 3200# that these situations occurred with max_heap_table_size=16384 3201# and optimizer_join_cache_level equals 1 and 0, respectively. 3202# Finally execute a test that does not overflow the heap table. 3203explain 3204select count(*) from t0 A, t0 B, t0 C 3205where C.a in (select a from t1 D); 3206id select_type table type possible_keys key key_len ref rows Extra 32071 SIMPLE A ALL NULL NULL NULL NULL 10 NULL 32081 SIMPLE B ALL NULL NULL NULL NULL 10 Using join buffer (Block Nested Loop) 32091 SIMPLE C ALL NULL NULL NULL NULL 10 Using where; Using join buffer (Block Nested Loop) 32101 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.C.a 1 NULL 32112 MATERIALIZED D ALL NULL NULL NULL NULL 12 NULL 3212flush status; 3213select count(*) from t0 A, t0 B, t0 C 3214where C.a in (select a from t1 D); 3215count(*) 3216400 3217show status like 'Created_tmp_disk_tables'; 3218Variable_name Value 3219Created_tmp_disk_tables 0 3220set @@max_heap_table_size= @save_max_heap_table_size; 3221flush status; 3222select count(*) from t0 A, t0 B, t0 C 3223where C.a in (select a from t1 D); 3224count(*) 3225400 3226show status like 'Created_tmp_disk_tables'; 3227Variable_name Value 3228Created_tmp_disk_tables 0 3229drop table t0, t1; 3230create table t0 (a int); 3231insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 3232create table t2(a int); 3233insert into t2 values (1),(2); 3234create table t3 ( a int , filler char(100), key(a)); 3235insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; 3236explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); 3237id select_type table type possible_keys key key_len ref rows Extra 32381 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL Using where 32391 SIMPLE t3 ref a a 5 <subquery2>.a 1 Using join buffer (Batched Key Access) 32402 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 NULL 3241select * from t3 where a in (select a from t2); 3242a filler 32431 filler 32442 filler 3245drop table t0, t2, t3; 3246create table t1 (a date); 3247insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); 3248create table t2 (a int); 3249insert into t2 values (1),(2); 3250create table t3 (a char(10)); 3251insert into t3 select * from t1; 3252insert into t3 values (1),(2); 3253explain select * from t2 where a in (select a from t1); 3254id select_type table type possible_keys key key_len ref rows Extra 32551 SIMPLE t2 ALL NULL NULL NULL NULL 2 NULL 32561 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where; FirstMatch(t2); Using join buffer (Block Nested Loop) 3257explain select * from t2 where a in (select a from t2); 3258id select_type table type possible_keys key key_len ref rows Extra 32591 SIMPLE t2 ALL NULL NULL NULL NULL 2 NULL 32601 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t2); Using join buffer (Block Nested Loop) 3261explain select * from t2 where a in (select a from t3); 3262id select_type table type possible_keys key key_len ref rows Extra 32631 SIMPLE t2 ALL NULL NULL NULL NULL 2 NULL 32641 SIMPLE t3 ALL NULL NULL NULL NULL 6 Using where; FirstMatch(t2); Using join buffer (Block Nested Loop) 3265explain select * from t1 where a in (select a from t3); 3266id select_type table type possible_keys key key_len ref rows Extra 32671 SIMPLE t1 ALL NULL NULL NULL NULL 4 NULL 32681 SIMPLE t3 ALL NULL NULL NULL NULL 6 Using where; FirstMatch(t1); Using join buffer (Block Nested Loop) 3269drop table t1, t2, t3; 3270create table t1 (a decimal); 3271insert into t1 values (1),(2); 3272explain select * from t1 where a in (select a from t1); 3273id select_type table type possible_keys key key_len ref rows Extra 32741 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL 32751 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1); Using join buffer (Block Nested Loop) 3276drop table t1; 3277create table t1 (a int); 3278insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 3279create table t2 as select * from t1; 3280create table t3 (a int, b int, filler char(100), key(a)); 3281insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; 3282explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; 3283id select_type table type possible_keys key key_len ref rows Extra 32841 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where 32851 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL Using where; Using join buffer (Block Nested Loop) 32861 SIMPLE t3 ref a a 5 <subquery2>.a 10 Using join buffer (Batched Key Access) 32872 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 NULL 3288explain 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; 3289EXPLAIN 3290{ 3291 "query_block": { 3292 "select_id": 1, 3293 "nested_loop": [ 3294 { 3295 "table": { 3296 "table_name": "t1", 3297 "access_type": "ALL", 3298 "rows": 10, 3299 "filtered": 100, 3300 "attached_condition": "(`test`.`t1`.`a` = 3)" 3301 } 3302 }, 3303 { 3304 "table": { 3305 "table_name": "<subquery2>", 3306 "access_type": "ALL", 3307 "attached_condition": "(((`<subquery2>`.`a` < 10) or (`<subquery2>`.`a` > 30)) and (`<subquery2>`.`a` is not null))", 3308 "materialized_from_subquery": { 3309 "using_temporary_table": true, 3310 "query_block": { 3311 "table": { 3312 "table_name": "t2", 3313 "access_type": "ALL", 3314 "rows": 10, 3315 "filtered": 100 3316 } 3317 } 3318 } 3319 } 3320 }, 3321 { 3322 "table": { 3323 "table_name": "t3", 3324 "access_type": "ref", 3325 "possible_keys": [ 3326 "a" 3327 ], 3328 "key": "a", 3329 "used_key_parts": [ 3330 "a" 3331 ], 3332 "key_length": "5", 3333 "ref": [ 3334 "<subquery2>.a" 3335 ], 3336 "rows": 10, 3337 "filtered": 100, 3338 "using_join_buffer": "Batched Key Access" 3339 } 3340 } 3341 ] 3342 } 3343} 3344Warnings: 3345Note 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` semi join (`test`.`t2`) join `test`.`t3` where ((`test`.`t3`.`a` = `<subquery2>`.`a`) and (`test`.`t1`.`a` = 3) and ((`<subquery2>`.`a` < 10) or (`<subquery2>`.`a` > 30))) 3346explain select straight_join * from t1 A, t1 B where A.a in (select a from t2); 3347id select_type table type possible_keys key key_len ref rows Extra 33481 PRIMARY A ALL NULL NULL NULL NULL 10 Using where 33491 PRIMARY B ALL NULL NULL NULL NULL 10 Using join buffer (Block Nested Loop) 33502 SUBQUERY t2 ALL NULL NULL NULL NULL 10 NULL 3351explain select * from t2 where a in (select straight_join A.a from t1 A, t1 B); 3352id select_type table type possible_keys key key_len ref rows Extra 33531 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where 33542 SUBQUERY A ALL NULL NULL NULL NULL 10 NULL 33552 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer (Block Nested Loop) 3356explain select * from t2 where a in (select straight_join A.a from t1 A, t1 B); 3357id select_type table type possible_keys key key_len ref rows Extra 33581 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where 33592 SUBQUERY A ALL NULL NULL NULL NULL 10 NULL 33602 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer (Block Nested Loop) 3361explain select straight_join * from t2 X, t2 Y 3362where X.a in (select straight_join A.a from t1 A, t1 B); 3363id select_type table type possible_keys key key_len ref rows Extra 33641 PRIMARY X ALL NULL NULL NULL NULL 10 Using where 33651 PRIMARY Y ALL NULL NULL NULL NULL 10 Using join buffer (Block Nested Loop) 33662 SUBQUERY A ALL NULL NULL NULL NULL 10 NULL 33672 SUBQUERY B ALL NULL NULL NULL NULL 10 Using join buffer (Block Nested Loop) 3368create table t0 (a int, b int); 3369insert into t0 values(1,1); 3370explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); 3371id select_type table type possible_keys key key_len ref rows Extra 33721 SIMPLE t0 system NULL NULL NULL NULL 1 NULL 33731 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL Using where 33741 SIMPLE t3 ref a a 5 <subquery2>.a 10 Using join buffer (Batched Key Access) 33752 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 NULL 3376create table t4 as select a as x, a as y from t1; 3377explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); 3378id select_type table type possible_keys key key_len ref rows Extra 33791 SIMPLE t0 system NULL NULL NULL NULL 1 NULL 33801 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL Using where 33811 SIMPLE t3 ref a a 5 <subquery2>.x 10 Using where; Using join buffer (Batched Key Access) 33822 MATERIALIZED t4 ALL NULL NULL NULL NULL 10 NULL 3383drop table t0,t1,t2,t3,t4; 3384create table t0 (a int); 3385insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 3386create table t1 (a int, b int, filler char(100), key(a,b)); 3387insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; 3388create table t2 as select * from t1; 3389explain select * from t2 where a in (select b from t1 where a=3); 3390id select_type table type possible_keys key key_len ref rows Extra 33911 SIMPLE t2 ALL NULL NULL NULL NULL 100 Using where 33921 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.t2.a 1 NULL 33932 MATERIALIZED t1 ref a a 5 const 8 Using index 3394explain select * from t2 where (b,a) in (select a,b from t1 where a=3); 3395id select_type table type possible_keys key key_len ref rows Extra 33961 SIMPLE t2 ALL NULL NULL NULL NULL 100 Using where 33971 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 10 test.t2.b,test.t2.a 1 Using where 33982 MATERIALIZED t1 ref a a 5 const 8 Using index 3399drop table t1,t2; 3400create table t1 (a int, b int); 3401insert into t1 select a,a from t0; 3402create table t2 (a int, b int); 3403insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; 3404explain select * from t1 where (a,b) in (select a,b from t2); 3405id select_type table type possible_keys key key_len ref rows Extra 34061 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where 34071 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 10 test.t1.a,test.t1.b 1 NULL 34082 MATERIALIZED t2 ALL NULL NULL NULL NULL 100 NULL 3409drop table t0, t1, t2; 3410create table t0 (a decimal(4,2)); 3411insert into t0 values (10.24), (22.11); 3412create table t1 as select * from t0; 3413insert into t1 select * from t0; 3414explain select * from t0 where a in (select a from t1); 3415id select_type table type possible_keys key key_len ref rows Extra 34161 SIMPLE t0 ALL NULL NULL NULL NULL 2 NULL 34171 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where; FirstMatch(t0); Using join buffer (Block Nested Loop) 3418select * from t0 where a in (select a from t1); 3419a 342010.24 342122.11 3422drop table t0, t1; 3423create table t0(a date); 3424insert into t0 values ('2008-01-01'),('2008-02-02'); 3425create table t1 as select * from t0; 3426insert into t1 select * from t0; 3427explain select * from t0 where a in (select a from t1); 3428id select_type table type possible_keys key key_len ref rows Extra 34291 SIMPLE t0 ALL NULL NULL NULL NULL 2 NULL 34301 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where; FirstMatch(t0); Using join buffer (Block Nested Loop) 3431select * from t0 where a in (select a from t1); 3432a 34332008-01-01 34342008-02-02 3435drop table t0, t1; 3436create table t0(a int); 3437insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 3438create table t1 as select a as a, a as b, a as c from t0 where a < 3; 3439create table t2 as select a as a, a as b from t0 where a < 3; 3440insert into t2 select * from t2; 3441explain 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); 3442id select_type table type possible_keys key key_len ref rows Extra 34431 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where 34441 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 15 test.t1.a,test.t1.b,test.t1.c 1 NULL 34452 MATERIALIZED X ALL NULL NULL NULL NULL 6 Using where 34462 MATERIALIZED Y ALL NULL NULL NULL NULL 6 Using join buffer (Block Nested Loop) 34472 MATERIALIZED Z ALL NULL NULL NULL NULL 6 Using join buffer (Block Nested Loop) 3448drop table t0,t1,t2; 3449set @save_join_buffer_size = @@join_buffer_size; 3450set join_buffer_size= 8192; 3451create table t0 (a int); 3452insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 3453create table t1 (a int, filler1 binary(200), filler2 binary(200)); 3454insert into t1 select a, 'filler123456', 'filler123456' from t0; 3455insert into t1 select a+10, 'filler123456', 'filler123456' from t0; 3456create table t2 as select * from t1; 3457insert into t1 select a+20, 'filler123456', 'filler123456' from t0; 3458insert into t1 values (2, 'duplicate ok', 'duplicate ok'); 3459insert into t1 values (18, 'duplicate ok', 'duplicate ok'); 3460insert into t2 values (3, 'duplicate ok', 'duplicate ok'); 3461insert into t2 values (19, 'duplicate ok', 'duplicate ok'); 3462explain select 3463a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z 3464from t1 ot where a in (select a from t2 it); 3465id select_type table type possible_keys key key_len ref rows Extra 34661 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 34671 SIMPLE ot ALL NULL NULL NULL NULL 32 Using where; Using join buffer (Block Nested Loop) 34682 MATERIALIZED it ALL NULL NULL NULL NULL 22 NULL 3469select 3470a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z 3471from t1 ot where a in (select a from t2 it); 3472a mid(filler1, 1,10) Z 34730 filler1234 1 34741 filler1234 1 347510 filler1234 1 347611 filler1234 1 347712 filler1234 1 347813 filler1234 1 347914 filler1234 1 348015 filler1234 1 348116 filler1234 1 348217 filler1234 1 348318 duplicate 1 348418 filler1234 1 348519 filler1234 1 34862 duplicate 1 34872 filler1234 1 34883 filler1234 1 34894 filler1234 1 34905 filler1234 1 34916 filler1234 1 34927 filler1234 1 34938 filler1234 1 34949 filler1234 1 3495explain select 3496a, mid(filler1, 1,10), length(filler1)=length(filler2) 3497from t2 ot where a in (select a from t1 it); 3498id select_type table type possible_keys key key_len ref rows Extra 34991 SIMPLE ot ALL NULL NULL NULL NULL 22 Using where 35001 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.ot.a 1 NULL 35012 MATERIALIZED it ALL NULL NULL NULL NULL 32 NULL 3502select 3503a, mid(filler1, 1,10), length(filler1)=length(filler2) 3504from t2 ot where a in (select a from t1 it); 3505a mid(filler1, 1,10) length(filler1)=length(filler2) 35060 filler1234 1 35071 filler1234 1 350810 filler1234 1 350911 filler1234 1 351012 filler1234 1 351113 filler1234 1 351214 filler1234 1 351315 filler1234 1 351416 filler1234 1 351517 filler1234 1 351618 filler1234 1 351719 duplicate 1 351819 filler1234 1 35192 filler1234 1 35203 duplicate 1 35213 filler1234 1 35224 filler1234 1 35235 filler1234 1 35246 filler1234 1 35257 filler1234 1 35268 filler1234 1 35279 filler1234 1 3528insert into t1 select a+20, 'filler123456', 'filler123456' from t0; 3529insert into t1 select a+20, 'filler123456', 'filler123456' from t0; 3530explain select 3531a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z 3532from t1 ot where a in (select a from t2 it); 3533id select_type table type possible_keys key key_len ref rows Extra 35341 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 35351 SIMPLE ot ALL NULL NULL NULL NULL 52 Using where; Using join buffer (Block Nested Loop) 35362 MATERIALIZED it ALL NULL NULL NULL NULL 22 NULL 3537select 3538a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z 3539from t1 ot where a in (select a from t2 it); 3540a mid(filler1, 1,10) Z 35410 filler1234 1 35421 filler1234 1 354310 filler1234 1 354411 filler1234 1 354512 filler1234 1 354613 filler1234 1 354714 filler1234 1 354815 filler1234 1 354916 filler1234 1 355017 filler1234 1 355118 duplicate 1 355218 filler1234 1 355319 filler1234 1 35542 duplicate 1 35552 filler1234 1 35563 filler1234 1 35574 filler1234 1 35585 filler1234 1 35596 filler1234 1 35607 filler1234 1 35618 filler1234 1 35629 filler1234 1 3563explain select 3564a, mid(filler1, 1,10), length(filler1)=length(filler2) 3565from t2 ot where a in (select a from t1 it); 3566id select_type table type possible_keys key key_len ref rows Extra 35671 SIMPLE ot ALL NULL NULL NULL NULL 22 Using where 35681 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.ot.a 1 NULL 35692 MATERIALIZED it ALL NULL NULL NULL NULL 52 NULL 3570select 3571a, mid(filler1, 1,10), length(filler1)=length(filler2) 3572from t2 ot where a in (select a from t1 it); 3573a mid(filler1, 1,10) length(filler1)=length(filler2) 35740 filler1234 1 35751 filler1234 1 357610 filler1234 1 357711 filler1234 1 357812 filler1234 1 357913 filler1234 1 358014 filler1234 1 358115 filler1234 1 358216 filler1234 1 358317 filler1234 1 358418 filler1234 1 358519 duplicate 1 358619 filler1234 1 35872 filler1234 1 35883 duplicate 1 35893 filler1234 1 35904 filler1234 1 35915 filler1234 1 35926 filler1234 1 35937 filler1234 1 35948 filler1234 1 35959 filler1234 1 3596set @@join_buffer_size = @save_join_buffer_size; 3597drop table t1, t2; 3598create table t1 (a int, b int, key(a)); 3599create table t2 (a int, b int, key(a)); 3600create table t3 (a int, b int, key(a)); 3601insert into t1 select a,a from t0; 3602insert into t2 select a,a from t0; 3603insert into t3 select a,a from t0; 3604t2 and t3 must be use 'ref', not 'ALL': 3605explain select * 3606from t0 where a in 3607(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); 3608id select_type table type possible_keys key key_len ref rows Extra 36091 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where 36101 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 9 test.t0.a 1 Using where 36112 MATERIALIZED t1 index a a 5 NULL 10 Using index 36122 MATERIALIZED t2 ref a a 5 test.t1.a 1 Using index 36132 MATERIALIZED t3 ref a a 5 test.t1.a 1 Using index 3614drop table t0, t1,t2,t3; 3615 3616Test that neither MaterializeLookup strategy for semijoin, 3617nor subquery materialization is used when BLOBs are involved 3618(except when arguments of some functions). 3619 3620set @prefix_len = 6; 3621set @blob_len = 16; 3622set @suffix_len = @blob_len - @prefix_len; 3623create table t1_16 (a1 blob(16), a2 blob(16)); 3624create table t2_16 (b1 blob(16), b2 blob(16)); 3625create table t3_16 (c1 blob(16), c2 blob(16)); 3626insert into t1_16 values 3627(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); 3628insert into t1_16 values 3629(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 3630insert into t1_16 values 3631(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 3632insert into t2_16 values 3633(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 3634insert into t2_16 values 3635(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 3636insert into t2_16 values 3637(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 3638insert into t3_16 values 3639(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 3640insert into t3_16 values 3641(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 3642insert into t3_16 values 3643(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 3644insert into t3_16 values 3645(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); 3646explain extended select left(a1,7), left(a2,7) 3647from t1_16 3648where a1 in (select b1 from t2_16 where b1 > '0'); 3649id select_type table type possible_keys key key_len ref rows filtered Extra 36501 SIMPLE t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where 36511 SIMPLE t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_16); Using join buffer (Block Nested Loop) 3652Warnings: 3653Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0')) 3654select left(a1,7), left(a2,7) 3655from t1_16 3656where a1 in (select b1 from t2_16 where b1 > '0'); 3657left(a1,7) left(a2,7) 36581 - 01x 2 - 01x 36591 - 02x 2 - 02x 3660explain extended select left(a1,7), left(a2,7) 3661from t1_16 3662where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); 3663id select_type table type possible_keys key key_len ref rows filtered Extra 36641 SIMPLE t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where 36651 SIMPLE t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_16); Using join buffer (Block Nested Loop) 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` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t1_16`.`a1` > '0')) 3668select left(a1,7), left(a2,7) 3669from t1_16 3670where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); 3671left(a1,7) left(a2,7) 36721 - 01x 2 - 01x 36731 - 02x 2 - 02x 3674explain extended select left(a1,7), left(a2,7) 3675from t1_16 3676where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); 3677id select_type table type possible_keys key key_len ref rows filtered Extra 36781 SIMPLE t1_16 ALL NULL NULL NULL NULL 3 100.00 NULL 36791 SIMPLE t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_16); Using join buffer (Block Nested Loop) 3680Warnings: 3681Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` semi join (`test`.`t2_16`) where ((`test`.`t2_16`.`b1` > '0') and (`test`.`t1_16`.`a1` = substr(`test`.`t2_16`.`b1`,1,16))) 3682select left(a1,7), left(a2,7) 3683from t1_16 3684where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); 3685left(a1,7) left(a2,7) 36861 - 01x 2 - 01x 36871 - 02x 2 - 02x 3688explain extended select left(a1,7), left(a2,7) 3689from t1_16 3690where a1 in (select group_concat(b1) from t2_16 group by b2); 3691id select_type table type possible_keys key key_len ref rows filtered Extra 36921 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where 36932 DEPENDENT SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using filesort 3694Warnings: 3695Note 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 ','))))) 3696select left(a1,7), left(a2,7) 3697from t1_16 3698where a1 in (select group_concat(b1) from t2_16 group by b2); 3699left(a1,7) left(a2,7) 37001 - 01x 2 - 01x 37011 - 02x 2 - 02x 3702set @@group_concat_max_len = 256; 3703explain extended select left(a1,7), left(a2,7) 3704from t1_16 3705where a1 in (select group_concat(b1) from t2_16 group by b2); 3706id select_type table type possible_keys key key_len ref rows filtered Extra 37071 PRIMARY t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where 37082 SUBQUERY t2_16 ALL NULL NULL NULL NULL 3 100.00 Using filesort 3709Warnings: 3710Note 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)`))))) 3711select left(a1,7), left(a2,7) 3712from t1_16 3713where a1 in (select group_concat(b1) from t2_16 group by b2); 3714left(a1,7) left(a2,7) 37151 - 01x 2 - 01x 37161 - 02x 2 - 02x 3717create table t1 (a1 char(8), a2 char(8)); 3718create table t2 (b1 char(8), b2 char(8)); 3719create table t3 (c1 char(8), c2 char(8)); 3720insert into t1 values ('1 - 00', '2 - 00'); 3721insert into t1 values ('1 - 01', '2 - 01'); 3722insert into t1 values ('1 - 02', '2 - 02'); 3723insert into t2 values ('1 - 01', '2 - 01'); 3724insert into t2 values ('1 - 01', '2 - 01'); 3725insert into t2 values ('1 - 02', '2 - 02'); 3726insert into t2 values ('1 - 02', '2 - 02'); 3727insert into t2 values ('1 - 03', '2 - 03'); 3728insert into t3 values ('1 - 01', '2 - 01'); 3729insert into t3 values ('1 - 02', '2 - 02'); 3730insert into t3 values ('1 - 03', '2 - 03'); 3731insert into t3 values ('1 - 04', '2 - 04'); 3732explain extended 3733select * from t1 3734where concat(a1,'x') IN 3735(select left(a1,8) from t1_16 3736where (a1, a2) IN 3737(select t2_16.b1, t2_16.b2 from t2_16, t2 3738where t2.b2 = substring(t2_16.b2,1,6) and 3739t2.b1 IN (select c1 from t3 where c2 > '0'))); 3740id select_type table type possible_keys key key_len ref rows filtered Extra 37411 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Start temporary 37421 SIMPLE t1_16 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (Block Nested Loop) 37431 SIMPLE t2_16 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (Block Nested Loop) 37441 SIMPLE t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (Block Nested Loop) 37451 SIMPLE t2 ALL NULL NULL NULL NULL 5 100.00 Using where; End temporary; Using join buffer (Block Nested Loop) 3746Warnings: 3747Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2_16` join `test`.`t2` join `test`.`t1_16`) where ((`test`.`t2_16`.`b2` = `test`.`t1_16`.`a2`) and (`test`.`t2_16`.`b1` = `test`.`t1_16`.`a1`) and (`test`.`t2`.`b1` = `test`.`t3`.`c1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) 3748drop table t1_16, t2_16, t3_16, t1, t2, t3; 3749set @blob_len = 512; 3750set @suffix_len = @blob_len - @prefix_len; 3751create table t1_512 (a1 blob(512), a2 blob(512)); 3752create table t2_512 (b1 blob(512), b2 blob(512)); 3753create table t3_512 (c1 blob(512), c2 blob(512)); 3754insert into t1_512 values 3755(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); 3756insert into t1_512 values 3757(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 3758insert into t1_512 values 3759(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 3760insert into t2_512 values 3761(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 3762insert into t2_512 values 3763(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 3764insert into t2_512 values 3765(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 3766insert into t3_512 values 3767(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 3768insert into t3_512 values 3769(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 3770insert into t3_512 values 3771(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 3772insert into t3_512 values 3773(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); 3774explain extended select left(a1,7), left(a2,7) 3775from t1_512 3776where a1 in (select b1 from t2_512 where b1 > '0'); 3777id select_type table type possible_keys key key_len ref rows filtered Extra 37781 SIMPLE t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where 37791 SIMPLE t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_512); Using join buffer (Block Nested Loop) 3780Warnings: 3781Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0')) 3782select left(a1,7), left(a2,7) 3783from t1_512 3784where a1 in (select b1 from t2_512 where b1 > '0'); 3785left(a1,7) left(a2,7) 37861 - 01x 2 - 01x 37871 - 02x 2 - 02x 3788explain extended select left(a1,7), left(a2,7) 3789from t1_512 3790where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); 3791id select_type table type possible_keys key key_len ref rows filtered Extra 37921 SIMPLE t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where 37931 SIMPLE t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_512); Using join buffer (Block Nested Loop) 3794Warnings: 3795Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b2` = `test`.`t1_512`.`a2`) and (`test`.`t2_512`.`b1` = `test`.`t1_512`.`a1`) and (`test`.`t1_512`.`a1` > '0')) 3796select left(a1,7), left(a2,7) 3797from t1_512 3798where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); 3799left(a1,7) left(a2,7) 38001 - 01x 2 - 01x 38011 - 02x 2 - 02x 3802explain extended select left(a1,7), left(a2,7) 3803from t1_512 3804where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); 3805id select_type table type possible_keys key key_len ref rows filtered Extra 38061 SIMPLE t1_512 ALL NULL NULL NULL NULL 3 100.00 NULL 38071 SIMPLE t2_512 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_512); Using join buffer (Block Nested Loop) 3808Warnings: 3809Note 1003 /* select#1 */ select left(`test`.`t1_512`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_512`.`a2`,7) AS `left(a2,7)` from `test`.`t1_512` semi join (`test`.`t2_512`) where ((`test`.`t2_512`.`b1` > '0') and (`test`.`t1_512`.`a1` = substr(`test`.`t2_512`.`b1`,1,512))) 3810select left(a1,7), left(a2,7) 3811from t1_512 3812where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); 3813left(a1,7) left(a2,7) 38141 - 01x 2 - 01x 38151 - 02x 2 - 02x 3816explain extended select left(a1,7), left(a2,7) 3817from t1_512 3818where a1 in (select group_concat(b1) from t2_512 group by b2); 3819id select_type table type possible_keys key key_len ref rows filtered Extra 38201 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where 38212 SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using filesort 3822Warnings: 3823Note 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)`))))) 3824select left(a1,7), left(a2,7) 3825from t1_512 3826where a1 in (select group_concat(b1) from t2_512 group by b2); 3827left(a1,7) left(a2,7) 3828Warnings: 3829Warning 1260 Row 1 was cut by GROUP_CONCAT() 3830Warning 1260 Row 2 was cut by GROUP_CONCAT() 3831Warning 1260 Row 3 was cut by GROUP_CONCAT() 3832set @@group_concat_max_len = 256; 3833explain extended select left(a1,7), left(a2,7) 3834from t1_512 3835where a1 in (select group_concat(b1) from t2_512 group by b2); 3836id select_type table type possible_keys key key_len ref rows filtered Extra 38371 PRIMARY t1_512 ALL NULL NULL NULL NULL 3 100.00 Using where 38382 SUBQUERY t2_512 ALL NULL NULL NULL NULL 3 100.00 Using filesort 3839Warnings: 3840Note 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)`))))) 3841select left(a1,7), left(a2,7) 3842from t1_512 3843where a1 in (select group_concat(b1) from t2_512 group by b2); 3844left(a1,7) left(a2,7) 3845Warnings: 3846Warning 1260 Row 1 was cut by GROUP_CONCAT() 3847Warning 1260 Row 2 was cut by GROUP_CONCAT() 3848Warning 1260 Row 3 was cut by GROUP_CONCAT() 3849drop table t1_512, t2_512, t3_512; 3850set @blob_len = 513; 3851set @suffix_len = @blob_len - @prefix_len; 3852create table t1_513 (a1 blob(513), a2 blob(513)); 3853create table t2_513 (b1 blob(513), b2 blob(513)); 3854create table t3_513 (c1 blob(513), c2 blob(513)); 3855insert into t1_513 values 3856(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); 3857insert into t1_513 values 3858(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 3859insert into t1_513 values 3860(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 3861insert into t2_513 values 3862(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 3863insert into t2_513 values 3864(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 3865insert into t2_513 values 3866(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 3867insert into t3_513 values 3868(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 3869insert into t3_513 values 3870(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 3871insert into t3_513 values 3872(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 3873insert into t3_513 values 3874(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); 3875explain extended select left(a1,7), left(a2,7) 3876from t1_513 3877where a1 in (select b1 from t2_513 where b1 > '0'); 3878id select_type table type possible_keys key key_len ref rows filtered Extra 38791 SIMPLE t1_513 ALL NULL NULL NULL NULL 3 100.00 Using where 38801 SIMPLE t2_513 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_513); Using join buffer (Block Nested Loop) 3881Warnings: 3882Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` = `test`.`t1_513`.`a1`) and (`test`.`t1_513`.`a1` > '0')) 3883select left(a1,7), left(a2,7) 3884from t1_513 3885where a1 in (select b1 from t2_513 where b1 > '0'); 3886left(a1,7) left(a2,7) 38871 - 01x 2 - 01x 38881 - 02x 2 - 02x 3889explain extended select left(a1,7), left(a2,7) 3890from t1_513 3891where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); 3892id select_type table type possible_keys key key_len ref rows filtered Extra 38931 SIMPLE t1_513 ALL NULL NULL NULL NULL 3 100.00 Using where 38941 SIMPLE t2_513 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_513); Using join buffer (Block Nested Loop) 3895Warnings: 3896Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b2` = `test`.`t1_513`.`a2`) and (`test`.`t2_513`.`b1` = `test`.`t1_513`.`a1`) and (`test`.`t1_513`.`a1` > '0')) 3897select left(a1,7), left(a2,7) 3898from t1_513 3899where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); 3900left(a1,7) left(a2,7) 39011 - 01x 2 - 01x 39021 - 02x 2 - 02x 3903explain extended select left(a1,7), left(a2,7) 3904from t1_513 3905where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); 3906id select_type table type possible_keys key key_len ref rows filtered Extra 39071 SIMPLE t1_513 ALL NULL NULL NULL NULL 3 100.00 NULL 39081 SIMPLE t2_513 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_513); Using join buffer (Block Nested Loop) 3909Warnings: 3910Note 1003 /* select#1 */ select left(`test`.`t1_513`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_513`.`a2`,7) AS `left(a2,7)` from `test`.`t1_513` semi join (`test`.`t2_513`) where ((`test`.`t2_513`.`b1` > '0') and (`test`.`t1_513`.`a1` = substr(`test`.`t2_513`.`b1`,1,513))) 3911select left(a1,7), left(a2,7) 3912from t1_513 3913where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); 3914left(a1,7) left(a2,7) 39151 - 01x 2 - 01x 39161 - 02x 2 - 02x 3917explain extended select left(a1,7), left(a2,7) 3918from t1_513 3919where a1 in (select group_concat(b1) from t2_513 group by b2); 3920id select_type table type possible_keys key key_len ref rows filtered Extra 39211 PRIMARY t1_513 ALL NULL NULL NULL NULL 3 100.00 Using where 39222 SUBQUERY t2_513 ALL NULL NULL NULL NULL 3 100.00 Using filesort 3923Warnings: 3924Note 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)`))))) 3925select left(a1,7), left(a2,7) 3926from t1_513 3927where a1 in (select group_concat(b1) from t2_513 group by b2); 3928left(a1,7) left(a2,7) 3929Warnings: 3930Warning 1260 Row 1 was cut by GROUP_CONCAT() 3931Warning 1260 Row 2 was cut by GROUP_CONCAT() 3932Warning 1260 Row 3 was cut by GROUP_CONCAT() 3933drop table t1_513, t2_513, t3_513; 3934set @blob_len = 1024; 3935set @suffix_len = @blob_len - @prefix_len; 3936create table t1_1024 (a1 blob(1024), a2 blob(1024)); 3937create table t2_1024 (b1 blob(1024), b2 blob(1024)); 3938create table t3_1024 (c1 blob(1024), c2 blob(1024)); 3939insert into t1_1024 values 3940(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); 3941insert into t1_1024 values 3942(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 3943insert into t1_1024 values 3944(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 3945insert into t2_1024 values 3946(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 3947insert into t2_1024 values 3948(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 3949insert into t2_1024 values 3950(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 3951insert into t3_1024 values 3952(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 3953insert into t3_1024 values 3954(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 3955insert into t3_1024 values 3956(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 3957insert into t3_1024 values 3958(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); 3959explain extended select left(a1,7), left(a2,7) 3960from t1_1024 3961where a1 in (select b1 from t2_1024 where b1 > '0'); 3962id select_type table type possible_keys key key_len ref rows filtered Extra 39631 SIMPLE t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where 39641 SIMPLE t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_1024); Using join buffer (Block Nested Loop) 3965Warnings: 3966Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0')) 3967select left(a1,7), left(a2,7) 3968from t1_1024 3969where a1 in (select b1 from t2_1024 where b1 > '0'); 3970left(a1,7) left(a2,7) 39711 - 01x 2 - 01x 39721 - 02x 2 - 02x 3973explain extended select left(a1,7), left(a2,7) 3974from t1_1024 3975where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); 3976id select_type table type possible_keys key key_len ref rows filtered Extra 39771 SIMPLE t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where 39781 SIMPLE t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_1024); Using join buffer (Block Nested Loop) 3979Warnings: 3980Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b2` = `test`.`t1_1024`.`a2`) and (`test`.`t2_1024`.`b1` = `test`.`t1_1024`.`a1`) and (`test`.`t1_1024`.`a1` > '0')) 3981select left(a1,7), left(a2,7) 3982from t1_1024 3983where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); 3984left(a1,7) left(a2,7) 39851 - 01x 2 - 01x 39861 - 02x 2 - 02x 3987explain extended select left(a1,7), left(a2,7) 3988from t1_1024 3989where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); 3990id select_type table type possible_keys key key_len ref rows filtered Extra 39911 SIMPLE t1_1024 ALL NULL NULL NULL NULL 3 100.00 NULL 39921 SIMPLE t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_1024); Using join buffer (Block Nested Loop) 3993Warnings: 3994Note 1003 /* select#1 */ select left(`test`.`t1_1024`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1024`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1024` semi join (`test`.`t2_1024`) where ((`test`.`t2_1024`.`b1` > '0') and (`test`.`t1_1024`.`a1` = substr(`test`.`t2_1024`.`b1`,1,1024))) 3995select left(a1,7), left(a2,7) 3996from t1_1024 3997where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); 3998left(a1,7) left(a2,7) 39991 - 01x 2 - 01x 40001 - 02x 2 - 02x 4001explain extended select left(a1,7), left(a2,7) 4002from t1_1024 4003where a1 in (select group_concat(b1) from t2_1024 group by b2); 4004id select_type table type possible_keys key key_len ref rows filtered Extra 40051 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where 40062 SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using filesort 4007Warnings: 4008Note 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)`))))) 4009select left(a1,7), left(a2,7) 4010from t1_1024 4011where a1 in (select group_concat(b1) from t2_1024 group by b2); 4012left(a1,7) left(a2,7) 4013Warnings: 4014Warning 1260 Row 1 was cut by GROUP_CONCAT() 4015Warning 1260 Row 2 was cut by GROUP_CONCAT() 4016Warning 1260 Row 3 was cut by GROUP_CONCAT() 4017set @@group_concat_max_len = 256; 4018explain extended select left(a1,7), left(a2,7) 4019from t1_1024 4020where a1 in (select group_concat(b1) from t2_1024 group by b2); 4021id select_type table type possible_keys key key_len ref rows filtered Extra 40221 PRIMARY t1_1024 ALL NULL NULL NULL NULL 3 100.00 Using where 40232 SUBQUERY t2_1024 ALL NULL NULL NULL NULL 3 100.00 Using filesort 4024Warnings: 4025Note 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)`))))) 4026select left(a1,7), left(a2,7) 4027from t1_1024 4028where a1 in (select group_concat(b1) from t2_1024 group by b2); 4029left(a1,7) left(a2,7) 4030Warnings: 4031Warning 1260 Row 1 was cut by GROUP_CONCAT() 4032Warning 1260 Row 2 was cut by GROUP_CONCAT() 4033Warning 1260 Row 3 was cut by GROUP_CONCAT() 4034drop table t1_1024, t2_1024, t3_1024; 4035set @blob_len = 1025; 4036set @suffix_len = @blob_len - @prefix_len; 4037create table t1_1025 (a1 blob(1025), a2 blob(1025)); 4038create table t2_1025 (b1 blob(1025), b2 blob(1025)); 4039create table t3_1025 (c1 blob(1025), c2 blob(1025)); 4040insert into t1_1025 values 4041(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); 4042insert into t1_1025 values 4043(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 4044insert into t1_1025 values 4045(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 4046insert into t2_1025 values 4047(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 4048insert into t2_1025 values 4049(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 4050insert into t2_1025 values 4051(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 4052insert into t3_1025 values 4053(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 4054insert into t3_1025 values 4055(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 4056insert into t3_1025 values 4057(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 4058insert into t3_1025 values 4059(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); 4060explain extended select left(a1,7), left(a2,7) 4061from t1_1025 4062where a1 in (select b1 from t2_1025 where b1 > '0'); 4063id select_type table type possible_keys key key_len ref rows filtered Extra 40641 SIMPLE t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where 40651 SIMPLE t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_1025); Using join buffer (Block Nested Loop) 4066Warnings: 4067Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0')) 4068select left(a1,7), left(a2,7) 4069from t1_1025 4070where a1 in (select b1 from t2_1025 where b1 > '0'); 4071left(a1,7) left(a2,7) 40721 - 01x 2 - 01x 40731 - 02x 2 - 02x 4074explain extended select left(a1,7), left(a2,7) 4075from t1_1025 4076where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); 4077id select_type table type possible_keys key key_len ref rows filtered Extra 40781 SIMPLE t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where 40791 SIMPLE t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_1025); Using join buffer (Block Nested Loop) 4080Warnings: 4081Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b2` = `test`.`t1_1025`.`a2`) and (`test`.`t2_1025`.`b1` = `test`.`t1_1025`.`a1`) and (`test`.`t1_1025`.`a1` > '0')) 4082select left(a1,7), left(a2,7) 4083from t1_1025 4084where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); 4085left(a1,7) left(a2,7) 40861 - 01x 2 - 01x 40871 - 02x 2 - 02x 4088explain extended select left(a1,7), left(a2,7) 4089from t1_1025 4090where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); 4091id select_type table type possible_keys key key_len ref rows filtered Extra 40921 SIMPLE t1_1025 ALL NULL NULL NULL NULL 3 100.00 NULL 40931 SIMPLE t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1_1025); Using join buffer (Block Nested Loop) 4094Warnings: 4095Note 1003 /* select#1 */ select left(`test`.`t1_1025`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_1025`.`a2`,7) AS `left(a2,7)` from `test`.`t1_1025` semi join (`test`.`t2_1025`) where ((`test`.`t2_1025`.`b1` > '0') and (`test`.`t1_1025`.`a1` = substr(`test`.`t2_1025`.`b1`,1,1025))) 4096select left(a1,7), left(a2,7) 4097from t1_1025 4098where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); 4099left(a1,7) left(a2,7) 41001 - 01x 2 - 01x 41011 - 02x 2 - 02x 4102explain extended select left(a1,7), left(a2,7) 4103from t1_1025 4104where a1 in (select group_concat(b1) from t2_1025 group by b2); 4105id select_type table type possible_keys key key_len ref rows filtered Extra 41061 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where 41072 SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using filesort 4108Warnings: 4109Note 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)`))))) 4110select left(a1,7), left(a2,7) 4111from t1_1025 4112where a1 in (select group_concat(b1) from t2_1025 group by b2); 4113left(a1,7) left(a2,7) 4114Warnings: 4115Warning 1260 Row 1 was cut by GROUP_CONCAT() 4116Warning 1260 Row 2 was cut by GROUP_CONCAT() 4117Warning 1260 Row 3 was cut by GROUP_CONCAT() 4118set @@group_concat_max_len = 256; 4119explain extended select left(a1,7), left(a2,7) 4120from t1_1025 4121where a1 in (select group_concat(b1) from t2_1025 group by b2); 4122id select_type table type possible_keys key key_len ref rows filtered Extra 41231 PRIMARY t1_1025 ALL NULL NULL NULL NULL 3 100.00 Using where 41242 SUBQUERY t2_1025 ALL NULL NULL NULL NULL 3 100.00 Using filesort 4125Warnings: 4126Note 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)`))))) 4127select left(a1,7), left(a2,7) 4128from t1_1025 4129where a1 in (select group_concat(b1) from t2_1025 group by b2); 4130left(a1,7) left(a2,7) 4131Warnings: 4132Warning 1260 Row 1 was cut by GROUP_CONCAT() 4133Warning 1260 Row 2 was cut by GROUP_CONCAT() 4134Warning 1260 Row 3 was cut by GROUP_CONCAT() 4135drop table t1_1025, t2_1025, t3_1025; 4136# 4137# WL#5561: Enable semi join transformation with outer join. 4138# 4139CREATE TABLE ot1(a INT); 4140CREATE TABLE ot2(a INT); 4141CREATE TABLE ot3(a INT); 4142CREATE TABLE it1(a INT); 4143CREATE TABLE it2(a INT); 4144CREATE TABLE it3(a INT); 4145INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); 4146INSERT INTO ot2 VALUES(0),(2),(4),(6); 4147INSERT INTO ot3 VALUES(0),(3),(6); 4148INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); 4149INSERT INTO it2 VALUES(0),(2),(4),(6); 4150INSERT INTO it3 VALUES(0),(3),(6); 4151# Test cases, Subquery Pattern 1 4152# Example SQ1.1: 4153explain SELECT * 4154FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4155WHERE ot1.a IN (SELECT a FROM it3); 4156id select_type table type possible_keys key key_len ref rows Extra 41571 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 41581 SIMPLE ot1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop) 41591 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop) 41602 MATERIALIZED it3 ALL NULL NULL NULL NULL 3 NULL 4161SELECT * 4162FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4163WHERE ot1.a IN (SELECT a FROM it3); 4164a a 41650 0 41663 NULL 41676 6 4168# Example SQ1.2: 4169explain SELECT * 4170FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4171WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); 4172id select_type table type possible_keys key key_len ref rows Extra 41731 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 41741 SIMPLE ot1 ALL NULL NULL NULL NULL 8 Using join buffer (Block Nested Loop) 41751 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop) 41762 MATERIALIZED it3 ALL NULL NULL NULL NULL 3 NULL 4177SELECT * 4178FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4179WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); 4180a a 41810 0 41821 NULL 41833 NULL 41845 NULL 41856 6 41867 NULL 4187# Example SQ1.3: 4188explain SELECT * 4189FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4190WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); 4191id select_type table type possible_keys key key_len ref rows Extra 41921 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL Using where 41931 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop) 41941 SIMPLE ot1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop) 41952 MATERIALIZED it3 ALL NULL NULL NULL NULL 3 NULL 4196SELECT * 4197FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4198WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); 4199a a 42000 0 42016 6 4202# More test cases 4203SELECT * 4204FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 4205WHERE ot1.a IN (SELECT a FROM it3); 4206a a 42070 0 42083 NULL 42096 6 4210SELECT * 4211FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 4212WHERE ot1.a IN (SELECT a+0 FROM it3); 4213a a 42140 0 42153 NULL 42166 6 4217SELECT * 4218FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 4219WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); 4220a a 42210 0 42221 NULL 42233 NULL 42245 NULL 42256 6 42267 NULL 4227SELECT * 4228FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4229WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); 4230a a 42310 0 42321 NULL 42333 NULL 42345 NULL 42356 6 42367 NULL 4237SELECT * 4238FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 4239WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); 4240a a 42410 0 42426 6 4243SELECT * 4244FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4245LEFT JOIN ot3 ON ot1.a=ot3.a 4246WHERE ot1.a IN (SELECT a FROM it3); 4247a a a 42480 0 0 42493 NULL 3 42506 6 6 4251SELECT * 4252FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4253LEFT JOIN ot3 ON ot1.a=ot3.a 4254WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); 4255a a a 42560 0 0 42571 NULL NULL 42583 NULL 3 42595 NULL NULL 42606 6 6 42617 NULL NULL 4262SELECT * 4263FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4264LEFT JOIN ot3 ON ot1.a=ot3.a 4265WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); 4266a a a 42670 0 0 42681 NULL NULL 42692 2 NULL 42703 NULL 3 42714 4 NULL 42725 NULL NULL 42736 6 6 42747 NULL NULL 4275SELECT * 4276FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4277LEFT JOIN ot3 ON ot2.a=ot3.a 4278WHERE ot1.a IN (SELECT a FROM it3); 4279a a a 42800 0 0 42813 NULL NULL 42826 6 6 4283SELECT * 4284FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4285LEFT JOIN ot3 ON ot2.a=ot3.a 4286WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); 4287a a a 42880 0 0 42891 NULL NULL 42903 NULL NULL 42915 NULL NULL 42926 6 6 42937 NULL NULL 4294SELECT * 4295FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4296LEFT JOIN ot3 ON ot2.a=ot3.a 4297WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); 4298a a a 42990 0 0 43001 NULL NULL 43012 2 NULL 43023 NULL NULL 43034 4 NULL 43045 NULL NULL 43056 6 6 43067 NULL NULL 4307# Test cases, Subquery Pattern 2 4308# Example SQ2.1: 4309explain SELECT * 4310FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); 4311id select_type table type possible_keys key key_len ref rows Extra 43121 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 43131 SIMPLE ot1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop) 43141 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop) 43152 MATERIALIZED it3 ALL NULL NULL NULL NULL 3 NULL 4316SELECT * 4317FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); 4318a a 43190 0 43206 6 4321# Example SQ2.2: 4322explain SELECT * 4323FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) 4324AND ot2.a IN (SELECT a FROM it3); 4325id select_type table type possible_keys key key_len ref rows Extra 43261 SIMPLE <subquery3> ALL NULL NULL NULL NULL NULL Using where 43271 SIMPLE ot1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop) 43281 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop) 43291 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 <subquery3>.a 1 NULL 43303 MATERIALIZED it3 ALL NULL NULL NULL NULL 3 NULL 43312 MATERIALIZED it2 ALL NULL NULL NULL NULL 4 NULL 4332SELECT * 4333FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) 4334AND ot2.a IN (SELECT a FROM it3); 4335a a 43360 0 43376 6 4338# More test cases 4339SELECT * 4340FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); 4341a a 43420 0 43436 6 4344SELECT * 4345FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); 4346a a 43470 0 43486 6 4349SELECT * 4350FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); 4351a a 43520 0 43536 6 4354SELECT * 4355FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); 4356a a 43570 0 43586 6 4359SELECT * 4360FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) 4361AND ot2.a IN (SELECT a+0 FROM it3); 4362a a 43630 0 43646 6 4365SELECT * 4366FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) 4367JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); 4368a a a 43690 0 0 43706 6 6 4371# Test cases, Subquery Pattern 3 4372# Example SQ3.1: 4373explain SELECT * 4374FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); 4375id select_type table type possible_keys key key_len ref rows Extra 43761 SIMPLE ot1 ALL NULL NULL NULL NULL 8 NULL 43771 SIMPLE it3 ALL NULL NULL NULL NULL 3 Using where; FirstMatch(ot1) 43781 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where 4379SELECT * 4380FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); 4381a a 43820 0 43831 NULL 43842 NULL 43853 NULL 43864 NULL 43875 NULL 43886 6 43897 NULL 4390# Example SQ3.2: 4391explain SELECT * 4392FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); 4393id select_type table type possible_keys key key_len ref rows Extra 43941 SIMPLE ot1 ALL NULL NULL NULL NULL 8 NULL 43951 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where 43961 SIMPLE it2 ALL NULL NULL NULL NULL 4 Using where; FirstMatch(ot2) 4397SELECT * 4398FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); 4399a a 44000 0 44011 NULL 44022 2 44033 NULL 44044 4 44055 NULL 44066 6 44077 NULL 4408# Example SQ3.3 4409explain SELECT * 4410FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) 4411AND ot2.a IN (SELECT a FROM it2); 4412id select_type table type possible_keys key key_len ref rows Extra 44131 SIMPLE ot1 ALL NULL NULL NULL NULL 8 NULL 44141 SIMPLE it1 ALL NULL NULL NULL NULL 8 Using where; FirstMatch(ot1) 44151 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where 44161 SIMPLE it2 ALL NULL NULL NULL NULL 4 Using where; FirstMatch(ot2) 4417SELECT * 4418FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) 4419AND ot2.a IN (SELECT a FROM it2); 4420a a 44210 0 44221 NULL 44232 2 44243 NULL 44254 4 44265 NULL 44276 6 44287 NULL 4429# Example SQ3.4 4430explain SELECT * 4431FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND 4432(ot1.a, ot2.a) IN (SELECT it1.a, it2.a 4433FROM it1 JOIN it2 ON it1.a=it2.a); 4434id select_type table type possible_keys key key_len ref rows Extra 44351 SIMPLE ot1 ALL NULL NULL NULL NULL 8 Start temporary 44361 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop) 44371 SIMPLE it2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop) 44381 SIMPLE it1 ALL NULL NULL NULL NULL 8 Using where; End temporary; Using join buffer (Block Nested Loop) 4439SELECT * 4440FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND 4441(ot1.a, ot2.a) IN (SELECT it1.a, it2.a 4442FROM it1 JOIN it2 ON it1.a=it2.a); 4443a a 44440 0 44451 NULL 44462 2 44473 NULL 44484 4 44495 NULL 44506 6 44517 NULL 4452# More test cases 4453SELECT * 4454FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); 4455a a 44560 0 44571 NULL 44582 NULL 44593 NULL 44604 NULL 44615 NULL 44626 6 44637 NULL 4464SELECT * 4465FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); 4466a a 44670 0 44681 NULL 44692 NULL 44703 NULL 44714 NULL 44725 NULL 44736 6 44747 NULL 4475SELECT * 4476FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); 4477a a 44780 0 44791 NULL 44802 2 44813 NULL 44824 4 44835 NULL 44846 6 44857 NULL 4486SELECT * 4487FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); 4488a a 44890 0 44901 NULL 44912 2 44923 NULL 44934 4 44945 NULL 44956 6 44967 NULL 4497SELECT * 4498FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) 4499AND ot2.a IN (SELECT a+0 FROM it2); 4500a a 45010 0 45021 NULL 45032 2 45043 NULL 45054 4 45065 NULL 45076 6 45087 NULL 4509SELECT * 4510FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND 4511(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 4512FROM it1 JOIN it2 ON it1.a=it2.a); 4513a a 45140 0 45151 NULL 45162 2 45173 NULL 45184 4 45195 NULL 45206 6 45217 NULL 4522SELECT * 4523FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) 4524LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); 4525a a a 45260 0 0 45271 NULL NULL 45282 NULL NULL 45293 NULL NULL 45304 NULL NULL 45315 NULL NULL 45326 6 6 45337 NULL NULL 4534SELECT * 4535FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) 4536LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); 4537a a a 45380 0 0 45391 NULL NULL 45402 NULL NULL 45413 NULL NULL 45424 NULL NULL 45435 NULL NULL 45446 6 6 45457 NULL NULL 4546# Test cases, Subquery Pattern 4 4547# Example SQ4.1: 4548explain SELECT * 4549FROM ot1 4550LEFT JOIN 4551(ot2 JOIN ot3 ON ot2.a=ot3.a) 4552ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4553id select_type table type possible_keys key key_len ref rows Extra 45541 SIMPLE ot1 ALL NULL NULL NULL NULL 8 NULL 45551 SIMPLE it1 ALL NULL NULL NULL NULL 8 Using where; FirstMatch(ot1) 45561 SIMPLE ot3 ALL NULL NULL NULL NULL 3 NULL 45571 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where 4558SELECT * 4559FROM ot1 4560LEFT JOIN 4561(ot2 JOIN ot3 ON ot2.a=ot3.a) 4562ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4563a a a 45640 0 0 45651 NULL NULL 45662 NULL NULL 45673 NULL NULL 45684 NULL NULL 45695 NULL NULL 45706 6 6 45717 NULL NULL 4572# Example SQ4.2: 4573explain SELECT * 4574FROM ot1 4575JOIN 4576(ot2 JOIN ot3 ON ot2.a=ot3.a) 4577ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4578id select_type table type possible_keys key key_len ref rows Extra 45791 SIMPLE ot3 ALL NULL NULL NULL NULL 3 Using where 45801 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop) 45811 SIMPLE ot1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop) 45821 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.ot3.a 1 NULL 45832 MATERIALIZED it1 ALL NULL NULL NULL NULL 8 NULL 4584SELECT * 4585FROM ot1 4586JOIN 4587(ot2 JOIN ot3 ON ot2.a=ot3.a) 4588ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4589a a a 45900 0 0 45916 6 6 4592# Example SQ4.3: 4593explain SELECT * 4594FROM ot1 4595JOIN 4596(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 4597ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4598id select_type table type possible_keys key key_len ref rows Extra 45991 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where 46001 SIMPLE ot3 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (Block Nested Loop) 46011 SIMPLE ot1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop) 46021 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.ot2.a 1 NULL 46032 MATERIALIZED it1 ALL NULL NULL NULL NULL 8 NULL 4604SELECT * 4605FROM ot1 4606JOIN 4607(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 4608ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4609a a a 46100 0 0 46112 2 NULL 46124 4 NULL 46136 6 6 4614# Example SQ4.4: 4615explain SELECT * 4616FROM ot1 4617LEFT JOIN 4618(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 4619ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4620id select_type table type possible_keys key key_len ref rows Extra 46211 SIMPLE ot1 ALL NULL NULL NULL NULL 8 NULL 46221 SIMPLE it1 ALL NULL NULL NULL NULL 8 Using where; FirstMatch(ot1) 46231 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where 46241 SIMPLE ot3 ALL NULL NULL NULL NULL 3 Using where 4625SELECT * 4626FROM ot1 4627LEFT JOIN 4628(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 4629ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4630a a a 46310 0 0 46321 NULL NULL 46332 2 NULL 46343 NULL NULL 46354 4 NULL 46365 NULL NULL 46376 6 6 46387 NULL NULL 4639# More test cases 4640SELECT * 4641FROM ot1 4642LEFT JOIN 4643(ot2 JOIN ot3 ON ot2.a=ot3.a+0) 4644ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4645a a a 46460 0 0 46471 NULL NULL 46482 NULL NULL 46493 NULL NULL 46504 NULL NULL 46515 NULL NULL 46526 6 6 46537 NULL NULL 4654SELECT * 4655FROM ot1 4656LEFT JOIN 4657(ot2 JOIN ot3 ON ot2.a=ot3.a) 4658ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); 4659a a a 46600 0 0 46611 NULL NULL 46622 NULL NULL 46633 NULL NULL 46644 NULL NULL 46655 NULL NULL 46666 6 6 46677 NULL NULL 4668SELECT * 4669FROM ot1 4670LEFT JOIN 4671(ot2 JOIN ot3 ON ot2.a=ot3.a) 4672ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); 4673a a a 46740 0 0 46751 NULL NULL 46762 NULL NULL 46773 NULL NULL 46784 NULL NULL 46795 NULL NULL 46806 6 6 46817 NULL NULL 4682SELECT * 4683FROM ot1 4684JOIN 4685(ot2 JOIN ot3 ON ot2.a=ot3.a+0) 4686ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4687a a a 46880 0 0 46896 6 6 4690SELECT * 4691FROM ot1 4692JOIN 4693(ot2 JOIN ot3 ON ot2.a=ot3.a) 4694ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); 4695a a a 46960 0 0 46976 6 6 4698SELECT * 4699FROM ot1 4700JOIN 4701(ot2 JOIN ot3 ON ot2.a=ot3.a) 4702ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); 4703a a a 47040 0 0 47056 6 6 4706SELECT * 4707FROM ot1 4708JOIN 4709(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) 4710ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4711a a a 47120 0 0 47132 2 NULL 47144 4 NULL 47156 6 6 4716SELECT * 4717FROM ot1 4718JOIN 4719(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 4720ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); 4721a a a 47220 0 0 47232 2 NULL 47244 4 NULL 47256 6 6 4726SELECT * 4727FROM ot1 4728JOIN 4729(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 4730ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); 4731a a a 47320 0 0 47332 2 NULL 47344 4 NULL 47356 6 6 4736SELECT * 4737FROM ot1 4738LEFT JOIN 4739(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) 4740ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4741a a a 47420 0 0 47431 NULL NULL 47442 2 NULL 47453 NULL NULL 47464 4 NULL 47475 NULL NULL 47486 6 6 47497 NULL NULL 4750SELECT * 4751FROM ot1 4752LEFT JOIN 4753(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 4754ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); 4755a a a 47560 0 0 47571 NULL NULL 47582 2 NULL 47593 NULL NULL 47604 4 NULL 47615 NULL NULL 47626 6 6 47637 NULL NULL 4764SELECT * 4765FROM ot1 4766LEFT JOIN 4767(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 4768ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); 4769a a a 47700 0 0 47711 NULL NULL 47722 2 NULL 47733 NULL NULL 47744 4 NULL 47755 NULL NULL 47766 6 6 47777 NULL NULL 4778SELECT * 4779FROM ot1 4780LEFT JOIN 4781(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 4782ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) 4783LEFT JOIN 4784ot1 AS ot4 4785ON ot2.a=ot4.a; 4786a a a a 47870 0 0 0 47881 NULL NULL NULL 47892 2 NULL 2 47903 NULL NULL NULL 47914 4 NULL 4 47925 NULL NULL NULL 47936 6 6 6 47947 NULL NULL NULL 4795SELECT * 4796FROM ot1 4797LEFT JOIN 4798(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a 4799LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) 4800ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 4801a a a a 48020 0 0 0 48031 NULL NULL NULL 48042 2 NULL NULL 48053 NULL NULL NULL 48064 4 NULL NULL 48075 NULL NULL NULL 48086 6 6 6 48097 NULL NULL NULL 4810DROP TABLE ot1,ot2,ot3,it1,it2,it3; 4811CREATE TABLE t ( 4812a INTEGER DEFAULT NULL 4813) ENGINE=InnoDB; 4814INSERT INTO t VALUES (1); 4815CREATE TABLE t2 ( 4816a INTEGER DEFAULT NULL 4817) ENGINE=InnoDB; 4818INSERT INTO t2 VALUES (1),(1); 4819CREATE TABLE t4 ( 4820a INTEGER DEFAULT NULL 4821) ENGINE=InnoDB; 4822INSERT INTO t4 VALUES (1),(1); 4823CREATE TABLE v ( 4824a INTEGER DEFAULT NULL 4825) ENGINE=InnoDB; 4826INSERT INTO v VALUES (1),(1); 4827explain SELECT * 4828FROM t AS t1 4829LEFT JOIN 4830(t2 4831LEFT JOIN t AS t3 4832ON t3.a IN (SELECT a FROM t AS it) 4833JOIN t4 4834ON t4.a=100 4835) 4836ON TRUE 4837WHERE t1.a IN (SELECT * FROM v AS it2); 4838id select_type table type possible_keys key key_len ref rows Extra 48391 SIMPLE t1 ALL NULL NULL NULL NULL 1 NULL 48401 SIMPLE it2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1); Using join buffer (Block Nested Loop) 48411 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where 48421 SIMPLE t3 ALL NULL NULL NULL NULL 1 Using where 48431 SIMPLE it ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t3) 48441 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where 4845SELECT * 4846FROM t AS t1 4847LEFT JOIN 4848(t2 4849LEFT JOIN t AS t3 4850ON t3.a IN (SELECT a FROM t AS it) 4851JOIN t4 4852ON t4.a=100 4853) 4854ON TRUE 4855WHERE t1.a IN (SELECT * FROM v AS it2); 4856a a a a 48571 NULL NULL NULL 4858DROP TABLE t,t2,t4,v; 4859# End of WL#5561 4860# 4861# Bug#48868: Left outer join in subquery causes segmentation fault in 4862# make_join_select. 4863# 4864CREATE TABLE t1 (i INTEGER); 4865INSERT INTO t1 VALUES (1); 4866INSERT INTO t1 VALUES (2); 4867CREATE TABLE t2 (i INTEGER); 4868INSERT INTO t2 VALUES(1); 4869CREATE TABLE t3 (i INTEGER); 4870INSERT INTO t3 VALUES (1); 4871INSERT INTO t3 VALUES (2); 4872SELECT * FROM t1 WHERE (t1.i) IN 4873(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 4874i 48751 4876DROP TABLE t1, t2, t3; 4877 4878Bug#37899: Wrongly checked optimization prerequisite caused failed 4879assertion. 4880 4881CREATE TABLE t1 ( 4882`pk` int(11), 4883`varchar_nokey` varchar(5) 4884); 4885INSERT INTO t1 VALUES 4886(1,'qk'),(2,'j'),(3,'aew'); 4887SELECT * 4888FROM t1 4889WHERE varchar_nokey IN ( 4890SELECT 4891varchar_nokey 4892FROM 4893t1 4894) XOR pk = 30; 4895pk varchar_nokey 48961 qk 48972 j 48983 aew 4899drop table t1; 4900# 4901# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING 4902# 4903CREATE TABLE t1 ( 4904pk int(11) NOT NULL AUTO_INCREMENT, 4905int_nokey int(11) NOT NULL, 4906time_key time NOT NULL, 4907datetime_key datetime NOT NULL, 4908datetime_nokey datetime NOT NULL, 4909varchar_key varchar(1) NOT NULL, 4910varchar_nokey varchar(1) NOT NULL, 4911PRIMARY KEY (pk), 4912KEY time_key (time_key), 4913KEY datetime_key (datetime_key), 4914KEY varchar_key (varchar_key) 4915); 4916INSERT INTO t1 VALUES 4917(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), 4918(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), 4919(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), 4920(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), 4921(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), 4922(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), 4923(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), 4924(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), 4925(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), 4926(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), 4927(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), 4928(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), 4929(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), 4930(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), 4931(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), 4932(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), 4933(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), 4934(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), 4935(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), 4936(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); 4937CREATE TABLE t2 ( 4938pk int(11) NOT NULL AUTO_INCREMENT, 4939int_nokey int(11) NOT NULL, 4940time_key time NOT NULL, 4941datetime_key datetime NOT NULL, 4942datetime_nokey datetime NOT NULL, 4943varchar_key varchar(1) NOT NULL, 4944varchar_nokey varchar(1) NOT NULL, 4945PRIMARY KEY (pk), 4946KEY time_key (time_key), 4947KEY datetime_key (datetime_key), 4948KEY varchar_key (varchar_key) 4949); 4950INSERT INTO t2 VALUES 4951(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), 4952(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); 4953SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR 4954WHERE 4955OUTR.varchar_nokey IN (SELECT 4956INNR . varchar_nokey AS Y 4957FROM t2 AS INNR 4958WHERE 4959INNR . datetime_key >= INNR . time_key OR 4960INNR . pk = INNR . int_nokey 4961) 4962AND OUTR . varchar_nokey <= 'w' 4963HAVING X > '2012-12-12'; 4964X 4965drop table t1, t2; 4966 4967Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order 4968with semijoin=on" 4969 4970CREATE TABLE t1 ( 4971varchar_key varchar(1) DEFAULT NULL, 4972KEY varchar_key (varchar_key) 4973); 4974CREATE TABLE t2 ( 4975varchar_key varchar(1) DEFAULT NULL, 4976KEY varchar_key (varchar_key) 4977); 4978INSERT INTO t2 VALUES 4979(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), 4980('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), 4981('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), 4982('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), 4983('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), 4984('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), 4985('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), 4986('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); 4987CREATE TABLE t3 ( 4988varchar_key varchar(1) DEFAULT NULL, 4989KEY varchar_key (varchar_key) 4990) ENGINE=MyISAM DEFAULT CHARSET=latin1; 4991INSERT INTO t3 VALUES 4992(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), 4993('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); 4994SELECT varchar_key FROM t3 4995WHERE (SELECT varchar_key FROM t3 4996WHERE (varchar_key,varchar_key) 4997IN (SELECT t1.varchar_key, t2 .varchar_key 4998FROM t1 RIGHT JOIN t2 ON t1.varchar_key 4999) 5000); 5001varchar_key 5002DROP TABLE t1, t2, t3; 5003# 5004# Bug#46556 Returning incorrect, empty results for some IN subqueries 5005# w/semijoin=on 5006# 5007CREATE TABLE t0 ( 5008pk INTEGER, 5009vkey VARCHAR(1), 5010vnokey VARCHAR(1), 5011PRIMARY KEY (pk), 5012KEY vkey(vkey) 5013); 5014INSERT INTO t0 5015VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); 5016EXPLAIN EXTENDED SELECT vkey FROM t0 WHERE pk IN 5017(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); 5018id select_type table type possible_keys key key_len ref rows filtered Extra 50191 SIMPLE t0 ALL PRIMARY NULL NULL NULL 5 100.00 NULL 50201 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t0.pk 1 100.00 Using join buffer (Batched Key Access) 50211 SIMPLE t2 index vkey vkey 4 NULL 5 80.00 Using where; Using index; FirstMatch(t1); Using join buffer (Block Nested Loop) 5022Warnings: 5023Note 1003 /* select#1 */ select `test`.`t0`.`vkey` AS `vkey` from `test`.`t0` `t1` semi join (`test`.`t0` `t2`) join `test`.`t0` where ((`test`.`t2`.`vkey` = `test`.`t1`.`vnokey`) and (`test`.`t1`.`pk` = `test`.`t0`.`pk`)) 5024SELECT vkey FROM t0 WHERE pk IN 5025(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); 5026vkey 5027g 5028n 5029t 5030u 5031v 5032DROP TABLE t0; 5033# End of bug#46556 5034 5035Bug#48834: Procedure with view + subquery + semijoin=on 5036crashes on second call. 5037 5038CREATE TABLE t1 ( t1field integer, primary key (t1field)); 5039CREATE TABLE t2 ( t2field integer, primary key (t2field)); 5040CREATE VIEW v1 AS 5041SELECT t1field as v1field 5042FROM t1 A 5043WHERE A.t1field IN (SELECT t1field FROM t2 ); 5044CREATE VIEW v2 AS 5045SELECT t2field as v2field 5046FROM t2 A 5047WHERE A.t2field IN (SELECT t2field FROM t2 ); 5048CREATE PROCEDURE p1 () 5049BEGIN 5050SELECT v1field 5051FROM v1 5052WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); 5053END| 5054INSERT INTO t1 VALUES (1),(2),(3); 5055INSERT INTO t2 VALUES (2),(3),(4); 5056CALL p1; 5057v1field 50582 50593 5060CALL p1; 5061v1field 50622 50633 5064DROP TABLE t1,t2; 5065DROP VIEW v1,v2; 5066DROP PROCEDURE p1; 5067# End of BUG#48834 5068# 5069# Bug#46692 "Crash occurring on queries with nested FROM subqueries 5070# using materialization." 5071# 5072CREATE TABLE t1 ( 5073pk INTEGER PRIMARY KEY, 5074int_key INTEGER, 5075KEY int_key(int_key) 5076); 5077INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); 5078CREATE TABLE t2 ( 5079pk INTEGER PRIMARY KEY, 5080int_key INTEGER, 5081KEY int_key(int_key) 5082); 5083INSERT INTO t2 VALUES (1,7),(2,2); 5084SELECT * FROM t1 WHERE (140, 4) IN 5085(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); 5086pk int_key 5087DROP TABLE t1, t2; 5088# 5089# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query 5090# causes crash." 5091# 5092CREATE TABLE t1 ( 5093pk INTEGER PRIMARY KEY, 5094int_nokey INTEGER, 5095int_key INTEGER, 5096date_key DATE, 5097datetime_nokey DATETIME, 5098varchar_nokey VARCHAR(1) 5099); 5100CREATE TABLE t2 ( 5101date_nokey DATE 5102); 5103CREATE TABLE t3 ( 5104pk INTEGER PRIMARY KEY, 5105int_nokey INTEGER, 5106date_key date, 5107varchar_key VARCHAR(1), 5108varchar_nokey VARCHAR(1), 5109KEY date_key (date_key) 5110); 5111SELECT date_key FROM t1 5112WHERE (int_key, int_nokey) 5113IN (SELECT t3.int_nokey, t3.pk 5114FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) 5115WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk 5116) 5117AND (varchar_nokey <> 'f' OR NOT int_key < 7); 5118date_key 5119# 5120# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery 5121# + AND in outer query". 5122# 5123INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), 5124(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), 5125(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), 5126(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), 5127(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), 5128(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), 5129(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), 5130(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); 5131INSERT INTO t3 VALUES (1,9,'0000-00-00','b','b'), 5132(2,2,'2002-09-17','h','h'); 5133SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey 5134WHERE t1.varchar_nokey 5135IN (SELECT varchar_nokey FROM t1 5136WHERE (pk) 5137IN (SELECT t3.int_nokey 5138FROM t3 LEFT JOIN t1 ON t1.varchar_nokey 5139WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' 5140 ) 5141); 5142varchar_nokey 5143DROP TABLE t1, t2, t3; 5144# 5145# Bug#45219 "Crash on SELECT DISTINCT query containing a 5146# LEFT JOIN in subquery" 5147# 5148CREATE TABLE t1 ( 5149pk INTEGER NOT NULL, 5150int_nokey INTEGER NOT NULL, 5151datetime_key DATETIME NOT NULL, 5152varchar_key VARCHAR(1) NOT NULL, 5153PRIMARY KEY (pk), 5154KEY datetime_key (datetime_key), 5155KEY varchar_key (varchar_key) 5156); 5157INSERT INTO t1 VALUES 5158(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), 5159(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), 5160(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), 5161(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), 5162(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), 5163(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), 5164(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), 5165(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), 5166(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), 5167(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); 5168CREATE TABLE t2 LIKE t1; 5169INSERT INTO t2 VALUES 5170(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), 5171(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), 5172(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), 5173(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), 5174(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), 5175(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), 5176(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), 5177(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), 5178(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), 5179(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); 5180CREATE TABLE t3 LIKE t1; 5181INSERT INTO t3 VALUES 5182(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); 5183SELECT DISTINCT datetime_key FROM t1 5184WHERE (int_nokey, pk) 5185IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key) 5186AND pk = 9; 5187datetime_key 5188DROP TABLE t1, t2, t3; 5189# 5190# Bug#46550 Azalea returning duplicate results for some IN subqueries 5191# w/ semijoin=on 5192# 5193DROP TABLE IF EXISTS t0, t1, t2; 5194CREATE TABLE t0 ( 5195int_key int(11) DEFAULT NULL, 5196varchar_key varchar(1) DEFAULT NULL, 5197varchar_nokey varchar(1) DEFAULT NULL, 5198KEY int_key (int_key), 5199KEY varchar_key (varchar_key,int_key) 5200); 5201INSERT INTO t0 VALUES 5202(1,'m','m'), 5203(40,'h','h'), 5204(1,'r','r'), 5205(1,'h','h'), 5206(9,'x','x'), 5207(NULL,'q','q'), 5208(NULL,'k','k'), 5209(7,'l','l'), 5210(182,'k','k'), 5211(202,'a','a'), 5212(7,'x','x'), 5213(6,'j','j'), 5214(119,'z','z'), 5215(4,'d','d'), 5216(5,'h','h'), 5217(1,'u','u'), 5218(3,'q','q'), 5219(7,'a','a'), 5220(3,'e','e'), 5221(6,'l','l'); 5222CREATE TABLE t1 ( 5223int_key int(11) DEFAULT NULL, 5224varchar_key varchar(1) DEFAULT NULL, 5225varchar_nokey varchar(1) DEFAULT NULL, 5226KEY int_key (int_key), 5227KEY varchar_key (varchar_key,int_key) 5228); 5229INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); 5230CREATE TABLE t2 ( 5231int_key int(11) DEFAULT NULL, 5232varchar_key varchar(1) DEFAULT NULL, 5233varchar_nokey varchar(1) DEFAULT NULL, 5234KEY int_key (int_key), 5235KEY varchar_key (varchar_key,int_key) 5236); 5237INSERT INTO t2 VALUES (123,NULL,NULL); 5238SELECT int_key 5239FROM t0 5240WHERE varchar_nokey IN ( 5241SELECT t1 .varchar_key from t1 5242); 5243int_key 52449 52457 5246SELECT t0.int_key 5247FROM t0 5248WHERE t0.varchar_nokey IN ( 5249SELECT t1_1 .varchar_key 5250FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key 5251); 5252int_key 52539 52547 5255EXPLAIN 5256SELECT t0.int_key 5257FROM t0 5258WHERE t0.varchar_nokey IN ( 5259SELECT t1_1 .varchar_key 5260FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key 5261); 5262id select_type table type possible_keys key key_len ref rows Extra 52631 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 52641 SIMPLE t0 ALL NULL NULL NULL NULL 20 Using where; Using join buffer (Block Nested Loop) 52652 MATERIALIZED t1_1 index varchar_key varchar_key 9 NULL 2 Using where; Using index 52662 MATERIALIZED t1_2 index NULL int_key 5 NULL 2 Using index; Using join buffer (Block Nested Loop) 5267SELECT t0.int_key 5268FROM t0, t2 5269WHERE t0.varchar_nokey IN ( 5270SELECT t1_1 .varchar_key 5271FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key 5272); 5273int_key 52749 52757 5276EXPLAIN 5277SELECT t0.int_key 5278FROM t0, t2 5279WHERE t0.varchar_nokey IN ( 5280SELECT t1_1 .varchar_key 5281FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key 5282); 5283id select_type table type possible_keys key key_len ref rows Extra 52841 SIMPLE t2 system NULL NULL NULL NULL 1 NULL 52851 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 52861 SIMPLE t0 ALL NULL NULL NULL NULL 20 Using where; Using join buffer (Block Nested Loop) 52872 MATERIALIZED t1_1 index varchar_key varchar_key 9 NULL 2 Using where; Using index 52882 MATERIALIZED t1_2 index NULL int_key 5 NULL 2 Using index; Using join buffer (Block Nested Loop) 5289DROP TABLE t0, t1, t2; 5290# End of bug#46550 5291 5292Bug #48073 Subquery on char columns from view crashes Mysql 5293 5294DROP TABLE IF EXISTS t1, t2; 5295DROP VIEW IF EXISTS v1; 5296CREATE TABLE t1 ( 5297city VARCHAR(50) NOT NULL, 5298country_id SMALLINT UNSIGNED NOT NULL 5299); 5300INSERT INTO t1 VALUES 5301('Batna',2), 5302('Bchar',2), 5303('Skikda',2), 5304('Tafuna',3), 5305('Algeria',2) ; 5306CREATE TABLE t2 ( 5307country_id SMALLINT UNSIGNED NOT NULL, 5308country VARCHAR(50) NOT NULL 5309); 5310INSERT INTO t2 VALUES 5311(2,'Algeria'), 5312(3,'American Samoa') ; 5313CREATE VIEW v1 AS 5314SELECT country_id, country 5315FROM t2 5316WHERE LEFT(country,1) = "A" 5317; 5318SELECT city, country_id 5319FROM t1 5320WHERE city IN ( 5321SELECT country 5322FROM t2 5323WHERE LEFT(country, 1) = "A" 5324); 5325city country_id 5326Algeria 2 5327SELECT city, country_id 5328FROM t1 5329WHERE city IN ( 5330SELECT country 5331FROM v1 5332); 5333city country_id 5334Algeria 2 5335drop table t1, t2; 5336drop view v1; 5337# End of bug#48073 5338 5339Bug#49097 subquery with view generates wrong result with 5340non-prepared statement 5341 5342DROP TABLE IF EXISTS t1, t2; 5343DROP VIEW IF EXISTS v1; 5344CREATE TABLE t1 ( 5345city VARCHAR(50) NOT NULL, 5346country_id SMALLINT UNSIGNED NOT NULL 5347); 5348INSERT INTO t1 VALUES 5349('Batna',2), 5350('Bchar',2), 5351('Skikda',2), 5352('Tafuna',3), 5353('Algeria',2) ; 5354CREATE TABLE t2 ( 5355country_id SMALLINT UNSIGNED NOT NULL, 5356country VARCHAR(50) NOT NULL 5357); 5358INSERT INTO t2 VALUES 5359(2,'Algeria'), 5360(3,'XAmerican Samoa') ; 5361CREATE VIEW v1 AS 5362SELECT country_id, country 5363FROM t2 5364WHERE LEFT(country,1) = "A" 5365; 5366SELECT city, country_id 5367FROM t1 5368WHERE country_id IN ( 5369SELECT country_id 5370FROM t2 5371WHERE LEFT(country,1) = "A" 5372); 5373city country_id 5374Batna 2 5375Bchar 2 5376Skikda 2 5377Algeria 2 5378SELECT city, country_id 5379FROM t1 5380WHERE country_id IN ( 5381SELECT country_id 5382FROM v1 5383); 5384city country_id 5385Batna 2 5386Bchar 2 5387Skikda 2 5388Algeria 2 5389PREPARE stmt FROM 5390" 5391SELECT city, country_id 5392FROM t1 5393WHERE country_id IN ( 5394 SELECT country_id 5395 FROM v1 5396); 5397"; 5398execute stmt; 5399city country_id 5400Batna 2 5401Bchar 2 5402Skikda 2 5403Algeria 2 5404deallocate prepare stmt; 5405drop table t1, t2; 5406drop view v1; 5407# End of Bug#49097 5408# 5409# Bug#49198 Wrong result for second call of procedure 5410# with view in subselect. 5411# 5412CREATE TABLE t1 (t1field integer, primary key (t1field)); 5413CREATE TABLE t2 (t2field integer, primary key (t2field)); 5414CREATE TABLE t3 (t3field integer, primary key (t3field)); 5415CREATE VIEW v2 AS SELECT * FROM t2; 5416CREATE VIEW v3 AS SELECT * FROM t3; 5417INSERT INTO t1 VALUES(1),(2); 5418INSERT INTO t2 VALUES(1),(2); 5419INSERT INTO t3 VALUES(1),(2); 5420PREPARE stmt FROM 5421" 5422SELECT t1field 5423FROM t1 5424WHERE t1field IN (SELECT * FROM v2); 5425"; 5426EXECUTE stmt; 5427t1field 54281 54292 5430EXECUTE stmt; 5431t1field 54321 54332 5434PREPARE stmt FROM 5435" 5436EXPLAIN 5437SELECT t1field 5438FROM t1 5439WHERE t1field IN (SELECT * FROM v2) 5440 AND t1field IN (SELECT * FROM v3) 5441"; 5442EXECUTE stmt; 5443id select_type table type possible_keys key key_len ref rows Extra 54441 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 2 Using index 54451 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 Using index 54461 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 Using index 5447EXECUTE stmt; 5448id select_type table type possible_keys key key_len ref rows Extra 54491 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 2 Using index 54501 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 Using index 54511 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 Using index 5452DROP TABLE t1, t2, t3; 5453DROP VIEW v2, v3; 5454# End of Bug#49198 5455# 5456# Bug#48623 Multiple subqueries are optimized incorrectly 5457# 5458CREATE TABLE ot(val VARCHAR(10)); 5459CREATE TABLE it1(val VARCHAR(10)); 5460CREATE TABLE it2(val VARCHAR(10)); 5461INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); 5462INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); 5463INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); 5464EXPLAIN 5465SELECT * 5466FROM ot 5467WHERE ot.val IN (SELECT it1.val FROM it1 5468WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') 5469AND ot.val IN (SELECT it2.val FROM it2 5470WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); 5471id select_type table type possible_keys key key_len ref rows Extra 54721 SIMPLE ot ALL NULL NULL NULL NULL 5 Using where 54731 SIMPLE <subquery3> eq_ref <auto_key> <auto_key> 13 test.ot.val 1 NULL 54741 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 13 test.ot.val 1 NULL 54753 MATERIALIZED it2 ALL NULL NULL NULL NULL 5 Using where 54762 MATERIALIZED it1 ALL NULL NULL NULL NULL 6 Using where 5477SELECT * 5478FROM ot 5479WHERE ot.val IN (SELECT it1.val FROM it1 5480WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') 5481AND ot.val IN (SELECT it2.val FROM it2 5482WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); 5483val 5484aaa 5485eee 5486DROP TABLE ot; 5487DROP TABLE it1; 5488DROP TABLE it2; 5489# End of Bug#48623 5490# 5491# Bug #51487 Assertion failure when semi-join flattening occurs 5492# for a subquery in HAVING 5493# 5494CREATE TABLE t1 (a INT, b INT); 5495INSERT INTO t1 VALUES (1,10),(2,11),(1,13); 5496CREATE TABLE t2 AS SELECT * FROM t1; 5497CREATE TABLE t3 AS SELECT * FROM t1; 5498SELECT COUNT(*) FROM t1 5499GROUP BY t1.a 5500HAVING t1.a IN (SELECT t3.a FROM t3 5501WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); 5502COUNT(*) 55032 55041 5505DROP TABLE t1, t2, t3; 5506# End of Bug#51487 5507# 5508# BUG#38075: Wrong result: rows matching a subquery with outer join not returned 5509# 5510DROP TABLE IF EXISTS ot1, it1, it2; 5511CREATE TABLE it2 ( 5512int_key int(11) NOT NULL, 5513datetime_key datetime NOT NULL, 5514KEY int_key (int_key), 5515KEY datetime_key (datetime_key) 5516); 5517INSERT INTO it2 VALUES 5518(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), 5519(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), 5520(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), 5521(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), 5522(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), 5523(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), 5524(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), 5525(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), 5526(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), 5527(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); 5528CREATE TABLE ot1 ( 5529int_nokey int(11) NOT NULL, 5530int_key int(11) NOT NULL, 5531KEY int_key (int_key) 5532); 5533INSERT INTO ot1 VALUES 5534(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), 5535(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); 5536CREATE TABLE it1 ( 5537int_nokey int(11) NOT NULL, 5538int_key int(11) NOT NULL, 5539KEY int_key (int_key) 5540); 5541INSERT INTO it1 VALUES 5542(9,5), (0,4); 5543SELECT int_key FROM ot1 5544WHERE int_nokey IN (SELECT it2.int_key 5545FROM it1 LEFT JOIN it2 ON it2.datetime_key); 5546int_key 55470 55480 55490 55500 55510 55520 55532 55542 55553 55565 55575 55587 55597 55607 55618 55629 55639 5564EXPLAIN 5565SELECT int_key FROM ot1 5566WHERE int_nokey IN (SELECT it2.int_key 5567FROM it1 LEFT JOIN it2 ON it2.datetime_key); 5568id select_type table type possible_keys key key_len ref rows Extra 55691 SIMPLE it1 index NULL int_key 4 NULL 2 Using index; Start temporary 55701 SIMPLE ot1 ALL NULL NULL NULL NULL 20 Using join buffer (Block Nested Loop) 55711 SIMPLE it2 ref int_key int_key 4 test.ot1.int_nokey 2 Using where; End temporary; Using join buffer (Batched Key Access) 5572DROP TABLE ot1, it1, it2; 5573# End of BUG#38075 5574# 5575# BUG#50089: Second call of procedure with view in subselect crashes server 5576# 5577CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); 5578CREATE VIEW v1 AS 5579SELECT t1field AS v1field 5580FROM t1 a 5581WHERE a.t1field IN (SELECT t1field FROM t1); 5582INSERT INTO t1 VALUES(1),(2); 5583SELECT t1field 5584FROM t1 5585WHERE t1field IN (SELECT v1field FROM v1); 5586t1field 55871 55882 5589EXPLAIN 5590SELECT t1field 5591FROM t1 5592WHERE t1field IN (SELECT v1field FROM v1); 5593id select_type table type possible_keys key key_len ref rows Extra 55941 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 2 Using index 55951 SIMPLE a eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 Using index 55961 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 Using index 5597SELECT t1.t1field 5598FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); 5599t1field 56001 56011 56022 56032 5604EXPLAIN 5605SELECT t1field 5606FROM t1 5607WHERE t1field IN (SELECT v1field FROM v1); 5608id select_type table type possible_keys key key_len ref rows Extra 56091 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 2 Using index 56101 SIMPLE a eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 Using index 56111 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 Using index 5612CREATE PROCEDURE p1() 5613BEGIN 5614SELECT t1field 5615FROM t1 5616WHERE t1field IN (SELECT v1field FROM v1); 5617END| 5618CALL p1; 5619t1field 56201 56212 5622CALL p1; 5623t1field 56241 56252 5626PREPARE stmt FROM 5627" 5628SELECT t1field 5629FROM t1 5630WHERE t1field IN (SELECT v1field FROM v1); 5631"; 5632EXECUTE stmt; 5633t1field 56341 56352 5636EXECUTE stmt; 5637t1field 56381 56392 5640DROP PROCEDURE p1; 5641DROP VIEW v1; 5642DROP TABLE t1; 5643# End of BUG#50089 5644# 5645# Bug#45191: Incorrectly initialized semi-join led to a wrong result. 5646# 5647CREATE TABLE STAFF (EMPNUM CHAR(3) NOT NULL, 5648EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)); 5649CREATE TABLE PROJ (PNUM CHAR(3) NOT NULL, 5650PNAME CHAR(20), PTYPE CHAR(6), 5651BUDGET DECIMAL(9), 5652CITY CHAR(15)); 5653CREATE TABLE WORKS (EMPNUM CHAR(3) NOT NULL, 5654PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)); 5655INSERT INTO STAFF VALUES ('E1','Alice',12,'Deale'); 5656INSERT INTO STAFF VALUES ('E2','Betty',10,'Vienna'); 5657INSERT INTO STAFF VALUES ('E3','Carmen',13,'Vienna'); 5658INSERT INTO STAFF VALUES ('E4','Don',12,'Deale'); 5659INSERT INTO STAFF VALUES ('E5','Ed',13,'Akron'); 5660INSERT INTO PROJ VALUES ('P1','MXSS','Design',10000,'Deale'); 5661INSERT INTO PROJ VALUES ('P2','CALM','Code',30000,'Vienna'); 5662INSERT INTO PROJ VALUES ('P3','SDP','Test',30000,'Tampa'); 5663INSERT INTO PROJ VALUES ('P4','SDP','Design',20000,'Deale'); 5664INSERT INTO PROJ VALUES ('P5','IRM','Test',10000,'Vienna'); 5665INSERT INTO PROJ VALUES ('P6','PAYR','Design',50000,'Deale'); 5666INSERT INTO WORKS VALUES ('E1','P1',40); 5667INSERT INTO WORKS VALUES ('E1','P2',20); 5668INSERT INTO WORKS VALUES ('E1','P3',80); 5669INSERT INTO WORKS VALUES ('E1','P4',20); 5670INSERT INTO WORKS VALUES ('E1','P5',12); 5671INSERT INTO WORKS VALUES ('E1','P6',12); 5672INSERT INTO WORKS VALUES ('E2','P1',40); 5673INSERT INTO WORKS VALUES ('E2','P2',80); 5674INSERT INTO WORKS VALUES ('E3','P2',20); 5675INSERT INTO WORKS VALUES ('E4','P2',20); 5676INSERT INTO WORKS VALUES ('E4','P4',40); 5677INSERT INTO WORKS VALUES ('E4','P5',80); 5678explain SELECT EMPNUM, EMPNAME 5679FROM STAFF 5680WHERE EMPNUM IN 5681(SELECT EMPNUM FROM WORKS 5682WHERE PNUM IN 5683(SELECT PNUM FROM PROJ)); 5684id select_type table type possible_keys key key_len ref rows Extra 56851 SIMPLE STAFF ALL NULL NULL NULL NULL 5 Using where 56861 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 3 test.STAFF.EMPNUM 1 NULL 56872 MATERIALIZED PROJ ALL NULL NULL NULL NULL 6 NULL 56882 MATERIALIZED WORKS ALL NULL NULL NULL NULL 12 Using where; Using join buffer (Block Nested Loop) 5689SELECT EMPNUM, EMPNAME 5690FROM STAFF 5691WHERE EMPNUM IN 5692(SELECT EMPNUM FROM WORKS 5693WHERE PNUM IN 5694(SELECT PNUM FROM PROJ)); 5695EMPNUM EMPNAME 5696E1 Alice 5697E2 Betty 5698E3 Carmen 5699E4 Don 5700drop table STAFF,WORKS,PROJ; 5701# End of bug#45191 5702# 5703# BUG#36896: Server crash on SELECT FROM DUAL 5704# 5705create table t1 (a int); 5706select 1 as res from dual where (1) in (select * from t1); 5707res 5708drop table t1; 5709 5710BUG#40118 Crash when running Batched Key Access and requiring one match for each key 5711 5712create table t0(a int); 5713insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 5714create table t1 (a int, key(a)); 5715insert into t1 select * from t0; 5716alter table t1 add b int not null, add filler char(200); 5717insert into t1 select * from t1; 5718insert into t1 select * from t1; 5719select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); 5720a 57210 57221 57232 57243 57254 57265 57276 57287 57298 57309 5731drop table t0, t1; 5732# 5733# BUG#32665 Query with dependent subquery is too slow 5734# 5735create table t1 ( 5736idIndividual int primary key 5737); 5738insert into t1 values (1),(2); 5739create table t2 ( 5740idContact int primary key, 5741contactType int, 5742idObj int 5743); 5744insert into t2 values (1,1,1),(2,2,2),(3,3,3); 5745create table t3 ( 5746idAddress int primary key, 5747idContact int, 5748postalStripped varchar(100) 5749); 5750insert into t3 values (1,1, 'foo'), (2,2,'bar'); 5751The following must be converted to a semi-join: 5752explain extended SELECT a.idIndividual FROM t1 a 5753WHERE a.idIndividual IN 5754( SELECT c.idObj FROM t3 cona 5755INNER JOIN t2 c ON c.idContact=cona.idContact 5756WHERE cona.postalStripped='T2H3B2' 5757 ); 5758id select_type table type possible_keys key key_len ref rows filtered Extra 57591 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL 0.00 NULL 57601 SIMPLE a index PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using index; Using join buffer (Block Nested Loop) 57612 MATERIALIZED cona ALL NULL NULL NULL NULL 2 100.00 Using where 57622 MATERIALIZED c eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 Using join buffer (Batched Key Access) 5763Warnings: 5764Note 1003 /* select#1 */ select `test`.`a`.`idIndividual` AS `idIndividual` from `test`.`t1` `a` semi join (`test`.`t3` `cona` join `test`.`t2` `c`) where ((`test`.`c`.`idContact` = `test`.`cona`.`idContact`) and (`test`.`a`.`idIndividual` = `<subquery2>`.`idObj`) and (`test`.`cona`.`postalStripped` = 'T2H3B2')) 5765drop table t1,t2,t3; 5766CREATE TABLE t1 (one int, two int, flag char(1)); 5767CREATE TABLE t2 (one int, two int, flag char(1)); 5768INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); 5769INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); 5770SELECT * FROM t1 5771WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); 5772one two flag 57735 6 N 57747 8 N 5775SELECT * FROM t1 5776WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); 5777one two flag 57785 6 N 57797 8 N 5780insert into t2 values (null,null,'N'); 5781insert into t2 values (null,3,'0'); 5782insert into t2 values (null,5,'0'); 5783insert into t2 values (10,null,'0'); 5784insert into t1 values (10,3,'0'); 5785insert into t1 values (10,5,'0'); 5786insert into t1 values (10,10,'0'); 5787SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; 5788one two test 57891 2 NULL 57902 3 NULL 57913 4 NULL 57925 6 1 57937 8 1 579410 3 NULL 579510 5 NULL 579610 10 NULL 5797SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); 5798one two 57995 6 58007 8 5801SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; 5802one two test 58031 2 NULL 58042 3 NULL 58053 4 NULL 58065 6 1 58077 8 1 580810 3 NULL 580910 5 NULL 581010 10 NULL 5811SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; 5812one two test 58131 2 0 58142 3 NULL 58153 4 0 58165 6 0 58177 8 0 581810 3 NULL 581910 5 NULL 582010 10 NULL 5821SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; 5822one two test 58231 2 0 58242 3 NULL 58253 4 0 58265 6 0 58277 8 0 582810 3 NULL 582910 5 NULL 583010 10 NULL 5831explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; 5832id select_type table type possible_keys key key_len ref rows filtered Extra 58331 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 NULL 58342 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where 5835Warnings: 5836Note 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` 5837explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); 5838id select_type table type possible_keys key key_len ref rows filtered Extra 58391 SIMPLE t1 ALL NULL NULL NULL NULL 8 100.00 Using where 58401 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 10 test.t1.one,test.t1.two 1 100.00 NULL 58412 MATERIALIZED t2 ALL NULL NULL NULL NULL 9 100.00 Using where 5842Warnings: 5843Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`<subquery2>`.`two` = `test`.`t1`.`two`) and (`<subquery2>`.`one` = `test`.`t1`.`one`) and (`test`.`t2`.`flag` = 'N')) 5844explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; 5845id select_type table type possible_keys key key_len ref rows filtered Extra 58461 PRIMARY t1 ALL NULL NULL NULL NULL 8 100.00 NULL 58472 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 100.00 Using where 5848Warnings: 5849Note 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` 5850DROP TABLE t1,t2; 5851CREATE TABLE t1 (a char(5), b char(5)); 5852INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); 5853SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); 5854a b 5855aaa aaa 5856DROP TABLE t1; 5857CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)); 5858INSERT INTO t1 VALUES ('a', 'aa'); 5859INSERT INTO t1 VALUES ('a', 'aaa'); 5860SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); 5861a b 5862CREATE INDEX I1 ON t1 (a); 5863CREATE INDEX I2 ON t1 (b); 5864EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); 5865id select_type table type possible_keys key key_len ref rows Extra 58661 SIMPLE t1 index I1 I1 2 NULL 2 Using index; LooseScan 58671 SIMPLE t1 ALL I2 NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 5868SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); 5869a b 5870CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)); 5871INSERT INTO t2 SELECT * FROM t1; 5872CREATE INDEX I1 ON t2 (a); 5873CREATE INDEX I2 ON t2 (b); 5874EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); 5875id select_type table type possible_keys key key_len ref rows Extra 58761 SIMPLE t2 index I1 I1 4 NULL 2 Using index; LooseScan 58771 SIMPLE t2 ALL I2 NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 5878SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); 5879a b 5880EXPLAIN 5881SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); 5882id select_type table type possible_keys key key_len ref rows Extra 58831 SIMPLE t1 index I1 I1 2 NULL 2 Using where; Using index; LooseScan 58841 SIMPLE t1 ALL I2 NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 5885SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); 5886a b 5887DROP TABLE t1,t2; 5888# 5889# BUG#45928 "Differing query results depending on MRR and 5890# engine_condition_pushdown settings" 5891# 5892CREATE TABLE `t1` ( 5893`pk` int(11) NOT NULL AUTO_INCREMENT, 5894`time_nokey` time NOT NULL, 5895`varchar_key` varchar(1) NOT NULL, 5896`varchar_nokey` varchar(1) NOT NULL, 5897PRIMARY KEY (`pk`), 5898KEY `varchar_key` (`varchar_key`) 5899) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; 5900INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); 5901SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( 5902SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER 5903BY `pk` ; 5904G1 5905DROP TABLE t1; 5906# 5907# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), 5908# file item.cc, line 4448" 5909# 5910DROP TABLE IF EXISTS C, BB; 5911CREATE TABLE C ( 5912varchar_nokey varchar(1) NOT NULL 5913); 5914INSERT INTO C VALUES 5915('k'),('a'),(''),('u'),('e'),('v'),('i'), 5916('t'),('u'),('f'),('u'),('m'),('j'),('f'), 5917('v'),('j'),('g'),('e'),('h'),('z'); 5918CREATE TABLE BB ( 5919varchar_nokey varchar(1) NOT NULL 5920); 5921INSERT INTO BB VALUES ('i'),('t'); 5922SELECT varchar_nokey FROM C 5923WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey 5924FROM BB); 5925ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' 5926SELECT varchar_nokey FROM C 5927WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey 5928FROM BB); 5929ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' 5930DROP TABLE C,BB; 5931# 5932# During work with BUG#45863 I had problems with a query that was 5933# optimized differently in regular and prepared mode. 5934# Because there was a bug in one of the selected strategies, I became 5935# aware of the problem. Adding an EXPLAIN query to catch this. 5936DROP TABLE IF EXISTS t1, t2, t3; 5937CREATE TABLE t1 5938(EMPNUM CHAR(3) NOT NULL, 5939EMPNAME CHAR(20), 5940GRADE DECIMAL(4), 5941CITY CHAR(15)); 5942CREATE TABLE t2 5943(PNUM CHAR(3) NOT NULL, 5944PNAME CHAR(20), 5945PTYPE CHAR(6), 5946BUDGET DECIMAL(9), 5947CITY CHAR(15)); 5948CREATE TABLE t3 5949(EMPNUM CHAR(3) NOT NULL, 5950PNUM CHAR(3) NOT NULL, 5951HOURS DECIMAL(5)); 5952INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); 5953INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); 5954INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); 5955INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); 5956INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); 5957INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); 5958INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); 5959INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); 5960INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); 5961INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); 5962INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); 5963INSERT INTO t3 VALUES ('E1','P1',40); 5964INSERT INTO t3 VALUES ('E1','P2',20); 5965INSERT INTO t3 VALUES ('E1','P3',80); 5966INSERT INTO t3 VALUES ('E1','P4',20); 5967INSERT INTO t3 VALUES ('E1','P5',12); 5968INSERT INTO t3 VALUES ('E1','P6',12); 5969INSERT INTO t3 VALUES ('E2','P1',40); 5970INSERT INTO t3 VALUES ('E2','P2',80); 5971INSERT INTO t3 VALUES ('E3','P2',20); 5972INSERT INTO t3 VALUES ('E4','P2',20); 5973INSERT INTO t3 VALUES ('E4','P4',40); 5974INSERT INTO t3 VALUES ('E4','P5',80); 5975CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); 5976EXPLAIN SELECT EMPNAME 5977FROM t1 5978WHERE EMPNUM IN 5979(SELECT EMPNUM 5980FROM t3 5981WHERE PNUM IN 5982(SELECT PNUM 5983FROM t2 5984WHERE PTYPE = 'Design')); 5985id select_type table type possible_keys key key_len ref rows Extra 59861 SIMPLE t1 ALL t1_IDX NULL NULL NULL 5 Using where 59871 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 3 test.t1.EMPNUM 1 NULL 59882 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 Using where 59892 MATERIALIZED t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (Block Nested Loop) 5990PREPARE stmt FROM "EXPLAIN SELECT EMPNAME 5991FROM t1 5992WHERE EMPNUM IN 5993 (SELECT EMPNUM 5994 FROM t3 5995 WHERE PNUM IN 5996 (SELECT PNUM 5997 FROM t2 5998 WHERE PTYPE = 'Design'))"; 5999EXECUTE stmt; 6000id select_type table type possible_keys key key_len ref rows Extra 60011 SIMPLE t1 ALL t1_IDX NULL NULL NULL 5 Using where 60021 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 3 test.t1.EMPNUM 1 NULL 60032 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 Using where 60042 MATERIALIZED t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (Block Nested Loop) 6005EXECUTE stmt; 6006id select_type table type possible_keys key key_len ref rows Extra 60071 SIMPLE t1 ALL t1_IDX NULL NULL NULL 5 Using where 60081 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 3 test.t1.EMPNUM 1 NULL 60092 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 Using where 60102 MATERIALIZED t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (Block Nested Loop) 6011DEALLOCATE PREPARE stmt; 6012DROP INDEX t1_IDX ON t1; 6013CREATE INDEX t1_IDX ON t1(EMPNUM); 6014EXPLAIN SELECT EMPNAME 6015FROM t1 6016WHERE EMPNUM IN 6017(SELECT EMPNUM 6018FROM t3 6019WHERE PNUM IN 6020(SELECT PNUM 6021FROM t2 6022WHERE PTYPE = 'Design')); 6023id select_type table type possible_keys key key_len ref rows Extra 60241 SIMPLE t1 ALL t1_IDX NULL NULL NULL 5 Using where 60251 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 3 test.t1.EMPNUM 1 NULL 60262 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 Using where 60272 MATERIALIZED t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (Block Nested Loop) 6028PREPARE stmt FROM "EXPLAIN SELECT EMPNAME 6029FROM t1 6030WHERE EMPNUM IN 6031 (SELECT EMPNUM 6032 FROM t3 6033 WHERE PNUM IN 6034 (SELECT PNUM 6035 FROM t2 6036 WHERE PTYPE = 'Design'))"; 6037EXECUTE stmt; 6038id select_type table type possible_keys key key_len ref rows Extra 60391 SIMPLE t1 ALL t1_IDX NULL NULL NULL 5 Using where 60401 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 3 test.t1.EMPNUM 1 NULL 60412 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 Using where 60422 MATERIALIZED t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (Block Nested Loop) 6043EXECUTE stmt; 6044id select_type table type possible_keys key key_len ref rows Extra 60451 SIMPLE t1 ALL t1_IDX NULL NULL NULL 5 Using where 60461 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 3 test.t1.EMPNUM 1 NULL 60472 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 Using where 60482 MATERIALIZED t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (Block Nested Loop) 6049DEALLOCATE PREPARE stmt; 6050DROP INDEX t1_IDX ON t1; 6051EXPLAIN SELECT EMPNAME 6052FROM t1 6053WHERE EMPNUM IN 6054(SELECT EMPNUM 6055FROM t3 6056WHERE PNUM IN 6057(SELECT PNUM 6058FROM t2 6059WHERE PTYPE = 'Design')); 6060id select_type table type possible_keys key key_len ref rows Extra 60611 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where 60621 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 3 test.t1.EMPNUM 1 NULL 60632 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 Using where 60642 MATERIALIZED t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (Block Nested Loop) 6065PREPARE stmt FROM "EXPLAIN SELECT EMPNAME 6066FROM t1 6067WHERE EMPNUM IN 6068 (SELECT EMPNUM 6069 FROM t3 6070 WHERE PNUM IN 6071 (SELECT PNUM 6072 FROM t2 6073 WHERE PTYPE = 'Design'))"; 6074EXECUTE stmt; 6075id select_type table type possible_keys key key_len ref rows Extra 60761 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where 60771 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 3 test.t1.EMPNUM 1 NULL 60782 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 Using where 60792 MATERIALIZED t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (Block Nested Loop) 6080EXECUTE stmt; 6081id select_type table type possible_keys key key_len ref rows Extra 60821 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where 60831 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 3 test.t1.EMPNUM 1 NULL 60842 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 Using where 60852 MATERIALIZED t3 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (Block Nested Loop) 6086DEALLOCATE PREPARE stmt; 6087DROP TABLE t1, t2, t3; 6088# 6089# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing 6090# 6091CREATE TABLE t1 ( 6092i1_key INT, 6093i2 INT, 6094i3 INT, 6095KEY i1_index (i1_key) 6096); 6097INSERT INTO t1 VALUES (9,1,2), (9,2,1); 6098CREATE TABLE t2 ( 6099pk INT NOT NULL, 6100i1 INT, 6101PRIMARY KEY (pk) 6102); 6103INSERT INTO t2 VALUES (9,1); 6104SELECT pk 6105FROM t2 6106WHERE 6107pk IN ( 6108SELECT i1_key 6109FROM t1 6110WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 6111ORDER BY t1.i2 desc); 6112pk 61139 6114DROP TABLE t1,t2; 6115# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result 6116# 6117CREATE TABLE t1( 6118id INTEGER 6119); 6120INSERT INTO t1 VALUES(10),(20); 6121create table t2 select * from t1; 6122create table t3 select * from t1; 6123SELECT * 6124FROM t1 6125WHERE 1 IN(SELECT 1 6126FROM t2 6127WHERE 1 IN(SELECT 1 6128FROM t3)); 6129id 613010 613120 6132explain extended SELECT * 6133FROM t1 6134WHERE 1 IN(SELECT 1 6135FROM t2 6136WHERE 1 IN(SELECT 1 6137FROM t3)); 6138id select_type table type possible_keys key key_len ref rows filtered Extra 61391 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 NULL 61401 SIMPLE <subquery2> const <auto_key> <auto_key> 4 const 1 100.00 NULL 61412 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00 NULL 61422 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop) 6143Warnings: 6144Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where 1 6145delete from t2; 6146delete from t3; 6147INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); 6148insert into t2 select * from t1; 6149insert into t3 select * from t1; 6150create table t4 select * from t1; 6151SELECT * 6152FROM t1 6153WHERE 1 IN(SELECT 1 6154FROM t2 6155WHERE 1 IN(SELECT 1 6156FROM t3 6157WHERE 1 IN(SELECT 1 6158FROM t4))); 6159id 616010 616120 616230 616340 616450 616560 616670 616780 616890 6169explain SELECT * 6170FROM t1 6171WHERE 1 IN(SELECT 1 6172FROM t2 6173WHERE 1 IN(SELECT 1 6174FROM t3 6175WHERE 1 IN(SELECT 1 6176FROM t4))); 6177id select_type table type possible_keys key key_len ref rows Extra 61781 SIMPLE t1 ALL NULL NULL NULL NULL 9 NULL 61791 SIMPLE <subquery2> const <auto_key> <auto_key> 4 const 1 NULL 61802 MATERIALIZED t2 ALL NULL NULL NULL NULL 9 NULL 61812 MATERIALIZED t3 ALL NULL NULL NULL NULL 9 Using join buffer (Block Nested Loop) 61822 MATERIALIZED t4 ALL NULL NULL NULL NULL 9 Using join buffer (Block Nested Loop) 6183SELECT * 6184FROM t1 6185WHERE 1 IN(SELECT 1 6186FROM t1 6187WHERE 1 IN(SELECT 1 6188FROM t1 6189WHERE 1 IN(SELECT 1 6190FROM t1))); 6191id 619210 619320 619430 619540 619650 619760 619870 619980 620090 6201drop table t1,t2,t3,t4; 6202# 6203# Bug#53236 Segfault in DTCollation::set(DTCollation&) 6204# 6205CREATE TABLE t1 ( 6206pk INTEGER AUTO_INCREMENT, 6207col_varchar VARCHAR(1), 6208PRIMARY KEY (pk) 6209) 6210; 6211INSERT INTO t1 (col_varchar) 6212VALUES 6213('w'), 6214('m') 6215; 6216SELECT table1.pk 6217FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = 6218table2.col_varchar) ) 6219WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, 6220SUBQUERY1_t1.pk AS SUBQUERY1_field2 6221FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 6222ON (SUBQUERY1_t2.col_varchar = 6223SUBQUERY1_t1.col_varchar) ) ) 6224; 6225pk 6226drop table t1; 6227# 6228# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" 6229# 6230create table t1 (uid int, fid int); 6231insert into t1 values (1,1), (3,1); 6232create table t2 (uid int, name varchar(128)); 6233insert into t2 values (1, "A"), (2, "B"); 6234create table t3 (uid int, fid int, index(uid)); 6235insert into t3 values (1,3), (1,3); 6236create table t4 (uid int); 6237insert into t4 values (3); 6238explain select t2.uid from t2, t1 6239where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) 6240and t2.uid=t1.fid; 6241id select_type table type possible_keys key key_len ref rows Extra 62421 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 62431 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop) 62441 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 62452 MATERIALIZED t4 ALL NULL NULL NULL NULL 1 NULL 62462 MATERIALIZED t3 ref uid uid 5 const 1 Using where; Using join buffer (Batched Key Access) 6247select t2.uid from t2, t1 6248where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) 6249and t2.uid=t1.fid; 6250uid 62511 6252drop table t1,t2,t3,t4; 6253CREATE TABLE t1 ( 6254pk int, 6255a varchar(1), 6256b varchar(4), 6257c varchar(4), 6258d varchar(4), 6259PRIMARY KEY (pk) 6260); 6261INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); 6262CREATE TABLE t2 LIKE t1; 6263INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); 6264EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); 6265id select_type table type possible_keys key key_len ref rows Extra 62661 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL 62671 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop) 6268SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); 6269pk 62702 6271SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); 6272pk 62732 6274DROP TABLE t1, t2; 6275CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; 6276INSERT INTO t1 (f1, f2) VALUES (1, 1.789); 6277INSERT INTO t1 (f1, f2) VALUES (13, 1.454); 6278INSERT INTO t1 (f1, f2) VALUES (10, 1.668); 6279CREATE TABLE t2 LIKE t1; 6280INSERT INTO t2 VALUES (1, 1.789); 6281INSERT INTO t2 VALUES (13, 1.454); 6282EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); 6283id select_type table type possible_keys key key_len ref rows Extra 62841 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 62851 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (Block Nested Loop) 62862 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 NULL 6287SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); 6288COUNT(*) 62892 6290DROP TABLE t1, t2; 6291CREATE TABLE t1 ( 6292ID int(11) NOT NULL auto_increment, 6293Name char(35) NOT NULL default '', 6294Country char(3) NOT NULL default '', 6295Population int(11) NOT NULL default '0', 6296PRIMARY KEY (ID), 6297INDEX (Population), 6298INDEX (Country) 6299); 6300CREATE TABLE t2 ( 6301Code char(3) NOT NULL default '', 6302Name char(52) NOT NULL default '', 6303SurfaceArea float(10,2) NOT NULL default '0.00', 6304Population int(11) NOT NULL default '0', 6305Capital int(11) default NULL, 6306PRIMARY KEY (Code), 6307UNIQUE INDEX (Name), 6308INDEX (Population) 6309); 6310CREATE TABLE t3 ( 6311Country char(3) NOT NULL default '', 6312Language char(30) NOT NULL default '', 6313Percentage float(3,1) NOT NULL default '0.0', 6314PRIMARY KEY (Country, Language), 6315INDEX (Percentage) 6316); 6317EXPLAIN SELECT Name FROM t2 6318WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) 6319AND 6320t2.Code IN (SELECT Country FROM t3 6321WHERE Language='English' AND Percentage > 10 AND 6322t2.Population > 100000); 6323id select_type table type possible_keys key key_len ref rows Extra 63241 SIMPLE t1 range Population,Country Population 4 NULL 1 Using index condition; Using MRR; Start temporary 63251 SIMPLE t2 eq_ref PRIMARY,Population PRIMARY 3 test.t1.Country 1 Using where; End temporary; Using join buffer (Batched Key Access) 63261 SIMPLE t3 eq_ref PRIMARY,Percentage PRIMARY 33 test.t1.Country,const 1 Using index condition; Using where; Using join buffer (Batched Key Access) 6327EXPLAIN FORMAT=JSON SELECT Name FROM t2 6328WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) 6329AND 6330t2.Code IN (SELECT Country FROM t3 6331WHERE Language='English' AND Percentage > 10 AND 6332t2.Population > 100000); 6333EXPLAIN 6334{ 6335 "query_block": { 6336 "select_id": 1, 6337 "nested_loop": [ 6338 { 6339 "duplicates_removal": { 6340 "using_temporary_table": true, 6341 "nested_loop": [ 6342 { 6343 "table": { 6344 "table_name": "t1", 6345 "access_type": "range", 6346 "possible_keys": [ 6347 "Population", 6348 "Country" 6349 ], 6350 "key": "Population", 6351 "used_key_parts": [ 6352 "Population" 6353 ], 6354 "key_length": "4", 6355 "rows": 1, 6356 "filtered": 100, 6357 "index_condition": "(`test`.`t1`.`Population` > 5000000)", 6358 "using_MRR": true 6359 } 6360 }, 6361 { 6362 "table": { 6363 "table_name": "t2", 6364 "access_type": "eq_ref", 6365 "possible_keys": [ 6366 "PRIMARY", 6367 "Population" 6368 ], 6369 "key": "PRIMARY", 6370 "used_key_parts": [ 6371 "Code" 6372 ], 6373 "key_length": "3", 6374 "ref": [ 6375 "test.t1.Country" 6376 ], 6377 "rows": 1, 6378 "filtered": 100, 6379 "using_join_buffer": "Batched Key Access", 6380 "attached_condition": "(`test`.`t2`.`Population` > 100000)" 6381 } 6382 } 6383 ] 6384 } 6385 }, 6386 { 6387 "table": { 6388 "table_name": "t3", 6389 "access_type": "eq_ref", 6390 "possible_keys": [ 6391 "PRIMARY", 6392 "Percentage" 6393 ], 6394 "key": "PRIMARY", 6395 "used_key_parts": [ 6396 "Country", 6397 "Language" 6398 ], 6399 "key_length": "33", 6400 "ref": [ 6401 "test.t1.Country", 6402 "const" 6403 ], 6404 "rows": 1, 6405 "filtered": 100, 6406 "index_condition": "(`test`.`t3`.`Language` = 'English')", 6407 "using_join_buffer": "Batched Key Access", 6408 "attached_condition": "(`test`.`t3`.`Percentage` > 10)" 6409 } 6410 } 6411 ] 6412 } 6413} 6414Warnings: 6415Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 6416Note 1003 /* select#1 */ select `test`.`t2`.`Name` AS `Name` from `test`.`t3` semi join (`test`.`t1`) join `test`.`t2` where ((`test`.`t2`.`Code` = `test`.`t1`.`Country`) and (`test`.`t3`.`Country` = `test`.`t1`.`Country`) and (`test`.`t3`.`Language` = 'English') and (`test`.`t3`.`Percentage` > 10) and (`test`.`t2`.`Population` > 100000) and (`test`.`t1`.`Population` > 5000000)) 6417DROP TABLE t1,t2,t3; 6418CREATE TABLE t1 ( 6419Code char(3) NOT NULL DEFAULT '', 6420Name char(52) NOT NULL DEFAULT '', 6421Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', 6422Region char(26) NOT NULL DEFAULT '', 6423SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', 6424IndepYear smallint(6) DEFAULT NULL, 6425Population int(11) NOT NULL DEFAULT '0', 6426LifeExpectancy float(3,1) DEFAULT NULL, 6427GNP float(10,2) DEFAULT NULL, 6428GNPOld float(10,2) DEFAULT NULL, 6429LocalName char(45) NOT NULL DEFAULT '', 6430GovernmentForm char(45) NOT NULL DEFAULT '', 6431HeadOfState char(60) DEFAULT NULL, 6432Capital int(11) DEFAULT NULL, 6433Code2 char(2) NOT NULL DEFAULT '', 6434PRIMARY KEY (Code) 6435); 6436CREATE TABLE t2 ( 6437ID int(11) NOT NULL AUTO_INCREMENT, 6438Name char(35) NOT NULL DEFAULT '', 6439CountryCode char(3) NOT NULL DEFAULT '', 6440District char(20) NOT NULL DEFAULT '', 6441Population int(11) NOT NULL DEFAULT '0', 6442PRIMARY KEY (ID), 6443KEY CountryCode (CountryCode) 6444); 6445Fill the table with test data 6446This must not use LooseScan: 6447EXPLAIN SELECT Name FROM t1 6448WHERE t1.Code IN ( 6449SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); 6450id select_type table type possible_keys key key_len ref rows Extra 64511 SIMPLE t1 ALL PRIMARY NULL NULL NULL 31 Using where 64521 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 3 test.t1.Code 1 NULL 64532 MATERIALIZED t2 ALL CountryCode NULL NULL NULL 545 Using where 6454SELECT Name FROM t1 6455WHERE t1.Code IN ( 6456SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); 6457Name 6458Austria 6459Canada 6460China 6461Czech Republic 6462drop table t1, t2; 6463create table t0 (a int); 6464insert into t0 values (0),(1),(2),(3),(4); 6465create table t1 (a int, b int, key(a)); 6466insert into t1 select a,a from t0; 6467create table t2 (a int, b int, primary key(a)); 6468insert into t2 select * from t1; 6469Table t2, unlike table t1, should be displayed as pulled out 6470explain extended select * from t0 6471where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and 6472t1.b=t2.b); 6473id select_type table type possible_keys key key_len ref rows filtered Extra 64741 SIMPLE t0 ALL NULL NULL NULL NULL 5 100.00 Using where; Start temporary 64751 SIMPLE t1 ref a a 5 test.t0.a 1 100.00 Using join buffer (Batched Key Access) 64761 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 100.00 Using where; End temporary; Using join buffer (Batched Key Access) 6477Warnings: 6478Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 6479Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) join `test`.`t0` where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`t0`.`a`) and (`test`.`t2`.`a` = `test`.`t0`.`a`)) 6480update t1 set a=3, b=11 where a=4; 6481update t2 set b=11 where a=3; 6482create temporary table tmp select * from t0 where t0.a in 6483(select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); 6484create temporary table tmp_as_ref (a int); 6485insert into tmp_as_ref values(0),(1),(2),(3); 6486select * from tmp; 6487a 64880 64891 64902 64913 6492drop table t0, t1, t2, tmp, tmp_as_ref; 6493CREATE TABLE t1 ( 6494id int(11) NOT NULL, 6495PRIMARY KEY (id)); 6496CREATE TABLE t2 ( 6497id int(11) NOT NULL, 6498fid int(11) NOT NULL, 6499PRIMARY KEY (id)); 6500insert into t1 values(1); 6501insert into t2 values(1,7503),(2,1); 6502explain select count(*) 6503from t1 6504where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); 6505ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' 6506drop table t1, t2; 6507create table t1 (a int, b int, key (a), key (b)); 6508insert into t1 values (2,4),(2,4),(2,4); 6509select t1.a from t1 6510where 6511t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); 6512a 6513drop table t1; 6514create table t1(a int,b int,key(a),key(b)); 6515insert into t1 values (1,1),(2,2),(3,3); 6516select 1 from t1 6517where t1.a not in (select 1 from t1 6518where t1.a in (select 1 from t1) 6519group by t1.b); 65201 65211 65221 6523drop table t1; 6524CREATE TABLE t1 6525(EMPNUM CHAR(3) NOT NULL, 6526EMPNAME CHAR(20), 6527GRADE DECIMAL(4), 6528CITY CHAR(15)); 6529CREATE TABLE t2 6530(PNUM CHAR(3) NOT NULL, 6531PNAME CHAR(20), 6532PTYPE CHAR(6), 6533BUDGET DECIMAL(9), 6534CITY CHAR(15)); 6535CREATE TABLE t3 6536(EMPNUM CHAR(3) NOT NULL, 6537PNUM CHAR(3) NOT NULL, 6538HOURS DECIMAL(5)); 6539INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); 6540INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); 6541INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); 6542INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); 6543INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); 6544INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); 6545INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); 6546INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); 6547INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); 6548INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); 6549INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); 6550INSERT INTO t3 VALUES ('E1','P1',40); 6551INSERT INTO t3 VALUES ('E1','P2',20); 6552INSERT INTO t3 VALUES ('E1','P3',80); 6553INSERT INTO t3 VALUES ('E1','P4',20); 6554INSERT INTO t3 VALUES ('E1','P5',12); 6555INSERT INTO t3 VALUES ('E1','P6',12); 6556INSERT INTO t3 VALUES ('E2','P1',40); 6557INSERT INTO t3 VALUES ('E2','P2',80); 6558INSERT INTO t3 VALUES ('E3','P2',20); 6559INSERT INTO t3 VALUES ('E4','P2',20); 6560INSERT INTO t3 VALUES ('E4','P4',40); 6561INSERT INTO t3 VALUES ('E4','P5',80); 6562SELECT * FROM t1; 6563EMPNUM EMPNAME GRADE CITY 6564E1 Alice 12 Deale 6565E2 Betty 10 Vienna 6566E3 Carmen 13 Vienna 6567E4 Don 12 Deale 6568E5 Ed 13 Akron 6569CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); 6570SELECT EMPNAME 6571FROM t1 6572WHERE EMPNUM IN 6573(SELECT EMPNUM 6574FROM t3 6575WHERE PNUM IN 6576(SELECT PNUM 6577FROM t2 6578WHERE PTYPE = 'Design')); 6579EMPNAME 6580Alice 6581Betty 6582Don 6583DROP INDEX t1_IDX ON t1; 6584CREATE INDEX t1_IDX ON t1(EMPNUM); 6585SELECT EMPNAME 6586FROM t1 6587WHERE EMPNUM IN 6588(SELECT EMPNUM 6589FROM t3 6590WHERE PNUM IN 6591(SELECT PNUM 6592FROM t2 6593WHERE PTYPE = 'Design')); 6594EMPNAME 6595Alice 6596Betty 6597Don 6598DROP INDEX t1_IDX ON t1; 6599SELECT EMPNAME 6600FROM t1 6601WHERE EMPNUM IN 6602(SELECT EMPNUM 6603FROM t3 6604WHERE PNUM IN 6605(SELECT PNUM 6606FROM t2 6607WHERE PTYPE = 'Design')); 6608EMPNAME 6609Alice 6610Betty 6611Don 6612DROP TABLE t1, t2, t3; 6613CREATE TABLE t1 (f1 INT NOT NULL); 6614CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; 6615SELECT * FROM v1; 6616a 6617drop view v1; 6618drop table t1; 6619create table t0 (a int); 6620insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 6621create table t1(a int, b int); 6622insert into t1 values (0,0),(1,1),(2,2); 6623create table t2 as select * from t1; 6624create table t3 (pk int, a int, primary key(pk)); 6625insert into t3 select a,a from t0; 6626explain 6627select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); 6628id select_type table type possible_keys key key_len ref rows Extra 66291 SIMPLE t1 ALL NULL NULL NULL NULL 3 NULL 66301 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where 66311 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.a 1 Using index 6632drop table t0, t1, t2, t3; 6633create table t0 (a int); 6634insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 6635create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; 6636create table t2 (id int, a int, primary key(id), key(a)) as select a as id, a as a from t1; 6637show create table t2; 6638Table Create Table 6639t2 CREATE TABLE `t2` ( 6640 `id` int(11) NOT NULL DEFAULT '0', 6641 `a` int(11) DEFAULT NULL, 6642 PRIMARY KEY (`id`), 6643 KEY `a` (`a`) 6644) ENGINE=MyISAM DEFAULT CHARSET=latin1 6645set @a=0; 6646create table t3 as select * from t2 limit 0; 6647insert into t3 select @a:=@a+1, t2.a from t2, t0; 6648insert into t3 select @a:=@a+1, t2.a from t2, t0; 6649insert into t3 select @a:=@a+1, t2.a from t2, t0; 6650alter table t3 add primary key(id), add key(a); 6651The following must use loose index scan over t3, key a: 6652explain select count(a) from t2 where a in ( SELECT a FROM t3); 6653id select_type table type possible_keys key key_len ref rows Extra 66541 SIMPLE t2 index a a 5 NULL 1000 Using where; Using index 66551 SIMPLE t3 ref a a 5 test.t2.a 30 Using index; FirstMatch(t2) 6656select count(a) from t2 where a in ( SELECT a FROM t3); 6657count(a) 66581000 6659drop table t0,t1,t2,t3; 6660# 6661# Bug#33062: subquery in stored routine cause crash 6662# 6663CREATE TABLE t1(a INT); 6664CREATE TABLE t2(c INT); 6665CREATE PROCEDURE p1(v1 int) 6666BEGIN 6667SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); 6668END 6669// 6670CREATE PROCEDURE p2(v1 int) 6671BEGIN 6672SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); 6673END 6674// 6675CREATE PROCEDURE p3(v1 int) 6676BEGIN 6677SELECT 1 6678FROM 6679t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, 6680t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, 6681t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, 6682t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, 6683t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, 6684t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, 6685t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, 6686t1 t57,t1 t58,t1 t59,t1 t60 6687WHERE t01.a IN (SELECT c FROM t2); 6688END 6689// 6690CREATE PROCEDURE p4(v1 int) 6691BEGIN 6692SELECT 1 6693FROM 6694t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, 6695t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, 6696t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, 6697t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, 6698t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, 6699t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, 6700t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, 6701t1 t57,t1 t58,t1 t59,t1 t60 6702WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); 6703END 6704// 6705CALL p1(1); 67061 6707CALL p2(1); 67081 6709CALL p3(1); 67101 6711CALL p4(1); 67121 6713DROP TABLE t1, t2; 6714DROP PROCEDURE p1; 6715DROP PROCEDURE p2; 6716DROP PROCEDURE p3; 6717DROP PROCEDURE p4; 6718# 6719# Bug#48213 Materialized subselect crashes if using GEOMETRY type 6720# 6721CREATE TABLE t1 ( 6722pk int, 6723a varchar(1), 6724b varchar(4), 6725c tinyblob, 6726d blob, 6727e mediumblob, 6728f longblob, 6729g tinytext, 6730h text, 6731i mediumtext, 6732j longtext, 6733k geometry, 6734PRIMARY KEY (pk) 6735); 6736INSERT 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))')); 6737CREATE TABLE t2 LIKE t1; 6738INSERT 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))')); 6739EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); 6740id select_type table type possible_keys key key_len ref rows filtered Extra 67411 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 NULL 67421 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop) 6743Warnings: 6744Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) 6745SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); 6746pk 67472 6748EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); 6749id select_type table type possible_keys key key_len ref rows filtered Extra 67501 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 NULL 67511 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop) 6752Warnings: 6753Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`c` = `test`.`t1`.`c`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) 6754SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); 6755pk 67561 67572 6758EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); 6759id select_type table type possible_keys key key_len ref rows filtered Extra 67601 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 NULL 67611 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop) 6762Warnings: 6763Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`d` = `test`.`t1`.`d`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) 6764SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); 6765pk 67662 6767EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); 6768id select_type table type possible_keys key key_len ref rows filtered Extra 67691 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 NULL 67701 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop) 6771Warnings: 6772Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`e` = `test`.`t1`.`e`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) 6773SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); 6774pk 67751 67762 6777EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); 6778id select_type table type possible_keys key key_len ref rows filtered Extra 67791 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 NULL 67801 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop) 6781Warnings: 6782Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`f` = `test`.`t1`.`f`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) 6783SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); 6784pk 67851 67862 6787EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); 6788id select_type table type possible_keys key key_len ref rows filtered Extra 67891 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 NULL 67901 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop) 6791Warnings: 6792Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`g` = `test`.`t1`.`g`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) 6793SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); 6794pk 67951 67962 6797EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); 6798id select_type table type possible_keys key key_len ref rows filtered Extra 67991 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 NULL 68001 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop) 6801Warnings: 6802Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`h` = `test`.`t1`.`h`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) 6803SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); 6804pk 68051 68062 6807EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); 6808id select_type table type possible_keys key key_len ref rows filtered Extra 68091 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 NULL 68101 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop) 6811Warnings: 6812Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`i` = `test`.`t1`.`i`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) 6813SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); 6814pk 68151 68162 6817EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); 6818id select_type table type possible_keys key key_len ref rows filtered Extra 68191 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 NULL 68201 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop) 6821Warnings: 6822Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`j` = `test`.`t1`.`j`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) 6823SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); 6824pk 68251 68262 6827EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); 6828id select_type table type possible_keys key key_len ref rows filtered Extra 68291 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 NULL 68301 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop) 6831Warnings: 6832Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`k` = `test`.`t1`.`k`) and (`test`.`t2`.`b` = `test`.`t1`.`b`) and (`test`.`t2`.`pk` > 0)) 6833SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); 6834pk 68351 68362 6837DROP TABLE t1, t2; 6838# End of Bug#48213 6839# 6840# BUG#53060: LooseScan semijoin strategy does not return all rows 6841# 6842CREATE TABLE t1 (i INTEGER); 6843INSERT INTO t1 VALUES (1), (2), (3), (4), (5); 6844CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); 6845INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); 6846EXPLAIN 6847SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); 6848id select_type table type possible_keys key key_len ref rows Extra 68491 SIMPLE t2 index k k 10 NULL 4 Using where; Using index; LooseScan 68501 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (Block Nested Loop) 6851SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); 6852i 68531 68542 6855DROP TABLE t1, t2; 6856# End of BUG#53060 6857# 6858# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" 6859# 6860create table t1 (uid int, fid int, index(uid)); 6861insert into t1 values 6862(1,1), (1,2), (1,3), (1,4), 6863(2,5), (2,6), (2,7), (2,8), 6864(3,1), (3,2), (3,9); 6865create table t2 (uid int primary key, name varchar(128), index(name)); 6866insert into t2 values 6867(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), 6868(6, "F"), (7, "G"), (8, "H"), (9, "I"); 6869create table t3 (uid int, fid int, index(uid)); 6870insert into t3 values 6871(1,1), (1,2), (1,3),(1,4), 6872(2,5), (2,6), (2,7), (2,8), 6873(3,1), (3,2), (3,9); 6874create table t4 (uid int primary key, name varchar(128), index(name)); 6875insert into t4 values 6876(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), 6877(6, "F"), (7, "G"), (8, "H"), (9, "I"); 6878explain select name from t2, t1 6879where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) 6880and t2.uid=t1.fid; 6881id select_type table type possible_keys key key_len ref rows Extra 68821 SIMPLE t3 ref uid uid 5 const 4 Using where; Start temporary 68831 SIMPLE t4 eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 Using index 68841 SIMPLE t1 ref uid uid 5 test.t3.fid 2 Using where; Using join buffer (Batched Key Access) 68851 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 End temporary; Using join buffer (Batched Key Access) 6886select name from t2, t1 6887where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) 6888and t2.uid=t1.fid; 6889name 6890A 6891A 6892B 6893B 6894C 6895D 6896E 6897F 6898G 6899H 6900I 6901drop table t1,t2,t3,t4; 6902# 6903# Bug#43768 Prepared query with nested subqueries core dump on second execution 6904# 6905CREATE TABLE t1 ( 6906id INT PRIMARY KEY, 6907partner_id VARCHAR(35) 6908); 6909INSERT INTO t1 VALUES 6910(1, 'partner1'), (2, 'partner2'), 6911(3, 'partner3'), (4, 'partner4'); 6912CREATE TABLE t2 ( 6913id INT NOT NULL, 6914t1_line_id INT, 6915article_id VARCHAR(20), 6916PRIMARY KEY(id, t1_line_id) 6917); 6918INSERT INTO t2 VALUES 6919(1, 1, 'sup'), (2, 1, 'sup'), 6920(2, 2, 'sup'), (2, 3, 'sup'), 6921(2, 4, 'imp'), (3, 1, 'sup'), 6922(4, 1, 'sup'); 6923CREATE TABLE t3 ( 6924user_id VARCHAR(50), 6925article_id VARCHAR(20) NOT NULL, 6926PRIMARY KEY(user_id) 6927); 6928INSERT INTO t3 VALUES('nicke', 'imp'); 6929EXPLAIN 6930SELECT t1.partner_id 6931FROM t1 6932WHERE t1.id IN ( 6933SELECT t2.id 6934FROM t2 6935WHERE article_id IN ( 6936SELECT article_id FROM t3 6937WHERE user_id = 'nicke' 6938 ) 6939); 6940id select_type table type possible_keys key key_len ref rows Extra 69411 SIMPLE t3 system PRIMARY NULL NULL NULL 1 NULL 69421 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 NULL 69431 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.id 1 Using where; FirstMatch(t1); Using join buffer (Batched Key Access) 6944SELECT t1.partner_id 6945FROM t1 6946WHERE t1.id IN ( 6947SELECT t2.id 6948FROM t2 6949WHERE article_id IN ( 6950SELECT article_id FROM t3 6951WHERE user_id = 'nicke' 6952 ) 6953); 6954partner_id 6955partner2 6956PREPARE stmt FROM 6957'EXPLAIN SELECT t1.partner_id 6958FROM t1 6959WHERE t1.id IN ( 6960 SELECT t2.id 6961 FROM t2 6962 WHERE article_id IN ( 6963 SELECT article_id FROM t3 6964 WHERE user_id = \'nicke\' 6965 ) 6966 )'; 6967EXECUTE stmt; 6968id select_type table type possible_keys key key_len ref rows Extra 69691 SIMPLE t3 system PRIMARY NULL NULL NULL 1 NULL 69701 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 NULL 69711 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.id 1 Using where; FirstMatch(t1); Using join buffer (Batched Key Access) 6972EXECUTE stmt; 6973id select_type table type possible_keys key key_len ref rows Extra 69741 SIMPLE t3 system PRIMARY NULL NULL NULL 1 NULL 69751 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 NULL 69761 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.id 1 Using where; FirstMatch(t1); Using join buffer (Batched Key Access) 6977PREPARE stmt FROM 6978'SELECT t1.partner_id 6979FROM t1 6980WHERE t1.id IN ( 6981 SELECT t2.id 6982 FROM t2 6983 WHERE article_id IN ( 6984 SELECT article_id FROM t3 6985 WHERE user_id = \'nicke\' 6986 ) 6987 )'; 6988EXECUTE stmt; 6989partner_id 6990partner2 6991EXECUTE stmt; 6992partner_id 6993partner2 6994DROP TABLE t1,t2,t3; 6995# End of Bug#43768 6996# 6997# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result 6998# 6999CREATE TABLE t1 (i INTEGER); 7000CREATE TABLE t2 (i INTEGER); 7001CREATE TABLE t3 (i INTEGER); 7002INSERT INTO t1 VALUES (1), (2); 7003INSERT INTO t2 VALUES (6); 7004INSERT INTO t3 VALUES (1), (2); 7005explain extended SELECT * FROM t1 WHERE (t1.i) IN 7006(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); 7007id select_type table type possible_keys key key_len ref rows filtered Extra 70081 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL 0.00 NULL 70091 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (Block Nested Loop) 70102 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 100.00 NULL 70112 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (Block Nested Loop) 7012Warnings: 7013Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `<subquery2>`.`i`) 7014SELECT * FROM t1 WHERE (t1.i) IN 7015(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); 7016i 70171 70182 7019drop table t1,t2,t3; 7020# 7021# BUG#49453: re-execution of prepared statement with view 7022# and semijoin crashes 7023# 7024CREATE TABLE t1 (city VARCHAR(50), country_id INT); 7025CREATE TABLE t2 (country_id INT, country VARCHAR(50)); 7026INSERT INTO t1 VALUES 7027('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; 7028INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); 7029CREATE VIEW v1 AS 7030SELECT country_id as vf_country_id 7031FROM t2 7032WHERE LEFT(country,1) = "A"; 7033PREPARE stmt FROM " 7034SELECT city, country_id 7035FROM t1 7036WHERE country_id IN (SELECT vf_country_id FROM v1); 7037"; 7038 7039EXECUTE stmt; 7040city country_id 7041Batna 2 7042Bchar 2 7043Skikda 2 7044Algeria 2 7045EXECUTE stmt; 7046city country_id 7047Batna 2 7048Bchar 2 7049Skikda 2 7050Algeria 2 7051DROP TABLE t1,t2; 7052DROP VIEW v1; 7053# 7054# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch 7055# and duplicates weedout) 7056# 7057create table t1 (a int); 7058create table t2 (a int); 7059create table t3 (a int); 7060insert into t1 values(1),(1); 7061insert into t2 values(1),(1),(1),(1); 7062insert into t3 values(2),(2); 7063explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); 7064id select_type table type possible_keys key key_len ref rows Extra 70651 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where 70661 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.t1.a 1 NULL 70672 MATERIALIZED t2 ALL NULL NULL NULL NULL 4 NULL 70682 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 7069select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); 7070a 70711 70721 7073drop table t1,t2,t3; 7074# 7075# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) 7076# 7077CREATE TABLE t1 (a INT); 7078CREATE TABLE t2 (a INT); 7079CREATE TABLE t3 (a INT); 7080INSERT INTO t1 VALUES(1),(1); 7081INSERT INTO t2 VALUES(1),(1); 7082INSERT INTO t3 VALUES(2),(2); 7083explain SELECT * FROM t1 7084WHERE t1.a IN (SELECT t2.a 7085FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); 7086id select_type table type possible_keys key key_len ref rows Extra 70871 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where 70881 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.t1.a 1 NULL 70892 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 NULL 70902 MATERIALIZED t2inner ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop) 70912 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 7092SELECT * FROM t1 7093WHERE t1.a IN (SELECT t2.a 7094FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); 7095a 70961 70971 7098DROP TABLE t1,t2,t3; 7099# 7100# BUG#52329 - Wrong result: subquery materialization, IN, 7101# non-null field followed by nullable 7102# 7103CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); 7104CREATE TABLE t2a (b1 char(8), b2 char(8)); 7105CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); 7106CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); 7107INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); 7108INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), 7109('1 - 11', '2 - 21'), 7110('1 - 12', '2 - 22'), 7111('1 - 12', '2 - 22'), 7112('1 - 13', '2 - 23'); 7113INSERT INTO t2b SELECT * FROM t2a; 7114INSERT INTO t2c SELECT * FROM t2a; 7115SELECT * FROM t1 7116WHERE (a1, a2) IN ( 7117SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); 7118a1 a2 71191 - 12 2 - 22 7120SELECT * FROM t1 7121WHERE (a1, a2) IN ( 7122SELECT b1, b2 FROM t2a WHERE b1 > '0'); 7123a1 a2 71241 - 12 2 - 22 7125SELECT * FROM t1 7126WHERE (a1, a2) IN ( 7127SELECT b1, b2 FROM t2b WHERE b1 > '0'); 7128a1 a2 71291 - 12 2 - 22 7130SELECT * FROM t1 7131WHERE (a1, a2) IN ( 7132SELECT b1, b2 FROM t2c WHERE b1 > '0'); 7133a1 a2 71341 - 12 2 - 22 7135DROP TABLE t1,t2a,t2b,t2c; 7136# End BUG#52329 7137# 7138# Bug#45174: Incorrectly applied equality propagation caused wrong 7139# result on a query with a materialized semi-join. 7140# 7141CREATE TABLE t1 ( 7142varchar_nokey varchar(1) NOT NULL 7143); 7144INSERT INTO t1 VALUES 7145('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), 7146('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); 7147CREATE TABLE t2 ( 7148pk int NOT NULL, 7149varchar_key varchar(1) NOT NULL, 7150varchar_nokey varchar(1) NOT NULL, 7151PRIMARY KEY(pk), 7152KEY varchar_key(varchar_key) 7153); 7154INSERT INTO t2 VALUES 7155(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), 7156(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), 7157(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); 7158SELECT varchar_nokey 7159FROM t1 7160WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey 7161FROM t2 7162WHERE varchar_nokey < 'n' XOR pk); 7163varchar_nokey 7164explain SELECT varchar_nokey 7165FROM t1 7166WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey 7167FROM t2 7168WHERE varchar_nokey < 'n' XOR pk); 7169id select_type table type possible_keys key key_len ref rows Extra 71701 SIMPLE t1 ALL NULL NULL NULL NULL 18 Using where 71711 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 6 test.t1.varchar_nokey,test.t1.varchar_nokey 1 NULL 71722 MATERIALIZED t2 ALL varchar_key NULL NULL NULL 15 Using where 7173DROP TABLE t1, t2; 7174# End of the test for bug#45174. 7175# 7176# Bug#50019: Wrong result for IN-query with materialization 7177# 7178CREATE TABLE t1(i INT); 7179INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); 7180CREATE TABLE t2(i INT); 7181INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); 7182CREATE TABLE t3(i INT); 7183INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); 7184SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i 7185FROM t2 JOIN t3 7186WHERE t2.i + t3.i = 5); 7187i 71881 71892 71903 71914 7192explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i 7193FROM t2 JOIN t3 7194WHERE t2.i + t3.i = 5); 7195id select_type table type possible_keys key key_len ref rows Extra 71961 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where 71971 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 5 test.t1.i 1 NULL 71982 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 NULL 71992 MATERIALIZED t3 ALL NULL NULL NULL NULL 10 Using where; Using join buffer (Block Nested Loop) 7200DROP TABLE t1,t2,t3; 7201# End of the test for bug#50019. 7202# 7203# Bug#52068: Optimizer generates invalid semijoin materialization plan 7204# 7205CREATE TABLE ot1(a INTEGER); 7206INSERT INTO ot1 VALUES(5), (8); 7207CREATE TABLE it2(a INTEGER); 7208INSERT INTO it2 VALUES(9), (5), (1), (8); 7209CREATE TABLE it3(a INTEGER); 7210INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); 7211CREATE TABLE ot4(a INTEGER); 7212INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); 7213SELECT * FROM ot1,ot4 7214WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a 7215FROM it2,it3); 7216a a 72175 1 72188 1 72195 5 72208 5 72215 7 72228 7 72235 7 72248 7 72255 1 72268 1 7227explain SELECT * FROM ot1,ot4 7228WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a 7229FROM it2,it3); 7230id select_type table type possible_keys key key_len ref rows Extra 72311 SIMPLE ot1 ALL NULL NULL NULL NULL 2 NULL 72321 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL Using where; Using join buffer (Block Nested Loop) 72331 SIMPLE ot4 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop) 72342 MATERIALIZED it2 ALL NULL NULL NULL NULL 4 NULL 72352 MATERIALIZED it3 ALL NULL NULL NULL NULL 6 Using join buffer (Block Nested Loop) 7236DROP TABLE IF EXISTS ot1, ot4, it2, it3; 7237# End of the test for bug#52068. 7238# 7239# Bug#57623: subquery within before insert trigger causes crash (sj=on) 7240# 7241CREATE TABLE ot1(a INT); 7242CREATE TABLE ot2(a INT); 7243CREATE TABLE ot3(a INT); 7244CREATE TABLE it1(a INT); 7245INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); 7246INSERT INTO ot2 VALUES(0),(2),(4),(6); 7247INSERT INTO ot3 VALUES(0),(3),(6); 7248INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); 7249explain SELECT * 7250FROM ot1 7251LEFT JOIN 7252(ot2 JOIN ot3 on ot2.a=ot3.a) 7253ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); 7254id select_type table type possible_keys key key_len ref rows Extra 72551 SIMPLE ot1 ALL NULL NULL NULL NULL 8 NULL 72561 SIMPLE it1 ALL NULL NULL NULL NULL 8 Using where; FirstMatch(ot1) 72571 SIMPLE ot3 ALL NULL NULL NULL NULL 3 NULL 72581 SIMPLE ot2 ALL NULL NULL NULL NULL 4 Using where 7259SELECT * 7260FROM ot1 7261LEFT JOIN 7262(ot2 JOIN ot3 on ot2.a=ot3.a) 7263ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); 7264a a a 72650 0 0 72661 NULL NULL 72672 NULL NULL 72683 NULL NULL 72694 NULL NULL 72705 NULL NULL 72716 6 6 72727 NULL NULL 7273prepare s from 'SELECT * 7274FROM ot1 7275LEFT JOIN 7276(ot2 JOIN ot3 on ot2.a=ot3.a) 7277ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; 7278execute s; 7279a a a 72800 0 0 72811 NULL NULL 72822 NULL NULL 72833 NULL NULL 72844 NULL NULL 72855 NULL NULL 72866 6 6 72877 NULL NULL 7288execute s; 7289a a a 72900 0 0 72911 NULL NULL 72922 NULL NULL 72933 NULL NULL 72944 NULL NULL 72955 NULL NULL 72966 6 6 72977 NULL NULL 7298deallocate prepare s; 7299DROP TABLE ot1, ot2, ot3, it1; 7300# End of the test for bug#57623. 7301# 7302# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on 7303# 7304CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; 7305CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; 7306INSERT INTO t1 VALUES (1); 7307INSERT INTO t2 VALUES (1,1), (2,1); 7308EXPLAIN SELECT * FROM t2 7309WHERE f2 IN (SELECT t1.f1 7310FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); 7311id select_type table type possible_keys key key_len ref rows Extra 73121 SIMPLE t1 ALL NULL NULL NULL NULL 1 Start temporary 73131 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 73141 SIMPLE b1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 73151 SIMPLE b2 ALL NULL NULL NULL NULL 2 End temporary; Using join buffer (Block Nested Loop) 7316SELECT * FROM t2 7317WHERE f2 IN (SELECT t1.f1 7318FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); 7319f1 f2 73201 1 73212 1 7322DROP TABLE t1, t2; 7323# End of the test for bug#11766739. 7324# 7325# Bug#11766642: crash in Item_field::register_field_in_read_map with view 7326# 7327CREATE TABLE t1(a INT); 7328CREATE VIEW v1 AS SELECT a FROM t1; 7329INSERT INTO t1 VALUES (0),(1),(2); 7330SELECT a FROM t1 WHERE a IN 7331(SELECT a XOR a FROM v1) 7332ORDER BY a; 7333a 73340 7335DROP TABLE t1; 7336DROP VIEW v1; 7337# 7338# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 7339# 7340CREATE TABLE t1 ( 7341f2 varchar(1024) 7342); 7343INSERT INTO t1 VALUES ('v'),('we'); 7344CREATE TABLE t2 ( 7345col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, 7346col_int_key int, 7347col_int int 7348); 7349INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); 7350CREATE TABLE t3 ( 7351col_int_key int, 7352col_int int 7353); 7354INSERT INTO t3 VALUES (4,4); 7355SELECT * 7356FROM t1 7357WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 7358FROM t2 AS a1 LEFT JOIN t3 AS a2 7359ON a1.col_int_key = a2.col_int_key 7360WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); 7361f2 7362we 7363v 7364DROP TABLE t1,t2,t3; 7365# 7366# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT 7367# OF ROWS WHEN JCL>=3 7368# 7369CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); 7370INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); 7371CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); 7372INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); 7373CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); 7374INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); 7375SELECT table2.col_int_key 7376from t3 as table1 join t1 as table2 on table2.col_int_nokey 7377where table1.col_int_nokey in 7378( 7379select subquery2_t2.col_int_nokey 7380from t3 as subquery2_t1 7381right join 7382t2 as subquery2_t2 7383join t1 as subquery2_t3 7384on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey 7385on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey 7386where subquery2_t1.col_varchar_key != table1.col_varchar_key 7387or subquery2_t2.pk <= table1.pk 7388); 7389col_int_key 73906 73916 7392DROP TABLE t1,t2,t3; 7393# 7394# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE 7395# 7396CREATE TABLE t1 (i1 int); 7397INSERT INTO t1 VALUES (1); 7398CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; 7399INSERT INTO t2 VALUES (1, 2),(7, 3); 7400SELECT GRANDPARENT1.i1 7401FROM t2 AS GRANDPARENT1 7402WHERE GRANDPARENT1.i2 7403IN ( SELECT PARENT1.i2 7404FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) 7405WHERE 7406GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) 7407ORDER BY PARENT1.i1) 7408ORDER BY GRANDPARENT1.i2 ; 7409i1 74101 7411DROP TABLE t1,t2; 7412# 7413# Bug#12640083: Same query executed as WHERE subquery gives different 7414# results on IN() compare 7415# 7416CREATE TABLE t1 ( 7417pk int NOT NULL, 7418col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, 7419col_varchar_10_latin1_key varchar(10) DEFAULT NULL, 7420PRIMARY KEY (pk), 7421KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), 7422KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) 7423); 7424INSERT INTO t1 VALUES 7425(1, 'a', 'a'), 7426(2, 'ab', 'ab'), 7427(3, 'abc', 'abc'), 7428(4, 'abcd', 'abcd'); 7429CREATE TABLE t2 ( 7430pk int NOT NULL AUTO_INCREMENT, 7431PRIMARY KEY (pk) 7432) ENGINE=Innodb; 7433CREATE TABLE t3 7434SELECT alias1.col_varchar_10_latin1_key 7435FROM t1 AS alias1 7436LEFT JOIN t1 AS alias2 7437JOIN t2 AS alias3 7438ON alias2.col_varchar_10_latin1_key 7439ON alias1.col_varchar_1024_utf8_key 7440WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; 7441EXPLAIN SELECT * 7442FROM t3 7443WHERE col_varchar_10_latin1_key IN ( 7444SELECT alias1.col_varchar_10_latin1_key 7445FROM t1 AS alias1 7446LEFT JOIN t1 AS alias2 7447JOIN t2 AS alias3 7448ON alias2.col_varchar_10_latin1_key 7449ON alias1.col_varchar_1024_utf8_key 7450WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); 7451id select_type table type possible_keys key key_len ref rows Extra 74521 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where 74531 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 13 test.t3.col_varchar_10_latin1_key 1 NULL 74542 MATERIALIZED alias1 ALL NULL NULL NULL NULL 4 Using where 74552 MATERIALIZED alias3 index NULL PRIMARY 4 NULL 1 Using where; Using index; Using join buffer (Block Nested Loop) 74562 MATERIALIZED alias2 index NULL col_varchar_10_latin1_key 13 NULL 4 Using where; Using index; Using join buffer (Block Nested Loop) 7457SELECT * 7458FROM t3 7459WHERE col_varchar_10_latin1_key IN ( 7460SELECT alias1.col_varchar_10_latin1_key 7461FROM t1 AS alias1 7462LEFT JOIN t1 AS alias2 7463JOIN t2 AS alias3 7464ON alias2.col_varchar_10_latin1_key 7465ON alias1.col_varchar_1024_utf8_key 7466WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); 7467col_varchar_10_latin1_key 7468a 7469ab 7470DROP TABLE t1, t2, t3; 7471# End of the test for bug#12640083. 7472# 7473# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output 7474# 7475CREATE TABLE t1 ( 7476pk int NOT NULL, 7477col_int_key int NOT NULL, 7478col_varchar_nokey varchar(1) NOT NULL, 7479col_varchar_key varchar(1) NOT NULL, 7480PRIMARY KEY(pk), 7481KEY col_int_key(col_int_key), 7482KEY col_varchar_key(col_varchar_key, col_int_key) 7483) engine=innodb; 7484INSERT INTO t1 VALUES 7485(1,7,'a','a'), 7486(2,0,'v','v'), 7487(3,9,'c','c'), 7488(4,3,'m','m'), 7489(5,2,'a','a'), 7490(6,1,'d','d'), 7491(7,8,'y','y'), 7492(8,6,'t','t'), 7493(11,7,'a','x'), 7494(12,0,'v','v'), 7495(13,9,'c','c'), 7496(14,3,'m','m'), 7497(15,2,'a','x'), 7498(16,1,'d','d'), 7499(17,8,'y','y'), 7500(18,6,'t','u'); 7501CREATE TABLE t2 ( 7502pk int NOT NULL, 7503col_int_key int NOT NULL, 7504col_varchar_key varchar(1) NOT NULL, 7505PRIMARY KEY(pk), 7506KEY col_varchar_key(col_varchar_key, col_int_key) 7507) engine=innodb; 7508INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES 7509(8,7,'c'), 7510(11,4,'l'), 7511(12,7,'b'), 7512(13,0,'c'), 7513(14,2,'i'), 7514(15,9,'h'), 7515(16,4,'q'), 7516(17,1,'m'), 7517(18,9,'b'), 7518(19,2,'e'), 7519(20,1,'c'), 7520(21,7,'z'), 7521(22,4,'l'), 7522(23,7,'z'), 7523(24,0,'c'), 7524(25,2,'i'), 7525(26,9,'h'), 7526(27,4,'q'), 7527(28,0,'a'), 7528(29,1,'d'); 7529EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y 7530FROM t1 AS outr 7531WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key 7532FROM t2 AS innr 7533WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) 7534AND outr.col_varchar_nokey < 't' 7535ORDER BY outr.col_varchar_key, outr.pk; 7536id select_type table type possible_keys key key_len ref rows Extra 75371 SIMPLE innr index_merge PRIMARY,col_varchar_key col_varchar_key,PRIMARY 3,4 NULL 2 Using sort_union(col_varchar_key,PRIMARY); Using where; Using temporary; Using filesort; Start temporary 75381 SIMPLE outr ref col_varchar_key col_varchar_key 3 test.innr.col_varchar_key 1 Using where; End temporary; Using join buffer (Batched Key Access) 7539SELECT outr.col_varchar_key AS x, outr.pk AS y 7540FROM t1 AS outr 7541WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key 7542FROM t2 AS innr 7543WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) 7544AND outr.col_varchar_nokey < 't' 7545ORDER BY outr.col_varchar_key, outr.pk; 7546x y 7547a 1 7548a 5 7549c 3 7550c 13 7551DROP TABLE t1, t2; 7552# End of bug#12603200 7553# 7554# Bug#12603183: Segfault in hp_movelink 7555# 7556CREATE TABLE t1 ( 7557col_varchar_key varchar(1) , 7558col_varchar_nokey varchar(1) , 7559KEY col_varchar_key(col_varchar_key) 7560); 7561INSERT INTO t1 VALUES 7562('i','i'), 7563('h','h'), 7564('q','q'), 7565('a','a'), 7566('v','v'), 7567('u','u'), 7568('s','s'), 7569('y','y'), 7570('z','z'), 7571('h','h'), 7572('p','p'), 7573('e','e'), 7574('i','i'), 7575('y','y'), 7576('w','w'); 7577CREATE TABLE t2 ( 7578col_varchar_nokey varchar(1) 7579); 7580INSERT INTO t2 VALUES 7581('b'); 7582EXPLAIN SELECT grandparent1.col_varchar_nokey 7583FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) 7584WHERE (grandparent1.col_varchar_key) IN 7585(SELECT parent1.col_varchar_nokey 7586FROM t1 AS parent1 7587WHERE parent1.col_varchar_key IN 7588(SELECT child1.col_varchar_nokey AS c1 7589FROM t1 AS child1 LEFT JOIN t2 AS child2 7590ON (child1.col_varchar_key > child2.col_varchar_nokey))); 7591id select_type table type possible_keys key key_len ref rows Extra 75921 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL Using where 75931 SIMPLE grandparent1 ref col_varchar_key col_varchar_key 4 <subquery2>.col_varchar_nokey 2 Using join buffer (Batched Key Access) 75941 SIMPLE grandparent2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 75952 MATERIALIZED child1 ALL NULL NULL NULL NULL 15 Using where 75962 MATERIALIZED child2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 75972 MATERIALIZED parent1 ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 Using join buffer (Batched Key Access) 7598SELECT grandparent1.col_varchar_nokey 7599FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) 7600WHERE (grandparent1.col_varchar_key) IN 7601(SELECT parent1.col_varchar_nokey 7602FROM t1 AS parent1 7603WHERE parent1.col_varchar_key IN 7604(SELECT child1.col_varchar_nokey AS c1 7605FROM t1 AS child1 LEFT JOIN t2 AS child2 7606ON (child1.col_varchar_key > child2.col_varchar_nokey))); 7607col_varchar_nokey 7608a 7609e 7610h 7611h 7612i 7613i 7614p 7615q 7616s 7617u 7618v 7619w 7620y 7621y 7622z 7623DROP TABLE t1, t2; 7624# End of test for bug#12603183. 7625# 7626# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery 7627# 7628CREATE TABLE t1 ( 7629col_int_key INT NOT NULL, 7630col_datetime_key DATETIME NOT NULL, 7631col_varchar_key VARCHAR(1) NOT NULL, 7632KEY col_int_key (col_int_key), 7633KEY col_datetime_key(col_datetime_key), 7634KEY col_varchar_key (col_varchar_key,col_int_key) 7635) ENGINE=InnoDB; 7636INSERT INTO t1 VALUES 7637(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), 7638(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), 7639(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), 7640(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), 7641(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), 7642(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), 7643(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), 7644(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), 7645(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), 7646(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); 7647CREATE TABLE t2 ( 7648col_varchar_nokey VARCHAR(1) NOT NULL 7649) ENGINE=InnoDB; 7650INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); 7651explain SELECT col_varchar_key 7652FROM t1 7653WHERE col_varchar_key IN (SELECT col_varchar_nokey 7654FROM t2) 7655ORDER BY col_datetime_key LIMIT 4; 7656id select_type table type possible_keys key key_len ref rows Extra 76571 SIMPLE t1 ALL col_varchar_key NULL NULL NULL 20 Using where; Using filesort 76581 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 3 test.t1.col_varchar_key 1 NULL 76592 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 NULL 7660SELECT col_varchar_key 7661FROM t1 7662WHERE col_varchar_key IN (SELECT col_varchar_nokey 7663FROM t2) 7664ORDER BY col_datetime_key LIMIT 4; 7665col_varchar_key 7666v 7667y 7668v 7669y 7670DROP TABLE t1, t2; 7671# End of test for bug#12818569. 7672# 7673# Bug#12803439: Assert in replace_subcondition() on update query 7674# 7675CREATE TABLE t1(a INTEGER); 7676INSERT INTO t1 values(1), (2); 7677CREATE TABLE t2(a INTEGER); 7678INSERT INTO t2 VALUES(1), (3); 7679SELECT * 7680FROM t1 7681WHERE a IN (SELECT a 7682FROM t2 7683HAVING a IN (SELECT a 7684FROM t2) 7685) 7686HAVING a IN (SELECT a 7687FROM t2); 7688a 76891 7690DROP TABLE t1, t2; 7691# End of test for bug#12803439. 7692# 7693# Bug#12797534: Segfault in hp_movelink still exists 7694# 7695CREATE TABLE t1 ( 7696g1 VARCHAR(1) NOT NULL 7697) ENGINE=InnoDB; 7698INSERT INTO t1 VALUES ('d'), ('s'); 7699CREATE TABLE t2 ( 7700pk INT NOT NULL, 7701col_int_key INT NOT NULL, 7702col_varchar_key VARCHAR(1) NOT NULL, 7703col_varchar_nokey VARCHAR(1) NOT NULL, 7704PRIMARY KEY (pk), 7705KEY col_varchar_key(col_varchar_key, col_int_key) 7706) ENGINE=InnoDB; 7707INSERT INTO t2 VALUES 7708(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), 7709(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), 7710(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), 7711(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), 7712(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); 7713CREATE TABLE t3 ( 7714pk INTEGER NOT NULL, 7715PRIMARY KEY (pk) 7716) ENGINE=InnoDB; 7717INSERT INTO t3 VALUES (10); 7718EXPLAIN SELECT * 7719FROM t1 7720WHERE g1 NOT IN 7721(SELECT grandparent1.col_varchar_nokey AS g1 7722FROM t2 AS grandparent1 7723WHERE grandparent1.col_varchar_key IN 7724(SELECT parent1.col_varchar_nokey AS p1 7725FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) 7726) 7727AND grandparent1.col_varchar_key IS NOT NULL 7728); 7729id select_type table type possible_keys key key_len ref rows Extra 77301 PRIMARY t1 ALL NULL NULL NULL NULL ROWS Using where 77312 SUBQUERY <subquery3> ALL NULL NULL NULL NULL ROWS NULL 77322 SUBQUERY grandparent1 ref col_varchar_key col_varchar_key 3 <subquery3>.p1 ROWS Using index condition; Using join buffer (Batched Key Access) 77333 MATERIALIZED parent1 ALL NULL NULL NULL NULL ROWS NULL 77343 MATERIALIZED parent2 eq_ref PRIMARY PRIMARY 4 test.parent1.pk ROWS Using index 7735SELECT * 7736FROM t1 7737WHERE g1 NOT IN 7738(SELECT grandparent1.col_varchar_nokey AS g1 7739FROM t2 AS grandparent1 7740WHERE grandparent1.col_varchar_key IN 7741(SELECT parent1.col_varchar_nokey AS p1 7742FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) 7743) 7744AND grandparent1.col_varchar_key IS NOT NULL 7745); 7746g1 7747DROP TABLE t1, t2, t3; 7748CREATE TABLE t1 ( 7749pk INTEGER AUTO_INCREMENT, 7750col_int_key INTEGER , 7751col_varchar_key VARCHAR(1) , 7752col_varchar_nokey VARCHAR(1) , 7753PRIMARY KEY (pk), 7754KEY (col_varchar_key,col_int_key) 7755) ENGINE=INNODB; 7756INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES 7757(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); 7758CREATE TABLE t2 ( 7759pk INTEGER AUTO_INCREMENT, 7760col_int_key INTEGER , 7761col_varchar_key VARCHAR(1) , 7762col_varchar_nokey VARCHAR(1) , 7763PRIMARY KEY (pk), 7764KEY (col_int_key), 7765KEY (col_varchar_key,col_int_key) 7766) AUTO_INCREMENT=10 ENGINE=INNODB; 7767INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES 7768(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); 7769CREATE TABLE t3 7770SELECT outr.col_varchar_nokey AS x 7771FROM t1 AS outr 7772WHERE outr.col_varchar_nokey IN 7773(SELECT innr.col_varchar_nokey AS y 7774FROM t2 AS innr 7775WHERE innr.col_int_key IS NULL) 7776AND outr.col_varchar_nokey IS NOT NULL 7777AND NOT col_varchar_key IS NULL; 7778SELECT * 7779FROM t3 7780WHERE x NOT IN 7781(SELECT outr.col_varchar_nokey AS x 7782FROM t1 AS outr 7783WHERE outr.col_varchar_nokey IN 7784(SELECT innr.col_varchar_nokey AS y 7785FROM t2 AS innr 7786WHERE innr.col_int_key IS NULL) 7787AND outr.col_varchar_nokey IS NOT NULL 7788AND NOT col_varchar_key IS NULL); 7789x 7790DROP TABLE t1, t2, t3; 7791# End of test for bug#12797534. 7792# 7793# Bug#12714094: Assert in optimize_semijoin_nests() 7794# 7795CREATE TABLE it ( 7796pk int NOT NULL, 7797col_varchar VARCHAR(10) DEFAULT NULL, 7798PRIMARY KEY (pk) 7799) ENGINE=MyISAM; 7800INSERT INTO it VALUES (1, 'g'); 7801CREATE TABLE ot 7802SELECT alias1.pk AS field1 7803FROM it AS alias1 7804LEFT JOIN it AS alias2 7805ON alias1.col_varchar = alias2.col_varchar 7806; 7807SELECT * 7808FROM ot 7809WHERE field1 IN ( 7810SELECT alias1.pk 7811FROM it AS alias1 7812LEFT JOIN it AS alias2 7813ON alias1.col_varchar = alias2.col_varchar 7814); 7815field1 78161 7817DROP TABLE it, ot; 7818# End of test for bug#12714094 7819# 7820# Bug#12867557: Valgrind: conditional jump/move at key_cmp 7821# 7822CREATE TABLE t1 ( 7823pk INTEGER AUTO_INCREMENT, 7824col_int_key INTEGER, 7825PRIMARY KEY (pk), 7826KEY (col_int_key) 7827) AUTO_INCREMENT=10; 7828INSERT INTO t1 (col_int_key) VALUES (8); 7829CREATE TABLE t2 ( 7830pk INTEGER AUTO_INCREMENT, 7831col_int_key INTEGER, 7832col_time_key TIME, 7833PRIMARY KEY (pk), 7834KEY (col_int_key), 7835KEY (col_time_key) 7836) AUTO_INCREMENT=10; 7837INSERT INTO t2 (col_int_key, col_time_key) 7838VALUES 7839(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), 7840(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), 7841(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), 7842(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), 7843(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), 7844(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), 7845(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); 7846CREATE TABLE t0 7847SELECT DISTINCT grandparent1.col_time_key AS g1 7848FROM t2 AS grandparent1 7849WHERE grandparent1.col_int_key IN 7850(SELECT parent1.col_int_key AS p1 7851FROM t1 AS parent1) 7852AND grandparent1.pk > 9; 7853UPDATE t0 7854SET g1 = g1 7855WHERE g1 IN 7856(SELECT grandparent1.col_time_key AS g1 7857FROM t2 AS grandparent1 7858WHERE grandparent1.col_int_key IN 7859(SELECT parent1.col_int_key AS p1 7860FROM t1 AS parent1) 7861AND grandparent1.pk > 9); 7862DROP TABLE t0, t1, t2; 7863# End of test for bug#12867557 7864# 7865# Bug#12711441: crash in fix_after_pullout 7866# 7867CREATE TABLE t1 ( 7868pk int NOT NULL, 7869col_int_nokey int DEFAULT NULL, 7870col_int_key int DEFAULT NULL, 7871col_time_key time DEFAULT NULL, 7872col_varchar_key varchar(1) DEFAULT NULL, 7873PRIMARY KEY (pk) 7874); 7875CREATE VIEW v1 AS SELECT * FROM t1; 7876CREATE TABLE t2 ( 7877col_int_key int DEFAULT NULL, 7878col_varchar_key varchar(1) DEFAULT NULL, 7879col_varchar_nokey varchar(1) DEFAULT NULL, 7880KEY col_varchar_key(col_varchar_key, col_int_key) 7881); 7882CREATE TABLE t3 ( 7883pk int NOT NULL, 7884col_int_key INT DEFAULT NULL, 7885PRIMARY KEY (pk) 7886); 7887CREATE TABLE t4 ( 7888col_int_nokey INT DEFAULT NULL, 7889col_varchar_key varchar(1) DEFAULT NULL, 7890col_varchar_nokey varchar(1) DEFAULT NULL, 7891KEY col_varchar_key(col_varchar_key) 7892); 7893CREATE TABLE ts 7894SELECT alias1.col_time_key AS field1 7895FROM v1 AS alias1 7896RIGHT JOIN t3 AS alias2 7897ON alias2.col_int_key = alias1.col_int_nokey 7898WHERE alias1.pk >= SOME( 7899SELECT SQ1_alias1.pk AS SQ1_field1 7900FROM t3 AS SQ1_alias1 7901INNER JOIN (t2 AS SQ1_alias2 7902INNER JOIN t4 AS SQ1_alias3 7903ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) 7904ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key 7905WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key 7906AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) 7907; 7908SELECT * FROM ts WHERE field1 IN ( 7909SELECT alias1.col_time_key AS field1 7910FROM v1 AS alias1 7911RIGHT JOIN t3 AS alias2 7912ON alias2.col_int_key = alias1.col_int_nokey 7913WHERE alias1.pk >= SOME( 7914SELECT SQ1_alias1.pk AS SQ1_field1 7915FROM t3 AS SQ1_alias1 7916INNER JOIN (t2 AS SQ1_alias2 7917INNER JOIN t4 AS SQ1_alias3 7918ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) 7919ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key 7920WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key 7921AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) 7922); 7923field1 7924DROP TABLE t1, t2, t3, t4, ts; 7925DROP VIEW v1; 7926# End of test for bug#12711441. 7927# 7928# Bug#12664936: Same query executed as where subquery ... 7929# 7930CREATE TABLE t1 ( 7931col_varchar_key VARCHAR(1), 7932KEY col_varchar_key (col_varchar_key) 7933); 7934INSERT INTO t1 VALUES 7935('o'), ('w'), ('m'), ('q'), 7936('f'), ('p'), ('j'), ('c'); 7937CREATE TABLE t2 ( 7938col_int_nokey INTEGER, 7939col_int_key INTEGER, 7940col_varchar_key varchar(1), 7941KEY col_int_key (col_int_key) 7942); 7943INSERT INTO t2 VALUES 7944(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), 7945(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); 7946CREATE TABLE t4 7947SELECT t2.col_int_nokey, t2.col_varchar_key 7948FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key 7949WHERE t2.col_int_key = 1; 7950EXPLAIN SELECT * 7951FROM t4 7952WHERE (col_int_nokey, col_varchar_key) IN 7953(SELECT t2.col_int_nokey, t2.col_varchar_key 7954FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key 7955WHERE t2.col_int_key = 1 7956); 7957id select_type table type possible_keys key key_len ref rows Extra 79581 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where 79591 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 9 test.t4.col_int_nokey,test.t4.col_varchar_key 1 NULL 79602 MATERIALIZED t2 ref col_int_key col_int_key 5 const 3 Using where 79612 MATERIALIZED t1 ref col_varchar_key col_varchar_key 4 test.t2.col_varchar_key 2 Using index 7962SELECT * 7963FROM t4 7964WHERE (col_int_nokey, col_varchar_key) IN 7965(SELECT t2.col_int_nokey, t2.col_varchar_key 7966FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key 7967WHERE t2.col_int_key = 1 7968); 7969col_int_nokey col_varchar_key 79708 o 79712 q 7972DROP TABLE t1, t2, t4; 7973# End of test for bug#12664936. 7974# 7975# Bug#13340270: assertion table->sort.record_pointers == __null 7976# 7977CREATE TABLE t1 ( 7978pk int NOT NULL, 7979col_int_key int DEFAULT NULL, 7980col_varchar_key varchar(1) DEFAULT NULL, 7981col_varchar_nokey varchar(1) DEFAULT NULL, 7982PRIMARY KEY (pk), 7983KEY col_int_key (col_int_key), 7984KEY col_varchar_key (col_varchar_key, col_int_key) 7985) ENGINE=InnoDB; 7986INSERT INTO t1 VALUES 7987(10,8,'x','x'), 7988(11,7,'d','d'), 7989(12,1,'r','r'), 7990(13,7,'f','f'), 7991(14,9,'y','y'), 7992(15,NULL,'u','u'), 7993(16,1,'m','m'), 7994(17,9,NULL,NULL), 7995(18,2,'o','o'), 7996(19,9,'w','w'), 7997(20,2,'m','m'), 7998(21,4,'q','q'); 7999CREATE TABLE t2 8000SELECT alias1.col_varchar_nokey AS field1 8001FROM t1 AS alias1 JOIN t1 AS alias2 8002ON alias2.col_int_key = alias1.pk OR 8003alias2.col_int_key = alias1.col_int_key 8004WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' 8005 8006; 8007EXPLAIN SELECT * 8008FROM t2 8009WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 8010FROM t1 AS alias1 JOIN t1 AS alias2 8011ON alias2.col_int_key = alias1.pk OR 8012alias2.col_int_key = alias1.col_int_key 8013WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' 8014); 8015id select_type table type possible_keys key key_len ref rows Extra 80161 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where 80171 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 4 test.t2.field1 1 NULL 80182 MATERIALIZED 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 80192 MATERIALIZED alias2 ALL col_int_key NULL NULL NULL 12 Range checked for each record (index map: 0x2) 8020SELECT * 8021FROM t2 8022WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 8023FROM t1 AS alias1 JOIN t1 AS alias2 8024ON alias2.col_int_key = alias1.pk OR 8025alias2.col_int_key = alias1.col_int_key 8026WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' 8027); 8028field1 8029o 8030o 8031DROP TABLE t1, t2; 8032# End of test for bug#13340270. 8033# 8034# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy 8035# 8036CREATE TABLE ot1(a INTEGER); 8037INSERT INTO ot1 VALUES(1), (2), (3); 8038CREATE TABLE ot2(a INTEGER); 8039INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); 8040CREATE TABLE it1(a INTEGER); 8041INSERT INTO it1 VALUES(1), (3), (5), (7); 8042CREATE TABLE it2(a INTEGER); 8043INSERT INTO it2 VALUES(1), (3), (5), (7), (9); 8044explain SELECT ot1.a, ot2.a 8045FROM ot1, ot2 8046WHERE ot1.a IN (SELECT a FROM it1) AND 8047ot2.a IN (SELECT a FROM it2); 8048id select_type table type possible_keys key key_len ref rows Extra 80491 SIMPLE ot1 ALL NULL NULL NULL NULL 3 NULL 80501 SIMPLE it1 ALL NULL NULL NULL NULL 4 Using where; FirstMatch(ot1); Using join buffer (Block Nested Loop) 80511 SIMPLE <subquery3> ALL NULL NULL NULL NULL NULL Using join buffer (Block Nested Loop) 80521 SIMPLE ot2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (Block Nested Loop) 80533 MATERIALIZED it2 ALL NULL NULL NULL NULL 5 NULL 8054SELECT ot1.a, ot2.a 8055FROM ot1, ot2 8056WHERE ot1.a IN (SELECT a FROM it1) AND 8057ot2.a IN (SELECT a FROM it2); 8058a a 80591 1 80603 1 8061DROP TABLE ot1, ot2, it1, it2; 8062# End of test for bug#13335319. 8063# 8064# Bug#13334882: Assertion keypart_map failed in MyIsam function 8065# 8066CREATE TABLE t1 ( 8067pk int NOT NULL, 8068col_int_nokey INT NOT NULL, 8069col_int_key INT NOT NULL, 8070PRIMARY KEY (pk), 8071KEY col_int_key (col_int_key) 8072) ENGINE=MyISAM; 8073INSERT INTO t1 VALUES 8074(1,4,0), 8075(2,6,8), 8076(3,3,1), 8077(7,2,6), 8078(8,9,1), 8079(9,3,6), 8080(10,8,2), 8081(11,1,4), 8082(12,8,8), 8083(13,8,4), 8084(14,5,4); 8085CREATE TABLE t2 ( 8086pk int NOT NULL, 8087col_int_nokey int NOT NULL, 8088col_int_key int NOT NULL, 8089PRIMARY KEY (pk), 8090KEY col_int_key (col_int_key) 8091) ENGINE=MyISAM; 8092INSERT INTO t2 VALUES 8093(10,8,7); 8094CREATE TABLE t3 8095SELECT grandparent1.col_int_nokey AS g1 8096FROM t1 AS grandparent1 8097WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN 8098(SELECT parent1.col_int_key AS p1, 8099parent1.col_int_key AS p2 8100FROM t1 AS parent1 8101LEFT JOIN t2 AS parent2 8102ON parent1.col_int_nokey = parent2.col_int_key 8103) 8104AND grandparent1.col_int_key <> 3 8105; 8106explain SELECT * FROM t3 8107WHERE g1 NOT IN 8108(SELECT grandparent1.col_int_nokey AS g1 8109FROM t1 AS grandparent1 8110WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN 8111(SELECT parent1.col_int_key AS p1, 8112parent1.col_int_key AS p2 8113FROM t1 AS parent1 8114LEFT JOIN t2 AS parent2 8115ON parent1.col_int_nokey = parent2.col_int_key 8116) 8117AND grandparent1.col_int_key <> 3 8118); 8119id select_type table type possible_keys key key_len ref rows Extra 81201 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 81212 DEPENDENT SUBQUERY grandparent1 ref col_int_key col_int_key 4 func 2 Using index condition; Using where 81222 DEPENDENT SUBQUERY <subquery3> eq_ref <auto_key> <auto_key> 8 test.grandparent1.col_int_nokey,test.grandparent1.col_int_nokey 1 NULL 81233 MATERIALIZED parent1 ref col_int_key col_int_key 4 func 2 NULL 81243 MATERIALIZED parent2 index col_int_key col_int_key 4 NULL 1 Using where; Using index; Using join buffer (Block Nested Loop) 8125explain format=json SELECT * FROM t3 8126WHERE g1 NOT IN 8127(SELECT grandparent1.col_int_nokey AS g1 8128FROM t1 AS grandparent1 8129WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN 8130(SELECT parent1.col_int_key AS p1, 8131parent1.col_int_key AS p2 8132FROM t1 AS parent1 8133LEFT JOIN t2 AS parent2 8134ON parent1.col_int_nokey = parent2.col_int_key 8135) 8136AND grandparent1.col_int_key <> 3 8137); 8138EXPLAIN 8139{ 8140 "query_block": { 8141 "select_id": 1, 8142 "table": { 8143 "message": "Impossible WHERE noticed after reading const tables", 8144 "attached_subqueries": [ 8145 { 8146 "dependent": true, 8147 "cacheable": false, 8148 "query_block": { 8149 "select_id": 3, 8150 "nested_loop": [ 8151 { 8152 "table": { 8153 "table_name": "grandparent1", 8154 "access_type": "ref", 8155 "possible_keys": [ 8156 "col_int_key" 8157 ], 8158 "key": "col_int_key", 8159 "used_key_parts": [ 8160 "col_int_key" 8161 ], 8162 "key_length": "4", 8163 "ref": [ 8164 "func" 8165 ], 8166 "rows": 2, 8167 "filtered": 100, 8168 "index_condition": "(`test`.`grandparent1`.`col_int_key` <> 3)", 8169 "attached_condition": "(((`test`.`grandparent1`.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`) and (<cache>('8') = `test`.`grandparent1`.`col_int_nokey`)) and ((`test`.`grandparent1`.`col_int_nokey` is not null) and (`test`.`grandparent1`.`col_int_nokey` is not null)))" 8170 } 8171 }, 8172 { 8173 "table": { 8174 "table_name": "<subquery3>", 8175 "access_type": "eq_ref", 8176 "key": "<auto_key>", 8177 "key_length": "8", 8178 "ref": [ 8179 "test.grandparent1.col_int_nokey", 8180 "test.grandparent1.col_int_nokey" 8181 ], 8182 "rows": 1, 8183 "materialized_from_subquery": { 8184 "using_temporary_table": true, 8185 "query_block": { 8186 "nested_loop": [ 8187 { 8188 "table": { 8189 "table_name": "parent1", 8190 "access_type": "ref", 8191 "possible_keys": [ 8192 "col_int_key" 8193 ], 8194 "key": "col_int_key", 8195 "used_key_parts": [ 8196 "col_int_key" 8197 ], 8198 "key_length": "4", 8199 "ref": [ 8200 "func" 8201 ], 8202 "rows": 2, 8203 "filtered": 100 8204 } 8205 }, 8206 { 8207 "table": { 8208 "table_name": "parent2", 8209 "access_type": "index", 8210 "possible_keys": [ 8211 "col_int_key" 8212 ], 8213 "key": "col_int_key", 8214 "used_key_parts": [ 8215 "col_int_key" 8216 ], 8217 "key_length": "4", 8218 "rows": 1, 8219 "filtered": 100, 8220 "using_index": true, 8221 "using_join_buffer": "Block Nested Loop", 8222 "attached_condition": "<if>(is_not_null_compl(parent2), (`test`.`parent1`.`col_int_nokey` = `test`.`parent2`.`col_int_key`), true)" 8223 } 8224 } 8225 ] 8226 } 8227 } 8228 } 8229 } 8230 ] 8231 } 8232 } 8233 ] 8234 } 8235 } 8236} 8237Warnings: 8238Note 1003 /* select#1 */ select '8' AS `g1` from dual where (not(<in_optimizer>('8',<exists>(/* select#2 */ select 1 from `test`.`t1` `grandparent1` semi join (`test`.`t1` `parent1` left join `test`.`t2` `parent2` on((`test`.`parent1`.`col_int_nokey` = `test`.`parent2`.`col_int_key`))) where ((`test`.`grandparent1`.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`) and (`<subquery3>`.`p1` = `test`.`grandparent1`.`col_int_nokey`) and (`<subquery3>`.`p2` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`grandparent1`.`col_int_key` <> 3) and (<cache>('8') = `test`.`grandparent1`.`col_int_nokey`)))))) 8239SELECT * FROM t3 8240WHERE g1 NOT IN 8241(SELECT grandparent1.col_int_nokey AS g1 8242FROM t1 AS grandparent1 8243WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN 8244(SELECT parent1.col_int_key AS p1, 8245parent1.col_int_key AS p2 8246FROM t1 AS parent1 8247LEFT JOIN t2 AS parent2 8248ON parent1.col_int_nokey = parent2.col_int_key 8249) 8250AND grandparent1.col_int_key <> 3 8251); 8252g1 8253DROP TABLE t1, t2, t3; 8254# End of test for bug#13334882. 8255# 8256# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution 8257# 8258CREATE TABLE t1 ( 8259col_int_nokey INT, 8260col_varchar_nokey VARCHAR(1) 8261); 8262INSERT INTO t1 VALUES 8263(1,'o'), 8264(2,'t'); 8265CREATE TABLE t2 LIKE t1; 8266INSERT INTO t2 VALUES 8267(1,'o'), 8268(4,'f'); 8269CREATE VIEW v_t2 AS SELECT * FROM t2; 8270CREATE TABLE t3 LIKE t1; 8271INSERT INTO t3 VALUES 8272(1,'o'), 8273(4,'f'); 8274explain SELECT alias1.col_varchar_nokey 8275FROM t1 AS alias1 8276INNER JOIN v_t2 AS alias2 8277ON alias2.col_int_nokey = alias1.col_int_nokey AND 8278'o' IN (SELECT col_varchar_nokey 8279FROM t3); 8280id select_type table type possible_keys key key_len ref rows Extra 82811 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; FirstMatch 82821 SIMPLE alias1 ALL NULL NULL NULL NULL 2 Using join buffer (Block Nested Loop) 82831 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 8284SELECT alias1.col_varchar_nokey 8285FROM t1 AS alias1 8286INNER JOIN v_t2 AS alias2 8287ON alias2.col_int_nokey = alias1.col_int_nokey AND 8288'o' IN (SELECT col_varchar_nokey 8289FROM t3); 8290col_varchar_nokey 8291o 8292PREPARE stmt FROM "SELECT alias1.col_varchar_nokey 8293FROM t1 AS alias1 8294INNER JOIN v_t2 AS alias2 8295ON alias2.col_int_nokey = alias1.col_int_nokey AND 8296'o' IN (SELECT col_varchar_nokey 8297FROM t3)"; 8298EXECUTE stmt; 8299col_varchar_nokey 8300o 8301DROP VIEW v_t2; 8302DROP TABLE t1, t2, t3; 8303# End of test for bug#13339643. 8304# 8305# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses 8306# 8307CREATE TABLE t1 ( 8308pk int NOT NULL, 8309col_int_nokey int NOT NULL, 8310col_int_key int NOT NULL, 8311PRIMARY KEY (pk), 8312KEY col_int_key (col_int_key) 8313) ENGINE=MyIsam; 8314INSERT INTO t1 VALUES 8315(10,1,7), (13,7,3), (18,0,1), (23,8,1); 8316CREATE TABLE t2 ( 8317pk int NOT NULL, 8318col_int_key int NOT NULL, 8319PRIMARY KEY (pk), 8320KEY col_int_key (col_int_key) 8321) ENGINE=MyIsam; 8322INSERT INTO t2 VALUES (1,7); 8323EXPLAIN SELECT t1a.* 8324FROM t1 AS t1a 8325JOIN t1 AS t1b USING ( col_int_nokey ) 8326WHERE t1a.col_int_key IN ( 8327SELECT pk 8328FROM t2 8329WHERE col_int_key IN ( 8330SELECT col_int_nokey 8331FROM t1 8332) 8333); 8334id select_type table type possible_keys key key_len ref rows Extra 83351 SIMPLE t2 system PRIMARY,col_int_key NULL NULL NULL 1 NULL 83361 SIMPLE t1a ref col_int_key col_int_key 4 const 1 NULL 83371 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where; FirstMatch(t1a); Using join buffer (Block Nested Loop) 83381 SIMPLE t1b ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop) 8339SELECT t1a.* 8340FROM t1 AS t1a 8341JOIN t1 AS t1b USING ( col_int_nokey ) 8342WHERE t1a.col_int_key IN ( 8343SELECT pk 8344FROM t2 8345WHERE col_int_key IN ( 8346SELECT col_int_nokey 8347FROM t1 8348) 8349); 8350pk col_int_nokey col_int_key 835118 0 1 835223 8 1 8353ALTER TABLE t1 ENGINE=Innodb; 8354ALTER TABLE t2 ENGINE=Innodb; 8355SELECT t1a.* 8356FROM t1 AS t1a 8357JOIN t1 AS t1b USING ( col_int_nokey ) 8358WHERE t1a.col_int_key IN ( 8359SELECT pk 8360FROM t2 8361WHERE col_int_key IN ( 8362SELECT col_int_nokey 8363FROM t1 8364) 8365); 8366pk col_int_nokey col_int_key 836718 0 1 836823 8 1 8369DROP TABLE t1, t2; 8370# End of test for bug#13424134. 8371# 8372# Bug#13414014: Extra rows in result on semijoin query with where ... 8373# 8374CREATE TABLE t1 ( 8375c INT, 8376d INT, 8377a VARCHAR(1), 8378b VARCHAR(1), 8379KEY a (a) 8380); 8381INSERT INTO t1 VALUES 8382(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); 8383CREATE TABLE t2 ( 8384a VARCHAR(1), 8385KEY a (a) 8386); 8387INSERT INTO t2 VALUES 8388('c'), (NULL), ('x'), ('q'); 8389explain SELECT * 8390FROM t2 AS ot 8391WHERE (a, a) IN 8392(SELECT a, b 8393FROM t1 AS it 8394WHERE it.a = 'x' OR it.c > it.d 8395) 8396; 8397id select_type table type possible_keys key key_len ref rows Extra 83981 SIMPLE ot index a a 4 NULL 4 Using index 83991 SIMPLE it ALL a NULL NULL NULL 3 Using where; FirstMatch(ot); Using join buffer (Block Nested Loop) 8400SELECT * 8401FROM t2 AS ot 8402WHERE (a, a) IN 8403(SELECT a, b 8404FROM t1 AS it 8405WHERE it.a = 'x' OR it.c > it.d 8406) 8407; 8408a 8409x 8410q 8411DROP TABLE t1, t2; 8412# End of test for bug#13414014. 8413# 8414# Bug#13545215: Missing rows on nested in-subquery with materialization 8415# 8416CREATE TABLE t1 ( 8417col_int_key int, 8418col_varchar_key varchar(1), 8419col_varchar_nokey varchar(1), 8420KEY col_int_key (col_int_key), 8421KEY col_varchar_key (col_varchar_key,col_int_key) 8422) ; 8423INSERT INTO t1 VALUES 8424(8,'x','x'), (0,'p','p'), (8,'c','c'); 8425CREATE TABLE t2 ( 8426pk int NOT NULL, 8427col_varchar_key varchar(1), 8428col_varchar_nokey varchar(1), 8429PRIMARY KEY (pk), 8430KEY col_varchar_key (col_varchar_key) 8431); 8432INSERT INTO t2 VALUES 8433(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), 8434(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); 8435CREATE TABLE t3 ( 8436col_int_nokey int 8437); 8438INSERT INTO t3 VALUES (7); 8439explain SELECT grandparent1.col_varchar_nokey 8440FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) 8441WHERE grandparent1.col_varchar_key IN ( 8442SELECT col_varchar_nokey 8443FROM t2 AS parent1 8444WHERE col_varchar_key IN ( 8445SELECT child1.col_varchar_nokey 8446FROM t2 AS child1 LEFT JOIN t3 AS child2 8447ON child1.pk < child2.col_int_nokey 8448) 8449); 8450id select_type table type possible_keys key key_len ref rows Extra 84511 SIMPLE grandparent1 ALL col_int_key,col_varchar_key NULL NULL NULL 3 Using where 84521 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 4 test.grandparent1.col_varchar_key 1 NULL 84531 SIMPLE grandparent2 index col_int_key col_int_key 5 NULL 3 Using where; Using index; Using join buffer (Block Nested Loop) 84542 MATERIALIZED child1 ALL NULL NULL NULL NULL 8 NULL 84552 MATERIALIZED child2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (Block Nested Loop) 84562 MATERIALIZED parent1 ALL col_varchar_key NULL NULL NULL 8 Using where; Using join buffer (Block Nested Loop) 8457SELECT grandparent1.col_varchar_nokey 8458FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) 8459WHERE grandparent1.col_varchar_key IN ( 8460SELECT col_varchar_nokey 8461FROM t2 AS parent1 8462WHERE col_varchar_key IN ( 8463SELECT child1.col_varchar_nokey 8464FROM t2 AS child1 LEFT JOIN t3 AS child2 8465ON child1.pk < child2.col_int_nokey 8466) 8467); 8468col_varchar_nokey 8469c 8470c 8471p 8472x 8473x 8474DROP TABLE t1, t2, t3; 8475# End of test for bug#13545215. 8476# 8477# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND 8478# MATERIALIZATION + SEMIJOIN ON 8479# 8480CREATE TABLE t1 ( 8481col_int_key int(11) DEFAULT NULL, 8482col_varchar_key varchar(1) DEFAULT NULL, 8483col_varchar_nokey varchar(1) DEFAULT NULL, 8484KEY col_int_key (col_int_key), 8485KEY col_varchar_key (col_varchar_key,col_int_key) 8486); 8487INSERT INTO t1 VALUES (4,'v','v'); 8488INSERT INTO t1 VALUES (62,'v','v'); 8489INSERT INTO t1 VALUES (7,'c','c'); 8490INSERT INTO t1 VALUES (1,NULL,NULL); 8491EXPLAIN SELECT 8492alias1.col_varchar_nokey AS a1_nokey, 8493alias1.col_varchar_key AS a1_key, 8494alias2.col_varchar_nokey AS a2_nokey 8495FROM 8496t1 AS alias1, t1 AS alias2 8497WHERE 8498(alias1.col_varchar_nokey,alias2.col_varchar_nokey) 8499IN 8500( 8501SELECT 8502SQ2_alias2.col_varchar_nokey, SQ2_alias1.col_varchar_key 8503FROM 8504t1 AS SQ2_alias1, t1 AS SQ2_alias2 8505) 8506; 8507id select_type table type possible_keys key key_len ref rows Extra 85081 SIMPLE alias1 ALL NULL NULL NULL NULL 4 Using where 85091 SIMPLE alias2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (Block Nested Loop) 85101 SIMPLE <subquery2> eq_ref <auto_key> <auto_key> 8 test.alias1.col_varchar_nokey,test.alias2.col_varchar_nokey 1 NULL 85112 MATERIALIZED SQ2_alias1 index col_varchar_key col_varchar_key 9 NULL 4 Using index 85122 MATERIALIZED SQ2_alias2 ALL NULL NULL NULL NULL 4 Using join buffer (Block Nested Loop) 8513SELECT 8514alias1.col_varchar_nokey AS a1_nokey, 8515alias1.col_varchar_key AS a1_key, 8516alias2.col_varchar_nokey AS a2_nokey 8517FROM 8518t1 AS alias1, t1 AS alias2 8519WHERE 8520(alias1.col_varchar_nokey,alias2.col_varchar_nokey) 8521IN 8522( 8523SELECT 8524SQ2_alias2.col_varchar_nokey, SQ2_alias1.col_varchar_key 8525FROM 8526t1 AS SQ2_alias1, t1 AS SQ2_alias2 8527) 8528; 8529a1_nokey a1_key a2_nokey 8530c c c 8531c c v 8532c c v 8533v v c 8534v v c 8535v v v 8536v v v 8537v v v 8538v v v 8539DROP TABLE t1; 8540# 8541# Bug#13541406: Wrong result with loosescan on select .. where .. in 8542# 8543CREATE TABLE t1 ( 8544col_int_key INT NOT NULL, 8545col_varchar_nokey VARCHAR(1) NOT NULL, 8546KEY col_int_key (col_int_key) 8547) ENGINE=InnoDB; 8548INSERT INTO t1 VALUES 8549(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), 8550(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), 8551(9,'e'), (5,'i'), (0,'y'), (3,'w'); 8552CREATE TABLE t2 ( 8553pk INT NOT NULL, 8554col_int_key INT NOT NULL, 8555col_varchar_key VARCHAR(1) NOT NULL, 8556col_varchar_nokey VARCHAR(1) NOT NULL, 8557PRIMARY KEY (pk), 8558KEY col_int_key (col_int_key), 8559KEY col_varchar_key (col_varchar_key,col_int_key) 8560) ENGINE=InnoDB; 8561INSERT INTO t2 VALUES 8562(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), 8563(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), 8564(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), 8565(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), 8566(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); 8567# This query should never use a LooseScan strategy 8568explain SELECT ot1.col_int_key AS field1 8569FROM t2 AS ot1, t2 AS ot2 8570WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( 8571SELECT it2.col_varchar_nokey, it1.col_varchar_key 8572FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); 8573id select_type table type possible_keys key key_len ref rows Extra 85741 SIMPLE ot2 ALL NULL NULL NULL NULL 20 Start temporary 85751 SIMPLE it1 ref PRIMARY,col_varchar_key col_varchar_key 3 test.ot2.col_varchar_nokey 1 Using index 85761 SIMPLE it2 ref col_int_key col_int_key 4 test.it1.pk 1 Using join buffer (Batched Key Access) 85771 SIMPLE ot1 ref col_varchar_key col_varchar_key 3 test.it2.col_varchar_nokey 1 Using index; End temporary 8578SELECT ot1.col_int_key AS field1 8579FROM t2 AS ot1, t2 AS ot2 8580WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( 8581SELECT it2.col_varchar_nokey, it1.col_varchar_key 8582FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); 8583field1 85841 85851 85861 85872 85886 85896 85906 85916 85926 85938 85948 85958 85968 85978 85988 85999 8600DROP TABLE t1, t2; 8601# End of test for bug#13541406. 8602# 8603# Bug#13576391: Missing rows on select with in-subquery and 8604# batched-key-access=on and semijoin 8605# 8606CREATE TABLE t1 ( 8607col_int_nokey int NOT NULL, 8608col_varchar_key varchar(1) NOT NULL, 8609KEY col_varchar_key (col_varchar_key) 8610) engine=InnoDB; 8611INSERT INTO t1 VALUES 8612(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), 8613(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), 8614(6,'e'), (3,'i'), (6,'y'), (6,'w'); 8615CREATE TABLE t2 ( 8616col_int_nokey int NOT NULL, 8617col_varchar_nokey varchar(1) NOT NULL 8618) engine=InnoDB; 8619INSERT INTO t2 VALUES 8620(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), 8621(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), 8622(1,'q'), (6,'w'), (2,'d'), (9,'e'); 8623explain SELECT col_varchar_nokey 8624FROM t2 AS ot 8625WHERE col_varchar_nokey IN ( 8626SELECT col_varchar_key 8627FROM t1 AS it 8628WHERE it.col_int_nokey <= it.col_int_nokey 8629AND NOT ot.col_int_nokey < 2 8630) 8631ORDER BY col_varchar_nokey; 8632id select_type table type possible_keys key key_len ref rows Extra 86331 SIMPLE ot ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort 86341 SIMPLE it ref col_varchar_key col_varchar_key 3 test.ot.col_varchar_nokey 1 FirstMatch(ot); Using join buffer (Batched Key Access) 8635SELECT col_varchar_nokey 8636FROM t2 AS ot 8637WHERE col_varchar_nokey IN ( 8638SELECT col_varchar_key 8639FROM t1 AS it 8640WHERE it.col_int_nokey <= it.col_int_nokey 8641AND NOT ot.col_int_nokey < 2 8642) 8643ORDER BY col_varchar_nokey; 8644col_varchar_nokey 8645c 8646e 8647p 8648s 8649v 8650w 8651y 8652ALTER TABLE t1 ENGINE=MyISAM; 8653ALTER TABLE t2 ENGINE=MyISAM; 8654explain SELECT col_varchar_nokey 8655FROM t2 AS ot 8656WHERE col_varchar_nokey IN ( 8657SELECT col_varchar_key 8658FROM t1 AS it 8659WHERE it.col_int_nokey <= it.col_int_nokey 8660AND NOT ot.col_int_nokey < 2 8661) 8662ORDER BY col_varchar_nokey; 8663id select_type table type possible_keys key key_len ref rows Extra 86641 SIMPLE ot ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort 86651 SIMPLE it ref col_varchar_key col_varchar_key 3 test.ot.col_varchar_nokey 2 FirstMatch(ot); Using join buffer (Batched Key Access) 8666SELECT col_varchar_nokey 8667FROM t2 AS ot 8668WHERE col_varchar_nokey IN ( 8669SELECT col_varchar_key 8670FROM t1 AS it 8671WHERE it.col_int_nokey <= it.col_int_nokey 8672AND NOT ot.col_int_nokey < 2 8673) 8674ORDER BY col_varchar_nokey; 8675col_varchar_nokey 8676c 8677e 8678p 8679s 8680v 8681w 8682y 8683ALTER TABLE t1 ENGINE=Memory; 8684ALTER TABLE t2 ENGINE=Memory; 8685explain SELECT col_varchar_nokey 8686FROM t2 AS ot 8687WHERE col_varchar_nokey IN ( 8688SELECT col_varchar_key 8689FROM t1 AS it 8690WHERE it.col_int_nokey <= it.col_int_nokey 8691AND NOT ot.col_int_nokey < 2 8692) 8693ORDER BY col_varchar_nokey; 8694id select_type table type possible_keys key key_len ref rows Extra 86951 SIMPLE ot ALL NULL NULL NULL NULL 20 Using where; Using filesort 86961 SIMPLE it ref col_varchar_key col_varchar_key 3 test.ot.col_varchar_nokey 2 FirstMatch(ot) 8697SELECT col_varchar_nokey 8698FROM t2 AS ot 8699WHERE col_varchar_nokey IN ( 8700SELECT col_varchar_key 8701FROM t1 AS it 8702WHERE it.col_int_nokey <= it.col_int_nokey 8703AND NOT ot.col_int_nokey < 2 8704) 8705ORDER BY col_varchar_nokey; 8706col_varchar_nokey 8707c 8708e 8709p 8710s 8711v 8712w 8713y 8714DROP TABLE t1, t2; 8715# End of test for bug#13576391. 8716# 8717# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" 8718# 8719CREATE TABLE t1 ( 8720id INT, 8721col_varchar_key VARCHAR(1), 8722col_varchar_nokey VARCHAR(1), 8723KEY (col_varchar_key) 8724); 8725INSERT INTO t1 VALUES (100,'m','m'), 8726(200,'b','b'), (300,'x','x'); 8727CREATE TABLE t2 ( 8728col_varchar_key VARCHAR(1), 8729col_varchar_nokey VARCHAR(1), 8730KEY (col_varchar_key) 8731); 8732INSERT INTO t2 VALUES ('b','b'); 8733CREATE TABLE t3 ( 8734col_varchar_key VARCHAR(1), 8735col_varchar_nokey VARCHAR(1), 8736KEY (col_varchar_key) 8737); 8738INSERT INTO t3 VALUES ('k','k'); 8739EXPLAIN SELECT GP1.id 8740FROM t1 AS GP1 JOIN t3 AS GP2 8741ON GP2.col_varchar_key <> GP1.col_varchar_nokey 8742WHERE (GP1.col_varchar_nokey, GP1.col_varchar_nokey) 8743IN ( 8744SELECT col_varchar_nokey, col_varchar_nokey 8745FROM t1 8746WHERE col_varchar_nokey 8747IN ( SELECT col_varchar_key 8748FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) 8749) 8750; 8751id select_type table type possible_keys key key_len ref rows Extra 87521 SIMPLE GP2 system NULL NULL NULL NULL 1 NULL 87531 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL Using where 87541 SIMPLE GP1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (Block Nested Loop) 87552 MATERIALIZED t2 index col_varchar_key col_varchar_key 4 NULL 1 Using index 87562 MATERIALIZED t3 ref col_varchar_key col_varchar_key 4 test.t2.col_varchar_key 2 Using index 87572 MATERIALIZED t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (Block Nested Loop) 8758SELECT GP1.id 8759FROM t1 AS GP1 JOIN t3 AS GP2 8760ON GP2.col_varchar_key <> GP1.col_varchar_nokey 8761WHERE (GP1.col_varchar_nokey, GP1.col_varchar_nokey) 8762IN ( 8763SELECT col_varchar_nokey, col_varchar_nokey 8764FROM t1 8765WHERE col_varchar_nokey 8766IN ( SELECT col_varchar_key 8767FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) 8768) 8769; 8770id 8771200 8772DROP TABLE t1,t2,t3; 8773# 8774# Bug #13596176: Missing row on select with nested in clause when 8775# matr=on and bnl=off + MyISAM 8776# 8777CREATE TABLE t1 ( 8778int_key int DEFAULT NULL, 8779vc_key varchar(1) DEFAULT NULL, 8780vc_nokey varchar(1) DEFAULT NULL, 8781KEY int_key (int_key), 8782KEY vc_key (vc_key, int_key) 8783) ENGINE=MyISAM; 8784INSERT INTO t1 VALUES 8785(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), 8786(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), 8787(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), 8788(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), 8789(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); 8790CREATE TABLE t2 ( 8791int_key int DEFAULT NULL, 8792vc_key varchar(1) DEFAULT NULL, 8793KEY int_key (int_key), 8794KEY vc_key (vc_key, int_key) 8795) ENGINE=MyISAM; 8796INSERT INTO t2 VALUES (8,'g'); 8797explain SELECT vc_key 8798FROM t1 as outr 8799WHERE (vc_nokey, vc_key ) IN 8800(SELECT vc_nokey, vc_nokey 8801FROM t1 middle 8802WHERE vc_nokey IN 8803(SELECT child1.vc_key 8804FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) 8805) 8806); 8807id select_type table type possible_keys key key_len ref rows Extra 88081 SIMPLE child1 index int_key,vc_key vc_key 9 NULL 1 Using where; Using index; Start temporary 88091 SIMPLE outr ref vc_key vc_key 4 test.child1.vc_key 3 Using where; Using join buffer (Batched Key Access) 88101 SIMPLE child2 ref int_key int_key 5 test.child1.int_key 3 Using index 88111 SIMPLE middle ALL NULL NULL NULL NULL 20 Using where; End temporary; Using join buffer (Block Nested Loop) 8812SELECT vc_key 8813FROM t1 as outr 8814WHERE (vc_nokey, vc_key ) IN 8815(SELECT vc_nokey, vc_nokey 8816FROM t1 middle 8817WHERE vc_nokey IN 8818(SELECT child1.vc_key 8819FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) 8820) 8821); 8822vc_key 8823g 8824DROP TABLE t1, t2; 8825# End of test for bug#13596176. 8826# 8827# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS 8828# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO 8829# ROWS + INDEX DOES NOT RETURN NULL 8830# 8831CREATE TABLE t1 ( 8832pk int(11) PRIMARY KEY, 8833int_key int(11), 8834KEY int_key (int_key) 8835); 8836INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); 8837SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); 8838MIN(int_key) 8839NULL 8840SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); 8841MIN(int_key) 88420 8843SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; 8844MIN(pk) 8845NULL 8846DROP TABLE t1; 8847# BUG#13726217: Crash in Item_ident::fix_after_pullout() 8848CREATE TABLE t1(a INTEGER) engine=innodb; 8849INSERT INTO t1 VALUES (0); 8850SELECT 0 8851FROM t1 8852WHERE 0 IN 8853(SELECT 0 8854FROM t1 8855WHERE 0 LIKE 8856(SELECT elt(a, 0) AS b 8857FROM t1 8858GROUP BY a 8859HAVING b 8860) 8861); 88620 8863DROP TABLE t1; 8864# End of test for bug#13726217. 8865# BUG#13773979: Missing rows on second execution of prepared statement 8866CREATE TABLE t1 ( 8867col_int_nokey INT, 8868col_int_key INT, 8869col_varchar_key VARCHAR(1) 8870); 8871INSERT INTO t1 VALUES 8872(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), 8873(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); 8874CREATE VIEW v1 AS SELECT * FROM t1; 8875SELECT * 8876FROM t1 8877WHERE col_int_key IN ( 8878SELECT alias1.col_int_nokey AS field1 8879FROM v1 AS alias1 8880WHERE alias1.col_varchar_key < 'v' 8881); 8882col_int_nokey col_int_key col_varchar_key 88831 7 v 88847 0 s 88854 9 l 88862 2 i 8887prepare stmt FROM "SELECT * 8888FROM t1 8889WHERE col_int_key IN ( 8890SELECT alias1.col_int_nokey AS field1 8891FROM v1 AS alias1 8892WHERE alias1.col_varchar_key < 'v' 8893)"; 8894execute stmt; 8895col_int_nokey col_int_key col_varchar_key 88961 7 v 88977 0 s 88984 9 l 88992 2 i 8900execute stmt; 8901col_int_nokey col_int_key col_varchar_key 89021 7 v 89037 0 s 89044 9 l 89052 2 i 8906DEALLOCATE PREPARE stmt; 8907DROP VIEW v1; 8908DROP TABLE t1; 8909# End of test for bug#13773979. 8910# 8911# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN 8912# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER 8913# 8914CREATE TABLE t1 ( 8915col_int_key INT(11) NOT NULL, 8916col_datetime_key DATETIME NOT NULL, 8917col_varchar_key VARCHAR(1) NOT NULL, 8918col_varchar_nokey VARCHAR(1) NOT NULL, 8919KEY col_int_key (col_int_key), 8920KEY col_datetime_key (col_datetime_key), 8921KEY col_varchar_key (col_varchar_key,col_int_key) 8922); 8923INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); 8924INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); 8925CREATE TABLE t2 ( 8926col_int_key INT(11) NOT NULL, 8927col_datetime_key DATETIME NOT NULL, 8928col_varchar_key VARCHAR(1) NOT NULL, 8929col_varchar_nokey VARCHAR(1) NOT NULL, 8930KEY col_int_key (col_int_key), 8931KEY col_datetime_key (col_datetime_key), 8932KEY col_varchar_key (col_varchar_key,col_int_key) 8933); 8934INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); 8935SET @old_depth=@@optimizer_search_depth; 8936SET optimizer_search_depth=4; 8937EXPLAIN SELECT col_datetime_key 8938FROM t1 as outr 8939WHERE col_datetime_key IN ( 8940SELECT alias1.col_datetime_key 8941FROM t1 AS alias1 8942LEFT JOIN t1 as alias3 8943STRAIGHT_JOIN ( t2 AS alias4 8944JOIN t1 AS alias5 8945ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) 8946ON alias5.col_int_key < alias4.col_int_key 8947ON alias5.col_varchar_key = alias4.col_varchar_key 8948); 8949id select_type table type possible_keys key key_len ref rows Extra 89501 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 89511 SIMPLE outr index col_datetime_key col_datetime_key 5 NULL 2 Using where; Using index; Using join buffer (Block Nested Loop) 89522 MATERIALIZED alias1 index NULL col_datetime_key 5 NULL 2 Using index 89532 MATERIALIZED alias4 ALL col_int_key,col_varchar_key NULL NULL NULL 1 NULL 89542 MATERIALIZED alias5 ref col_int_key,col_varchar_key col_varchar_key 3 test.alias4.col_varchar_key 1 Using where; Using index 89552 MATERIALIZED alias3 index NULL col_int_key 4 NULL 2 Using index 8956SELECT col_datetime_key 8957FROM t1 as outr 8958WHERE col_datetime_key IN ( 8959SELECT alias1.col_datetime_key 8960FROM t1 AS alias1 8961LEFT JOIN t1 as alias3 8962STRAIGHT_JOIN ( t2 AS alias4 8963JOIN t1 AS alias5 8964ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) 8965ON alias5.col_int_key < alias4.col_int_key 8966ON alias5.col_varchar_key = alias4.col_varchar_key 8967); 8968col_datetime_key 89692002-02-13 17:30:06 89702008-09-27 00:34:58 8971DROP TABLE t1,t2; 8972SET @@optimizer_search_depth=@old_depth; 8973# 8974# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 8975# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN 8976# 8977CREATE TABLE t1 ( 8978col_int_key INT, 8979col_varchar_key VARCHAR(1), 8980KEY col_int_key (col_int_key), 8981KEY col_varchar_key (col_varchar_key) 8982); 8983INSERT INTO t1 VALUES (8,'x'); 8984CREATE TABLE t2 ( 8985col_varchar_key VARCHAR(1), 8986KEY col_varchar_key (col_varchar_key) 8987); 8988INSERT INTO t2 VALUES ('x'), ('y'); 8989explain SELECT MIN(col_int_key) 8990FROM t1 as t1_outer 8991HAVING (1, 2) IN ( 8992SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) 8993FROM t1 as t1_inner JOIN t2 8994ON t2.col_varchar_key = t1_inner.col_varchar_key 8995); 8996id select_type table type possible_keys key key_len ref rows Extra 89971 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away 89982 SUBQUERY t1_inner system col_varchar_key NULL NULL NULL 1 NULL 89992 SUBQUERY t2 ref col_varchar_key col_varchar_key 4 const 1 Using index 9000SELECT MIN(col_int_key) 9001FROM t1 as t1_outer 9002HAVING (1, 2) IN ( 9003SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) 9004FROM t1 as t1_inner JOIN t2 9005ON t2.col_varchar_key = t1_inner.col_varchar_key 9006); 9007MIN(col_int_key) 9008DROP TABLE t1,t2; 9009# Bug#13838810: Segfault in evaluate_null_complemented_join_record 9010CREATE TABLE t1 ( 9011pk int NOT NULL, 9012col_int_nokey int DEFAULT NULL, 9013col_int_key int DEFAULT NULL, 9014col_varchar_key varchar(1) DEFAULT NULL, 9015PRIMARY KEY (pk), 9016KEY col_int_key (col_int_key), 9017KEY col_varchar_key (col_varchar_key,col_int_key) 9018) ENGINE=InnoDB; 9019INSERT INTO t1 VALUES (10,NULL,8,'x'); 9020CREATE TABLE t2 ( 9021pk int NOT NULL, 9022col_varchar_nokey varchar(1) DEFAULT NULL, 9023PRIMARY KEY (pk) 9024) ENGINE=InnoDB; 9025INSERT INTO t2 VALUES (1,'x'); 9026CREATE TABLE t3 ( 9027pk int NOT NULL, 9028col_varchar_key varchar(1) DEFAULT NULL, 9029col_varchar_nokey varchar(1) DEFAULT NULL, 9030PRIMARY KEY (pk), 9031KEY col_varchar_key (col_varchar_key) 9032) ENGINE=InnoDB; 9033INSERT INTO t3 VALUES 9034(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); 9035EXPLAIN SELECT table1.pk,table2.pk, table3.pk 9036FROM t2 AS table1 9037LEFT JOIN t1 AS table2 9038LEFT JOIN t1 AS table3 9039ON table3.col_int_key = table2.col_int_key 9040ON table3.pk = table2.col_int_nokey AND 9041table1.col_varchar_nokey IN ( 9042SELECT subquery3_t1.col_varchar_nokey 9043FROM t3 AS subquery3_t1 9044LEFT JOIN t1 AS subquery3_t2 9045ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key 9046WHERE subquery3_t2.col_int_nokey <> 9 9047) 9048; 9049id select_type table type possible_keys key key_len ref rows Extra 90501 SIMPLE table1 ALL NULL NULL NULL NULL 1 NULL 90511 SIMPLE table2 ALL col_int_key NULL NULL NULL 1 Using where 90521 SIMPLE table3 eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 Using where 90531 SIMPLE subquery3_t2 ALL col_varchar_key NULL NULL NULL 1 Using where 90541 SIMPLE subquery3_t1 ref col_varchar_key col_varchar_key 4 test.subquery3_t2.col_varchar_key 1 Using where; FirstMatch(table3) 9055SELECT table1.pk,table2.pk, table3.pk 9056FROM t2 AS table1 9057LEFT JOIN t1 AS table2 9058LEFT JOIN t1 AS table3 9059ON table3.col_int_key = table2.col_int_key 9060ON table3.pk = table2.col_int_nokey AND 9061table1.col_varchar_nokey IN ( 9062SELECT subquery3_t1.col_varchar_nokey 9063FROM t3 AS subquery3_t1 9064LEFT JOIN t1 AS subquery3_t2 9065ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key 9066WHERE subquery3_t2.col_int_nokey <> 9 9067) 9068; 9069pk pk pk 90701 NULL NULL 9071DROP TABLE t1, t2, t3; 9072Extra test case for specific code coverage 9073CREATE TABLE t1(pk INTEGER); 9074INSERT INTO t1 VALUES(1), (2); 9075explain SELECT * 9076FROM t1 AS ot1 LEFT JOIN t1 AS ot2 9077ON ot1.pk=ot2.pk AND 9078ot2.pk IN 9079(SELECT it1.pk 9080FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); 9081id select_type table type possible_keys key key_len ref rows Extra 90821 SIMPLE ot1 ALL NULL NULL NULL NULL 2 Start temporary 90831 SIMPLE ot2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 90841 SIMPLE it1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (Block Nested Loop) 90851 SIMPLE it2 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (Block Nested Loop) 9086SELECT * 9087FROM t1 AS ot1 LEFT JOIN t1 AS ot2 9088ON ot1.pk=ot2.pk AND 9089ot2.pk IN 9090(SELECT it1.pk 9091FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); 9092pk pk 90931 1 90942 2 9095DROP TABLE t1; 9096# End of test for bug#13838810. 9097# 9098# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN 9099# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER 9100# 9101CREATE TABLE t1 ( 9102col_int_key INT(11) NOT NULL, 9103col_datetime_key DATETIME NOT NULL, 9104col_varchar_key VARCHAR(1) NOT NULL, 9105col_varchar_nokey VARCHAR(1) NOT NULL, 9106KEY col_int_key (col_int_key), 9107KEY col_datetime_key (col_datetime_key), 9108KEY col_varchar_key (col_varchar_key,col_int_key) 9109); 9110INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); 9111INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); 9112CREATE TABLE t2 ( 9113col_int_key INT(11) NOT NULL, 9114col_datetime_key DATETIME NOT NULL, 9115col_varchar_key VARCHAR(1) NOT NULL, 9116col_varchar_nokey VARCHAR(1) NOT NULL, 9117KEY col_int_key (col_int_key), 9118KEY col_datetime_key (col_datetime_key), 9119KEY col_varchar_key (col_varchar_key,col_int_key) 9120); 9121INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); 9122SET @old_depth=@@optimizer_search_depth; 9123SET optimizer_search_depth=4; 9124EXPLAIN SELECT col_datetime_key 9125FROM t1 as outr 9126WHERE col_datetime_key IN ( 9127SELECT alias1.col_datetime_key 9128FROM t1 AS alias1 9129LEFT JOIN t1 as alias3 9130STRAIGHT_JOIN ( t2 AS alias4 9131JOIN t1 AS alias5 9132ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) 9133ON alias5.col_int_key < alias4.col_int_key 9134ON alias5.col_varchar_key = alias4.col_varchar_key 9135); 9136id select_type table type possible_keys key key_len ref rows Extra 91371 SIMPLE <subquery2> ALL NULL NULL NULL NULL NULL NULL 91381 SIMPLE outr index col_datetime_key col_datetime_key 5 NULL 2 Using where; Using index; Using join buffer (Block Nested Loop) 91392 MATERIALIZED alias1 index NULL col_datetime_key 5 NULL 2 Using index 91402 MATERIALIZED alias4 ALL col_int_key,col_varchar_key NULL NULL NULL 1 NULL 91412 MATERIALIZED alias5 ref col_int_key,col_varchar_key col_varchar_key 3 test.alias4.col_varchar_key 1 Using where; Using index 91422 MATERIALIZED alias3 index NULL col_int_key 4 NULL 2 Using index 9143SELECT col_datetime_key 9144FROM t1 as outr 9145WHERE col_datetime_key IN ( 9146SELECT alias1.col_datetime_key 9147FROM t1 AS alias1 9148LEFT JOIN t1 as alias3 9149STRAIGHT_JOIN ( t2 AS alias4 9150JOIN t1 AS alias5 9151ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) 9152ON alias5.col_int_key < alias4.col_int_key 9153ON alias5.col_varchar_key = alias4.col_varchar_key 9154); 9155col_datetime_key 91562002-02-13 17:30:06 91572008-09-27 00:34:58 9158DROP TABLE t1,t2; 9159SET @@optimizer_search_depth=@old_depth; 9160# 9161# Bug#13845930: Segfault in st_join_table::and_with_condition 9162# 9163CREATE TABLE t1 ( 9164col_int INTEGER 9165); 9166CREATE TABLE t2 ( 9167col_varchar_1 VARCHAR(1), 9168col_varchar_2 VARCHAR(1) 9169); 9170INSERT INTO t2 VALUES ('x','x'), ('c','c'); 9171PREPARE stmt FROM ' 9172SELECT alias2.col_varchar_2 AS field1 9173FROM t2 AS alias1 9174 JOIN 9175 (t2 AS alias2 9176 LEFT JOIN t2 AS alias3 9177 ON (8, 92) IN 9178 (SELECT sq1_alias1.col_int, 9179 sq1_alias2.col_int 9180 FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 9181 ) 9182 ) 9183 ON alias3.col_varchar_1 = alias2.col_varchar_2 9184'; 9185EXECUTE stmt; 9186field1 9187EXECUTE stmt; 9188field1 9189DEALLOCATE prepare stmt; 9190DROP TABLE t1, t2; 9191# End of test for bug#13845930. 9192# 9193# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' 9194# in ha_innobase::index_read 9195# 9196CREATE TABLE t1 ( 9197pk INTEGER AUTO_INCREMENT, 9198col_int_nokey INT, 9199col_int_key INT, 9200col_varchar_key VARCHAR(1), 9201col_varchar_nokey VARCHAR(1), 9202PRIMARY KEY (pk), 9203KEY (col_varchar_key) 9204) ENGINE=INNODB; 9205INSERT INTO t1 ( 9206col_int_key, col_int_nokey, 9207col_varchar_key, col_varchar_nokey 9208) VALUES 9209(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), 9210(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), 9211(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), 9212(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), 9213(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); 9214CREATE TABLE t2 ( 9215pk INT AUTO_INCREMENT, 9216col_int_nokey INT, 9217col_int_key INT, 9218PRIMARY KEY (pk), 9219KEY (col_int_key) 9220) AUTO_INCREMENT=10 ENGINE=INNODB; 9221INSERT INTO t2 (col_int_key, col_int_nokey) VALUES 9222(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), 9223(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), 9224(NULL, 6), (0, 2), (NULL, 9), (8, 6); 9225CREATE TABLE t3 ( 9226pk INT AUTO_INCREMENT, 9227col_varchar_key VARCHAR(1), 9228PRIMARY KEY (pk), 9229KEY (col_varchar_key) 9230) ENGINE=INNODB; 9231INSERT INTO t3 (col_varchar_key) VALUES 9232('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), 9233('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); 9234CREATE VIEW v1 AS 9235SELECT table2.col_varchar_nokey AS field1 9236FROM t2 AS table1 9237INNER JOIN (t1 AS table2 9238STRAIGHT_JOIN t2 AS table3 9239ON table3.col_int_key = table2.pk AND 9240table3.col_int_nokey = ANY 9241(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 9242FROM t2 AS subquery1_t1 9243RIGHT OUTER JOIN t1 AS subquery1_t2 9244INNER JOIN t1 AS subquery1_t3 9245ON subquery1_t3.col_int_key = subquery1_t2.pk 9246ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey 9247WHERE subquery1_t1.pk > 1 9248) 9249) 9250ON table3.col_int_key IN 9251(SELECT subquery2_t1.col_int_key AS subquery2_field1 9252FROM t2 AS subquery2_t1 9253RIGHT OUTER JOIN t3 AS subquery2_t2 9254LEFT OUTER JOIN t1 AS subquery2_t3 9255ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key 9256ON subquery2_t3.pk = subquery2_t2.pk 9257) 9258; 9259explain SELECT * FROM v1; 9260id select_type table type possible_keys key key_len ref rows Extra 92611 SIMPLE table1 index NULL col_int_key 5 NULL 20 Using index 92621 SIMPLE <subquery3> ALL NULL NULL NULL NULL NULL Using join buffer (Block Nested Loop) 92631 SIMPLE table2 ALL PRIMARY NULL NULL NULL 20 Using where; Using join buffer (Block Nested Loop) 92641 SIMPLE table3 ref col_int_key col_int_key 5 test.table2.pk 1 Using where; Using join buffer (Batched Key Access) 92651 SIMPLE <subquery4> eq_ref <auto_key> <auto_key> 5 test.table2.pk 1 NULL 92663 MATERIALIZED subquery1_t2 ALL PRIMARY NULL NULL NULL 20 Using where 92673 MATERIALIZED subquery1_t3 ref col_varchar_key col_varchar_key 4 test.subquery1_t2.col_varchar_nokey 1 Using where; Using join buffer (Batched Key Access) 92683 MATERIALIZED subquery1_t1 index PRIMARY col_int_key 5 NULL 20 Using where; Using index; Using join buffer (Block Nested Loop) 92694 MATERIALIZED subquery2_t3 index PRIMARY,col_varchar_key col_varchar_key 4 NULL 20 Using where; Using index 92704 MATERIALIZED subquery2_t2 eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 Using where 92714 MATERIALIZED subquery2_t1 index col_int_key col_int_key 5 NULL 20 Using index; Using join buffer (Block Nested Loop) 9272SELECT * FROM v1; 9273field1 9274v 9275v 9276v 9277v 9278v 9279v 9280v 9281v 9282v 9283v 9284v 9285v 9286v 9287v 9288v 9289v 9290v 9291v 9292v 9293v 9294DROP VIEW v1; 9295DROP TABLE t1,t2,t3; 9296# End of test for bug#13855925. 9297# 9298# Bug#13897959: Segfault in setup_semijoin_dups_elimination() 9299# 9300CREATE TABLE t1 ( 9301col_datetime_key DATETIME DEFAULT NULL, 9302KEY col_datetime_key (col_datetime_key) 9303) ENGINE=MyISAM; 9304INSERT INTO t1 VALUES 9305('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), 9306('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), 9307('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); 9308CREATE TABLE t2 ( 9309col_date_nokey date DEFAULT NULL, 9310col_time_key time DEFAULT NULL, 9311col_datetime_key datetime DEFAULT NULL, 9312col_varchar_key varchar(1) DEFAULT NULL, 9313col_varchar_nokey varchar(1) DEFAULT NULL, 9314KEY col_time_key (col_time_key), 9315KEY col_datetime_key (col_datetime_key), 9316KEY col_varchar_key(col_varchar_key) 9317) ENGINE=MyISAM; 9318INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); 9319SELECT grandparent1.col_varchar_nokey 9320FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) 9321WHERE grandparent1.col_varchar_nokey IN ( 9322SELECT col_varchar_nokey 9323FROM t2 AS parent1 9324WHERE parent1.col_time_key > grandparent1.col_date_nokey 9325); 9326col_varchar_nokey 9327DROP TABLE t1, t2; 9328# End of test for bug#13897959. 9329# 9330# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN 9331# BEST_EXTENSION_BY_LIMITED_SEARCH 9332# 9333CREATE TABLE t1 ( 9334pk int(11) NOT NULL, 9335col_int_nokey INT, 9336col_int_key INT, 9337col_varchar_key VARCHAR(1), 9338col_varchar_nokey VARCHAR(1), 9339PRIMARY KEY (pk), 9340KEY col_int_key (col_int_key), 9341KEY col_varchar_key (col_varchar_key,col_int_key) 9342); 9343INSERT INTO t1 VALUES (26,6,NULL,'f','f'); 9344INSERT INTO t1 VALUES (29,6,8,'c','c'); 9345CREATE TABLE t2 ( 9346pk INT NOT NULL, 9347col_int_nokey INT, 9348col_int_key INT, 9349col_varchar_key VARCHAR(1), 9350col_varchar_nokey VARCHAR(1), 9351PRIMARY KEY (pk), 9352KEY col_int_key (col_int_key), 9353KEY col_varchar_key (col_varchar_key,col_int_key) 9354); 9355INSERT INTO t2 VALUES (1,2,4,'v','v'); 9356INSERT INTO t2 VALUES (2,150,62,'v','v'); 9357INSERT INTO t2 VALUES (5,5,0,'x','x'); 9358INSERT INTO t2 VALUES (6,3,7,'i','i'); 9359INSERT INTO t2 VALUES (7,1,7,'e','e'); 9360CREATE VIEW view_c AS SELECT * FROM t2; 9361PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 9362FROM t1 AS alias1 9363RIGHT JOIN t2 AS alias2 9364INNER JOIN t1 AS alias3 9365ON (alias3.col_varchar_key = alias2.col_varchar_key ) 9366ON ( "v" ) IN ( 9367SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 9368FROM t1 AS sq1_alias1 9369) 9370WHERE alias3.pk IN ( 9371SELECT sq2_alias1.col_int_key AS sq2_field1 9372FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) 9373) 9374'; 9375EXECUTE prep_stmt_7430; 9376field1 9377NULL 9378EXECUTE prep_stmt_7430; 9379field1 9380NULL 9381EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 9382FROM t1 AS alias1 9383RIGHT JOIN t2 AS alias2 9384INNER JOIN t1 AS alias3 9385ON (alias3.col_varchar_key = alias2.col_varchar_key ) 9386ON ( "v" ) IN ( 9387SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 9388FROM t1 AS sq1_alias1 9389) 9390WHERE alias3.pk IN ( 9391SELECT sq2_alias1.col_int_key AS sq2_field1 9392FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) 9393) 9394; 9395id select_type table type possible_keys key key_len ref rows Extra 93961 SIMPLE alias3 ALL PRIMARY,col_varchar_key NULL NULL NULL 2 Using where 93971 SIMPLE sq2_alias2 index NULL PRIMARY 4 NULL 2 Using index 93981 SIMPLE t2 ref col_int_key col_int_key 5 test.alias3.pk 2 Using index; FirstMatch(alias3) 93991 SIMPLE alias2 ref col_varchar_key col_varchar_key 4 test.alias3.col_varchar_key 1 Using index 94001 SIMPLE sq1_alias1 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(alias2) 94011 SIMPLE alias1 index NULL col_varchar_key 9 NULL 2 Using index 9402PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 9403FROM t1 AS alias1 9404RIGHT JOIN t2 AS alias2 9405INNER JOIN t1 AS alias3 9406ON (alias3.col_varchar_key = alias2.col_varchar_key ) 9407ON ( "v" ) IN ( 9408SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 9409FROM t1 AS sq1_alias1 9410) 9411WHERE alias3.pk IN ( 9412SELECT sq2_alias1.col_int_key AS sq2_field1 9413FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) 9414WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key 9415AND sq2_alias1.col_varchar_key < "l" 9416 ) 9417'; 9418EXECUTE prep_stmt_7430; 9419field1 9420NULL 9421EXECUTE prep_stmt_7430; 9422field1 9423NULL 9424EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 9425FROM t1 AS alias1 9426RIGHT JOIN t2 AS alias2 9427INNER JOIN t1 AS alias3 9428ON (alias3.col_varchar_key = alias2.col_varchar_key ) 9429ON ( "v" ) IN ( 9430SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 9431FROM t1 AS sq1_alias1 9432) 9433WHERE alias3.pk IN ( 9434SELECT sq2_alias1.col_int_key AS sq2_field1 9435FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) 9436WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key 9437AND sq2_alias1.col_varchar_key < "l" 9438 ) 9439; 9440id select_type table type possible_keys key key_len ref rows Extra 94411 SIMPLE t2 range col_int_key,col_varchar_key col_varchar_key 4 NULL 2 Using index condition; Using MRR; Start temporary 94421 SIMPLE alias3 eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.t2.col_int_key 1 Using where; Using join buffer (Batched Key Access) 94431 SIMPLE alias2 ref col_varchar_key col_varchar_key 4 test.alias3.col_varchar_key 1 Using index 94441 SIMPLE sq2_alias2 index NULL PRIMARY 4 NULL 2 Using index; End temporary; Using join buffer (Block Nested Loop) 94451 SIMPLE sq1_alias1 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(sq2_alias2) 94461 SIMPLE alias1 index NULL col_varchar_key 9 NULL 2 Using index 9447DROP TABLE t1,t2; 9448DROP VIEW view_c; 9449# 9450# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD 9451# ON SECOND EXEC OF PREP STMT 9452# 9453CREATE TABLE t1 ( 9454pk INT, 9455col_int_nokey INT, 9456col_int_key INT, 9457col_varchar_key VARCHAR(1), 9458col_varchar_nokey VARCHAR(1), 9459KEY col_varchar_key (col_varchar_key) 9460); 9461CREATE VIEW view_b AS SELECT * FROM t1; 9462PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 9463FROM t1 AS alias1 9464INNER JOIN t1 AS alias2 9465ON (alias1.col_varchar_key = alias2.col_varchar_nokey 9466AND ( alias1.col_int_key ) IN ( 9467SELECT t1.col_int_nokey 9468FROM t1 9469) 9470) 9471WHERE alias1.col_varchar_key IN ( 9472SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 9473FROM view_b AS sq2_alias1 9474INNER JOIN t1 AS sq2_alias2 9475ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) 9476WHERE sq2_alias1.pk > alias2.pk 9477) 9478'; 9479EXECUTE prep_stmt_20421; 9480field1 9481EXECUTE prep_stmt_20421; 9482field1 9483EXPLAIN SELECT alias2.col_varchar_nokey AS field1 9484FROM t1 AS alias1 9485INNER JOIN t1 AS alias2 9486ON (alias1.col_varchar_key = alias2.col_varchar_nokey 9487AND ( alias1.col_int_key ) IN ( 9488SELECT t1.col_int_nokey 9489FROM t1 9490) 9491) 9492WHERE alias1.col_varchar_key IN ( 9493SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 9494FROM view_b AS sq2_alias1 9495INNER JOIN t1 AS sq2_alias2 9496ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) 9497WHERE sq2_alias1.pk > alias2.pk 9498) 9499; 9500id select_type table type possible_keys key key_len ref rows Extra 95011 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 9502ALTER TABLE t1 DROP INDEX col_varchar_key; 9503PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 9504FROM t1 AS alias1 9505INNER JOIN t1 AS alias2 9506ON (alias1.col_varchar_key = alias2.col_varchar_nokey 9507AND ( alias1.col_int_key ) IN ( 9508SELECT t1.col_int_nokey 9509FROM t1 9510) 9511) 9512WHERE alias1.col_varchar_key IN ( 9513SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 9514FROM view_b AS sq2_alias1 9515INNER JOIN t1 AS sq2_alias2 9516ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) 9517WHERE sq2_alias1.pk > alias2.pk 9518) 9519'; 9520EXECUTE prep_stmt_20421; 9521field1 9522EXECUTE prep_stmt_20421; 9523field1 9524EXPLAIN SELECT alias2.col_varchar_nokey AS field1 9525FROM t1 AS alias1 9526INNER JOIN t1 AS alias2 9527ON (alias1.col_varchar_key = alias2.col_varchar_nokey 9528AND ( alias1.col_int_key ) IN ( 9529SELECT t1.col_int_nokey 9530FROM t1 9531) 9532) 9533WHERE alias1.col_varchar_key IN ( 9534SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 9535FROM view_b AS sq2_alias1 9536INNER JOIN t1 AS sq2_alias2 9537ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) 9538WHERE sq2_alias1.pk > alias2.pk 9539) 9540; 9541id select_type table type possible_keys key key_len ref rows Extra 95421 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 9543DROP TABLE t1; 9544DROP VIEW view_b; 9545# 9546# Bug#13907277: Segfault in evaluate_null_complemented_join_record 9547# 9548CREATE TABLE t1 ( 9549pk INTEGER, 9550col_varchar_nokey VARCHAR(1), 9551col_varchar_key VARCHAR(1), 9552PRIMARY KEY (pk) 9553); 9554INSERT INTO t1 VALUES (1, 'x', 'x'); 9555CREATE TABLE t2 ( 9556pk INTEGER, 9557PRIMARY KEY (pk) 9558); 9559INSERT INTO t2 VALUES (1); 9560CREATE TABLE t3 ( 9561pk INTEGER, 9562col_int_nokey INTEGER, 9563col_int_key INTEGER, 9564col_varchar_nokey VARCHAR(1), 9565PRIMARY KEY (pk) 9566); 9567INSERT INTO t3 VALUES (1, 6, 5, 'r'); 9568explain SELECT outer_t1.pk, outer_t2.pk 9569FROM t3 AS outer_t1 9570RIGHT JOIN t2 AS outer_t2 9571ON outer_t1.col_int_nokey IN 9572(SELECT inner_t1.col_int_nokey 9573FROM t3 AS inner_t1 9574LEFT JOIN t1 AS inner_t2 9575INNER JOIN t1 AS inner_t3 9576ON inner_t3.pk = inner_t2.pk 9577ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key 9578); 9579id select_type table type possible_keys key key_len ref rows Extra 95801 SIMPLE outer_t2 system NULL NULL NULL NULL 1 NULL 95811 SIMPLE outer_t1 ALL NULL NULL NULL NULL 1 Using where 95821 SIMPLE inner_t1 ALL NULL NULL NULL NULL 1 Using where 95831 SIMPLE inner_t2 ALL PRIMARY NULL NULL NULL 1 NULL 95841 SIMPLE inner_t3 eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 Using where; FirstMatch(outer_t1) 9585SELECT outer_t1.pk, outer_t2.pk 9586FROM t3 AS outer_t1 9587RIGHT JOIN t2 AS outer_t2 9588ON outer_t1.col_int_nokey IN 9589(SELECT inner_t1.col_int_nokey 9590FROM t3 AS inner_t1 9591LEFT JOIN t1 AS inner_t2 9592INNER JOIN t1 AS inner_t3 9593ON inner_t3.pk = inner_t2.pk 9594ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key 9595); 9596pk pk 95971 1 9598DROP TABLE t1, t2, t3; 9599# End of test for bug#13907277. 9600# 9601# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution 9602# 9603CREATE TABLE t1 ( 9604pk INTEGER, 9605col_varchar_key VARCHAR(1), 9606col_varchar_nokey VARCHAR(1) 9607); 9608PREPARE stmt FROM " 9609SELECT MIN(alias2.col_varchar_key) AS field1 9610FROM t1 AS alias1 9611 INNER JOIN (t1 AS alias2 9612 INNER JOIN t1 AS alias3 9613 ON 8 IN 9614 (SELECT sq1_alias1.pk AS sq1_field2 9615 FROM t1 AS sq1_alias1 9616 WHERE 9 IN 9617 (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 9618 FROM t1 AS t1_sq1_alias1 9619 ) 9620 ) 9621 ) 9622 ON alias3.col_varchar_nokey = alias2.col_varchar_key 9623WHERE EXISTS 9624 (SELECT sq2_alias1.pk AS sq2_field1 9625 FROM t1 AS sq2_alias1 9626 WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey 9627 ) 9628"; 9629EXECUTE stmt; 9630field1 9631NULL 9632EXECUTE stmt; 9633field1 9634NULL 9635DEALLOCATE PREPARE stmt; 9636DROP TABLE t1; 9637# End of test for bug#13955713. 9638# 9639# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() 9640# 9641CREATE TABLE t1 ( 9642pk INT, 9643col_varchar_key VARCHAR(1), 9644col_varchar_nokey VARCHAR(1) 9645); 9646CREATE TABLE t2 ( 9647pk INT, 9648col_varchar_key VARCHAR(1), 9649col_varchar_nokey VARCHAR(1) 9650); 9651INSERT INTO t2 VALUES 9652(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), 9653(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), 9654(18,'v','v'), (19,NULL,NULL), (20,'r','r'); 9655CREATE TABLE t3 ( 9656pk INT, 9657col_int_key INT, 9658col_varchar_key VARCHAR(1), 9659KEY col_int_key (col_int_key) 9660); 9661INSERT INTO t3 VALUES 9662(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), 9663(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), 9664(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), 9665(27,0,'p'), (28,NULL,'j'), (29,8,'c'); 9666CREATE VIEW view_inline_0 AS 9667SELECT t1.* 9668FROM t1 INNER JOIN t3 9669ON t1.pk = t3.pk; 9670CREATE VIEW view_inline_1 AS 9671SELECT sq2_alias2.col_varchar_key AS sq2_field1, 9672sq2_alias1.col_varchar_key AS sq2_field2 9673FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 9674ON sq2_alias1.pk = sq2_alias2.col_int_key; 9675CREATE VIEW view_inline_2 AS 9676SELECT 'p', 'p' UNION SELECT 'k', 's'; 9677explain SELECT SUM(alias1.col_varchar_nokey) AS field2 9678FROM t2 AS alias2 9679LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 9680ON alias2.col_varchar_key = alias1.col_varchar_key AND 9681(alias2.col_varchar_nokey, alias2.col_varchar_key) IN 9682(SELECT * FROM view_inline_1 9683) 9684WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN 9685(SELECT * FROM view_inline_2 9686); 9687id select_type table type possible_keys key key_len ref rows Extra 96881 PRIMARY <subquery4> ALL NULL NULL NULL NULL NULL Using where 96891 PRIMARY <derived2> ref <auto_key0> <auto_key0> 8 <subquery4>.p,<subquery4>.My_exp_p 2 NULL 96901 PRIMARY alias2 ALL NULL NULL NULL NULL 11 Using where; Using join buffer (Block Nested Loop) 96911 PRIMARY <subquery3> eq_ref <auto_key> <auto_key> 8 test.alias2.col_varchar_nokey,<subquery4>.p 1 NULL 96924 MATERIALIZED <derived7> ALL NULL NULL NULL NULL 2 NULL 96933 MATERIALIZED sq2_alias1 ALL NULL NULL NULL NULL 15 NULL 96943 MATERIALIZED sq2_alias2 ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 Using join buffer (Batched Key Access) 96957 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used 96968 UNION NULL NULL NULL NULL NULL NULL NULL No tables used 9697NULL UNION RESULT <union7,8> ALL NULL NULL NULL NULL NULL Using temporary 96982 DERIVED NULL NULL NULL NULL NULL NULL NULL no matching row in const table 9699SELECT SUM(alias1.col_varchar_nokey) AS field2 9700FROM t2 AS alias2 9701LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 9702ON alias2.col_varchar_key = alias1.col_varchar_key AND 9703(alias2.col_varchar_nokey, alias2.col_varchar_key) IN 9704(SELECT * FROM view_inline_1 9705) 9706WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN 9707(SELECT * FROM view_inline_2 9708); 9709field2 9710NULL 9711DROP VIEW view_inline_0, view_inline_1, view_inline_2; 9712DROP TABLE t1, t2, t3; 9713# End of test for bug#13956813. 9714# 9715# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... 9716# 9717CREATE TABLE t1 ( 9718pk INTEGER AUTO_INCREMENT, 9719col_int_nokey INTEGER, 9720col_int_key INTEGER, 9721col_varchar_key VARCHAR(1), 9722col_varchar_nokey VARCHAR(1), 9723PRIMARY KEY (pk), 9724KEY (col_int_key), 9725KEY (col_varchar_key, col_int_key) 9726); 9727INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) 9728VALUES 9729(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), 9730(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), 9731(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), 9732(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), 9733(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); 9734CREATE TABLE t2 ( 9735pk INTEGER AUTO_INCREMENT, 9736col_int_nokey INTEGER NOT NULL, 9737col_time_key TIME NOT NULL, 9738col_time_nokey TIME NOT NULL, 9739PRIMARY KEY (pk), 9740KEY (col_time_key) 9741) ENGINE=InnoDB; 9742INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES 9743(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), 9744(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), 9745(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), 9746(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), 9747(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), 9748(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), 9749(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), 9750(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), 9751(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), 9752(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); 9753explain SELECT ot1.col_int_key AS x 9754FROM t1 AS ot2 9755LEFT JOIN t1 AS ot1 9756ON ot2.col_varchar_nokey > ot1.col_varchar_key 9757WHERE (ot1.col_int_nokey, ot1.pk) IN 9758(SELECT it1.pk AS x, 9759it1.col_int_nokey AS y 9760FROM t2 AS it2 9761LEFT JOIN t2 AS it1 9762ON it2.col_time_nokey = it1.col_time_key 9763) AND ot1.pk IS NULL 9764; 9765id select_type table type possible_keys key key_len ref rows Extra 97661 SIMPLE ot1 const PRIMARY,col_varchar_key PRIMARY 4 const 1 Using where 97671 SIMPLE it1 eq_ref PRIMARY,col_time_key PRIMARY 4 test.ot1.col_int_nokey 1 Using where 97681 SIMPLE it2 ALL NULL NULL NULL NULL 20 Using where; FirstMatch(it1); Using join buffer (Block Nested Loop) 97691 SIMPLE ot2 ALL NULL NULL NULL NULL 20 Using where; Using join buffer (Block Nested Loop) 9770SELECT ot1.col_int_key AS x 9771FROM t1 AS ot2 9772LEFT JOIN t1 AS ot1 9773ON ot2.col_varchar_nokey > ot1.col_varchar_key 9774WHERE (ot1.col_int_nokey, ot1.pk) IN 9775(SELECT it1.pk AS x, 9776it1.col_int_nokey AS y 9777FROM t2 AS it2 9778LEFT JOIN t2 AS it1 9779ON it2.col_time_nokey = it1.col_time_key 9780) AND ot1.pk IS NULL 9781; 9782x 9783DROP TABLE t1, t2; 9784# End of test for bug#13974177. 9785# 9786# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... 9787# 9788CREATE TABLE t1 ( 9789pk INT, 9790col_int_key INT, 9791col_varchar_key VARCHAR(1), 9792PRIMARY KEY (pk), 9793KEY col_varchar_key (col_varchar_key,col_int_key) 9794); 9795CREATE TABLE t2 ( 9796pk INT, 9797col_int_key INT, 9798col_varchar_key VARCHAR(1), 9799col_varchar_nokey VARCHAR(1), 9800PRIMARY KEY (pk) 9801) ENGINE=InnoDB; 9802CREATE TABLE t3 ( 9803i INT 9804); 9805explain SELECT table1.pk AS field1 9806FROM ( SELECT subquery1_t1. * 9807FROM t2 AS subquery1_t1 9808JOIN t2 AS subquery1_t2 9809ON subquery1_t2.pk = subquery1_t1.pk) AS table1 9810STRAIGHT_JOIN t2 AS table2 9811ON table1.col_int_key IN (SELECT 7 FROM t3) 9812WHERE table1.col_varchar_nokey IN 9813(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 9814FROM t1 AS subquery3_t1 9815) 9816; 9817id select_type table type possible_keys key key_len ref rows Extra 98181 PRIMARY subquery3_t1 index col_varchar_key col_varchar_key 9 NULL 0 Using where; Using index; LooseScan 98191 PRIMARY <derived2> ref <auto_key0> <auto_key0> 9 const,test.subquery3_t1.col_varchar_key 2 NULL 98201 PRIMARY t3 ALL NULL NULL NULL NULL 0 FirstMatch(<derived2>); Using join buffer (Block Nested Loop) 98211 PRIMARY table2 index NULL PRIMARY 4 NULL 1 Using index; Using join buffer (Block Nested Loop) 98222 DERIVED subquery1_t1 ALL PRIMARY NULL NULL NULL 1 NULL 98232 DERIVED subquery1_t2 eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 Using index 9824SELECT table1.pk AS field1 9825FROM ( SELECT subquery1_t1. * 9826FROM t2 AS subquery1_t1 9827JOIN t2 AS subquery1_t2 9828ON subquery1_t2.pk = subquery1_t1.pk) AS table1 9829STRAIGHT_JOIN t2 AS table2 9830ON table1.col_int_key IN (SELECT 7 FROM t3) 9831WHERE table1.col_varchar_nokey IN 9832(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 9833FROM t1 AS subquery3_t1 9834) 9835; 9836field1 9837DROP TABLE t1, t2, t3; 9838# End of test for bug#13971022. 9839# 9840# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH 9841# TIME/DATETIME COMPARE" - Subquery part of test. 9842# 9843SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); 9844CREATE TABLE t1 ( 9845pk INT NOT NULL, 9846col_int_nokey INT, 9847col_int_key INT NOT NULL, 9848PRIMARY KEY (pk), 9849KEY col_int_key (col_int_key) 9850) ENGINE=InnoDB; 9851INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), 9852(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), 9853(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), 9854(27,3,5), (28,6,0), (29,6,3); 9855CREATE TABLE t2 ( 9856col_int_nokey INT NOT NULL, 9857col_datetime_key DATETIME NOT NULL, 9858col_varchar_key VARCHAR(1) NOT NULL, 9859KEY col_datetime_key (col_datetime_key), 9860KEY col_varchar_key (col_varchar_key) 9861) ENGINE=InnoDB; 9862INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); 9863CREATE TABLE t3 ( 9864col_time_key TIME, 9865KEY col_time_key (col_time_key) 9866) ENGINE=InnoDB; 9867INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), 9868('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), 9869('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), 9870('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), 9871('02:59:24'), ('00:01:58'); 9872EXPLAIN EXTENDED SELECT outr.col_int_nokey 9873FROM t2 as outr 9874STRAIGHT_JOIN t3 AS outr2 9875ON outr2.col_time_key > outr.col_datetime_key 9876WHERE outr.col_int_nokey IN ( 9877SELECT col_int_key 9878FROM t1 AS innr 9879WHERE innr.pk >= innr.col_int_nokey 9880) AND ( 9881outr.col_int_nokey <= 6 9882OR 9883outr.col_varchar_key IS NULL 9884); 9885id select_type table type possible_keys key key_len ref rows filtered Extra 98861 SIMPLE outr ALL col_datetime_key NULL NULL NULL 1 100.00 Using where 98871 SIMPLE innr ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 100.00 Using where; FirstMatch(outr); Using join buffer (Batched Key Access) 98881 SIMPLE outr2 ALL col_time_key NULL NULL NULL 20 100.00 Range checked for each record (index map: 0x1) 9889Warnings: 9890Note 1003 /* select#1 */ select `test`.`outr`.`col_int_nokey` AS `col_int_nokey` from `test`.`t2` `outr` semi join (`test`.`t1` `innr`) straight_join `test`.`t3` `outr2` where ((`test`.`innr`.`col_int_key` = `test`.`outr`.`col_int_nokey`) and (`test`.`outr`.`col_int_nokey` <= 6) and (`test`.`innr`.`pk` >= `test`.`innr`.`col_int_nokey`) and (`test`.`outr2`.`col_time_key` > `test`.`outr`.`col_datetime_key`)) 9891SELECT outr.col_int_nokey 9892FROM t2 as outr 9893STRAIGHT_JOIN t3 AS outr2 9894ON outr2.col_time_key > outr.col_datetime_key 9895WHERE outr.col_int_nokey IN ( 9896SELECT col_int_key 9897FROM t1 AS innr 9898WHERE innr.pk >= innr.col_int_nokey 9899) AND ( 9900outr.col_int_nokey <= 6 9901OR 9902outr.col_varchar_key IS NULL 9903); 9904col_int_nokey 99051 99061 99071 99081 99091 99101 99111 99121 99131 99141 99151 99161 99171 99181 99191 99201 99211 99221 99231 99241 9925DROP TABLE t1,t2,t3; 9926SET TIMESTAMP = DEFAULT; 9927# End of test for bug#13623473. 9928# 9929# Bug#13980954: Missing data on left join + null value + where..in 9930# 9931CREATE TABLE t1 ( 9932ik INT, 9933vc varchar(1) 9934); 9935INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); 9936CREATE TABLE t2 ( 9937ik INT, 9938vc varchar(1) 9939); 9940INSERT INTO t2 VALUES 9941(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); 9942explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik 9943FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc 9944WHERE t2.vc IN (SELECT vc FROM t2 AS t3); 9945EXPLAIN 9946{ 9947 "query_block": { 9948 "select_id": 1, 9949 "nested_loop": [ 9950 { 9951 "table": { 9952 "table_name": "t2", 9953 "access_type": "ALL", 9954 "rows": 6, 9955 "filtered": 100, 9956 "attached_condition": "(`test`.`t2`.`vc` is not null)" 9957 } 9958 }, 9959 { 9960 "table": { 9961 "table_name": "<subquery2>", 9962 "access_type": "eq_ref", 9963 "key": "<auto_key>", 9964 "key_length": "4", 9965 "ref": [ 9966 "test.t2.vc" 9967 ], 9968 "rows": 1, 9969 "materialized_from_subquery": { 9970 "using_temporary_table": true, 9971 "query_block": { 9972 "table": { 9973 "table_name": "t3", 9974 "access_type": "ALL", 9975 "rows": 6, 9976 "filtered": 100 9977 } 9978 } 9979 } 9980 } 9981 }, 9982 { 9983 "table": { 9984 "table_name": "t1", 9985 "access_type": "ALL", 9986 "rows": 2, 9987 "filtered": 100, 9988 "using_join_buffer": "Block Nested Loop", 9989 "attached_condition": "<if>(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" 9990 } 9991 } 9992 ] 9993 } 9994} 9995Warnings: 9996Note 1003 /* select#1 */ select `test`.`t2`.`vc` AS `vc`,`test`.`t2`.`ik` AS `t2_ik`,`test`.`t1`.`ik` AS `t1_ik` from `test`.`t2` semi join (`test`.`t2` `t3`) left join `test`.`t1` on((`test`.`t1`.`vc` = `test`.`t2`.`vc`)) where (`<subquery2>`.`vc` = `test`.`t2`.`vc`) 9997SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik 9998FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc 9999WHERE t2.vc IN (SELECT vc FROM t2 AS t3); 10000vc t2_ik t1_ik 10001x 0 8 10002x 0 NULL 10003i 7 NULL 10004e 7 NULL 10005p 1 NULL 10006s 7 NULL 10007j 1 NULL 10008DROP TABLE t1, t2; 10009# End of test for bug#13980954. 10010# 10011# Bug#14048292: Segfault in Item_field::result_type on 2nd execution 10012# of prep stmt with join of view 10013# 10014CREATE TABLE t1 ( 10015col_int INT 10016); 10017INSERT INTO t1 VALUES (0), (1); 10018CREATE VIEW view_t1 AS SELECT * FROM t1; 10019explain SELECT alias1.col_int 10020FROM t1 AS alias1 10021LEFT JOIN view_t1 AS alias2 10022ON alias1.col_int IN 10023(SELECT sq1_alias1.col_int 10024FROM t1 AS sq1_alias1 10025); 10026id select_type table type possible_keys key key_len ref rows Extra 100271 SIMPLE alias1 ALL NULL NULL NULL NULL 2 NULL 100281 SIMPLE sq1_alias1 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(alias1) 100291 SIMPLE t1 ALL NULL NULL NULL NULL 2 NULL 10030PREPARE stmt FROM "SELECT alias1.col_int 10031FROM t1 AS alias1 10032LEFT JOIN view_t1 AS alias2 10033ON alias1.col_int IN 10034(SELECT sq1_alias1.col_int 10035FROM t1 AS sq1_alias1 10036)"; 10037EXECUTE stmt; 10038col_int 100390 100400 100411 100421 10043EXECUTE stmt; 10044col_int 100450 100460 100471 100481 10049DEALLOCATE PREPARE stmt; 10050DROP VIEW view_t1; 10051DROP TABLE t1; 10052# End of test for bug#14048292. 10053# 10054# Bug#14064201: Missing data on join of derived table + WHERE .. IN 10055# with two operands 10056# 10057CREATE TABLE t1 ( 10058col_varchar_nokey VARCHAR(1) 10059); 10060INSERT INTO t1 VALUES 10061('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), 10062('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); 10063CREATE TABLE t2 ( 10064col_varchar_key VARCHAR(1), 10065col_varchar_nokey VARCHAR(1), 10066KEY col_varchar_key(col_varchar_key) 10067); 10068INSERT INTO t2 VALUES 10069('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); 10070explain format=json SELECT * 10071FROM (SELECT * FROM t2) AS derived1 10072LEFT JOIN t1 10073USING (col_varchar_nokey) 10074WHERE (col_varchar_nokey, col_varchar_nokey) IN 10075(SELECT col_varchar_nokey, col_varchar_key 10076FROM t2 AS derived2 10077); 10078EXPLAIN 10079{ 10080 "query_block": { 10081 "select_id": 1, 10082 "nested_loop": [ 10083 { 10084 "table": { 10085 "table_name": "<subquery3>", 10086 "access_type": "ALL", 10087 "attached_condition": "((`<subquery3>`.`col_varchar_key` = `<subquery3>`.`col_varchar_nokey`) and (`<subquery3>`.`col_varchar_nokey` is not null))", 10088 "materialized_from_subquery": { 10089 "using_temporary_table": true, 10090 "query_block": { 10091 "table": { 10092 "table_name": "derived2", 10093 "access_type": "ALL", 10094 "possible_keys": [ 10095 "col_varchar_key" 10096 ], 10097 "rows": 7, 10098 "filtered": 100, 10099 "attached_condition": "(`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)" 10100 } 10101 } 10102 } 10103 } 10104 }, 10105 { 10106 "table": { 10107 "table_name": "derived1", 10108 "access_type": "ref", 10109 "possible_keys": [ 10110 "<auto_key0>" 10111 ], 10112 "key": "<auto_key0>", 10113 "used_key_parts": [ 10114 "col_varchar_nokey" 10115 ], 10116 "key_length": "4", 10117 "ref": [ 10118 "<subquery3>.col_varchar_nokey" 10119 ], 10120 "rows": 2, 10121 "filtered": 100, 10122 "materialized_from_subquery": { 10123 "using_temporary_table": true, 10124 "dependent": false, 10125 "cacheable": true, 10126 "query_block": { 10127 "select_id": 2, 10128 "table": { 10129 "table_name": "t2", 10130 "access_type": "ALL", 10131 "rows": 7, 10132 "filtered": 100 10133 } 10134 } 10135 } 10136 } 10137 }, 10138 { 10139 "table": { 10140 "table_name": "t1", 10141 "access_type": "ALL", 10142 "rows": 20, 10143 "filtered": 100, 10144 "using_join_buffer": "Block Nested Loop", 10145 "attached_condition": "<if>(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`), true)" 10146 } 10147 } 10148 ] 10149 } 10150} 10151Warnings: 10152Note 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` semi join (`test`.`t2` `derived2`) left join `test`.`t1` on(((`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_nokey` = `test`.`derived2`.`col_varchar_key`))) where ((`<subquery3>`.`col_varchar_key` = `<subquery3>`.`col_varchar_nokey`) and (`derived1`.`col_varchar_nokey` = `<subquery3>`.`col_varchar_nokey`) and (`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)) 10153SELECT * 10154FROM (SELECT * FROM t2) AS derived1 10155LEFT JOIN t1 10156USING (col_varchar_nokey) 10157WHERE (col_varchar_nokey, col_varchar_nokey) IN 10158(SELECT col_varchar_nokey, col_varchar_key 10159FROM t2 AS derived2 10160); 10161col_varchar_nokey col_varchar_key 10162v v 10163y y 10164c c 10165v v 10166y y 10167y y 10168j j 10169m m 10170d d 10171d d 10172DROP TABLE t1, t2; 10173CREATE TABLE t1 ( 10174col_int_nokey int NOT NULL, 10175col_int_key int NOT NULL, 10176KEY col_int_key (col_int_key) 10177); 10178INSERT INTO t1 VALUES 10179(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), 10180(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); 10181CREATE TABLE t2 ( 10182col_int_nokey int NOT NULL, 10183col_int_key int NOT NULL, 10184KEY col_int_key (col_int_key) 10185); 10186INSERT INTO t2 VALUES 10187(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), 10188(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); 10189explain format=json SELECT grandparent1.* 10190FROM t1 AS grandparent1 10191LEFT JOIN t1 USING (col_int_nokey) 10192WHERE (col_int_nokey, col_int_nokey) IN 10193(SELECT col_int_nokey, col_int_key 10194FROM t2 10195); 10196EXPLAIN 10197{ 10198 "query_block": { 10199 "select_id": 1, 10200 "nested_loop": [ 10201 { 10202 "table": { 10203 "table_name": "grandparent1", 10204 "access_type": "ALL", 10205 "rows": 20, 10206 "filtered": 100, 10207 "attached_condition": "((`test`.`grandparent1`.`col_int_nokey` is not null) and (`test`.`grandparent1`.`col_int_nokey` is not null))" 10208 } 10209 }, 10210 { 10211 "table": { 10212 "table_name": "<subquery2>", 10213 "access_type": "eq_ref", 10214 "key": "<auto_key>", 10215 "key_length": "8", 10216 "ref": [ 10217 "test.grandparent1.col_int_nokey", 10218 "test.grandparent1.col_int_nokey" 10219 ], 10220 "rows": 1, 10221 "materialized_from_subquery": { 10222 "using_temporary_table": true, 10223 "query_block": { 10224 "table": { 10225 "table_name": "t2", 10226 "access_type": "ALL", 10227 "possible_keys": [ 10228 "col_int_key" 10229 ], 10230 "rows": 20, 10231 "filtered": 100, 10232 "attached_condition": "(`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)" 10233 } 10234 } 10235 } 10236 } 10237 }, 10238 { 10239 "table": { 10240 "table_name": "t1", 10241 "access_type": "ALL", 10242 "rows": 20, 10243 "filtered": 100, 10244 "using_join_buffer": "Block Nested Loop", 10245 "attached_condition": "<if>(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" 10246 } 10247 } 10248 ] 10249 } 10250} 10251Warnings: 10252Note 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` semi join (`test`.`t2`) left join `test`.`t1` on(((`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_nokey` = `test`.`t2`.`col_int_key`))) where ((`<subquery2>`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`) and (`<subquery2>`.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)) 10253SELECT grandparent1.* 10254FROM t1 AS grandparent1 10255LEFT JOIN t1 USING (col_int_nokey) 10256WHERE (col_int_nokey, col_int_nokey) IN 10257(SELECT col_int_nokey, col_int_key 10258FROM t2 10259); 10260col_int_nokey col_int_key 102611 7 102621 6 102637 0 102647 3 102657 0 102667 3 102671 7 102681 6 102698 5 102708 1 102718 5 102728 1 10273DROP TABLE t1, t2; 10274CREATE TABLE t1 ( 10275pk int, 10276col_int_key int, 10277col_datetime_key datetime, 10278col_varchar_key varchar(1), 10279col_varchar_nokey varchar(1), 10280PRIMARY KEY (pk), 10281KEY col_int_key (col_int_key), 10282KEY col_datetime_key (col_datetime_key), 10283KEY col_varchar_key (col_varchar_key,col_int_key) 10284) engine=MyISAM; 10285INSERT INTO t1 VALUES 10286(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), 10287(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), 10288(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), 10289(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), 10290(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), 10291(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), 10292(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), 10293(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), 10294(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), 10295(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); 10296CREATE TABLE t2 ( 10297pk int, 10298col_int_key int, 10299col_datetime_key datetime, 10300col_varchar_key varchar(1), 10301col_varchar_nokey varchar(1), 10302PRIMARY KEY (pk), 10303KEY col_int_key (col_int_key), 10304KEY col_datetime_key (col_datetime_key), 10305KEY col_varchar_key (col_varchar_key,col_int_key) 10306) engine=MyISAM; 10307INSERT INTO t2 VALUES 10308(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), 10309(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), 10310(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), 10311(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), 10312(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), 10313(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), 10314(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), 10315(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), 10316(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), 10317(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); 10318SELECT alias1.col_datetime_key 10319FROM t2 AS alias1 10320RIGHT JOIN t2 AS alias2 10321JOIN t2 AS alias3 10322ON alias3.pk = alias2.pk 10323ON alias3.col_varchar_nokey = alias2.col_varchar_key OR 10324alias2.col_varchar_nokey 10325WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN 10326(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey 10327FROM t1 AS sq2_alias1, t1 AS sq2_alias2 10328WHERE sq2_alias2.col_int_key < 2); 10329col_datetime_key 103301900-01-01 00:00:00 103311900-01-01 00:00:00 103321900-01-01 00:00:00 103331900-01-01 00:00:00 103341900-01-01 00:00:00 103351900-01-01 00:00:00 103361900-01-01 00:00:00 103371900-01-01 00:00:00 103381900-01-01 00:00:00 103391900-01-01 00:00:00 103402001-01-20 12:47:23 103412001-01-20 12:47:23 103422001-02-15 03:08:38 103432001-02-15 03:08:38 103442002-01-16 00:00:00 103452002-01-16 00:00:00 103462002-02-13 17:30:06 103472002-02-13 17:30:06 103482002-08-20 22:48:00 103492002-08-20 22:48:00 103502002-08-25 20:35:06 103512002-08-25 20:35:06 103522002-12-08 11:34:58 103532002-12-08 11:34:58 103542004-10-02 20:31:15 103552004-10-02 20:31:15 103562005-08-15 00:00:00 103572005-08-15 00:00:00 103582006-10-12 04:32:53 103592006-10-12 04:32:53 103602007-05-28 00:00:00 103612007-05-28 00:00:00 103622008-05-16 08:09:06 103632008-05-16 08:09:06 103642008-07-02 00:00:00 103652008-07-02 00:00:00 103662008-09-27 00:34:58 103672008-09-27 00:34:58 103682009-07-25 09:21:20 103692009-07-25 09:21:20 10370ALTER TABLE t1 DISABLE KEYS; 10371ALTER TABLE t2 DISABLE KEYS; 10372explain format=json SELECT alias1.col_datetime_key 10373FROM t2 AS alias1 10374RIGHT JOIN t2 AS alias2 10375JOIN t2 AS alias3 10376ON alias3.pk = alias2.pk 10377ON alias3.col_varchar_nokey = alias2.col_varchar_key OR 10378alias2.col_varchar_nokey 10379WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN 10380(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey 10381FROM t1 AS sq2_alias1, t1 AS sq2_alias2 10382WHERE sq2_alias2.col_int_key < 2); 10383EXPLAIN 10384{ 10385 "query_block": { 10386 "select_id": 1, 10387 "nested_loop": [ 10388 { 10389 "table": { 10390 "table_name": "<subquery2>", 10391 "access_type": "ALL", 10392 "attached_condition": "(`<subquery2>`.`col_varchar_nokey` = `<subquery2>`.`col_varchar_key`)", 10393 "materialized_from_subquery": { 10394 "using_temporary_table": true, 10395 "query_block": { 10396 "nested_loop": [ 10397 { 10398 "table": { 10399 "table_name": "sq2_alias1", 10400 "access_type": "ALL", 10401 "rows": 20, 10402 "filtered": 100 10403 } 10404 }, 10405 { 10406 "table": { 10407 "table_name": "sq2_alias2", 10408 "access_type": "ALL", 10409 "rows": 20, 10410 "filtered": 100, 10411 "using_join_buffer": "Block Nested Loop", 10412 "attached_condition": "((`test`.`sq2_alias2`.`col_varchar_key` = `test`.`sq2_alias1`.`col_varchar_nokey`) and (`test`.`sq2_alias2`.`col_int_key` < 2))" 10413 } 10414 } 10415 ] 10416 } 10417 } 10418 } 10419 }, 10420 { 10421 "table": { 10422 "table_name": "alias2", 10423 "access_type": "ALL", 10424 "possible_keys": [ 10425 "PRIMARY" 10426 ], 10427 "rows": 20, 10428 "filtered": 100, 10429 "using_join_buffer": "Block Nested Loop", 10430 "attached_condition": "(`test`.`alias2`.`col_varchar_key` = `<subquery2>`.`col_varchar_key`)" 10431 } 10432 }, 10433 { 10434 "table": { 10435 "table_name": "alias3", 10436 "access_type": "eq_ref", 10437 "possible_keys": [ 10438 "PRIMARY" 10439 ], 10440 "key": "PRIMARY", 10441 "used_key_parts": [ 10442 "pk" 10443 ], 10444 "key_length": "4", 10445 "ref": [ 10446 "test.alias2.pk" 10447 ], 10448 "rows": 1, 10449 "filtered": 100, 10450 "using_join_buffer": "Batched Key Access" 10451 } 10452 }, 10453 { 10454 "table": { 10455 "table_name": "alias1", 10456 "access_type": "ALL", 10457 "rows": 20, 10458 "filtered": 100, 10459 "using_join_buffer": "Block Nested Loop", 10460 "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)" 10461 } 10462 } 10463 ] 10464 } 10465} 10466Warnings: 10467Note 1003 /* select#1 */ select `test`.`alias1`.`col_datetime_key` AS `col_datetime_key` from `test`.`t2` `alias2` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) join `test`.`t2` `alias3` left join `test`.`t2` `alias1` on((((`test`.`alias3`.`col_varchar_nokey` = `test`.`alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_varchar_key` = `test`.`sq2_alias1`.`col_varchar_nokey`)) or `test`.`alias2`.`col_varchar_nokey`)) where ((`test`.`alias3`.`pk` = `test`.`alias2`.`pk`) and (`<subquery2>`.`col_varchar_nokey` = `<subquery2>`.`col_varchar_key`) and (`test`.`alias2`.`col_varchar_key` = `<subquery2>`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_varchar_key` = `test`.`sq2_alias1`.`col_varchar_nokey`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) 10468SELECT alias1.col_datetime_key 10469FROM t2 AS alias1 10470RIGHT JOIN t2 AS alias2 10471JOIN t2 AS alias3 10472ON alias3.pk = alias2.pk 10473ON alias3.col_varchar_nokey = alias2.col_varchar_key OR 10474alias2.col_varchar_nokey 10475WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN 10476(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey 10477FROM t1 AS sq2_alias1, t1 AS sq2_alias2 10478WHERE sq2_alias2.col_int_key < 2); 10479col_datetime_key 104802002-02-13 17:30:06 104812002-02-13 17:30:06 104822008-09-27 00:34:58 104832008-09-27 00:34:58 104842007-05-28 00:00:00 104852007-05-28 00:00:00 104862009-07-25 09:21:20 104872009-07-25 09:21:20 104882002-01-16 00:00:00 104892002-01-16 00:00:00 104902006-10-12 04:32:53 104912006-10-12 04:32:53 104922001-02-15 03:08:38 104932001-02-15 03:08:38 104942004-10-02 20:31:15 104952004-10-02 20:31:15 104962002-08-20 22:48:00 104972002-08-20 22:48:00 104981900-01-01 00:00:00 104991900-01-01 00:00:00 105002005-08-15 00:00:00 105012005-08-15 00:00:00 105021900-01-01 00:00:00 105031900-01-01 00:00:00 105042008-05-16 08:09:06 105052008-05-16 08:09:06 105062001-01-20 12:47:23 105072001-01-20 12:47:23 105082008-07-02 00:00:00 105092008-07-02 00:00:00 105101900-01-01 00:00:00 105111900-01-01 00:00:00 105122002-12-08 11:34:58 105132002-12-08 11:34:58 105141900-01-01 00:00:00 105151900-01-01 00:00:00 105161900-01-01 00:00:00 105171900-01-01 00:00:00 105182002-08-25 20:35:06 105192002-08-25 20:35:06 10520DROP TABLE t1, t2; 10521# End of test for bug#14064201. 10522# 10523# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 10524# && IDX < PARENT_JOIN->TABLES 10525# 10526CREATE TABLE b (d INT); 10527CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); 10528SELECT(SELECT 1 10529FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) 10530FROM b) IN (SELECT d FROM c)) as cc FROM b; 10531cc 10532INSERT INTO b VALUE(1); 10533INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); 10534SELECT(SELECT d FROM b WHERE(SELECT d IN 10535(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN 10536(SELECT d FROM c)) as cc FROM c; 10537cc 105381 105391 105401 10541DROP TABLE b,c; 10542# 10543# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN 10544# 10545CREATE TABLE b ( 10546d INT(11) 10547); 10548CREATE TABLE c ( 10549d BLOB 10550) ; 10551CREATE TABLE d ( 10552b INT(11) 10553); 10554INSERT INTO b VALUES(1),(2),(4); 10555INSERT INTO c VALUES(1),(2),(3); 10556SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; 105571 10558INSERT INTO d VALUES(2); 10559SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; 105601 105611 105621 105631 10564DROP TABLE b,c,d; 10565# 10566# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT 10567# 10568CREATE TABLE t1 ( 10569ID int(11) NOT NULL AUTO_INCREMENT, 10570id2 int(11) DEFAULT NULL, 10571id3 int(11) DEFAULT NULL, 10572id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, 10573id5 int(11) DEFAULT NULL, 10574PRIMARY KEY (ID), 10575KEY id2 (id2), 10576KEY id3 (id3), 10577KEY id5 (id5) 10578) ENGINE=InnoDB; 10579INSERT INTO t1 VALUES 10580(123,1,1,'1',NULL), 10581(124,1,1,'2',NULL), 10582(125,1,1,'4',NULL), 10583(126,1,1,'3',NULL), 10584(127,1,1,'6',NULL), 10585(128,1,1,'8',NULL); 10586CREATE TABLE t2 ( 10587id6 int(11) NOT NULL, 10588id7 int(11) NOT NULL, 10589PRIMARY KEY (id6,id7), 10590KEY id7 (id7) 10591) ENGINE=InnoDB; 10592INSERT INTO t2 VALUES (126,123),(130,123),(135,123); 10593SELECT ID 10594FROM t1 p0 10595WHERE p0.id3=1 10596AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 10597p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); 10598ID 10599126 10600DROP TABLE t1,t2; 10601# 10602# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT 10603# 10604CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); 10605INSERT INTO t1 VALUES 10606(1,1), (1,2), (1,3), (1,4), 10607(2,5), (2,6), (2,7), (2,8), 10608(3,1), (3,2), (3,9); 10609CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); 10610INSERT INTO t2 VALUES 10611(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), 10612(6, "F"), (7, "G"), (8, "H"), (9, "I"); 10613CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); 10614INSERT INTO t3 VALUES 10615(1,1), (1,2), (1,3),(1,4), 10616(2,5), (2,6), (2,7), (2,8), 10617(3,1), (3,2), (3,9); 10618CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); 10619INSERT INTO t4 VALUES 10620(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), 10621(6, "F"), (7, "G"), (8, "H"), (9, "I"); 10622ANALYZE TABLE t1,t2,t3,t4; 10623Table Op Msg_type Msg_text 10624test.t1 analyze status OK 10625test.t2 analyze status OK 10626test.t3 analyze status OK 10627test.t4 analyze status OK 10628EXPLAIN SELECT name FROM t2, t1 10629WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) 10630AND t2.uid=t1.fid; 10631id select_type table type possible_keys key key_len ref rows Extra 106321 SIMPLE t3 ref uid uid 5 const 4 Using where; Start temporary 106331 SIMPLE t4 eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 Using index 106341 SIMPLE t1 ALL uid NULL NULL NULL 11 Using where; End temporary; Using join buffer (Block Nested Loop) 106351 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 Using join buffer (Batched Key Access) 10636FLUSH STATUS; 10637SELECT name FROM t2, t1 10638WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) 10639AND t2.uid=t1.fid; 10640name 10641A 10642A 10643B 10644B 10645C 10646D 10647E 10648F 10649G 10650H 10651I 10652SHOW STATUS LIKE '%handler_read%'; 10653Variable_name Value 10654Handler_read_first 0 10655Handler_read_key 16 10656Handler_read_last 0 10657Handler_read_next 15 10658Handler_read_prev 0 10659Handler_read_rnd 11 10660Handler_read_rnd_next 12 10661DROP TABLE t1,t2,t3,t4; 10662# End of test for Bug#18194196 10663# 10664# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT 10665# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() 10666# 10667CREATE TABLE t1 ( 10668col_int int(11), 10669pk int(11) NOT NULL, 10670col_int_key int(11) , 10671col_varchar varchar(1), 10672PRIMARY KEY (pk) 10673) ENGINE=MyISAM; 10674CREATE TABLE t2 ( 10675col_int int(11), 10676col_varchar varchar(1) 10677) ENGINE=MyISAM; 10678INSERT INTO t2 VALUES (19,'x'); 10679INSERT INTO t2 VALUES (20,'z'); 10680SELECT table1.col_varchar 10681FROM (t2 AS table1 RIGHT JOIN 10682((t2 STRAIGHT_JOIN t1 ON (t1.col_varchar = t2.col_varchar))) 10683ON (t1.pk = t2.col_int)) 10684WHERE (t1.pk IN (SELECT t1.col_int_key 10685FROM (t1 INNER JOIN t2 ON (t2.col_int = t1.col_int)))) 10686AND table1.col_varchar != 'q'; 10687col_varchar 10688DROP TABLE t1,t2; 10689# End of test for Bug#21184091 10690set @@optimizer_switch=@old_opt_switch; 10691# End of 5.6 tests 10692# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... 10693CREATE TABLE t1(a INTEGER) engine=innodb; 10694CREATE TABLE t2(b INTEGER) engine=innodb; 10695explain SELECT 1 10696FROM (SELECT 1 IN (SELECT 1 10697FROM t1 10698WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) 10699) 10700FROM t2 10701) AS z; 10702id select_type table type possible_keys key key_len ref rows Extra 107031 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 NULL 107042 DERIVED t2 ALL NULL NULL NULL NULL 1 NULL 107053 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 1 Using where 107065 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 1 Using where 107074 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 1 NULL 10708SELECT 1 10709FROM (SELECT 1 IN (SELECT 1 10710FROM t1 10711WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) 10712) 10713FROM t2 10714) AS z; 107151 10716DROP TABLE t1, t2; 10717CREATE TABLE t1(a INTEGER) engine=innodb; 10718explain SELECT (SELECT a 10719FROM t1 AS t2 10720WHERE a IN (SELECT t1.a+t2.a 10721FROM t1 AS t3)) 10722FROM t1 AS t1; 10723id select_type table type possible_keys key key_len ref rows Extra 107241 PRIMARY t1 ALL NULL NULL NULL NULL 1 NULL 107252 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 1 Using where 107262 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 1 FirstMatch(t2); Using join buffer (Block Nested Loop) 10727SELECT (SELECT a 10728FROM t1 AS t2 10729WHERE a IN (SELECT t1.a+t2.a 10730FROM t1 AS t3)) 10731FROM t1 AS t1; 10732(SELECT a 10733FROM t1 AS t2 10734WHERE a IN (SELECT t1.a+t2.a 10735FROM t1 AS t3)) 10736DROP TABLE t1; 10737# End of test for Bug#21139722 10738# 10739# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE 10740# 10741CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); 10742CREATE TABLE t2 (c INT PRIMARY KEY); 10743EXPLAIN SELECT 1 10744FROM t1 10745WHERE 1 IN (SELECT (c IS NULL) IN (SELECT a 10746FROM t1 10747WHERE b) 10748FROM t2); 10749id select_type table type possible_keys key key_len ref rows Extra 107501 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 107513 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 10752SELECT 1 10753FROM t1 10754WHERE 1 IN (SELECT (c IS NULL) IN (SELECT a 10755FROM t1 10756WHERE b) 10757FROM t2); 107581 10759DROP TABLE t1,t2; 10760# 10761# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT 10762# RESULTS IN 5.6 10763# 10764CREATE TABLE t(a INT,b INT); 10765INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); 10766EXPLAIN extended SELECT * 10767FROM t AS t1 10768WHERE t1.a IN (SELECT t2.a 10769FROM t AS t2 10770WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a 10771FROM t AS t3 10772WHERE t3.b=1)); 10773id select_type table type possible_keys key key_len ref rows filtered Extra 107741 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00 Using where 107751 PRIMARY <subquery2> eq_ref <auto_key> <auto_key> 5 test.t1.a 1 100.00 NULL 107762 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 100.00 Using where 107773 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 5 100.00 Using where 10778Warnings: 10779Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t` `t1` semi join (`test`.`t` `t2`) where ((`<subquery2>`.`a` = `test`.`t1`.`a`) and (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)))))) 10780SELECT * 10781FROM t AS t1 10782WHERE t1.a IN (SELECT t2.a 10783FROM t AS t2 10784WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a 10785FROM t AS t3 10786WHERE t3.b=1)); 10787a b 10788DROP TABLE t; 10789set optimizer_switch=default; 10790set optimizer_switch=default; 10791