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 partitions type possible_keys key key_len ref rows filtered Extra 191 SIMPLE t2 NULL index PRIMARY PRIMARY 4 NULL 4 100.00 Using index 201 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t2.a 1 100.00 Using index 21Warnings: 22Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 23Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where (`test`.`t1`.`a` = `test`.`t2`.`a`) 24select * from t2 where t2.a in (select a from t1 where t1.b <> 30); 25a 262 274 28explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); 29id select_type table partitions type possible_keys key key_len ref rows filtered Extra 301 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 75.00 Using where 311 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index 32Warnings: 33Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 34Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` <> 30)) 35select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); 36a 372 383 39explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); 40id select_type table partitions type possible_keys key key_len ref rows filtered Extra 411 SIMPLE t3 NULL index PRIMARY PRIMARY 4 NULL 3 100.00 Using index 421 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 25.00 Using where; Using join buffer (Block Nested Loop) 431 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index 44Warnings: 45Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 46Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = `test`.`t3`.`a`)) 47drop table t1, t2, t3; 48create table t1 (a int, b int, index a (a,b)); 49create table t2 (a int, index a (a)); 50create table t3 (a int, b int, index a (a)); 51insert into t1 values (1,10), (2,20), (3,30), (4,40); 52create table t0(a int); 53insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 54insert into t1 55select rand()*100000+200,rand()*100000 from t0 A, t0 B, t0 C, t0 D; 56insert into t2 values (2), (3), (4), (5); 57insert into t3 values (10,3), (20,4), (30,5); 58select * from t2 where t2.a in (select a from t1); 59a 602 613 624 63explain extended select * from t2 where t2.a in (select a from t1); 64id select_type table partitions type possible_keys key key_len ref rows filtered Extra 651 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index 661 SIMPLE t1 NULL ref a a 5 test.t2.a 101 100.00 Using index; FirstMatch(t2) 67Warnings: 68Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 69Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t2`.`a`) 70select * from t2 where t2.a in (select a from t1 where t1.b <> 30); 71a 722 734 74explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); 75id select_type table partitions type possible_keys key key_len ref rows filtered Extra 761 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index 771 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) 78Warnings: 79Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 80Note 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)) 81select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); 82a 832 843 85explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a); 86id select_type table partitions type possible_keys key key_len ref rows filtered Extra 871 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index 881 SIMPLE t3 NULL index a a 5 NULL 3 100.00 Using where; Using index 891 SIMPLE t1 NULL ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; FirstMatch(t2) 90Warnings: 91Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 92Note 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`)) 93insert into t1 values (3,31); 94select * from t2 where t2.a in (select a from t1 where t1.b <> 30); 95a 962 973 984 99select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31); 100a 1012 1024 103explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30); 104id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1051 SIMPLE t2 NULL index a a 5 NULL 4 100.00 Using where; Using index 1061 SIMPLE t1 NULL ref a a 5 test.t2.a 101 90.00 Using where; Using index; FirstMatch(t2) 107Warnings: 108Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 109Note 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)) 110drop table t0, t1, t2, t3; 111create table t0 (a int); 112insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 113create table t1(a int, b int); 114insert into t1 values (0,0),(1,1),(2,2); 115create table t2 as select * from t1; 116create table t11(a int, b int); 117create table t10 (pk int, a int, primary key(pk)); 118insert into t10 select a,a from t0; 119create table t12 like t10; 120insert into t12 select * from t10; 121Flattened because of dependency, t10=func(t1) 122explain select * from t1 where a in (select pk from t10); 123id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1241 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 1251 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index 126Warnings: 127Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (`test`.`t10`.`pk` = `test`.`t1`.`a`) 128select * from t1 where a in (select pk from t10); 129a b 1300 0 1311 1 1322 2 133A confluent case of dependency 134explain select * from t1 where a in (select a from t10 where pk=12); 135id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1361 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 137Warnings: 138Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where (multiple equal(12, NULL) and multiple equal(`test`.`t1`.`a`, NULL)) 139select * from t1 where a in (select a from t10 where pk=12); 140a b 141explain select * from t1 where a in (select a from t10 where pk=9); 142id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1431 SIMPLE t10 NULL const PRIMARY PRIMARY 4 const 1 100.00 NULL 1441 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where 145Warnings: 146Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t1` where ((`test`.`t1`.`a` = '9')) 147select * from t1 where a in (select a from t10 where pk=9); 148a b 149An empty table inside 150explain select * from t1 where a in (select a from t11); 151id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1521 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 0.00 NULL 1531 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (Block Nested Loop) 1542 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 0 0.00 NULL 155Warnings: 156Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t11`) where (`test`.`t1`.`a` = `<subquery2>`.`a`) 157select * from t1 where a in (select a from t11); 158a b 159explain select * from t1 where a in (select pk from t10) and b in (select pk from t10); 160id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1611 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 1621 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index 1631 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index 164Warnings: 165Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t10` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`b`) and (`test`.`t10`.`pk` = `test`.`t1`.`a`)) 166select * from t1 where a in (select pk from t10) and b in (select pk from t10); 167a b 1680 0 1691 1 1702 2 171flattening a nested subquery 172explain select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); 173id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1741 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 1751 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where; Using join buffer (Batched Key Access) 1761 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index 177Warnings: 178Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t12` join `test`.`t10` join `test`.`t1` where ((`test`.`t10`.`pk` = `test`.`t1`.`a`) and (`test`.`t12`.`pk` = `test`.`t10`.`a`)) 179select * from t1 where a in (select pk from t10 where t10.a in (select pk from t12)); 180a b 1810 0 1821 1 1832 2 184flattening subquery w/ several tables 185explain extended select * from t1 where a in (select t10.pk from t10, t12 where t12.pk=t10.a); 186id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1871 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 1881 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where; Using join buffer (Batched Key Access) 1891 SIMPLE t12 NULL eq_ref PRIMARY PRIMARY 4 test.t10.a 1 100.00 Using index 190Warnings: 191Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 192Note 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`)) 193subqueries within outer joins go into ON expr. 194explAin extended 195select * from t1 left join (t2 A, t2 B) on ( A.A= t1.A And B.A in (select pk from t10)); 196id select_type tABle pArtitions type possiBle_keys key key_len ref rows filtered ExtrA 1971 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL 1981 SIMPLE A NULL ALL NULL NULL NULL NULL 3 100.00 Using where 1991 SIMPLE B NULL ALL NULL NULL NULL NULL 3 100.00 NULL 2001 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.B.A 1 100.00 Using index 201Warnings: 202WArning 1681 'EXTENDED' is deprecAted And will Be removed in A future releAse. 203Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`A`.`A` AS `A`,`test`.`A`.`B` AS `B`,`test`.`B`.`A` AS `A`,`test`.`B`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2` `A` join `test`.`t2` `B`) on(((`test`.`t10`.`pk` = `test`.`B`.`A`) And (`test`.`A`.`A` = `test`.`t1`.`A`) And 1)) where 1 204t2 should be wrapped into OJ-nest, so we have "t1 LJ (t2 J t10)" 205explAin extended 206select * from t1 left join t2 on (t2.A= t1.A And t2.A in (select pk from t10)); 207id select_type tABle pArtitions type possiBle_keys key key_len ref rows filtered ExtrA 2081 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL 2091 SIMPLE t10 NULL eq_ref PRIMARY PRIMARY 4 test.t1.A 1 100.00 Using where; Using index 2101 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 211Warnings: 212WArning 1681 'EXTENDED' is deprecAted And will Be removed in A future releAse. 213Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join (`test`.`t10` join `test`.`t2`) on(((`test`.`t10`.`pk` = `test`.`t1`.`A`) And (`test`.`t2`.`A` = `test`.`t1`.`A`) And 1)) where 1 214we shouldn't flatten if we're going to get a join of > MAX_TABLES. 215explain select * from 216t1 s00, t1 s01, t1 s02, t1 s03, t1 s04,t1 s05,t1 s06,t1 s07,t1 s08,t1 s09, 217t1 s10, t1 s11, t1 s12, t1 s13, t1 s14,t1 s15,t1 s16,t1 s17,t1 s18,t1 s19, 218t1 s20, t1 s21, t1 s22, t1 s23, t1 s24,t1 s25,t1 s26,t1 s27,t1 s28,t1 s29, 219t1 s30, t1 s31, t1 s32, t1 s33, t1 s34,t1 s35,t1 s36,t1 s37,t1 s38,t1 s39, 220t1 s40, t1 s41, t1 s42, t1 s43, t1 s44,t1 s45,t1 s46,t1 s47,t1 s48,t1 s49 221where 222s00.a in ( 223select m00.a from 224t1 m00, t1 m01, t1 m02, t1 m03, t1 m04,t1 m05,t1 m06,t1 m07,t1 m08,t1 m09, 225t1 m10, t1 m11, t1 m12, t1 m13, t1 m14,t1 m15,t1 m16,t1 m17,t1 m18,t1 m19 226); 227id select_type table partitions type possible_keys key key_len ref rows filtered Extra 2281 PRIMARY s00 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 2291 PRIMARY s01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2301 PRIMARY s02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2311 PRIMARY s03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2321 PRIMARY s04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2331 PRIMARY s05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2341 PRIMARY s06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2351 PRIMARY s07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2361 PRIMARY s08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2371 PRIMARY s09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2381 PRIMARY s10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2391 PRIMARY s11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2401 PRIMARY s12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2411 PRIMARY s13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2421 PRIMARY s14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2431 PRIMARY s15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2441 PRIMARY s16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2451 PRIMARY s17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2461 PRIMARY s18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2471 PRIMARY s19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2481 PRIMARY s20 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2491 PRIMARY s21 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2501 PRIMARY s22 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2511 PRIMARY s23 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2521 PRIMARY s24 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2531 PRIMARY s25 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2541 PRIMARY s26 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2551 PRIMARY s27 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2561 PRIMARY s28 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2571 PRIMARY s29 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2581 PRIMARY s30 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2591 PRIMARY s31 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2601 PRIMARY s32 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2611 PRIMARY s33 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2621 PRIMARY s34 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2631 PRIMARY s35 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2641 PRIMARY s36 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2651 PRIMARY s37 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2661 PRIMARY s38 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2671 PRIMARY s39 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2681 PRIMARY s40 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2691 PRIMARY s41 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2701 PRIMARY s42 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2711 PRIMARY s43 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2721 PRIMARY s44 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2731 PRIMARY s45 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2741 PRIMARY s46 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2751 PRIMARY s47 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2761 PRIMARY s48 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2771 PRIMARY s49 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2782 SUBQUERY m00 NULL ALL NULL NULL NULL NULL 3 100.00 NULL 2792 SUBQUERY m01 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2802 SUBQUERY m02 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2812 SUBQUERY m03 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2822 SUBQUERY m04 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2832 SUBQUERY m05 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2842 SUBQUERY m06 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2852 SUBQUERY m07 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2862 SUBQUERY m08 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2872 SUBQUERY m09 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2882 SUBQUERY m10 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2892 SUBQUERY m11 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2902 SUBQUERY m12 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2912 SUBQUERY m13 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2922 SUBQUERY m14 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2932 SUBQUERY m15 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2942 SUBQUERY m16 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2952 SUBQUERY m17 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2962 SUBQUERY m18 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 2972 SUBQUERY m19 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (Block Nested Loop) 298Warnings: 299Note 1003 /* select#1 */ select `test`.`s00`.`a` AS `a`,`test`.`s00`.`b` AS `b`,`test`.`s01`.`a` AS `a`,`test`.`s01`.`b` AS `b`,`test`.`s02`.`a` AS `a`,`test`.`s02`.`b` AS `b`,`test`.`s03`.`a` AS `a`,`test`.`s03`.`b` AS `b`,`test`.`s04`.`a` AS `a`,`test`.`s04`.`b` AS `b`,`test`.`s05`.`a` AS `a`,`test`.`s05`.`b` AS `b`,`test`.`s06`.`a` AS `a`,`test`.`s06`.`b` AS `b`,`test`.`s07`.`a` AS `a`,`test`.`s07`.`b` AS `b`,`test`.`s08`.`a` AS `a`,`test`.`s08`.`b` AS `b`,`test`.`s09`.`a` AS `a`,`test`.`s09`.`b` AS `b`,`test`.`s10`.`a` AS `a`,`test`.`s10`.`b` AS `b`,`test`.`s11`.`a` AS `a`,`test`.`s11`.`b` AS `b`,`test`.`s12`.`a` AS `a`,`test`.`s12`.`b` AS `b`,`test`.`s13`.`a` AS `a`,`test`.`s13`.`b` AS `b`,`test`.`s14`.`a` AS `a`,`test`.`s14`.`b` AS `b`,`test`.`s15`.`a` AS `a`,`test`.`s15`.`b` AS `b`,`test`.`s16`.`a` AS `a`,`test`.`s16`.`b` AS `b`,`test`.`s17`.`a` AS `a`,`test`.`s17`.`b` AS `b`,`test`.`s18`.`a` AS `a`,`test`.`s18`.`b` AS `b`,`test`.`s19`.`a` AS `a`,`test`.`s19`.`b` AS `b`,`test`.`s20`.`a` AS `a`,`test`.`s20`.`b` AS `b`,`test`.`s21`.`a` AS `a`,`test`.`s21`.`b` AS `b`,`test`.`s22`.`a` AS `a`,`test`.`s22`.`b` AS `b`,`test`.`s23`.`a` AS `a`,`test`.`s23`.`b` AS `b`,`test`.`s24`.`a` AS `a`,`test`.`s24`.`b` AS `b`,`test`.`s25`.`a` AS `a`,`test`.`s25`.`b` AS `b`,`test`.`s26`.`a` AS `a`,`test`.`s26`.`b` AS `b`,`test`.`s27`.`a` AS `a`,`test`.`s27`.`b` AS `b`,`test`.`s28`.`a` AS `a`,`test`.`s28`.`b` AS `b`,`test`.`s29`.`a` AS `a`,`test`.`s29`.`b` AS `b`,`test`.`s30`.`a` AS `a`,`test`.`s30`.`b` AS `b`,`test`.`s31`.`a` AS `a`,`test`.`s31`.`b` AS `b`,`test`.`s32`.`a` AS `a`,`test`.`s32`.`b` AS `b`,`test`.`s33`.`a` AS `a`,`test`.`s33`.`b` AS `b`,`test`.`s34`.`a` AS `a`,`test`.`s34`.`b` AS `b`,`test`.`s35`.`a` AS `a`,`test`.`s35`.`b` AS `b`,`test`.`s36`.`a` AS `a`,`test`.`s36`.`b` AS `b`,`test`.`s37`.`a` AS `a`,`test`.`s37`.`b` AS `b`,`test`.`s38`.`a` AS `a`,`test`.`s38`.`b` AS `b`,`test`.`s39`.`a` AS `a`,`test`.`s39`.`b` AS `b`,`test`.`s40`.`a` AS `a`,`test`.`s40`.`b` AS `b`,`test`.`s41`.`a` AS `a`,`test`.`s41`.`b` AS `b`,`test`.`s42`.`a` AS `a`,`test`.`s42`.`b` AS `b`,`test`.`s43`.`a` AS `a`,`test`.`s43`.`b` AS `b`,`test`.`s44`.`a` AS `a`,`test`.`s44`.`b` AS `b`,`test`.`s45`.`a` AS `a`,`test`.`s45`.`b` AS `b`,`test`.`s46`.`a` AS `a`,`test`.`s46`.`b` AS `b`,`test`.`s47`.`a` AS `a`,`test`.`s47`.`b` AS `b`,`test`.`s48`.`a` AS `a`,`test`.`s48`.`b` AS `b`,`test`.`s49`.`a` AS `a`,`test`.`s49`.`b` AS `b` from `test`.`t1` `s00` join `test`.`t1` `s01` join `test`.`t1` `s02` join `test`.`t1` `s03` join `test`.`t1` `s04` join `test`.`t1` `s05` join `test`.`t1` `s06` join `test`.`t1` `s07` join `test`.`t1` `s08` join `test`.`t1` `s09` join `test`.`t1` `s10` join `test`.`t1` `s11` join `test`.`t1` `s12` join `test`.`t1` `s13` join `test`.`t1` `s14` join `test`.`t1` `s15` join `test`.`t1` `s16` join `test`.`t1` `s17` join `test`.`t1` `s18` join `test`.`t1` `s19` join `test`.`t1` `s20` join `test`.`t1` `s21` join `test`.`t1` `s22` join `test`.`t1` `s23` join `test`.`t1` `s24` join `test`.`t1` `s25` join `test`.`t1` `s26` join `test`.`t1` `s27` join `test`.`t1` `s28` join `test`.`t1` `s29` join `test`.`t1` `s30` join `test`.`t1` `s31` join `test`.`t1` `s32` join `test`.`t1` `s33` join `test`.`t1` `s34` join `test`.`t1` `s35` join `test`.`t1` `s36` join `test`.`t1` `s37` join `test`.`t1` `s38` join `test`.`t1` `s39` join `test`.`t1` `s40` join `test`.`t1` `s41` join `test`.`t1` `s42` join `test`.`t1` `s43` join `test`.`t1` `s44` join `test`.`t1` `s45` join `test`.`t1` `s46` join `test`.`t1` `s47` join `test`.`t1` `s48` join `test`.`t1` `s49` where <in_optimizer>(`test`.`s00`.`a`,`test`.`s00`.`a` in ( <materialize> (/* select#2 */ select `test`.`m00`.`a` from `test`.`t1` `m00` join `test`.`t1` `m01` join `test`.`t1` `m02` join `test`.`t1` `m03` join `test`.`t1` `m04` join `test`.`t1` `m05` join `test`.`t1` `m06` join `test`.`t1` `m07` join `test`.`t1` `m08` join `test`.`t1` `m09` join `test`.`t1` `m10` join `test`.`t1` `m11` join `test`.`t1` `m12` join `test`.`t1` `m13` join `test`.`t1` `m14` join `test`.`t1` `m15` join `test`.`t1` `m16` join `test`.`t1` `m17` join `test`.`t1` `m18` join `test`.`t1` `m19` where 1 ), <primary_index_lookup>(`test`.`s00`.`a` in <temporary table> on <auto_key> where ((`test`.`s00`.`a` = `materialized-subquery`.`a`))))) 300select * from 301t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) 302where t1.a < 5; 303a b a b 3040 0 0 0 3051 1 1 1 3062 2 2 2 307prepare s1 from 308' select * from 309 t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) 310 where t1.a < 5'; 311execute s1; 312a b a b 3130 0 0 0 3141 1 1 1 3152 2 2 2 316execute s1; 317a b a b 3180 0 0 0 3191 1 1 1 3202 2 2 2 321insert into t1 select (A.a + 10 * B.a),1 from t0 A, t0 B; 322explain extended select * from t1 where a in (select pk from t10 where pk<3); 323id select_type table partitions type possible_keys key key_len ref rows filtered Extra 3241 SIMPLE t10 NULL range PRIMARY PRIMARY 4 NULL 4 100.00 Using where; Using index 3251 SIMPLE t1 NULL ALL NULL NULL NULL NULL 103 10.00 Using where; Using join buffer (Block Nested Loop) 326Warnings: 327Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 328Note 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)) 329drop table t0, t1, t2; 330drop table t10, t11, t12; 331# 332# Check that subqueries with outer joins or straight_join work for 333# different permutations of const and non-const tables. (Ref. Bug#46692) 334# 335CREATE TABLE t1 (i INTEGER); 336CREATE TABLE t2 (i INTEGER); 337CREATE TABLE t3 (i INTEGER); 338SELECT (SELECT COUNT(*) from t1) AS c1, 339(SELECT COUNT(*) from t2) AS c2, 340(SELECT COUNT(*) from t3) AS c3; 341c1 c2 c3 3420 0 0 343EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 344(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 345id select_type table partitions type possible_keys key key_len ref rows filtered Extra 3461 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 347Warnings: 348Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) 349SELECT * FROM t1 WHERE (t1.i) IN 350(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 351i 352PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 353(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 354EXECUTE stmt; 355i 356EXECUTE stmt; 357i 358DEALLOCATE PREPARE stmt; 359EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 360(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 361id select_type table partitions type possible_keys key key_len ref rows filtered Extra 3621 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 363Warnings: 364Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) 365SELECT * FROM t1 WHERE (t1.i) IN 366(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 367i 368PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 369(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 370EXECUTE stmt; 371i 372EXECUTE stmt; 373i 374DEALLOCATE PREPARE stmt; 375EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 376(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 377id select_type table partitions type possible_keys key key_len ref rows filtered Extra 3781 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 379Warnings: 380Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) 381SELECT * FROM t1 WHERE (t1.i) IN 382(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 383i 384EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 385(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 386id select_type table partitions type possible_keys key key_len ref rows filtered Extra 3871 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 388Warnings: 389Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) 390SELECT * FROM t1 WHERE (t1.i) IN 391(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 392i 393EXPLAIN SELECT * FROM t1 WHERE (11) IN 394(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 395id select_type table partitions type possible_keys key key_len ref rows filtered Extra 3961 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 397Warnings: 398Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) 399SELECT * FROM t1 WHERE (11) IN 400(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 401i 402EXPLAIN SELECT * FROM t1 WHERE (11) IN 403(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 404id select_type table partitions type possible_keys key key_len ref rows filtered Extra 4051 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 406Warnings: 407Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 408Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where (NULL and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) 409SELECT * FROM t1 WHERE (11) IN 410(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 411i 412EXPLAIN SELECT * FROM t1 WHERE (11) IN 413(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 414id select_type table partitions type possible_keys key key_len ref rows filtered Extra 4151 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 416Warnings: 417Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) 418SELECT * FROM t1 WHERE (11) IN 419(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 420i 421EXPLAIN SELECT * FROM t1 WHERE (11) IN 422(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 423id select_type table partitions type possible_keys key key_len ref rows filtered Extra 4241 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 425Warnings: 426Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) 427SELECT * FROM t1 WHERE (11) IN 428(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 429i 430INSERT INTO t3 VALUES (2); 431SELECT (SELECT COUNT(*) from t1) AS c1, 432(SELECT COUNT(*) from t2) AS c2, 433(SELECT COUNT(*) from t3) AS c3; 434c1 c2 c3 4350 0 1 436EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 437(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 438id select_type table partitions type possible_keys key key_len ref rows filtered Extra 4391 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 440Warnings: 441Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) 442SELECT * FROM t1 WHERE (t1.i) IN 443(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 444i 445PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 446(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 447EXECUTE stmt; 448i 449EXECUTE stmt; 450i 451DEALLOCATE PREPARE stmt; 452EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 453(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 454id select_type table partitions type possible_keys key key_len ref rows filtered Extra 4551 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 456Warnings: 457Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) 458SELECT * FROM t1 WHERE (t1.i) IN 459(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 460i 461PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 462(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 463EXECUTE stmt; 464i 465EXECUTE stmt; 466i 467DEALLOCATE PREPARE stmt; 468EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 469(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 470id select_type table partitions type possible_keys key key_len ref rows filtered Extra 4711 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 472Warnings: 473Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) 474SELECT * FROM t1 WHERE (t1.i) IN 475(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 476i 477EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 478(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 479id select_type table partitions type possible_keys key key_len ref rows filtered Extra 4801 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 481Warnings: 482Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) 483SELECT * FROM t1 WHERE (t1.i) IN 484(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 485i 486EXPLAIN SELECT * FROM t1 WHERE (11) IN 487(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 488id select_type table partitions type possible_keys key key_len ref rows filtered Extra 4891 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 490Warnings: 491Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) 492SELECT * FROM t1 WHERE (11) IN 493(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 494i 495EXPLAIN SELECT * FROM t1 WHERE (11) IN 496(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 497id select_type table partitions type possible_keys key key_len ref rows filtered Extra 4981 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 499Warnings: 500Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 501Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where (NULL and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) 502SELECT * FROM t1 WHERE (11) IN 503(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 504i 505EXPLAIN SELECT * FROM t1 WHERE (11) IN 506(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 507id select_type table partitions type possible_keys key key_len ref rows filtered Extra 5081 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 509Warnings: 510Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) 511SELECT * FROM t1 WHERE (11) IN 512(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 513i 514EXPLAIN SELECT * FROM t1 WHERE (11) IN 515(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 516id select_type table partitions type possible_keys key key_len ref rows filtered Extra 5171 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 518Warnings: 519Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) 520SELECT * FROM t1 WHERE (11) IN 521(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 522i 523INSERT INTO t3 VALUES (1); 524SELECT (SELECT COUNT(*) from t1) AS c1, 525(SELECT COUNT(*) from t2) AS c2, 526(SELECT COUNT(*) from t3) AS c3; 527c1 c2 c3 5280 0 2 529EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 530(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 531id select_type table partitions type possible_keys key key_len ref rows filtered Extra 5321 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 533Warnings: 534Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) 535SELECT * FROM t1 WHERE (t1.i) IN 536(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 537i 538PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 539(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 540EXECUTE stmt; 541i 542EXECUTE stmt; 543i 544DEALLOCATE PREPARE stmt; 545EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 546(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 547id select_type table partitions type possible_keys key key_len ref rows filtered Extra 5481 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 549Warnings: 550Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) 551SELECT * FROM t1 WHERE (t1.i) IN 552(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 553i 554PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 555(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 556EXECUTE stmt; 557i 558EXECUTE stmt; 559i 560DEALLOCATE PREPARE stmt; 561EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 562(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 563id select_type table partitions type possible_keys key key_len ref rows filtered Extra 5641 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 565Warnings: 566Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) 567SELECT * FROM t1 WHERE (t1.i) IN 568(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 569i 570EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 571(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 572id select_type table partitions type possible_keys key key_len ref rows filtered Extra 5731 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 574Warnings: 575Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) 576SELECT * FROM t1 WHERE (t1.i) IN 577(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 578i 579EXPLAIN SELECT * FROM t1 WHERE (11) IN 580(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 581id select_type table partitions type possible_keys key key_len ref rows filtered Extra 5821 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 583Warnings: 584Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) 585SELECT * FROM t1 WHERE (11) IN 586(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 587i 588EXPLAIN SELECT * FROM t1 WHERE (11) IN 589(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 590id select_type table partitions type possible_keys key key_len ref rows filtered Extra 5911 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 592Warnings: 593Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 594Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where (NULL and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) 595SELECT * FROM t1 WHERE (11) IN 596(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 597i 598EXPLAIN SELECT * FROM t1 WHERE (11) IN 599(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 600id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6011 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 602Warnings: 603Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) 604SELECT * FROM t1 WHERE (11) IN 605(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 606i 607EXPLAIN SELECT * FROM t1 WHERE (11) IN 608(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 609id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6101 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 611Warnings: 612Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) 613SELECT * FROM t1 WHERE (11) IN 614(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 615i 616INSERT INTO t3 VALUES (0); 617DELETE FROM t3; 618INSERT INTO t2 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 0 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 partitions type possible_keys key key_len ref rows filtered Extra 6271 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 628Warnings: 629Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) 630SELECT * FROM t1 WHERE (t1.i) IN 631(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 632i 633PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 634(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 635EXECUTE stmt; 636i 637EXECUTE stmt; 638i 639DEALLOCATE PREPARE stmt; 640EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 641(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 642id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6431 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 644Warnings: 645Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) 646SELECT * FROM t1 WHERE (t1.i) IN 647(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 648i 649PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 650(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 651EXECUTE stmt; 652i 653EXECUTE stmt; 654i 655DEALLOCATE PREPARE stmt; 656EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 657(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 658id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6591 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 660Warnings: 661Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) 662SELECT * FROM t1 WHERE (t1.i) IN 663(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 664i 665EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 666(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 667id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6681 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 669Warnings: 670Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) 671SELECT * FROM t1 WHERE (t1.i) IN 672(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 673i 674EXPLAIN SELECT * FROM t1 WHERE (11) IN 675(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 676id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6771 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 678Warnings: 679Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) 680SELECT * FROM t1 WHERE (11) IN 681(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 682i 683EXPLAIN SELECT * FROM t1 WHERE (11) IN 684(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 685id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6861 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 687Warnings: 688Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 689Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where (NULL and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) 690SELECT * FROM t1 WHERE (11) IN 691(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 692i 693EXPLAIN SELECT * FROM t1 WHERE (11) IN 694(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 695id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6961 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 697Warnings: 698Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) 699SELECT * FROM t1 WHERE (11) IN 700(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 701i 702EXPLAIN SELECT * FROM t1 WHERE (11) IN 703(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 704id select_type table partitions type possible_keys key key_len ref rows filtered Extra 7051 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 706Warnings: 707Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) 708SELECT * FROM t1 WHERE (11) IN 709(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 710i 711INSERT INTO t3 VALUES (2); 712SELECT (SELECT COUNT(*) from t1) AS c1, 713(SELECT COUNT(*) from t2) AS c2, 714(SELECT COUNT(*) from t3) AS c3; 715c1 c2 c3 7160 1 1 717EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 718(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 719id select_type table partitions type possible_keys key key_len ref rows filtered Extra 7201 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 721Warnings: 722Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) 723SELECT * FROM t1 WHERE (t1.i) IN 724(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 725i 726PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 727(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 728EXECUTE stmt; 729i 730EXECUTE stmt; 731i 732DEALLOCATE PREPARE stmt; 733EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 734(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 735id select_type table partitions type possible_keys key key_len ref rows filtered Extra 7361 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 737Warnings: 738Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) 739SELECT * FROM t1 WHERE (t1.i) IN 740(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 741i 742PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 743(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 744EXECUTE stmt; 745i 746EXECUTE stmt; 747i 748DEALLOCATE PREPARE stmt; 749EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 750(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 751id select_type table partitions type possible_keys key key_len ref rows filtered Extra 7521 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 753Warnings: 754Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) 755SELECT * FROM t1 WHERE (t1.i) IN 756(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 757i 758EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 759(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 760id select_type table partitions type possible_keys key key_len ref rows filtered Extra 7611 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 762Warnings: 763Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) 764SELECT * FROM t1 WHERE (t1.i) IN 765(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 766i 767EXPLAIN SELECT * FROM t1 WHERE (11) IN 768(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 769id select_type table partitions type possible_keys key key_len ref rows filtered Extra 7701 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 771Warnings: 772Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) 773SELECT * FROM t1 WHERE (11) IN 774(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 775i 776EXPLAIN SELECT * FROM t1 WHERE (11) IN 777(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 778id select_type table partitions type possible_keys key key_len ref rows filtered Extra 7791 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 780Warnings: 781Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 782Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where (NULL and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) 783SELECT * FROM t1 WHERE (11) IN 784(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 785i 786EXPLAIN SELECT * FROM t1 WHERE (11) IN 787(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 788id select_type table partitions type possible_keys key key_len ref rows filtered Extra 7891 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 790Warnings: 791Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) 792SELECT * FROM t1 WHERE (11) IN 793(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 794i 795EXPLAIN SELECT * FROM t1 WHERE (11) IN 796(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 797id select_type table partitions type possible_keys key key_len ref rows filtered Extra 7981 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 799Warnings: 800Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) 801SELECT * FROM t1 WHERE (11) IN 802(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 803i 804INSERT INTO t3 VALUES (1); 805SELECT (SELECT COUNT(*) from t1) AS c1, 806(SELECT COUNT(*) from t2) AS c2, 807(SELECT COUNT(*) from t3) AS c3; 808c1 c2 c3 8090 1 2 810EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 811(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 812id select_type table partitions type possible_keys key key_len ref rows filtered Extra 8131 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 814Warnings: 815Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) 816SELECT * FROM t1 WHERE (t1.i) IN 817(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 818i 819PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 820(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 821EXECUTE stmt; 822i 823EXECUTE stmt; 824i 825DEALLOCATE PREPARE stmt; 826EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 827(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 828id select_type table partitions type possible_keys key key_len ref rows filtered Extra 8291 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 830Warnings: 831Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) 832SELECT * FROM t1 WHERE (t1.i) IN 833(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 834i 835PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 836(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 837EXECUTE stmt; 838i 839EXECUTE stmt; 840i 841DEALLOCATE PREPARE stmt; 842EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 843(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 844id select_type table partitions type possible_keys key key_len ref rows filtered Extra 8451 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 846Warnings: 847Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) 848SELECT * FROM t1 WHERE (t1.i) IN 849(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 850i 851EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 852(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 853id select_type table partitions type possible_keys key key_len ref rows filtered Extra 8541 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 855Warnings: 856Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) 857SELECT * FROM t1 WHERE (t1.i) IN 858(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 859i 860EXPLAIN SELECT * FROM t1 WHERE (11) IN 861(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 862id select_type table partitions type possible_keys key key_len ref rows filtered Extra 8631 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 864Warnings: 865Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) 866SELECT * FROM t1 WHERE (11) IN 867(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 868i 869EXPLAIN SELECT * FROM t1 WHERE (11) IN 870(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 871id select_type table partitions type possible_keys key key_len ref rows filtered Extra 8721 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 873Warnings: 874Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 875Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where (NULL and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) 876SELECT * FROM t1 WHERE (11) IN 877(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 878i 879EXPLAIN SELECT * FROM t1 WHERE (11) IN 880(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 881id select_type table partitions type possible_keys key key_len ref rows filtered Extra 8821 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 883Warnings: 884Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) 885SELECT * FROM t1 WHERE (11) IN 886(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 887i 888EXPLAIN SELECT * FROM t1 WHERE (11) IN 889(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 890id select_type table partitions type possible_keys key key_len ref rows filtered Extra 8911 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 892Warnings: 893Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) 894SELECT * FROM t1 WHERE (11) IN 895(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 896i 897INSERT INTO t3 VALUES (0); 898DELETE FROM t3; 899INSERT INTO t2 VALUES (1); 900SELECT (SELECT COUNT(*) from t1) AS c1, 901(SELECT COUNT(*) from t2) AS c2, 902(SELECT COUNT(*) from t3) AS c3; 903c1 c2 c3 9040 2 0 905EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 906(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 907id select_type table partitions type possible_keys key key_len ref rows filtered Extra 9081 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 909Warnings: 910Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) 911SELECT * FROM t1 WHERE (t1.i) IN 912(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 913i 914PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 915(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 916EXECUTE stmt; 917i 918EXECUTE stmt; 919i 920DEALLOCATE PREPARE stmt; 921EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 922(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 923id select_type table partitions type possible_keys key key_len ref rows filtered Extra 9241 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 925Warnings: 926Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) 927SELECT * FROM t1 WHERE (t1.i) IN 928(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 929i 930PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 931(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 932EXECUTE stmt; 933i 934EXECUTE stmt; 935i 936DEALLOCATE PREPARE stmt; 937EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 938(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 939id select_type table partitions type possible_keys key key_len ref rows filtered Extra 9401 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 941Warnings: 942Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) 943SELECT * FROM t1 WHERE (t1.i) IN 944(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 945i 946EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 947(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 948id select_type table partitions type possible_keys key key_len ref rows filtered Extra 9491 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 950Warnings: 951Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `<subquery2>`.`i`) 952SELECT * FROM t1 WHERE (t1.i) IN 953(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 954i 955EXPLAIN SELECT * FROM t1 WHERE (11) IN 956(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 957id select_type table partitions type possible_keys key key_len ref rows filtered Extra 9581 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 959Warnings: 960Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) 961SELECT * FROM t1 WHERE (11) IN 962(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 963i 964EXPLAIN SELECT * FROM t1 WHERE (11) IN 965(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 966id select_type table partitions type possible_keys key key_len ref rows filtered Extra 9671 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 968Warnings: 969Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 970Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where (NULL and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) 971SELECT * FROM t1 WHERE (11) IN 972(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 973i 974EXPLAIN SELECT * FROM t1 WHERE (11) IN 975(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 976id select_type table partitions type possible_keys key key_len ref rows filtered Extra 9771 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 978Warnings: 979Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) 980SELECT * FROM t1 WHERE (11) IN 981(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 982i 983EXPLAIN SELECT * FROM t1 WHERE (11) IN 984(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 985id select_type table partitions type possible_keys key key_len ref rows filtered Extra 9861 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 987Warnings: 988Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `<subquery2>`.`i`) 989SELECT * FROM t1 WHERE (11) IN 990(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 991i 992INSERT INTO t3 VALUES (2); 993SELECT (SELECT COUNT(*) from t1) AS c1, 994(SELECT COUNT(*) from t2) AS c2, 995(SELECT COUNT(*) from t3) AS c3; 996c1 c2 c3 9970 2 1 998EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 999(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1000id select_type table partitions type possible_keys key key_len ref rows filtered Extra 10011 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1002Warnings: 1003Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) 1004SELECT * FROM t1 WHERE (t1.i) IN 1005(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1006i 1007PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1008(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1009EXECUTE stmt; 1010i 1011EXECUTE stmt; 1012i 1013DEALLOCATE PREPARE stmt; 1014EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1015(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1016id select_type table partitions type possible_keys key key_len ref rows filtered Extra 10171 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1018Warnings: 1019Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) 1020SELECT * FROM t1 WHERE (t1.i) IN 1021(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1022i 1023PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1024(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1025EXECUTE stmt; 1026i 1027EXECUTE stmt; 1028i 1029DEALLOCATE PREPARE stmt; 1030EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1031(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1032id select_type table partitions type possible_keys key key_len ref rows filtered Extra 10331 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1034Warnings: 1035Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) 1036SELECT * FROM t1 WHERE (t1.i) IN 1037(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1038i 1039EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1040(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1041id select_type table partitions type possible_keys key key_len ref rows filtered Extra 10421 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1043Warnings: 1044Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) 1045SELECT * FROM t1 WHERE (t1.i) IN 1046(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1047i 1048EXPLAIN SELECT * FROM t1 WHERE (11) IN 1049(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1050id select_type table partitions type possible_keys key key_len ref rows filtered Extra 10511 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1052Warnings: 1053Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) 1054SELECT * FROM t1 WHERE (11) IN 1055(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1056i 1057EXPLAIN SELECT * FROM t1 WHERE (11) IN 1058(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1059id select_type table partitions type possible_keys key key_len ref rows filtered Extra 10601 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1061Warnings: 1062Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 1063Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where (NULL and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) 1064SELECT * FROM t1 WHERE (11) IN 1065(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1066i 1067EXPLAIN SELECT * FROM t1 WHERE (11) IN 1068(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1069id select_type table partitions type possible_keys key key_len ref rows filtered Extra 10701 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1071Warnings: 1072Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) 1073SELECT * FROM t1 WHERE (11) IN 1074(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1075i 1076EXPLAIN SELECT * FROM t1 WHERE (11) IN 1077(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1078id select_type table partitions type possible_keys key key_len ref rows filtered Extra 10791 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1080Warnings: 1081Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) 1082SELECT * FROM t1 WHERE (11) IN 1083(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1084i 1085INSERT INTO t3 VALUES (1); 1086SELECT (SELECT COUNT(*) from t1) AS c1, 1087(SELECT COUNT(*) from t2) AS c2, 1088(SELECT COUNT(*) from t3) AS c3; 1089c1 c2 c3 10900 2 2 1091EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1092(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1093id select_type table partitions type possible_keys key key_len ref rows filtered Extra 10941 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1095Warnings: 1096Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) 1097SELECT * FROM t1 WHERE (t1.i) IN 1098(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1099i 1100PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1101(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1102EXECUTE stmt; 1103i 1104EXECUTE stmt; 1105i 1106DEALLOCATE PREPARE stmt; 1107EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1108(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1109id select_type table partitions type possible_keys key key_len ref rows filtered Extra 11101 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1111Warnings: 1112Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`, `test`.`t2`.`i`) 1113SELECT * FROM t1 WHERE (t1.i) IN 1114(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1115i 1116PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1117(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1118EXECUTE stmt; 1119i 1120EXECUTE stmt; 1121i 1122DEALLOCATE PREPARE stmt; 1123EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1124(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1125id select_type table partitions type possible_keys key key_len ref rows filtered Extra 11261 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1127Warnings: 1128Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(NULL, `test`.`t3`.`i`) 1129SELECT * FROM t1 WHERE (t1.i) IN 1130(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1131i 1132EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1133(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1134id select_type table partitions type possible_keys key key_len ref rows filtered Extra 11351 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1136Warnings: 1137Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(NULL, `test`.`t3`.`i`) 1138SELECT * FROM t1 WHERE (t1.i) IN 1139(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1140i 1141EXPLAIN SELECT * FROM t1 WHERE (11) IN 1142(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1143id select_type table partitions type possible_keys key key_len ref rows filtered Extra 11441 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1145Warnings: 1146Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`) 1147SELECT * FROM t1 WHERE (11) IN 1148(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1149i 1150EXPLAIN SELECT * FROM t1 WHERE (11) IN 1151(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1152id select_type table partitions type possible_keys key key_len ref rows filtered Extra 11531 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1154Warnings: 1155Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 1156Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where (NULL and multiple equal(11, `test`.`t3`.`i`, `test`.`t2`.`i`)) 1157SELECT * FROM t1 WHERE (11) IN 1158(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1159i 1160EXPLAIN SELECT * FROM t1 WHERE (11) IN 1161(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1162id select_type table partitions type possible_keys key key_len ref rows filtered Extra 11631 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1164Warnings: 1165Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where multiple equal(11, `test`.`t3`.`i`) 1166SELECT * FROM t1 WHERE (11) IN 1167(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1168i 1169EXPLAIN SELECT * FROM t1 WHERE (11) IN 1170(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1171id select_type table partitions type possible_keys key key_len ref rows filtered Extra 11721 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 1173Warnings: 1174Note 1003 /* select#1 */ select NULL AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where multiple equal(11, `test`.`t3`.`i`) 1175SELECT * FROM t1 WHERE (11) IN 1176(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1177i 1178INSERT INTO t3 VALUES (0); 1179DELETE FROM t3; 1180INSERT INTO t2 VALUES (0); 1181DELETE FROM t2; 1182INSERT INTO t1 VALUES (2); 1183SELECT (SELECT COUNT(*) from t1) AS c1, 1184(SELECT COUNT(*) from t2) AS c2, 1185(SELECT COUNT(*) from t3) AS c3; 1186c1 c2 c3 11871 0 0 1188EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1189(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1190id select_type table partitions type possible_keys key key_len ref rows filtered Extra 11911 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 11921 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 11931 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) 1194Warnings: 1195Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) 1196SELECT * FROM t1 WHERE (t1.i) IN 1197(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1198i 1199PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1200(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1201EXECUTE stmt; 1202i 1203EXECUTE stmt; 1204i 1205DEALLOCATE PREPARE stmt; 1206EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1207(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1208id select_type table partitions type possible_keys key key_len ref rows filtered Extra 12091 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 12101 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 12111 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) 1212Warnings: 1213Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) 1214SELECT * FROM t1 WHERE (t1.i) IN 1215(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1216i 1217PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1218(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1219EXECUTE stmt; 1220i 1221EXECUTE stmt; 1222i 1223DEALLOCATE PREPARE stmt; 1224EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1225(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1226id select_type table partitions type possible_keys key key_len ref rows filtered Extra 12271 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 12281 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 12291 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) 1230Warnings: 1231Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') 1232SELECT * FROM t1 WHERE (t1.i) IN 1233(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1234i 1235EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1236(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1237id select_type table partitions type possible_keys key key_len ref rows filtered Extra 12381 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 12391 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL 12401 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) 1241Warnings: 1242Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') 1243SELECT * FROM t1 WHERE (t1.i) IN 1244(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1245i 1246EXPLAIN SELECT * FROM t1 WHERE (11) IN 1247(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1248id select_type table partitions type possible_keys key key_len ref rows filtered Extra 12491 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 12501 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 12511 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) 1252Warnings: 1253Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) 1254SELECT * FROM t1 WHERE (11) IN 1255(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1256i 1257EXPLAIN SELECT * FROM t1 WHERE (11) IN 1258(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1259id select_type table partitions type possible_keys key key_len ref rows filtered Extra 12601 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 12611 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 12621 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) 1263Warnings: 1264Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 1265Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and '2') 1266SELECT * FROM t1 WHERE (11) IN 1267(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1268i 1269EXPLAIN SELECT * FROM t1 WHERE (11) IN 1270(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1271id select_type table partitions type possible_keys key key_len ref rows filtered Extra 12721 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 12731 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 12741 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) 1275Warnings: 1276Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) 1277SELECT * FROM t1 WHERE (11) IN 1278(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1279i 1280EXPLAIN SELECT * FROM t1 WHERE (11) IN 1281(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1282id select_type table partitions type possible_keys key key_len ref rows filtered Extra 12831 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 12841 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL 12851 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) 1286Warnings: 1287Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) 1288SELECT * FROM t1 WHERE (11) IN 1289(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1290i 1291INSERT INTO t3 VALUES (2); 1292SELECT (SELECT COUNT(*) from t1) AS c1, 1293(SELECT COUNT(*) from t2) AS c2, 1294(SELECT COUNT(*) from t3) AS c3; 1295c1 c2 c3 12961 0 1 1297EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1298(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1299id select_type table partitions type possible_keys key key_len ref rows filtered Extra 13001 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 13011 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 13021 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 1303Warnings: 1304Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) 1305SELECT * FROM t1 WHERE (t1.i) IN 1306(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1307i 1308PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1309(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1310EXECUTE stmt; 1311i 1312EXECUTE stmt; 1313i 1314DEALLOCATE PREPARE stmt; 1315EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1316(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1317id select_type table partitions type possible_keys key key_len ref rows filtered Extra 13181 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 13191 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 13201 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 1321Warnings: 1322Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) 1323SELECT * FROM t1 WHERE (t1.i) IN 1324(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1325i 1326PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1327(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1328EXECUTE stmt; 1329i 1330EXECUTE stmt; 1331i 1332DEALLOCATE PREPARE stmt; 1333EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1334(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1335id select_type table partitions type possible_keys key key_len ref rows filtered Extra 13361 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 13371 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 13381 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) 1339Warnings: 1340Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') 1341SELECT * FROM t1 WHERE (t1.i) IN 1342(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1343i 13442 1345EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1346(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1347id select_type table partitions type possible_keys key key_len ref rows filtered Extra 13481 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 13491 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL 13501 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 1351Warnings: 1352Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') 1353SELECT * FROM t1 WHERE (t1.i) IN 1354(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1355i 1356EXPLAIN SELECT * FROM t1 WHERE (11) IN 1357(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1358id select_type table partitions type possible_keys key key_len ref rows filtered Extra 13591 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 13601 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 13611 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 1362Warnings: 1363Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) 1364SELECT * FROM t1 WHERE (11) IN 1365(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1366i 1367EXPLAIN SELECT * FROM t1 WHERE (11) IN 1368(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1369id select_type table partitions type possible_keys key key_len ref rows filtered Extra 13701 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 13711 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 13721 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 1373Warnings: 1374Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 1375Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and '2') 1376SELECT * FROM t1 WHERE (11) IN 1377(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1378i 1379EXPLAIN SELECT * FROM t1 WHERE (11) IN 1380(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1381id select_type table partitions type possible_keys key key_len ref rows filtered Extra 13821 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 13831 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 13841 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) 1385Warnings: 1386Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) 1387SELECT * FROM t1 WHERE (11) IN 1388(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1389i 1390EXPLAIN SELECT * FROM t1 WHERE (11) IN 1391(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1392id select_type table partitions type possible_keys key key_len ref rows filtered Extra 13931 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 13941 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL 13951 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 1396Warnings: 1397Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) 1398SELECT * FROM t1 WHERE (11) IN 1399(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1400i 1401INSERT INTO t3 VALUES (1); 1402SELECT (SELECT COUNT(*) from t1) AS c1, 1403(SELECT COUNT(*) from t2) AS c2, 1404(SELECT COUNT(*) from t3) AS c3; 1405c1 c2 c3 14061 0 2 1407EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1408(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1409id select_type table partitions type possible_keys key key_len ref rows filtered Extra 14101 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 14111 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 14121 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 1413Warnings: 1414Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) 1415SELECT * FROM t1 WHERE (t1.i) IN 1416(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1417i 1418PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1419(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1420EXECUTE stmt; 1421i 1422EXECUTE stmt; 1423i 1424DEALLOCATE PREPARE stmt; 1425EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1426(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1427id select_type table partitions type possible_keys key key_len ref rows filtered Extra 14281 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 14291 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 14301 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 1431Warnings: 1432Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) 1433SELECT * FROM t1 WHERE (t1.i) IN 1434(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1435i 1436PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1437(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1438EXECUTE stmt; 1439i 1440EXECUTE stmt; 1441i 1442DEALLOCATE PREPARE stmt; 1443EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1444(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1445id select_type table partitions type possible_keys key key_len ref rows filtered Extra 14461 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 14471 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where 14481 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) 1449Warnings: 1450Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') 1451SELECT * FROM t1 WHERE (t1.i) IN 1452(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1453i 14542 1455EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1456(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1457id select_type table partitions type possible_keys key key_len ref rows filtered Extra 14581 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 14591 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL 14601 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 1461Warnings: 1462Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') 1463SELECT * FROM t1 WHERE (t1.i) IN 1464(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1465i 1466EXPLAIN SELECT * FROM t1 WHERE (11) IN 1467(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1468id select_type table partitions type possible_keys key key_len ref rows filtered Extra 14691 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 14701 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 14711 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 1472Warnings: 1473Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) 1474SELECT * FROM t1 WHERE (11) IN 1475(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1476i 1477EXPLAIN SELECT * FROM t1 WHERE (11) IN 1478(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1479id select_type table partitions type possible_keys key key_len ref rows filtered Extra 14801 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 14811 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 14821 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 1483Warnings: 1484Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 1485Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and '2') 1486SELECT * FROM t1 WHERE (11) IN 1487(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1488i 1489EXPLAIN SELECT * FROM t1 WHERE (11) IN 1490(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1491id select_type table partitions type possible_keys key key_len ref rows filtered Extra 14921 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 14931 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where 14941 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) 1495Warnings: 1496Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) 1497SELECT * FROM t1 WHERE (11) IN 1498(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1499i 1500EXPLAIN SELECT * FROM t1 WHERE (11) IN 1501(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1502id select_type table partitions type possible_keys key key_len ref rows filtered Extra 15031 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 15041 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL 15051 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 1506Warnings: 1507Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) 1508SELECT * FROM t1 WHERE (11) IN 1509(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1510i 1511INSERT INTO t3 VALUES (0); 1512DELETE FROM t3; 1513INSERT INTO t2 VALUES (2); 1514SELECT (SELECT COUNT(*) from t1) AS c1, 1515(SELECT COUNT(*) from t2) AS c2, 1516(SELECT COUNT(*) from t3) AS c3; 1517c1 c2 c3 15181 1 0 1519EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1520(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1521id select_type table partitions type possible_keys key key_len ref rows filtered Extra 15221 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 15231 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 15241 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 1525Warnings: 1526Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) 1527SELECT * FROM t1 WHERE (t1.i) IN 1528(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1529i 1530PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1531(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1532EXECUTE stmt; 1533i 1534EXECUTE stmt; 1535i 1536DEALLOCATE PREPARE stmt; 1537EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1538(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1539id select_type table partitions type possible_keys key key_len ref rows filtered Extra 15401 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 15411 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 15421 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 1543Warnings: 1544Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) 1545SELECT * FROM t1 WHERE (t1.i) IN 1546(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1547i 1548PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1549(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1550EXECUTE stmt; 1551i 1552EXECUTE stmt; 1553i 1554DEALLOCATE PREPARE stmt; 1555EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1556(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1557id select_type table partitions type possible_keys key key_len ref rows filtered Extra 15581 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 15591 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 15601 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 1561Warnings: 1562Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') 1563SELECT * FROM t1 WHERE (t1.i) IN 1564(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1565i 1566EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1567(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1568id select_type table partitions type possible_keys key key_len ref rows filtered Extra 15691 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 15701 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL 15711 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) 1572Warnings: 1573Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') 1574SELECT * FROM t1 WHERE (t1.i) IN 1575(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1576i 1577EXPLAIN SELECT * FROM t1 WHERE (11) IN 1578(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1579id select_type table partitions type possible_keys key key_len ref rows filtered Extra 15801 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 15811 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 15821 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 1583Warnings: 1584Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) 1585SELECT * FROM t1 WHERE (11) IN 1586(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1587i 1588EXPLAIN SELECT * FROM t1 WHERE (11) IN 1589(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1590id select_type table partitions type possible_keys key key_len ref rows filtered Extra 15911 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 15921 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 15931 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 1594Warnings: 1595Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 1596Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and '2') 1597SELECT * FROM t1 WHERE (11) IN 1598(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1599i 1600EXPLAIN SELECT * FROM t1 WHERE (11) IN 1601(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1602id select_type table partitions type possible_keys key key_len ref rows filtered Extra 16031 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 16041 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 16051 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 1606Warnings: 1607Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) 1608SELECT * FROM t1 WHERE (11) IN 1609(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1610i 1611EXPLAIN SELECT * FROM t1 WHERE (11) IN 1612(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1613id select_type table partitions type possible_keys key key_len ref rows filtered Extra 16141 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 16151 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL 16161 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) 1617Warnings: 1618Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) 1619SELECT * FROM t1 WHERE (11) IN 1620(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1621i 1622INSERT INTO t3 VALUES (2); 1623SELECT (SELECT COUNT(*) from t1) AS c1, 1624(SELECT COUNT(*) from t2) AS c2, 1625(SELECT COUNT(*) from t3) AS c3; 1626c1 c2 c3 16271 1 1 1628EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1629(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1630id select_type table partitions type possible_keys key key_len ref rows filtered Extra 16311 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 16321 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 16331 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 1634Warnings: 1635Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) 1636SELECT * FROM t1 WHERE (t1.i) IN 1637(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1638i 16392 1640PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1641(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1642EXECUTE stmt; 1643i 16442 1645EXECUTE stmt; 1646i 16472 1648DEALLOCATE PREPARE stmt; 1649EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1650(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1651id select_type table partitions type possible_keys key key_len ref rows filtered Extra 16521 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 16531 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 16541 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 1655Warnings: 1656Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) 1657SELECT * FROM t1 WHERE (t1.i) IN 1658(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1659i 16602 1661PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1662(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1663EXECUTE stmt; 1664i 16652 1666EXECUTE stmt; 1667i 16682 1669DEALLOCATE PREPARE stmt; 1670EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1671(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1672id select_type table partitions type possible_keys key key_len ref rows filtered Extra 16731 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 16741 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 16751 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 1676Warnings: 1677Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') 1678SELECT * FROM t1 WHERE (t1.i) IN 1679(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1680i 16812 1682EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1683(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1684id select_type table partitions type possible_keys key key_len ref rows filtered Extra 16851 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 16861 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL 16871 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 1688Warnings: 1689Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') 1690SELECT * FROM t1 WHERE (t1.i) IN 1691(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1692i 16932 1694EXPLAIN SELECT * FROM t1 WHERE (11) IN 1695(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1696id select_type table partitions type possible_keys key key_len ref rows filtered Extra 16971 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 16981 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 16991 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 1700Warnings: 1701Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) 1702SELECT * FROM t1 WHERE (11) IN 1703(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1704i 1705EXPLAIN SELECT * FROM t1 WHERE (11) IN 1706(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1707id select_type table partitions type possible_keys key key_len ref rows filtered Extra 17081 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 17091 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 17101 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 1711Warnings: 1712Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 1713Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and '2') 1714SELECT * FROM t1 WHERE (11) IN 1715(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1716i 1717EXPLAIN SELECT * FROM t1 WHERE (11) IN 1718(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1719id select_type table partitions type possible_keys key key_len ref rows filtered Extra 17201 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 17211 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 17221 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 1723Warnings: 1724Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) 1725SELECT * FROM t1 WHERE (11) IN 1726(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1727i 1728EXPLAIN SELECT * FROM t1 WHERE (11) IN 1729(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1730id select_type table partitions type possible_keys key key_len ref rows filtered Extra 17311 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 17321 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL 17331 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 1734Warnings: 1735Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) 1736SELECT * FROM t1 WHERE (11) IN 1737(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1738i 1739INSERT INTO t3 VALUES (1); 1740SELECT (SELECT COUNT(*) from t1) AS c1, 1741(SELECT COUNT(*) from t2) AS c2, 1742(SELECT COUNT(*) from t3) AS c3; 1743c1 c2 c3 17441 1 2 1745EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1746(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1747id select_type table partitions type possible_keys key key_len ref rows filtered Extra 17481 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 17491 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 17501 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 1751Warnings: 1752Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) 1753SELECT * FROM t1 WHERE (t1.i) IN 1754(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1755i 17562 1757PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1758(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1759EXECUTE stmt; 1760i 17612 1762EXECUTE stmt; 1763i 17642 1765DEALLOCATE PREPARE stmt; 1766EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1767(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1768id select_type table partitions type possible_keys key key_len ref rows filtered Extra 17691 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 17701 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 17711 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 1772Warnings: 1773Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) 1774SELECT * FROM t1 WHERE (t1.i) IN 1775(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1776i 17772 1778PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1779(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1780EXECUTE stmt; 1781i 17822 1783EXECUTE stmt; 1784i 17852 1786DEALLOCATE PREPARE stmt; 1787EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1788(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1789id select_type table partitions type possible_keys key key_len ref rows filtered Extra 17901 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 17911 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where 17921 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 1793Warnings: 1794Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') 1795SELECT * FROM t1 WHERE (t1.i) IN 1796(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1797i 17982 1799EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1800(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1801id select_type table partitions type possible_keys key key_len ref rows filtered Extra 18021 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 18031 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL 18041 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 1805Warnings: 1806Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') 1807SELECT * FROM t1 WHERE (t1.i) IN 1808(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1809i 18102 1811EXPLAIN SELECT * FROM t1 WHERE (11) IN 1812(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1813id select_type table partitions type possible_keys key key_len ref rows filtered Extra 18141 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 18151 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 18161 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 1817Warnings: 1818Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) 1819SELECT * FROM t1 WHERE (11) IN 1820(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1821i 1822EXPLAIN SELECT * FROM t1 WHERE (11) IN 1823(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1824id select_type table partitions type possible_keys key key_len ref rows filtered Extra 18251 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 18261 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 18271 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 1828Warnings: 1829Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 1830Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and '2') 1831SELECT * FROM t1 WHERE (11) IN 1832(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1833i 1834EXPLAIN SELECT * FROM t1 WHERE (11) IN 1835(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1836id select_type table partitions type possible_keys key key_len ref rows filtered Extra 18371 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 18381 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where 18391 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 1840Warnings: 1841Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) 1842SELECT * FROM t1 WHERE (11) IN 1843(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1844i 1845EXPLAIN SELECT * FROM t1 WHERE (11) IN 1846(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1847id select_type table partitions type possible_keys key key_len ref rows filtered Extra 18481 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 18491 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL 18501 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 1851Warnings: 1852Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) 1853SELECT * FROM t1 WHERE (11) IN 1854(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1855i 1856INSERT INTO t3 VALUES (0); 1857DELETE FROM t3; 1858INSERT INTO t2 VALUES (1); 1859SELECT (SELECT COUNT(*) from t1) AS c1, 1860(SELECT COUNT(*) from t2) AS c2, 1861(SELECT COUNT(*) from t3) AS c3; 1862c1 c2 c3 18631 2 0 1864EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1865(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1866id select_type table partitions type possible_keys key key_len ref rows filtered Extra 18671 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 18681 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 18691 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 1870Warnings: 1871Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) 1872SELECT * FROM t1 WHERE (t1.i) IN 1873(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1874i 1875PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1876(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1877EXECUTE stmt; 1878i 1879EXECUTE stmt; 1880i 1881DEALLOCATE PREPARE stmt; 1882EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1883(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1884id select_type table partitions type possible_keys key key_len ref rows filtered Extra 18851 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 18861 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 18871 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 1888Warnings: 1889Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) 1890SELECT * FROM t1 WHERE (t1.i) IN 1891(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1892i 1893PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1894(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 1895EXECUTE stmt; 1896i 1897EXECUTE stmt; 1898i 1899DEALLOCATE PREPARE stmt; 1900EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1901(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1902id select_type table partitions type possible_keys key key_len ref rows filtered Extra 19031 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 19041 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 19051 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) 1906Warnings: 1907Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') 1908SELECT * FROM t1 WHERE (t1.i) IN 1909(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1910i 1911EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1912(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1913id select_type table partitions type possible_keys key key_len ref rows filtered Extra 19141 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 19151 SIMPLE <subquery2> NULL const <auto_key> <auto_key> 5 const 1 100.00 NULL 19162 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 19172 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (Block Nested Loop) 1918Warnings: 1919Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` straight_join `test`.`t3`) where ((`<subquery2>`.`i` = '2') and (`test`.`t3`.`i` = '2')) 1920SELECT * FROM t1 WHERE (t1.i) IN 1921(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1922i 1923EXPLAIN SELECT * FROM t1 WHERE (11) IN 1924(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1925id select_type table partitions type possible_keys key key_len ref rows filtered Extra 19261 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 19271 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 19281 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 1929Warnings: 1930Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) 1931SELECT * FROM t1 WHERE (11) IN 1932(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1933i 1934EXPLAIN SELECT * FROM t1 WHERE (11) IN 1935(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1936id select_type table partitions type possible_keys key key_len ref rows filtered Extra 19371 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 19381 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 19391 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 1940Warnings: 1941Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 1942Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and '2') 1943SELECT * FROM t1 WHERE (11) IN 1944(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 1945i 1946EXPLAIN SELECT * FROM t1 WHERE (11) IN 1947(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1948id select_type table partitions type possible_keys key key_len ref rows filtered Extra 19491 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 19501 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where 19511 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) 1952Warnings: 1953Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) 1954SELECT * FROM t1 WHERE (11) IN 1955(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 1956i 1957EXPLAIN SELECT * FROM t1 WHERE (11) IN 1958(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1959id select_type table partitions type possible_keys key key_len ref rows filtered Extra 19601 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 19611 SIMPLE <subquery2> NULL const <auto_key> <auto_key> 5 const 1 100.00 NULL 19622 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 19632 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (Block Nested Loop) 1964Warnings: 1965Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` straight_join `test`.`t3`) where ((`<subquery2>`.`i` = 11) and (`test`.`t3`.`i` = 11)) 1966SELECT * FROM t1 WHERE (11) IN 1967(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 1968i 1969INSERT INTO t3 VALUES (2); 1970SELECT (SELECT COUNT(*) from t1) AS c1, 1971(SELECT COUNT(*) from t2) AS c2, 1972(SELECT COUNT(*) from t3) AS c3; 1973c1 c2 c3 19741 2 1 1975EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1976(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1977id select_type table partitions type possible_keys key key_len ref rows filtered Extra 19781 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 19791 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 19801 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 1981Warnings: 1982Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) 1983SELECT * FROM t1 WHERE (t1.i) IN 1984(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 1985i 19862 1987PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 1988(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 1989EXECUTE stmt; 1990i 19912 1992EXECUTE stmt; 1993i 19942 1995DEALLOCATE PREPARE stmt; 1996EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 1997(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 1998id select_type table partitions type possible_keys key key_len ref rows filtered Extra 19991 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 20001 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 20011 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 2002Warnings: 2003Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = '2') and (`test`.`t2`.`i` = '2')) 2004SELECT * FROM t1 WHERE (t1.i) IN 2005(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2006i 20072 2008PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2009(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 2010EXECUTE stmt; 2011i 20122 2013EXECUTE stmt; 2014i 20152 2016DEALLOCATE PREPARE stmt; 2017EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2018(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2019id select_type table partitions type possible_keys key key_len ref rows filtered Extra 20201 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 20211 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 20221 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) 2023Warnings: 2024Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') 2025SELECT * FROM t1 WHERE (t1.i) IN 2026(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2027i 20282 2029EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2030(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2031id select_type table partitions type possible_keys key key_len ref rows filtered Extra 20321 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 20331 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 20341 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 2035Warnings: 2036Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') 2037SELECT * FROM t1 WHERE (t1.i) IN 2038(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2039i 20402 2041EXPLAIN SELECT * FROM t1 WHERE (11) IN 2042(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2043id select_type table partitions type possible_keys key key_len ref rows filtered Extra 20441 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 20451 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 20461 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 2047Warnings: 2048Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) 2049SELECT * FROM t1 WHERE (11) IN 2050(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2051i 2052EXPLAIN SELECT * FROM t1 WHERE (11) IN 2053(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2054id select_type table partitions type possible_keys key key_len ref rows filtered Extra 20551 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 20561 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 20571 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 2058Warnings: 2059Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 2060Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and '2') 2061SELECT * FROM t1 WHERE (11) IN 2062(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2063i 2064EXPLAIN SELECT * FROM t1 WHERE (11) IN 2065(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2066id select_type table partitions type possible_keys key key_len ref rows filtered Extra 20671 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 20681 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 20691 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) 2070Warnings: 2071Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) 2072SELECT * FROM t1 WHERE (11) IN 2073(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2074i 2075EXPLAIN SELECT * FROM t1 WHERE (11) IN 2076(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2077id select_type table partitions type possible_keys key key_len ref rows filtered Extra 20781 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 20791 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 20801 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 2081Warnings: 2082Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) 2083SELECT * FROM t1 WHERE (11) IN 2084(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2085i 2086INSERT INTO t3 VALUES (1); 2087SELECT (SELECT COUNT(*) from t1) AS c1, 2088(SELECT COUNT(*) from t2) AS c2, 2089(SELECT COUNT(*) from t3) AS c3; 2090c1 c2 c3 20911 2 2 2092EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2093(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2094id select_type table partitions type possible_keys key key_len ref rows filtered Extra 20951 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 20961 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where 20971 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 2098Warnings: 2099Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) 2100SELECT * FROM t1 WHERE (t1.i) IN 2101(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2102i 21032 2104PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2105(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 2106EXECUTE stmt; 2107i 21082 2109EXECUTE stmt; 2110i 21112 2112DEALLOCATE PREPARE stmt; 2113EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2114(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2115id select_type table partitions type possible_keys key key_len ref rows filtered Extra 21161 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 21171 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where 21181 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 2119Warnings: 2120Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = '2') and (`test`.`t3`.`i` = '2')) 2121SELECT * FROM t1 WHERE (t1.i) IN 2122(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2123i 21242 2125PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2126(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 2127EXECUTE stmt; 2128i 21292 2130EXECUTE stmt; 2131i 21322 2133DEALLOCATE PREPARE stmt; 2134EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2135(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2136id select_type table partitions type possible_keys key key_len ref rows filtered Extra 21371 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 21381 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where 21391 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) 2140Warnings: 2141Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = '2') 2142SELECT * FROM t1 WHERE (t1.i) IN 2143(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2144i 21452 2146EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2147(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2148id select_type table partitions type possible_keys key key_len ref rows filtered Extra 21491 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 21501 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 21511 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 2152Warnings: 2153Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = '2') 2154SELECT * FROM t1 WHERE (t1.i) IN 2155(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2156i 21572 2158EXPLAIN SELECT * FROM t1 WHERE (11) IN 2159(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2160id select_type table partitions type possible_keys key key_len ref rows filtered Extra 21611 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 21621 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where 21631 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 2164Warnings: 2165Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) 2166SELECT * FROM t1 WHERE (11) IN 2167(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2168i 2169EXPLAIN SELECT * FROM t1 WHERE (11) IN 2170(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2171id select_type table partitions type possible_keys key key_len ref rows filtered Extra 21721 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 21731 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where 21741 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 2175Warnings: 2176Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 2177Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and '2') 2178SELECT * FROM t1 WHERE (11) IN 2179(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2180i 2181EXPLAIN SELECT * FROM t1 WHERE (11) IN 2182(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2183id select_type table partitions type possible_keys key key_len ref rows filtered Extra 21841 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 21851 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where 21861 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) 2187Warnings: 2188Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) 2189SELECT * FROM t1 WHERE (11) IN 2190(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2191i 2192EXPLAIN SELECT * FROM t1 WHERE (11) IN 2193(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2194id select_type table partitions type possible_keys key key_len ref rows filtered Extra 21951 SIMPLE t1 NULL system NULL NULL NULL NULL 1 100.00 NULL 21961 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 21971 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 2198Warnings: 2199Note 1003 /* select#1 */ select '2' AS `i` from (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) 2200SELECT * FROM t1 WHERE (11) IN 2201(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2202i 2203INSERT INTO t3 VALUES (0); 2204DELETE FROM t3; 2205INSERT INTO t2 VALUES (0); 2206DELETE FROM t2; 2207INSERT INTO t1 VALUES (1); 2208SELECT (SELECT COUNT(*) from t1) AS c1, 2209(SELECT COUNT(*) from t2) AS c2, 2210(SELECT COUNT(*) from t3) AS c3; 2211c1 c2 c3 22122 0 0 2213EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2214(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2215id select_type table partitions type possible_keys key key_len ref rows filtered Extra 22161 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 0.00 NULL 22171 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 22182 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL 22192 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (Block Nested Loop) 2220Warnings: 2221Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `<subquery2>`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) 2222SELECT * FROM t1 WHERE (t1.i) IN 2223(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2224i 2225PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2226(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 2227EXECUTE stmt; 2228i 2229EXECUTE stmt; 2230i 2231DEALLOCATE PREPARE stmt; 2232EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2233(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2234id select_type table partitions type possible_keys key key_len ref rows filtered Extra 22351 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 0.00 NULL 22361 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 22372 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL 22382 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (Block Nested Loop) 2239Warnings: 2240Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `<subquery2>`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) 2241SELECT * FROM t1 WHERE (t1.i) IN 2242(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2243i 2244PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2245(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 2246EXECUTE stmt; 2247i 2248EXECUTE stmt; 2249i 2250DEALLOCATE PREPARE stmt; 2251EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2252(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2253id select_type table partitions type possible_keys key key_len ref rows filtered Extra 22541 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 0.00 NULL 22551 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 22562 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL 22572 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (Block Nested Loop) 2258Warnings: 2259Note 1003 /* select#1 */ select `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`) 2260SELECT * FROM t1 WHERE (t1.i) IN 2261(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2262i 2263EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2264(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2265id select_type table partitions type possible_keys key key_len ref rows filtered Extra 22661 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 0.00 NULL 22671 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 22682 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL 22692 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (Block Nested Loop) 2270Warnings: 2271Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `<subquery2>`.`i`) 2272SELECT * FROM t1 WHERE (t1.i) IN 2273(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2274i 2275EXPLAIN SELECT * FROM t1 WHERE (11) IN 2276(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2277id select_type table partitions type possible_keys key key_len ref rows filtered Extra 22781 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch 22791 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 22801 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) 2281Warnings: 2282Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) 2283SELECT * FROM t1 WHERE (11) IN 2284(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2285i 2286EXPLAIN SELECT * FROM t1 WHERE (11) IN 2287(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2288id select_type table partitions type possible_keys key key_len ref rows filtered Extra 22891 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary 22901 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (Block Nested Loop) 22911 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (Block Nested Loop) 2292Warnings: 2293Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 2294Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and `test`.`t1`.`i`) 2295SELECT * FROM t1 WHERE (11) IN 2296(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2297i 2298EXPLAIN SELECT * FROM t1 WHERE (11) IN 2299(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2300id select_type table partitions type possible_keys key key_len ref rows filtered Extra 23011 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch 23021 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 23031 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) 2304Warnings: 2305Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) 2306SELECT * FROM t1 WHERE (11) IN 2307(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2308i 2309EXPLAIN SELECT * FROM t1 WHERE (11) IN 2310(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2311id select_type table partitions type possible_keys key key_len ref rows filtered Extra 23121 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 FirstMatch 23131 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 23141 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch(t1) 2315Warnings: 2316Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) 2317SELECT * FROM t1 WHERE (11) IN 2318(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2319i 2320INSERT INTO t3 VALUES (2); 2321SELECT (SELECT COUNT(*) from t1) AS c1, 2322(SELECT COUNT(*) from t2) AS c2, 2323(SELECT COUNT(*) from t3) AS c3; 2324c1 c2 c3 23252 0 1 2326EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2327(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2328id select_type table partitions type possible_keys key key_len ref rows filtered Extra 23291 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 100.00 NULL 23301 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 23312 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL 23322 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (Block Nested Loop) 2333Warnings: 2334Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `<subquery2>`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) 2335SELECT * FROM t1 WHERE (t1.i) IN 2336(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2337i 2338PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2339(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 2340EXECUTE stmt; 2341i 2342EXECUTE stmt; 2343i 2344DEALLOCATE PREPARE stmt; 2345EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2346(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2347id select_type table partitions type possible_keys key key_len ref rows filtered Extra 23481 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 100.00 NULL 23491 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 23502 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL 23512 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (Block Nested Loop) 2352Warnings: 2353Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `<subquery2>`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) 2354SELECT * FROM t1 WHERE (t1.i) IN 2355(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2356i 2357PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2358(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 2359EXECUTE stmt; 2360i 2361EXECUTE stmt; 2362i 2363DEALLOCATE PREPARE stmt; 2364EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2365(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2366id select_type table partitions type possible_keys key key_len ref rows filtered Extra 23671 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 100.00 NULL 23681 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 23692 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL 23702 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (Block Nested Loop) 2371Warnings: 2372Note 1003 /* select#1 */ select `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`) 2373SELECT * FROM t1 WHERE (t1.i) IN 2374(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2375i 23762 2377EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2378(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2379id select_type table partitions type possible_keys key key_len ref rows filtered Extra 23801 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 100.00 NULL 23811 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 23822 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 0 0.00 NULL 23832 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (Block Nested Loop) 2384Warnings: 2385Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `<subquery2>`.`i`) 2386SELECT * FROM t1 WHERE (t1.i) IN 2387(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2388i 2389EXPLAIN SELECT * FROM t1 WHERE (11) IN 2390(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2391id select_type table partitions type possible_keys key key_len ref rows filtered Extra 23921 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch 23931 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 23941 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 2395Warnings: 2396Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) 2397SELECT * FROM t1 WHERE (11) IN 2398(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2399i 2400EXPLAIN SELECT * FROM t1 WHERE (11) IN 2401(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2402id select_type table partitions type possible_keys key key_len ref rows filtered Extra 24031 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary 24041 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (Block Nested Loop) 24051 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (Block Nested Loop) 2406Warnings: 2407Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 2408Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and `test`.`t1`.`i`) 2409SELECT * FROM t1 WHERE (11) IN 2410(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2411i 2412EXPLAIN SELECT * FROM t1 WHERE (11) IN 2413(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2414id select_type table partitions type possible_keys key key_len ref rows filtered Extra 24151 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 24161 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch 24171 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop) 2418Warnings: 2419Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) 2420SELECT * FROM t1 WHERE (11) IN 2421(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2422i 2423EXPLAIN SELECT * FROM t1 WHERE (11) IN 2424(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2425id select_type table partitions type possible_keys key key_len ref rows filtered Extra 24261 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 FirstMatch 24271 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 24281 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 2429Warnings: 2430Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) 2431SELECT * FROM t1 WHERE (11) IN 2432(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2433i 2434INSERT INTO t3 VALUES (1); 2435SELECT (SELECT COUNT(*) from t1) AS c1, 2436(SELECT COUNT(*) from t2) AS c2, 2437(SELECT COUNT(*) from t3) AS c3; 2438c1 c2 c3 24392 0 2 2440EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2441(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2442id select_type table partitions type possible_keys key key_len ref rows filtered Extra 24431 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary 24441 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 24451 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (Block Nested Loop) 2446Warnings: 2447Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) 2448SELECT * FROM t1 WHERE (t1.i) IN 2449(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2450i 2451PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2452(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 2453EXECUTE stmt; 2454i 2455EXECUTE stmt; 2456i 2457DEALLOCATE PREPARE stmt; 2458EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2459(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2460id select_type table partitions type possible_keys key key_len ref rows filtered Extra 24611 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary 24621 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 24631 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (Block Nested Loop) 2464Warnings: 2465Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) 2466SELECT * FROM t1 WHERE (t1.i) IN 2467(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2468i 2469PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2470(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 2471EXECUTE stmt; 2472i 2473EXECUTE stmt; 2474i 2475DEALLOCATE PREPARE stmt; 2476EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2477(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2478id select_type table partitions type possible_keys key key_len ref rows filtered Extra 24791 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary 24801 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (Block Nested Loop) 24811 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (Block Nested Loop) 2482Warnings: 2483Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) 2484SELECT * FROM t1 WHERE (t1.i) IN 2485(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2486i 24872 24881 2489EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2490(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2491id select_type table partitions type possible_keys key key_len ref rows filtered Extra 24921 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary 24931 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop) 24941 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (Block Nested Loop) 2495Warnings: 2496Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) 2497SELECT * FROM t1 WHERE (t1.i) IN 2498(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2499i 2500EXPLAIN SELECT * FROM t1 WHERE (11) IN 2501(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2502id select_type table partitions type possible_keys key key_len ref rows filtered Extra 25031 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch 25041 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 25051 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 2506Warnings: 2507Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) 2508SELECT * FROM t1 WHERE (11) IN 2509(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2510i 2511EXPLAIN SELECT * FROM t1 WHERE (11) IN 2512(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2513id select_type table partitions type possible_keys key key_len ref rows filtered Extra 25141 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary 25151 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 25161 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (Block Nested Loop) 2517Warnings: 2518Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 2519Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and `test`.`t1`.`i`) 2520SELECT * FROM t1 WHERE (11) IN 2521(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2522i 2523EXPLAIN SELECT * FROM t1 WHERE (11) IN 2524(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2525id select_type table partitions type possible_keys key key_len ref rows filtered Extra 25261 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where 25271 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch 25281 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop) 2529Warnings: 2530Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) 2531SELECT * FROM t1 WHERE (11) IN 2532(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2533i 2534EXPLAIN SELECT * FROM t1 WHERE (11) IN 2535(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2536id select_type table partitions type possible_keys key key_len ref rows filtered Extra 25371 SIMPLE t2 NULL ALL NULL NULL NULL NULL 0 0.00 FirstMatch 25381 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 25391 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 2540Warnings: 2541Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) 2542SELECT * FROM t1 WHERE (11) IN 2543(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2544i 2545INSERT INTO t3 VALUES (0); 2546DELETE FROM t3; 2547INSERT INTO t2 VALUES (2); 2548SELECT (SELECT COUNT(*) from t1) AS c1, 2549(SELECT COUNT(*) from t2) AS c2, 2550(SELECT COUNT(*) from t3) AS c3; 2551c1 c2 c3 25522 1 0 2553EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2554(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2555id select_type table partitions type possible_keys key key_len ref rows filtered Extra 25561 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 0.00 NULL 25571 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 25582 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL 25592 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (Block Nested Loop) 2560Warnings: 2561Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `<subquery2>`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) 2562SELECT * FROM t1 WHERE (t1.i) IN 2563(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2564i 2565PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2566(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 2567EXECUTE stmt; 2568i 2569EXECUTE stmt; 2570i 2571DEALLOCATE PREPARE stmt; 2572EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2573(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2574id select_type table partitions type possible_keys key key_len ref rows filtered Extra 25751 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 0.00 NULL 25761 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 25772 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL 25782 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (Block Nested Loop) 2579Warnings: 2580Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `<subquery2>`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) 2581SELECT * FROM t1 WHERE (t1.i) IN 2582(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2583i 2584PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2585(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 2586EXECUTE stmt; 2587i 2588EXECUTE stmt; 2589i 2590DEALLOCATE PREPARE stmt; 2591EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2592(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2593id select_type table partitions type possible_keys key key_len ref rows filtered Extra 25941 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 0.00 NULL 25951 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 25962 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 NULL 25972 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (Block Nested Loop) 2598Warnings: 2599Note 1003 /* select#1 */ select `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`) 2600SELECT * FROM t1 WHERE (t1.i) IN 2601(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2602i 2603EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2604(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2605id select_type table partitions type possible_keys key key_len ref rows filtered Extra 26061 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 0.00 NULL 26071 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 26082 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL 26092 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (Block Nested Loop) 2610Warnings: 2611Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `<subquery2>`.`i`) 2612SELECT * FROM t1 WHERE (t1.i) IN 2613(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2614i 2615EXPLAIN SELECT * FROM t1 WHERE (11) IN 2616(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2617id select_type table partitions type possible_keys key key_len ref rows filtered Extra 26181 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch 26191 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 26201 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 2621Warnings: 2622Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) 2623SELECT * FROM t1 WHERE (11) IN 2624(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2625i 2626EXPLAIN SELECT * FROM t1 WHERE (11) IN 2627(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2628id select_type table partitions type possible_keys key key_len ref rows filtered Extra 26291 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary 26301 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (Block Nested Loop) 26311 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (Block Nested Loop) 2632Warnings: 2633Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 2634Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and `test`.`t1`.`i`) 2635SELECT * FROM t1 WHERE (11) IN 2636(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2637i 2638EXPLAIN SELECT * FROM t1 WHERE (11) IN 2639(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2640id select_type table partitions type possible_keys key key_len ref rows filtered Extra 26411 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch 26421 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 26431 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t1) 2644Warnings: 2645Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) 2646SELECT * FROM t1 WHERE (11) IN 2647(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2648i 2649EXPLAIN SELECT * FROM t1 WHERE (11) IN 2650(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2651id select_type table partitions type possible_keys key key_len ref rows filtered Extra 26521 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL 26531 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch 26541 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop) 2655Warnings: 2656Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) 2657SELECT * FROM t1 WHERE (11) IN 2658(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2659i 2660INSERT INTO t3 VALUES (2); 2661SELECT (SELECT COUNT(*) from t1) AS c1, 2662(SELECT COUNT(*) from t2) AS c2, 2663(SELECT COUNT(*) from t3) AS c3; 2664c1 c2 c3 26652 1 1 2666EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2667(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2668id select_type table partitions type possible_keys key key_len ref rows filtered Extra 26691 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 100.00 NULL 26701 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 26712 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL 26722 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (Block Nested Loop) 2673Warnings: 2674Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `<subquery2>`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) 2675SELECT * FROM t1 WHERE (t1.i) IN 2676(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2677i 26782 2679PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2680(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 2681EXECUTE stmt; 2682i 26832 2684EXECUTE stmt; 2685i 26862 2687DEALLOCATE PREPARE stmt; 2688EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2689(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2690id select_type table partitions type possible_keys key key_len ref rows filtered Extra 26911 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 100.00 NULL 26921 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 26932 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL 26942 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (Block Nested Loop) 2695Warnings: 2696Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `<subquery2>`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) 2697SELECT * FROM t1 WHERE (t1.i) IN 2698(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2699i 27002 2701PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2702(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 2703EXECUTE stmt; 2704i 27052 2706EXECUTE stmt; 2707i 27082 2709DEALLOCATE PREPARE stmt; 2710EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2711(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2712id select_type table partitions type possible_keys key key_len ref rows filtered Extra 27131 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 100.00 NULL 27141 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 27152 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 NULL 27162 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (Block Nested Loop) 2717Warnings: 2718Note 1003 /* select#1 */ select `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`) 2719SELECT * FROM t1 WHERE (t1.i) IN 2720(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2721i 27222 2723EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2724(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2725id select_type table partitions type possible_keys key key_len ref rows filtered Extra 27261 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 100.00 NULL 27271 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 27282 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL 27292 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (Block Nested Loop) 2730Warnings: 2731Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `<subquery2>`.`i`) 2732SELECT * FROM t1 WHERE (t1.i) IN 2733(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2734i 27352 2736EXPLAIN SELECT * FROM t1 WHERE (11) IN 2737(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2738id select_type table partitions type possible_keys key key_len ref rows filtered Extra 27391 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 27401 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch 27411 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop) 2742Warnings: 2743Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) 2744SELECT * FROM t1 WHERE (11) IN 2745(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2746i 2747EXPLAIN SELECT * FROM t1 WHERE (11) IN 2748(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2749id select_type table partitions type possible_keys key key_len ref rows filtered Extra 27501 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary 27511 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (Block Nested Loop) 27521 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (Block Nested Loop) 2753Warnings: 2754Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 2755Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and `test`.`t1`.`i`) 2756SELECT * FROM t1 WHERE (11) IN 2757(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2758i 2759EXPLAIN SELECT * FROM t1 WHERE (11) IN 2760(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2761id select_type table partitions type possible_keys key key_len ref rows filtered Extra 27621 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 27631 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch 27641 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop) 2765Warnings: 2766Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) 2767SELECT * FROM t1 WHERE (11) IN 2768(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2769i 2770EXPLAIN SELECT * FROM t1 WHERE (11) IN 2771(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2772id select_type table partitions type possible_keys key key_len ref rows filtered Extra 27731 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL 27741 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch 27751 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop) 2776Warnings: 2777Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) 2778SELECT * FROM t1 WHERE (11) IN 2779(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2780i 2781INSERT INTO t3 VALUES (1); 2782SELECT (SELECT COUNT(*) from t1) AS c1, 2783(SELECT COUNT(*) from t2) AS c2, 2784(SELECT COUNT(*) from t3) AS c3; 2785c1 c2 c3 27862 1 2 2787EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2788(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2789id select_type table partitions type possible_keys key key_len ref rows filtered Extra 27901 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary 27911 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 27921 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (Block Nested Loop) 2793Warnings: 2794Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) 2795SELECT * FROM t1 WHERE (t1.i) IN 2796(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2797i 27982 2799PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2800(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 2801EXECUTE stmt; 2802i 28032 2804EXECUTE stmt; 2805i 28062 2807DEALLOCATE PREPARE stmt; 2808EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2809(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2810id select_type table partitions type possible_keys key key_len ref rows filtered Extra 28111 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary 28121 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 28131 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (Block Nested Loop) 2814Warnings: 2815Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) 2816SELECT * FROM t1 WHERE (t1.i) IN 2817(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2818i 28192 2820PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2821(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 2822EXECUTE stmt; 2823i 28242 2825EXECUTE stmt; 2826i 28272 2828DEALLOCATE PREPARE stmt; 2829EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2830(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2831id select_type table partitions type possible_keys key key_len ref rows filtered Extra 28321 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary 28331 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (Block Nested Loop) 28341 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (Block Nested Loop) 2835Warnings: 2836Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) 2837SELECT * FROM t1 WHERE (t1.i) IN 2838(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2839i 28402 28411 2842EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2843(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2844id select_type table partitions type possible_keys key key_len ref rows filtered Extra 28451 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary 28461 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop) 28471 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (Block Nested Loop) 2848Warnings: 2849Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = `test`.`t1`.`i`) 2850SELECT * FROM t1 WHERE (t1.i) IN 2851(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2852i 28532 28541 2855EXPLAIN SELECT * FROM t1 WHERE (11) IN 2856(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2857id select_type table partitions type possible_keys key key_len ref rows filtered Extra 28581 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 28591 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch 28601 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop) 2861Warnings: 2862Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) 2863SELECT * FROM t1 WHERE (11) IN 2864(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2865i 2866EXPLAIN SELECT * FROM t1 WHERE (11) IN 2867(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2868id select_type table partitions type possible_keys key key_len ref rows filtered Extra 28691 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary 28701 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 28711 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (Block Nested Loop) 2872Warnings: 2873Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 2874Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and `test`.`t1`.`i`) 2875SELECT * FROM t1 WHERE (11) IN 2876(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2877i 2878EXPLAIN SELECT * FROM t1 WHERE (11) IN 2879(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2880id select_type table partitions type possible_keys key key_len ref rows filtered Extra 28811 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where 28821 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch 28831 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop) 2884Warnings: 2885Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) 2886SELECT * FROM t1 WHERE (11) IN 2887(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2888i 2889EXPLAIN SELECT * FROM t1 WHERE (11) IN 2890(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2891id select_type table partitions type possible_keys key key_len ref rows filtered Extra 28921 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL 28931 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch 28941 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop) 2895Warnings: 2896Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) 2897SELECT * FROM t1 WHERE (11) IN 2898(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2899i 2900INSERT INTO t3 VALUES (0); 2901DELETE FROM t3; 2902INSERT INTO t2 VALUES (1); 2903SELECT (SELECT COUNT(*) from t1) AS c1, 2904(SELECT COUNT(*) from t2) AS c2, 2905(SELECT COUNT(*) from t3) AS c3; 2906c1 c2 c3 29072 2 0 2908EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2909(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2910id select_type table partitions type possible_keys key key_len ref rows filtered Extra 29111 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary 29121 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 29131 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (Block Nested Loop) 2914Warnings: 2915Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) 2916SELECT * FROM t1 WHERE (t1.i) IN 2917(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 2918i 2919PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2920(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 2921EXECUTE stmt; 2922i 2923EXECUTE stmt; 2924i 2925DEALLOCATE PREPARE stmt; 2926EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2927(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2928id select_type table partitions type possible_keys key key_len ref rows filtered Extra 29291 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary 29301 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 29311 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (Block Nested Loop) 2932Warnings: 2933Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) 2934SELECT * FROM t1 WHERE (t1.i) IN 2935(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2936i 2937PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 2938(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 2939EXECUTE stmt; 2940i 2941EXECUTE stmt; 2942i 2943DEALLOCATE PREPARE stmt; 2944EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2945(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2946id select_type table partitions type possible_keys key key_len ref rows filtered Extra 29471 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Start temporary 29481 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 29491 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (Block Nested Loop) 2950Warnings: 2951Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) 2952SELECT * FROM t1 WHERE (t1.i) IN 2953(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2954i 2955EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 2956(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2957id select_type table partitions type possible_keys key key_len ref rows filtered Extra 29581 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 0.00 NULL 29591 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 29602 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 29612 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using join buffer (Block Nested Loop) 2962Warnings: 2963Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `<subquery2>`.`i`) 2964SELECT * FROM t1 WHERE (t1.i) IN 2965(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 2966i 2967EXPLAIN SELECT * FROM t1 WHERE (11) IN 2968(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2969id select_type table partitions type possible_keys key key_len ref rows filtered Extra 29701 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch 29711 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 29721 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 2973Warnings: 2974Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) 2975SELECT * FROM t1 WHERE (11) IN 2976(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 2977i 2978EXPLAIN SELECT * FROM t1 WHERE (11) IN 2979(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2980id select_type table partitions type possible_keys key key_len ref rows filtered Extra 29811 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Start temporary 29821 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 29831 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (Block Nested Loop) 2984Warnings: 2985Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 2986Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and `test`.`t1`.`i`) 2987SELECT * FROM t1 WHERE (11) IN 2988(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 2989i 2990EXPLAIN SELECT * FROM t1 WHERE (11) IN 2991(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 2992id select_type table partitions type possible_keys key key_len ref rows filtered Extra 29931 SIMPLE t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; FirstMatch 29941 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 29951 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) 2996Warnings: 2997Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) 2998SELECT * FROM t1 WHERE (11) IN 2999(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 3000i 3001EXPLAIN SELECT * FROM t1 WHERE (11) IN 3002(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 3003id select_type table partitions type possible_keys key key_len ref rows filtered Extra 30041 SIMPLE <subquery2> NULL const <auto_key> <auto_key> 5 const 1 100.00 NULL 30051 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop) 30062 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 30072 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 0 0.00 Using where; Using join buffer (Block Nested Loop) 3008Warnings: 3009Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((`<subquery2>`.`i` = 11) and (`test`.`t3`.`i` = 11)) 3010SELECT * FROM t1 WHERE (11) IN 3011(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 3012i 3013INSERT INTO t3 VALUES (2); 3014SELECT (SELECT COUNT(*) from t1) AS c1, 3015(SELECT COUNT(*) from t2) AS c2, 3016(SELECT COUNT(*) from t3) AS c3; 3017c1 c2 c3 30182 2 1 3019EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 3020(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 3021id select_type table partitions type possible_keys key key_len ref rows filtered Extra 30221 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary 30231 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 30241 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (Block Nested Loop) 3025Warnings: 3026Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) 3027SELECT * FROM t1 WHERE (t1.i) IN 3028(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 3029i 30302 3031PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 3032(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 3033EXECUTE stmt; 3034i 30352 3036EXECUTE stmt; 3037i 30382 3039DEALLOCATE PREPARE stmt; 3040EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 3041(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 3042id select_type table partitions type possible_keys key key_len ref rows filtered Extra 30431 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary 30441 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 30451 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (Block Nested Loop) 3046Warnings: 3047Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`i` = `test`.`t3`.`i`) and (`test`.`t2`.`i` = `test`.`t3`.`i`)) 3048SELECT * FROM t1 WHERE (t1.i) IN 3049(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 3050i 30512 3052PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 3053(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 3054EXECUTE stmt; 3055i 30562 3057EXECUTE stmt; 3058i 30592 3060DEALLOCATE PREPARE stmt; 3061EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 3062(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 3063id select_type table partitions type possible_keys key key_len ref rows filtered Extra 30641 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary 30651 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 30661 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (Block Nested Loop) 3067Warnings: 3068Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) 3069SELECT * FROM t1 WHERE (t1.i) IN 3070(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 3071i 30722 3073EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 3074(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 3075id select_type table partitions type possible_keys key key_len ref rows filtered Extra 30761 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 100.00 NULL 30771 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 30782 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 30792 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using join buffer (Block Nested Loop) 3080Warnings: 3081Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t1`.`i` = `<subquery2>`.`i`) 3082SELECT * FROM t1 WHERE (t1.i) IN 3083(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 3084i 30852 3086EXPLAIN SELECT * FROM t1 WHERE (11) IN 3087(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 3088id select_type table partitions type possible_keys key key_len ref rows filtered Extra 30891 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 30901 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch 30911 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop) 3092Warnings: 3093Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11)) 3094SELECT * FROM t1 WHERE (11) IN 3095(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 3096i 3097EXPLAIN SELECT * FROM t1 WHERE (11) IN 3098(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 3099id select_type table partitions type possible_keys key key_len ref rows filtered Extra 31001 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary 31011 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 31021 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (Block Nested Loop) 3103Warnings: 3104Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 3105Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i` = 11) and (`test`.`t2`.`i` = 11) and `test`.`t1`.`i`) 3106SELECT * FROM t1 WHERE (11) IN 3107(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 3108i 3109EXPLAIN SELECT * FROM t1 WHERE (11) IN 3110(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 3111id select_type table partitions type possible_keys key key_len ref rows filtered Extra 31121 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 31131 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch 31141 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop) 3115Warnings: 3116Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) 3117SELECT * FROM t1 WHERE (11) IN 3118(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 3119i 3120EXPLAIN SELECT * FROM t1 WHERE (11) IN 3121(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 3122id select_type table partitions type possible_keys key key_len ref rows filtered Extra 31231 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 31241 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch 31251 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop) 3126Warnings: 3127Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`test`.`t3`.`i` = 11) 3128SELECT * FROM t1 WHERE (11) IN 3129(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 3130i 3131INSERT INTO t3 VALUES (1); 3132SELECT (SELECT COUNT(*) from t1) AS c1, 3133(SELECT COUNT(*) from t2) AS c2, 3134(SELECT COUNT(*) from t3) AS c3; 3135c1 c2 c3 31362 2 2 3137EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 3138(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 3139id select_type table partitions type possible_keys key key_len ref rows filtered Extra 31401 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where 31411 SIMPLE <subquery2> NULL eq_ref <auto_key> <auto_key> 5 test.t1.i 1 100.00 NULL 31422 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 31432 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 3144Warnings: 3145Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`<subquery2>`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) 3146SELECT * FROM t1 WHERE (t1.i) IN 3147(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i); 3148i 31492 31501 3151PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 3152(SELECT t3.i FROM t2 INNER JOIN t3 ON t2.i=t3.i)"; 3153EXECUTE stmt; 3154i 31552 31561 3157EXECUTE stmt; 3158i 31592 31601 3161DEALLOCATE PREPARE stmt; 3162EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 3163(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 3164id select_type table partitions type possible_keys key key_len ref rows filtered Extra 31651 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where 31661 SIMPLE <subquery2> NULL eq_ref <auto_key> <auto_key> 5 test.t1.i 1 100.00 NULL 31672 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 31682 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 3169Warnings: 3170Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`<subquery2>`.`i` = `test`.`t1`.`i`) and (`test`.`t3`.`i` = `test`.`t2`.`i`)) 3171SELECT * FROM t1 WHERE (t1.i) IN 3172(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 3173i 31742 31751 3176PREPARE stmt FROM "SELECT * FROM t1 WHERE (t1.i) IN 3177(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i)"; 3178EXECUTE stmt; 3179i 31802 31811 3182EXECUTE stmt; 3183i 31842 31851 3186DEALLOCATE PREPARE stmt; 3187EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 3188(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 3189id select_type table partitions type possible_keys key key_len ref rows filtered Extra 31901 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where 31911 SIMPLE <subquery2> NULL eq_ref <auto_key> <auto_key> 5 test.t1.i 1 100.00 NULL 31922 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 31932 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (Block Nested Loop) 3194Warnings: 3195Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`<subquery2>`.`i` = `test`.`t1`.`i`) 3196SELECT * FROM t1 WHERE (t1.i) IN 3197(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 3198i 31992 32001 3201EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 3202(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 3203id select_type table partitions type possible_keys key key_len ref rows filtered Extra 32041 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where 32051 SIMPLE <subquery2> NULL eq_ref <auto_key> <auto_key> 5 test.t1.i 1 100.00 NULL 32062 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 32072 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop) 3208Warnings: 3209Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where (`<subquery2>`.`i` = `test`.`t1`.`i`) 3210SELECT * FROM t1 WHERE (t1.i) IN 3211(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 3212i 32132 32141 3215EXPLAIN SELECT * FROM t1 WHERE (11) IN 3216(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 3217id select_type table partitions type possible_keys key key_len ref rows filtered Extra 32181 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where 32191 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch 32201 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop) 3221Warnings: 3222Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11)) 3223SELECT * FROM t1 WHERE (11) IN 3224(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 3225i 3226EXPLAIN SELECT * FROM t1 WHERE (11) IN 3227(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 3228id select_type table partitions type possible_keys key key_len ref rows filtered Extra 32291 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where 32301 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where 32311 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) 3232Warnings: 3233Note 1276 Field or reference 'test.t1.i' of SELECT #2 was resolved in SELECT #1 3234Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`i` = 11) and (`test`.`t3`.`i` = 11) and `test`.`t1`.`i`) 3235SELECT * FROM t1 WHERE (11) IN 3236(SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i); 3237i 3238EXPLAIN SELECT * FROM t1 WHERE (11) IN 3239(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 3240id select_type table partitions type possible_keys key key_len ref rows filtered Extra 32411 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where 32421 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch 32431 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop) 3244Warnings: 3245Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t3`.`i` = 11) 3246SELECT * FROM t1 WHERE (11) IN 3247(SELECT t3.i FROM t2 RIGHT JOIN t3 ON t2.i=t3.i); 3248i 3249EXPLAIN SELECT * FROM t1 WHERE (11) IN 3250(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 3251id select_type table partitions type possible_keys key key_len ref rows filtered Extra 32521 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 32531 SIMPLE <subquery2> NULL const <auto_key> <auto_key> 5 const 1 100.00 NULL 32542 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 32552 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 3256Warnings: 3257Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` straight_join `test`.`t3`) where ((`<subquery2>`.`i` = 11) and (`test`.`t3`.`i` = 11)) 3258SELECT * FROM t1 WHERE (11) IN 3259(SELECT t3.i FROM t2 STRAIGHT_JOIN t3); 3260i 3261INSERT INTO t3 VALUES (0); 3262DELETE FROM t3; 3263INSERT INTO t2 VALUES (0); 3264DELETE FROM t2; 3265INSERT INTO t1 VALUES (0); 3266DROP TABLE t1, t2, t3; 3267create table x1(k int primary key, d1 int, d2 int); 3268create table x2(k int primary key, d1 int, d2 int); 3269insert into x1 values 3270(10, 10, 10), 3271(20, 20, 20), 3272(21, 20, null), 3273(30, null, 30), 3274(40, 40, 40); 3275insert into x2 values 3276(10, 10, 10), 3277(20, 20, 20), 3278(21, 20, null), 3279(30, null, 30); 3280select * 3281from x1 3282where (d1, d2) in (select d1, d2 3283from x2); 3284k d1 d2 328510 10 10 328620 20 20 3287select * 3288from x1 3289where (d1, d2) in (select d1, d2 3290from x2) is true; 3291k d1 d2 329210 10 10 329320 20 20 3294select * 3295from x1 3296where (d1, d2) in (select d1, d2 3297from x2) is false; 3298k d1 d2 329940 40 40 3300select * 3301from x1 3302where (d1, d2) in (select d1, d2 3303from x2) is unknown; 3304k d1 d2 330521 20 NULL 330630 NULL 30 3307select * 3308from x1 3309where d1 in (select d1 3310from x2 3311where x1.d2=x2.d2); 3312k d1 d2 331310 10 10 331420 20 20 3315select * 3316from x1 3317where d1 in (select d1 3318from x2 3319where x1.d2=x2.d2) is true; 3320k d1 d2 332110 10 10 332220 20 20 3323select * 3324from x1 3325where d1 in (select d1 3326from x2 3327where x1.d2=x2.d2) is false; 3328k d1 d2 332921 20 NULL 333040 40 40 3331select * 3332from x1 3333where d1 in (select d1 3334from x2 3335where x1.d2=x2.d2) is unknown; 3336k d1 d2 333730 NULL 30 3338select * 3339from x1 3340where 1 in (select 1 3341from x2 3342where x1.d1=x2.d1 and x1.d2=x2.d2); 3343k d1 d2 334410 10 10 334520 20 20 3346select * 3347from x1 3348where 1 in (select 1 3349from x2 3350where x1.d1=x2.d1 and x1.d2=x2.d2) is true; 3351k d1 d2 335210 10 10 335320 20 20 3354select * 3355from x1 3356where 1 in (select 1 3357from x2 3358where x1.d1=x2.d1 and x1.d2=x2.d2) is false; 3359k d1 d2 336021 20 NULL 336130 NULL 30 336240 40 40 3363select * 3364from x1 3365where 1 in (select 1 3366from x2 3367where x1.d1=x2.d1 and x1.d2=x2.d2) is unknown; 3368k d1 d2 3369select * 3370from x1 3371where exists (select * 3372from x2 3373where x1.d1=x2.d1 and x1.d2=x2.d2); 3374k d1 d2 337510 10 10 337620 20 20 3377drop table x1; 3378drop table x2; 3379CREATE TABLE t1 ( 3380a int(11) NOT NULL, 3381b int(11) NOT NULL, 3382c datetime default NULL, 3383PRIMARY KEY (a), 3384KEY idx_bc (b,c) 3385); 3386INSERT INTO t1 VALUES 3387(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), 3388(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), 3389(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), 3390(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), 3391(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), 3392(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), 3393(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), 3394(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), 3395(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), 3396(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), 3397(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), 3398(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), 3399(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), 3400(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), 3401(154503,67,'2005-10-28 11:52:38'); 3402create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; 3403create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; 3404create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; 3405create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; 3406update t22 set c = '2005-12-08 15:58:27' where a = 255; 3407explain select t21.* from t21,t22 where t21.a = t22.a and 3408t22.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; 3409id select_type table partitions type possible_keys key key_len ref rows filtered Extra 34101 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 100.00 Using temporary; Using filesort 34111 SIMPLE t22 NULL ALL NULL NULL NULL NULL 26 3.85 Using where; Using join buffer (Block Nested Loop) 34121 SIMPLE t21 NULL ALL NULL NULL NULL NULL 26 10.00 Using where; Using join buffer (Block Nested Loop) 34132 MATERIALIZED t11 NULL ALL NULL NULL NULL NULL 8 12.50 Using where 34142 MATERIALIZED t12 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (Block Nested Loop) 3415Warnings: 3416Note 1003 /* select#1 */ select `test`.`t21`.`a` AS `a`,`test`.`t21`.`b` AS `b`,`test`.`t21`.`c` AS `c` from `test`.`t21` semi join (`test`.`t11` join `test`.`t12`) join `test`.`t22` where ((`test`.`t22`.`a` = `<subquery2>`.`a`) and (`test`.`t21`.`a` = `<subquery2>`.`a`) and (`test`.`t12`.`a` = `test`.`t11`.`a`) and isnull(`test`.`t22`.`c`) and (`test`.`t11`.`a` in (255,256)) and isnull(`test`.`t11`.`c`)) order by `test`.`t21`.`a` 3417explain format=json select * from t1 where a in (select a from t11); 3418EXPLAIN 3419{ 3420 "query_block": { 3421 "select_id": 1, 3422 "cost_info": { 3423 "query_cost": "18.43" 3424 }, 3425 "nested_loop": [ 3426 { 3427 "table": { 3428 "table_name": "<subquery2>", 3429 "access_type": "ALL", 3430 "materialized_from_subquery": { 3431 "using_temporary_table": true, 3432 "query_block": { 3433 "table": { 3434 "table_name": "t11", 3435 "access_type": "ALL", 3436 "rows_examined_per_scan": 8, 3437 "rows_produced_per_join": 8, 3438 "filtered": "100.00", 3439 "cost_info": { 3440 "read_cost": "2.03", 3441 "eval_cost": "1.60", 3442 "prefix_cost": "3.63", 3443 "data_read_per_join": "128" 3444 }, 3445 "used_columns": [ 3446 "a" 3447 ] 3448 } 3449 } 3450 } 3451 } 3452 }, 3453 { 3454 "table": { 3455 "table_name": "t1", 3456 "access_type": "eq_ref", 3457 "possible_keys": [ 3458 "PRIMARY" 3459 ], 3460 "key": "PRIMARY", 3461 "used_key_parts": [ 3462 "a" 3463 ], 3464 "key_length": "4", 3465 "ref": [ 3466 "<subquery2>.a" 3467 ], 3468 "rows_examined_per_scan": 1, 3469 "rows_produced_per_join": 1, 3470 "filtered": "100.00", 3471 "using_join_buffer": "Batched Key Access", 3472 "cost_info": { 3473 "read_cost": "1.00", 3474 "eval_cost": "0.20", 3475 "prefix_cost": "18.43", 3476 "data_read_per_join": "16" 3477 }, 3478 "used_columns": [ 3479 "a", 3480 "b", 3481 "c" 3482 ] 3483 } 3484 } 3485 ] 3486 } 3487} 3488Warnings: 3489Note 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`) 3490select t21.* from t21,t22 where t21.a = t22.a and 3491t22.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; 3492a b c 3493256 67 NULL 3494drop table t1, t11, t12, t21, t22; 3495create table t1(a int); 3496insert into t1 values (0),(1); 3497explain 3498select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; 3499id select_type table partitions type possible_keys key key_len ref rows filtered Extra 35001 PRIMARY x NULL ALL NULL NULL NULL NULL 2 100.00 NULL 35012 DEPENDENT SUBQUERY y NULL ALL NULL NULL NULL NULL 2 50.00 Using where 35022 DEPENDENT SUBQUERY z NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(y); Using join buffer (Block Nested Loop) 3503Warnings: 3504Note 1276 Field or reference 'test.x.a' of SELECT #2 was resolved in SELECT #1 3505Note 1003 /* select#1 */ select (/* select#2 */ select max(`test`.`y`.`a`) from `test`.`t1` `y` semi join (`test`.`t1` `z`) where ((`test`.`z`.`a` = `test`.`y`.`a`) and (`test`.`y`.`a` < `test`.`x`.`a`))) AS `subq` from `test`.`t1` `x` 3506select (select max(y.a) from t1 y where a in (select a from t1 z) and a < x.a) as subq from t1 x; 3507subq 3508NULL 35090 3510drop table t1; 3511create table t0 (a int); 3512insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 3513create table t1 as select * from t0; 3514insert into t1 select a+10 from t0; 3515insert into t0 values(2); 3516explain select * from t1 where 2 in (select a from t0); 3517id select_type table partitions type possible_keys key key_len ref rows filtered Extra 35181 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; FirstMatch 35191 SIMPLE t1 NULL ALL NULL NULL NULL NULL 20 100.00 Using join buffer (Block Nested Loop) 3520Warnings: 3521Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t0`) where (`test`.`t0`.`a` = 2) 3522select * from t1 where 2 in (select a from t0); 3523a 35240 35251 35262 35273 35284 35295 35306 35317 35328 35339 353410 353511 353612 353713 353814 353915 354016 354117 354218 354319 3544explain select * from (select a from t0) x where a in (select a from t1); 3545id select_type table partitions type possible_keys key key_len ref rows filtered Extra 35461 SIMPLE t0 NULL ALL NULL NULL NULL NULL 11 100.00 NULL 35471 SIMPLE <subquery3> NULL eq_ref <auto_key> <auto_key> 5 func 1 100.00 Using where 35483 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 20 100.00 NULL 3549Warnings: 3550Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`<subquery3>`.`a` = `test`.`t0`.`a`) 3551explain format=json select * from (select a from t0) x where a in (select a from t1); 3552EXPLAIN 3553{ 3554 "query_block": { 3555 "select_id": 1, 3556 "cost_info": { 3557 "query_cost": "18.45" 3558 }, 3559 "nested_loop": [ 3560 { 3561 "table": { 3562 "table_name": "t0", 3563 "access_type": "ALL", 3564 "rows_examined_per_scan": 11, 3565 "rows_produced_per_join": 11, 3566 "filtered": "100.00", 3567 "cost_info": { 3568 "read_cost": "2.02", 3569 "eval_cost": "2.20", 3570 "prefix_cost": "4.22", 3571 "data_read_per_join": "88" 3572 }, 3573 "used_columns": [ 3574 "a" 3575 ] 3576 } 3577 }, 3578 { 3579 "table": { 3580 "table_name": "<subquery3>", 3581 "access_type": "eq_ref", 3582 "key": "<auto_key>", 3583 "key_length": "5", 3584 "ref": [ 3585 "func" 3586 ], 3587 "rows_examined_per_scan": 1, 3588 "attached_condition": "(`<subquery3>`.`a` = `test`.`t0`.`a`)", 3589 "materialized_from_subquery": { 3590 "using_temporary_table": true, 3591 "query_block": { 3592 "table": { 3593 "table_name": "t1", 3594 "access_type": "ALL", 3595 "rows_examined_per_scan": 20, 3596 "rows_produced_per_join": 20, 3597 "filtered": "100.00", 3598 "cost_info": { 3599 "read_cost": "2.03", 3600 "eval_cost": "4.00", 3601 "prefix_cost": "6.03", 3602 "data_read_per_join": "160" 3603 }, 3604 "used_columns": [ 3605 "a" 3606 ] 3607 } 3608 } 3609 } 3610 } 3611 } 3612 ] 3613 } 3614} 3615Warnings: 3616Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`<subquery3>`.`a` = `test`.`t0`.`a`) 3617drop table t0, t1; 3618create table t0 (a int); 3619insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 3620create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); 3621insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; 3622insert into t1 select * from t1 where kp1 < 20; 3623create table t3 (a int); 3624insert into t3 select A.a + 10*B.a from t0 A, t0 B; 3625explain select * from t3 where a in (select kp1 from t1 where kp1<20); 3626id select_type table partitions type possible_keys key key_len ref rows filtered Extra 36271 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where 36281 SIMPLE <subquery2> NULL eq_ref <auto_key> <auto_key> 5 test.t3.a 1 100.00 NULL 36292 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index 3630Warnings: 3631Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`<subquery2>`.`kp1` = `test`.`t3`.`a`) and (`test`.`t1`.`kp1` < 20)) 3632select * from t3 where a in (select kp1 from t1 where kp1<20); 3633a 36340 36351 36362 36373 36384 36395 36406 36417 36428 36439 364410 364511 364612 364713 364814 364915 365016 365117 365218 365319 3654explain select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; 3655id select_type table partitions type possible_keys key key_len ref rows filtered Extra 36561 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 33.33 Using where 36571 SIMPLE <subquery2> NULL eq_ref <auto_key> <auto_key> 5 test.t3.a 1 100.00 NULL 36582 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using where; Using index 3659Warnings: 3660Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1`) where ((`<subquery2>`.`kp1` = `test`.`t3`.`a`) and (`test`.`t3`.`a` < 20) and (`test`.`t1`.`kp1` < 20)) 3661select * from t3 where a in (select kp1 from t1 where kp1<20) and a<20; 3662a 36630 36641 36652 36663 36674 36685 36696 36707 36718 36729 367310 367411 367512 367613 367714 367815 367916 368017 368118 368219 3683create table t4 (pk int primary key); 3684insert into t4 select a from t3; 3685explain select * from t3 where a in 3686(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); 3687id select_type table partitions type possible_keys key key_len ref rows filtered Extra 36881 SIMPLE t3 NULL ALL NULL NULL NULL NULL 100 100.00 Using where 36891 SIMPLE <subquery2> NULL eq_ref <auto_key> <auto_key> 5 test.t3.a 1 100.00 NULL 36902 MATERIALIZED t1 NULL range kp1 kp1 5 NULL 48 100.00 Using index condition; Using where; Using MRR 36912 MATERIALIZED t4 NULL eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index 3692Warnings: 3693Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a` from `test`.`t3` semi join (`test`.`t1` join `test`.`t4`) where ((`<subquery2>`.`kp1` = `test`.`t3`.`a`) and (`test`.`t4`.`pk` = `test`.`t1`.`c`) and (`test`.`t1`.`kp1` < 20)) 3694select * from t3 where a in 3695(select t1.kp1 from t1,t4 where kp1<20 and t4.pk=t1.c); 3696a 36970 36981 36992 37003 37014 37025 37036 37047 37058 37069 370710 370811 370912 371013 371114 371215 371316 371417 371518 371619 3717drop table t1, t3, t4; 3718create table t1 (a int); 3719insert into t1 values (0),(0),(0),(1),(1),(1),(2),(2),(2),(3),(3),(3); 3720set @save_max_heap_table_size=@@max_heap_table_size; 3721set @@max_heap_table_size= 16384; 3722# Attempt to make one test that overflows the heap table when a 3723# non-duplicate row is inserted and one test that overflows the 3724# heap table when a duplicate record is inserted. Debugging showed 3725# that these situations occurred with max_heap_table_size=16384 3726# and optimizer_join_cache_level equals 1 and 0, respectively. 3727# Finally execute a test that does not overflow the heap table. 3728explain 3729select count(*) from t0 a, t0 b, t0 c 3730where c.a in (select a from t1 d); 3731id select_type table partitions type possible_keys key key_len ref rows filtered Extra 37321 SIMPLE a NULL ALL NULL NULL NULL NULL 10 100.00 NULL 37331 SIMPLE b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (Block Nested Loop) 37341 SIMPLE c NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (Block Nested Loop) 37351 SIMPLE <subquery2> NULL eq_ref <auto_key> <auto_key> 5 test.c.a 1 100.00 NULL 37362 MATERIALIZED d NULL ALL NULL NULL NULL NULL 12 100.00 NULL 3737Warnings: 3738Note 1003 /* select#1 */ select count(0) AS `count(*)` from `test`.`t0` `a` semi join (`test`.`t1` `d`) join `test`.`t0` `b` join `test`.`t0` `c` where (`<subquery2>`.`a` = `test`.`c`.`a`) 3739flush status; 3740select count(*) from t0 a, t0 b, t0 c 3741where c.a in (select a from t1 d); 3742count(*) 3743400 3744show status like 'Created_tmp_disk_tables'; 3745Variable_name Value 3746Created_tmp_disk_tables 0 3747set @@max_heap_table_size= @save_max_heap_table_size; 3748flush status; 3749select count(*) from t0 a, t0 b, t0 c 3750where c.a in (select a from t1 d); 3751count(*) 3752400 3753show status like 'Created_tmp_disk_tables'; 3754Variable_name Value 3755Created_tmp_disk_tables 0 3756drop table t0, t1; 3757create table t0 (a int); 3758insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 3759create table t2(a int); 3760insert into t2 values (1),(2); 3761create table t3 ( a int , filler char(100), key(a)); 3762insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; 3763explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); 3764id select_type table partitions type possible_keys key key_len ref rows filtered Extra 37651 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary 37661 SIMPLE t3 NULL ref a a 5 test.t2.a 1 100.00 End temporary; Using join buffer (Batched Key Access) 3767Warnings: 3768Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((`test`.`t2`.`a` > 5) or (`test`.`t2`.`a` < 10))) 3769select * from t3 where a in (select a from t2); 3770a filler 37711 filler 37722 filler 3773drop table t0, t2, t3; 3774create table t1 (a date); 3775insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); 3776create table t2 (a int); 3777insert into t2 values (1),(2); 3778create table t3 (a char(10)); 3779insert into t3 select * from t1; 3780insert into t3 values (1),(2); 3781explain select * from t2 where a in (select a from t1); 3782id select_type table partitions type possible_keys key key_len ref rows filtered Extra 37831 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 37841 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t2); Using join buffer (Block Nested Loop) 3785Warnings: 3786Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where (`test`.`t2`.`a` = `test`.`t1`.`a`) 3787explain select * from t2 where a in (select a from t2); 3788id select_type table partitions type possible_keys key key_len ref rows filtered Extra 37891 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 37901 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t2); Using join buffer (Block Nested Loop) 3791Warnings: 3792Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`a` = `test`.`t2`.`a`) 3793explain select * from t2 where a in (select a from t3); 3794id select_type table partitions type possible_keys key key_len ref rows filtered Extra 37951 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 37961 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t2); Using join buffer (Block Nested Loop) 3797Warnings: 3798Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t2`.`a` = `test`.`t3`.`a`) 3799explain select * from t1 where a in (select a from t3); 3800id select_type table partitions type possible_keys key key_len ref rows filtered Extra 38011 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 100.00 NULL 38021 SIMPLE t3 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(t1); Using join buffer (Block Nested Loop) 3803Warnings: 3804Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t3`) where (`test`.`t1`.`a` = `test`.`t3`.`a`) 3805drop table t1, t2, t3; 3806create table t1 (a decimal); 3807insert into t1 values (1),(2); 3808explain select * from t1 where a in (select a from t1); 3809id select_type table partitions type possible_keys key key_len ref rows filtered Extra 38101 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 38111 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (Block Nested Loop) 3812Warnings: 3813Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t1`.`a`) 3814drop table t1; 3815create table t1 (a int); 3816insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 3817create table t2 as select * from t1; 3818create table t3 (a int, b int, filler char(100), key(a)); 3819insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; 3820explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; 3821id select_type table partitions type possible_keys key key_len ref rows filtered Extra 38221 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 10.00 Using where 38231 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 100.00 Using where; Using join buffer (Block Nested Loop) 38241 SIMPLE t3 NULL ref a a 5 <subquery2>.a 10 100.00 Using join buffer (Batched Key Access) 38252 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL 3826Warnings: 3827Note 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))) 3828explain 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; 3829EXPLAIN 3830{ 3831 "query_block": { 3832 "select_id": 1, 3833 "cost_info": { 3834 "query_cost": "134.03" 3835 }, 3836 "nested_loop": [ 3837 { 3838 "table": { 3839 "table_name": "t1", 3840 "access_type": "ALL", 3841 "rows_examined_per_scan": 10, 3842 "rows_produced_per_join": 1, 3843 "filtered": "10.00", 3844 "cost_info": { 3845 "read_cost": "3.82", 3846 "eval_cost": "0.20", 3847 "prefix_cost": "4.02", 3848 "data_read_per_join": "8" 3849 }, 3850 "used_columns": [ 3851 "a" 3852 ], 3853 "attached_condition": "(`test`.`t1`.`a` = 3)" 3854 } 3855 }, 3856 { 3857 "table": { 3858 "table_name": "<subquery2>", 3859 "access_type": "ALL", 3860 "attached_condition": "(((`<subquery2>`.`a` < 10) or (`<subquery2>`.`a` > 30)) and (`<subquery2>`.`a` is not null))", 3861 "materialized_from_subquery": { 3862 "using_temporary_table": true, 3863 "query_block": { 3864 "table": { 3865 "table_name": "t2", 3866 "access_type": "ALL", 3867 "rows_examined_per_scan": 10, 3868 "rows_produced_per_join": 10, 3869 "filtered": "100.00", 3870 "cost_info": { 3871 "read_cost": "2.02", 3872 "eval_cost": "2.00", 3873 "prefix_cost": "4.02", 3874 "data_read_per_join": "80" 3875 }, 3876 "used_columns": [ 3877 "a" 3878 ] 3879 } 3880 } 3881 } 3882 } 3883 }, 3884 { 3885 "table": { 3886 "table_name": "t3", 3887 "access_type": "ref", 3888 "possible_keys": [ 3889 "a" 3890 ], 3891 "key": "a", 3892 "used_key_parts": [ 3893 "a" 3894 ], 3895 "key_length": "5", 3896 "ref": [ 3897 "<subquery2>.a" 3898 ], 3899 "rows_examined_per_scan": 10, 3900 "rows_produced_per_join": 10, 3901 "filtered": "100.00", 3902 "using_join_buffer": "Batched Key Access", 3903 "cost_info": { 3904 "read_cost": "100.00", 3905 "eval_cost": "2.00", 3906 "prefix_cost": "134.03", 3907 "data_read_per_join": "1K" 3908 }, 3909 "used_columns": [ 3910 "a", 3911 "b", 3912 "filler" 3913 ] 3914 } 3915 } 3916 ] 3917 } 3918} 3919Warnings: 3920Note 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))) 3921explain select straight_join * from t1 a, t1 b where a.a in (select a from t2); 3922id select_type table partitions type possible_keys key key_len ref rows filtered Extra 39231 PRIMARY a NULL ALL NULL NULL NULL NULL 10 100.00 Using where 39241 PRIMARY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (Block Nested Loop) 39252 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL 3926Warnings: 3927Note 1003 /* select#1 */ select straight_join `test`.`a`.`a` AS `a`,`test`.`b`.`a` AS `a` from `test`.`t1` `a` join `test`.`t1` `b` where <in_optimizer>(`test`.`a`.`a`,`test`.`a`.`a` in ( <materialize> (/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` where 1 ), <primary_index_lookup>(`test`.`a`.`a` in <temporary table> on <auto_key> where ((`test`.`a`.`a` = `materialized-subquery`.`a`))))) 3928explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); 3929id select_type table partitions type possible_keys key key_len ref rows filtered Extra 39301 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where 39312 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL 39322 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (Block Nested Loop) 3933Warnings: 3934Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where 1 ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on <auto_key> where ((`test`.`t2`.`a` = `materialized-subquery`.`a`))))) 3935explain select * from t2 where a in (select straight_join a.a from t1 a, t1 b); 3936id select_type table partitions type possible_keys key key_len ref rows filtered Extra 39371 PRIMARY t2 NULL ALL NULL NULL NULL NULL 10 100.00 Using where 39382 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL 39392 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (Block Nested Loop) 3940Warnings: 3941Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where 1 ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on <auto_key> where ((`test`.`t2`.`a` = `materialized-subquery`.`a`))))) 3942explain select straight_join * from t2 x, t2 y 3943where x.a in (select straight_join a.a from t1 a, t1 b); 3944id select_type table partitions type possible_keys key key_len ref rows filtered Extra 39451 PRIMARY x NULL ALL NULL NULL NULL NULL 10 100.00 Using where 39461 PRIMARY y NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (Block Nested Loop) 39472 SUBQUERY a NULL ALL NULL NULL NULL NULL 10 100.00 NULL 39482 SUBQUERY b NULL ALL NULL NULL NULL NULL 10 100.00 Using join buffer (Block Nested Loop) 3949Warnings: 3950Note 1003 /* select#1 */ select straight_join `test`.`x`.`a` AS `a`,`test`.`y`.`a` AS `a` from `test`.`t2` `x` join `test`.`t2` `y` where <in_optimizer>(`test`.`x`.`a`,`test`.`x`.`a` in ( <materialize> (/* select#2 */ select straight_join `test`.`a`.`a` from `test`.`t1` `a` join `test`.`t1` `b` where 1 ), <primary_index_lookup>(`test`.`x`.`a` in <temporary table> on <auto_key> where ((`test`.`x`.`a` = `materialized-subquery`.`a`))))) 3951create table t0 (a int, b int); 3952insert into t0 values(1,1); 3953explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); 3954id select_type table partitions type possible_keys key key_len ref rows filtered Extra 39551 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL 39561 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 100.00 Using where 39571 SIMPLE t3 NULL ref a a 5 <subquery2>.a 10 100.00 Using join buffer (Batched Key Access) 39582 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL 3959Warnings: 3960Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t2`) where ((`test`.`t3`.`a` = `<subquery2>`.`a`) and ((`<subquery2>`.`a` < 10) or (`<subquery2>`.`a` > 30))) 3961create table t4 as select a as x, a as y from t1; 3962explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); 3963id select_type table partitions type possible_keys key key_len ref rows filtered Extra 39641 SIMPLE t0 NULL system NULL NULL NULL NULL 1 100.00 NULL 39651 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 100.00 Using where 39661 SIMPLE t3 NULL ref a a 5 <subquery2>.x 10 10.00 Using where; Using join buffer (Batched Key Access) 39672 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 10 100.00 NULL 3968Warnings: 3969Note 1003 /* select#1 */ select '1' AS `a`,'1' AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t3`.`filler` AS `filler` from `test`.`t3` semi join (`test`.`t4`) where ((`test`.`t3`.`b` = `<subquery2>`.`y`) and (`test`.`t3`.`a` = `<subquery2>`.`x`) and ((`<subquery2>`.`x` < 10) or (`<subquery2>`.`x` > 30))) 3970drop table t0,t1,t2,t3,t4; 3971create table t0 (a int); 3972insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 3973create table t1 (a int, b int, filler char(100), key(a,b)); 3974insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; 3975create table t2 as select * from t1; 3976explain select * from t2 where a in (select b from t1 where a=3); 3977id select_type table partitions type possible_keys key key_len ref rows filtered Extra 39781 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 100.00 Using where 39791 SIMPLE <subquery2> NULL eq_ref <auto_key> <auto_key> 5 test.t2.a 1 100.00 NULL 39802 MATERIALIZED t1 NULL ref a a 5 const 8 100.00 Using index 3981Warnings: 3982Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`<subquery2>`.`b` = `test`.`t2`.`a`) and (`test`.`t1`.`a` = 3)) 3983explain select * from t2 where (b,a) in (select a,b from t1 where a=3); 3984id select_type table partitions type possible_keys key key_len ref rows filtered Extra 39851 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where 39861 SIMPLE <subquery2> NULL eq_ref <auto_key> <auto_key> 10 test.t2.b,test.t2.a 1 100.00 Using where 39872 MATERIALIZED t1 NULL ref a a 5 const 8 100.00 Using index 3988Warnings: 3989Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`filler` AS `filler` from `test`.`t2` semi join (`test`.`t1`) where ((`<subquery2>`.`b` = `test`.`t2`.`a`) and (`test`.`t2`.`b` = 3) and (`<subquery2>`.`a` = 3) and (`test`.`t1`.`a` = 3)) 3990drop table t1,t2; 3991create table t1 (a int, b int); 3992insert into t1 select a,a from t0; 3993create table t2 (a int, b int); 3994insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; 3995explain select * from t1 where (a,b) in (select a,b from t2); 3996id select_type table partitions type possible_keys key key_len ref rows filtered Extra 39971 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where 39981 SIMPLE <subquery2> NULL eq_ref <auto_key> <auto_key> 10 test.t1.a,test.t1.b 1 100.00 NULL 39992 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 100 100.00 NULL 4000Warnings: 4001Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`<subquery2>`.`b` = `test`.`t1`.`b`) and (`<subquery2>`.`a` = `test`.`t1`.`a`)) 4002drop table t0, t1, t2; 4003# 4004# Bug#19695490: CRASH IN CREATE_REF_FOR_KEY ON SELECT + JOIN + UTF8 COLUMN 4005# + DATETIME INDEX. 4006# 4007CREATE TABLE t1 ( 4008field1 varchar(255) CHARACTER SET utf8, 4009field2 varchar(255) CHARACTER SET utf8 4010); 4011INSERT INTO t1 VALUES 4012('time','time'), 4013('lpjdzvkp','lpjdzvkp'), 4014('dzvkpai', 'dzvkpai'); 4015CREATE TABLE t2 ( col_varchar varchar(10)); 4016CREATE TABLE t3 ( 4017pk int(11) NOT NULL, 4018col_varchar_255_utf8_key varchar(255) CHARACTER SET utf8, 4019col_varchar_10_utf8_key varchar(10) CHARACTER SET utf8, 4020PRIMARY KEY (pk) 4021); 4022INSERT INTO t3 VALUES (22,'come','h'), 4023(23,'time','aaa'), 4024(24,'lpjdzvkp','ababa'), 4025(25,'d','GGDD'); 4026SELECT * FROM t1 WHERE (field1, field2) IN ( 4027SELECT table1.col_varchar_255_utf8_key AS field1, 4028table1.col_varchar_255_utf8_key AS field2 4029FROM t3 AS table1 LEFT JOIN t2 AS table2 4030ON table1.col_varchar_10_utf8_key <= 4031table2.col_varchar 4032WHERE table1.pk >= 6); 4033field1 field2 4034time time 4035lpjdzvkp lpjdzvkp 4036DROP TABLE t1,t2,t3; 4037create table t0 (a decimal(4,2)); 4038insert into t0 values (10.24), (22.11); 4039create table t1 as select * from t0; 4040insert into t1 select * from t0; 4041explain select * from t0 where a in (select a from t1); 4042id select_type table partitions type possible_keys key key_len ref rows filtered Extra 40431 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 40441 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0); Using join buffer (Block Nested Loop) 4045Warnings: 4046Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) 4047select * from t0 where a in (select a from t1); 4048a 404910.24 405022.11 4051drop table t0, t1; 4052create table t0(a date); 4053insert into t0 values ('2008-01-01'),('2008-02-02'); 4054create table t1 as select * from t0; 4055insert into t1 select * from t0; 4056explain select * from t0 where a in (select a from t1); 4057id select_type table partitions type possible_keys key key_len ref rows filtered Extra 40581 SIMPLE t0 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 40591 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t0); Using join buffer (Block Nested Loop) 4060Warnings: 4061Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1`) where (`test`.`t1`.`a` = `test`.`t0`.`a`) 4062select * from t0 where a in (select a from t1); 4063a 40642008-01-01 40652008-02-02 4066drop table t0, t1; 4067create table t0(a int); 4068insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 4069create table t1 as select a as a, a as b, a as c from t0 where a < 3; 4070create table t2 as select a as a, a as b from t0 where a < 3; 4071insert into t2 select * from t2; 4072explain 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); 4073id select_type table partitions type possible_keys key key_len ref rows filtered Extra 40741 SIMPLE x NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary 40751 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (Block Nested Loop) 40761 SIMPLE y NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (Block Nested Loop) 40771 SIMPLE z NULL ALL NULL NULL NULL NULL 6 16.67 Using where; End temporary; Using join buffer (Block Nested Loop) 4078Warnings: 4079Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` semi join (`test`.`t2` `x` join `test`.`t2` `y` join `test`.`t2` `z`) where ((`test`.`z`.`a` = `test`.`t1`.`c`) and (`test`.`y`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` = `test`.`x`.`a`) and (`test`.`x`.`b` = 33)) 4080drop table t0,t1,t2; 4081set @save_join_buffer_size = @@join_buffer_size; 4082set join_buffer_size= 8192; 4083create table t0 (a int); 4084insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 4085create table t1 (a int, filler1 binary(200), filler2 binary(200)); 4086insert into t1 select a, 'filler123456', 'filler123456' from t0; 4087insert into t1 select a+10, 'filler123456', 'filler123456' from t0; 4088create table t2 as select * from t1; 4089insert into t1 select a+20, 'filler123456', 'filler123456' from t0; 4090insert into t1 values (2, 'duplicate ok', 'duplicate ok'); 4091insert into t1 values (18, 'duplicate ok', 'duplicate ok'); 4092insert into t2 values (3, 'duplicate ok', 'duplicate ok'); 4093insert into t2 values (19, 'duplicate ok', 'duplicate ok'); 4094explain select 4095a, mid(filler1, 1,10), length(filler1)=length(filler2) as z 4096from t1 ot where a in (select a from t2 it); 4097id select_type table partitions type possible_keys key key_len ref rows filtered Extra 40981 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 100.00 NULL 40991 SIMPLE ot NULL ALL NULL NULL NULL NULL 32 10.00 Using where; Using join buffer (Block Nested Loop) 41002 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL 4101Warnings: 4102Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `<subquery2>`.`a`) 4103select 4104a, mid(filler1, 1,10), length(filler1)=length(filler2) as z 4105from t1 ot where a in (select a from t2 it); 4106a mid(filler1, 1,10) z 41070 filler1234 1 41081 filler1234 1 410910 filler1234 1 411011 filler1234 1 411112 filler1234 1 411213 filler1234 1 411314 filler1234 1 411415 filler1234 1 411516 filler1234 1 411617 filler1234 1 411718 duplicate 1 411818 filler1234 1 411919 filler1234 1 41202 duplicate 1 41212 filler1234 1 41223 filler1234 1 41234 filler1234 1 41245 filler1234 1 41256 filler1234 1 41267 filler1234 1 41278 filler1234 1 41289 filler1234 1 4129explain select 4130a, mid(filler1, 1,10), length(filler1)=length(filler2) 4131from t2 ot where a in (select a from t1 it); 4132id select_type table partitions type possible_keys key key_len ref rows filtered Extra 41331 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where 41341 SIMPLE <subquery2> NULL eq_ref <auto_key> <auto_key> 5 test.ot.a 1 100.00 NULL 41352 MATERIALIZED it NULL ALL NULL NULL NULL NULL 32 100.00 NULL 4136Warnings: 4137Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`<subquery2>`.`a` = `test`.`ot`.`a`) 4138select 4139a, mid(filler1, 1,10), length(filler1)=length(filler2) 4140from t2 ot where a in (select a from t1 it); 4141a mid(filler1, 1,10) length(filler1)=length(filler2) 41420 filler1234 1 41431 filler1234 1 414410 filler1234 1 414511 filler1234 1 414612 filler1234 1 414713 filler1234 1 414814 filler1234 1 414915 filler1234 1 415016 filler1234 1 415117 filler1234 1 415218 filler1234 1 415319 duplicate 1 415419 filler1234 1 41552 filler1234 1 41563 duplicate 1 41573 filler1234 1 41584 filler1234 1 41595 filler1234 1 41606 filler1234 1 41617 filler1234 1 41628 filler1234 1 41639 filler1234 1 4164insert into t1 select a+20, 'filler123456', 'filler123456' from t0; 4165insert into t1 select a+20, 'filler123456', 'filler123456' from t0; 4166explain select 4167a, mid(filler1, 1,10), length(filler1)=length(filler2) as z 4168from t1 ot where a in (select a from t2 it); 4169id select_type table partitions type possible_keys key key_len ref rows filtered Extra 41701 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 100.00 NULL 41711 SIMPLE ot NULL ALL NULL NULL NULL NULL 52 10.00 Using where; Using join buffer (Block Nested Loop) 41722 MATERIALIZED it NULL ALL NULL NULL NULL NULL 22 100.00 NULL 4173Warnings: 4174Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `z` from `test`.`t1` `ot` semi join (`test`.`t2` `it`) where (`test`.`ot`.`a` = `<subquery2>`.`a`) 4175select 4176a, mid(filler1, 1,10), length(filler1)=length(filler2) as z 4177from t1 ot where a in (select a from t2 it); 4178a mid(filler1, 1,10) z 41790 filler1234 1 41801 filler1234 1 418110 filler1234 1 418211 filler1234 1 418312 filler1234 1 418413 filler1234 1 418514 filler1234 1 418615 filler1234 1 418716 filler1234 1 418817 filler1234 1 418918 duplicate 1 419018 filler1234 1 419119 filler1234 1 41922 duplicate 1 41932 filler1234 1 41943 filler1234 1 41954 filler1234 1 41965 filler1234 1 41976 filler1234 1 41987 filler1234 1 41998 filler1234 1 42009 filler1234 1 4201explain select 4202a, mid(filler1, 1,10), length(filler1)=length(filler2) 4203from t2 ot where a in (select a from t1 it); 4204id select_type table partitions type possible_keys key key_len ref rows filtered Extra 42051 SIMPLE ot NULL ALL NULL NULL NULL NULL 22 100.00 Using where 42061 SIMPLE <subquery2> NULL eq_ref <auto_key> <auto_key> 5 test.ot.a 1 100.00 NULL 42072 MATERIALIZED it NULL ALL NULL NULL NULL NULL 52 100.00 NULL 4208Warnings: 4209Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a`,substr(`test`.`ot`.`filler1`,1,10) AS `mid(filler1, 1,10)`,(length(`test`.`ot`.`filler1`) = length(`test`.`ot`.`filler2`)) AS `length(filler1)=length(filler2)` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where (`<subquery2>`.`a` = `test`.`ot`.`a`) 4210select 4211a, mid(filler1, 1,10), length(filler1)=length(filler2) 4212from t2 ot where a in (select a from t1 it); 4213a mid(filler1, 1,10) length(filler1)=length(filler2) 42140 filler1234 1 42151 filler1234 1 421610 filler1234 1 421711 filler1234 1 421812 filler1234 1 421913 filler1234 1 422014 filler1234 1 422115 filler1234 1 422216 filler1234 1 422317 filler1234 1 422418 filler1234 1 422519 duplicate 1 422619 filler1234 1 42272 filler1234 1 42283 duplicate 1 42293 filler1234 1 42304 filler1234 1 42315 filler1234 1 42326 filler1234 1 42337 filler1234 1 42348 filler1234 1 42359 filler1234 1 4236set @@join_buffer_size = @save_join_buffer_size; 4237drop table t1, t2; 4238create table t1 (a int, b int, key(a)); 4239create table t2 (a int, b int, key(a)); 4240create table t3 (a int, b int, key(a)); 4241insert into t1 select a,a from t0; 4242insert into t2 select a,a from t0; 4243insert into t3 select a,a from t0; 4244t2 and t3 must be use 'ref', not 'ALL': 4245explain select * 4246from t0 where a in 4247(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a); 4248id select_type table partitions type possible_keys key key_len ref rows filtered Extra 42491 SIMPLE t0 NULL ALL NULL NULL NULL NULL 10 100.00 Using where 42501 SIMPLE <subquery2> NULL eq_ref <auto_key> <auto_key> 9 test.t0.a 1 100.00 Using where 42512 MATERIALIZED t1 NULL index a a 5 NULL 10 100.00 Using index 42522 MATERIALIZED t2 NULL ref a a 5 test.t1.a 1 100.00 Using index 42532 MATERIALIZED t3 NULL ref a a 5 test.t1.a 1 100.00 Using index 4254Warnings: 4255Note 1003 /* select#1 */ select `test`.`t0`.`a` AS `a` from `test`.`t0` semi join (`test`.`t1` join `test`.`t2` join `test`.`t3`) where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t3`.`a` = `test`.`t1`.`a`) and (`test`.`t0`.`a` = `<subquery2>`.`t2.a+t3.a`)) 4256drop table t0, t1,t2,t3; 4257 4258Test that neither MaterializeLookup strategy for semijoin, 4259nor subquery materialization is used when BLOBs are involved 4260(except when arguments of some functions). 4261 4262set @prefix_len = 6; 4263set @blob_len = 16; 4264set @suffix_len = @blob_len - @prefix_len; 4265create table t1_16 (a1 blob(16), a2 blob(16)); 4266create table t2_16 (b1 blob(16), b2 blob(16)); 4267create table t3_16 (c1 blob(16), c2 blob(16)); 4268insert into t1_16 values 4269(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); 4270insert into t1_16 values 4271(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 4272insert into t1_16 values 4273(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 4274insert into t2_16 values 4275(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 4276insert into t2_16 values 4277(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 4278insert into t2_16 values 4279(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 4280insert into t3_16 values 4281(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 4282insert into t3_16 values 4283(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 4284insert into t3_16 values 4285(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 4286insert into t3_16 values 4287(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); 4288explain extended select left(a1,7), left(a2,7) 4289from t1_16 4290where a1 in (select b1 from t2_16 where b1 > '0'); 4291id select_type table partitions type possible_keys key key_len ref rows filtered Extra 42921 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 42931 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (Block Nested Loop) 4294Warnings: 4295Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4296Note 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')) 4297select left(a1,7), left(a2,7) 4298from t1_16 4299where a1 in (select b1 from t2_16 where b1 > '0'); 4300left(a1,7) left(a2,7) 43011 - 01x 2 - 01x 43021 - 02x 2 - 02x 4303explain extended select left(a1,7), left(a2,7) 4304from t1_16 4305where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); 4306id select_type table partitions type possible_keys key key_len ref rows filtered Extra 43071 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 43081 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (Block Nested Loop) 4309Warnings: 4310Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4311Note 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')) 4312select left(a1,7), left(a2,7) 4313from t1_16 4314where (a1,a2) in (select b1, b2 from t2_16 where b1 > '0'); 4315left(a1,7) left(a2,7) 43161 - 01x 2 - 01x 43171 - 02x 2 - 02x 4318explain extended select left(a1,7), left(a2,7) 4319from t1_16 4320where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); 4321id select_type table partitions type possible_keys key key_len ref rows filtered Extra 43221 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 NULL 43231 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_16); Using join buffer (Block Nested Loop) 4324Warnings: 4325Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4326Note 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))) 4327select left(a1,7), left(a2,7) 4328from t1_16 4329where a1 in (select substring(b1,1,16) from t2_16 where b1 > '0'); 4330left(a1,7) left(a2,7) 43311 - 01x 2 - 01x 43321 - 02x 2 - 02x 4333explain extended select left(a1,7), left(a2,7) 4334from t1_16 4335where a1 in (select group_concat(b1) from t2_16 group by b2); 4336id select_type table partitions type possible_keys key key_len ref rows filtered Extra 43371 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 43382 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort 4339Warnings: 4340Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4341Note 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 ','))))) 4342select left(a1,7), left(a2,7) 4343from t1_16 4344where a1 in (select group_concat(b1) from t2_16 group by b2); 4345left(a1,7) left(a2,7) 43461 - 01x 2 - 01x 43471 - 02x 2 - 02x 4348set @@group_concat_max_len = 256; 4349explain extended select left(a1,7), left(a2,7) 4350from t1_16 4351where a1 in (select group_concat(b1) from t2_16 group by b2); 4352id select_type table partitions type possible_keys key key_len ref rows filtered Extra 43531 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 43542 SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort 4355Warnings: 4356Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4357Note 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)`))))) 4358select left(a1,7), left(a2,7) 4359from t1_16 4360where a1 in (select group_concat(b1) from t2_16 group by b2); 4361left(a1,7) left(a2,7) 43621 - 01x 2 - 01x 43631 - 02x 2 - 02x 4364create table t1 (a1 char(8), a2 char(8)); 4365create table t2 (b1 char(8), b2 char(8)); 4366create table t3 (c1 char(8), c2 char(8)); 4367insert into t1 values ('1 - 00', '2 - 00'); 4368insert into t1 values ('1 - 01', '2 - 01'); 4369insert into t1 values ('1 - 02', '2 - 02'); 4370insert into t2 values ('1 - 01', '2 - 01'); 4371insert into t2 values ('1 - 01', '2 - 01'); 4372insert into t2 values ('1 - 02', '2 - 02'); 4373insert into t2 values ('1 - 02', '2 - 02'); 4374insert into t2 values ('1 - 03', '2 - 03'); 4375insert into t3 values ('1 - 01', '2 - 01'); 4376insert into t3 values ('1 - 02', '2 - 02'); 4377insert into t3 values ('1 - 03', '2 - 03'); 4378insert into t3 values ('1 - 04', '2 - 04'); 4379insert into t3 values ('1 - 05', '2 - 05'); 4380insert into t3 values ('1 - 06', '2 - 06'); 4381insert into t3 values ('1 - 07', '2 - 07'); 4382insert into t3 values ('1 - 08', '2 - 08'); 4383explain extended 4384select * from t1 4385where concat(a1,'x') IN 4386(select left(a1,8) from t1_16 4387where (a1, a2) IN 4388(select t2_16.b1, t2_16.b2 from t2_16, t2 4389where t2.b2 = substring(t2_16.b2,1,6) and 4390t2.b1 IN (select c1 from t3 where c2 > '0'))); 4391id select_type table partitions type possible_keys key key_len ref rows filtered Extra 43921 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary 43931 SIMPLE t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (Block Nested Loop) 43941 SIMPLE t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (Block Nested Loop) 43951 SIMPLE t2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (Block Nested Loop) 43961 SIMPLE t3 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (Block Nested Loop) 4397Warnings: 4398Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4399Note 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`.`t3`.`c1` = `test`.`t2`.`b1`) and (`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and (`test`.`t3`.`c2` > '0') and (concat(`test`.`t1`.`a1`,'x') = left(`test`.`t1_16`.`a1`,8))) 4400drop table t1_16, t2_16, t3_16, t1, t2, t3; 4401set @blob_len = 512; 4402set @suffix_len = @blob_len - @prefix_len; 4403create table t1_512 (a1 blob(512), a2 blob(512)); 4404create table t2_512 (b1 blob(512), b2 blob(512)); 4405create table t3_512 (c1 blob(512), c2 blob(512)); 4406insert into t1_512 values 4407(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); 4408insert into t1_512 values 4409(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 4410insert into t1_512 values 4411(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 4412insert into t2_512 values 4413(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 4414insert into t2_512 values 4415(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 4416insert into t2_512 values 4417(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 4418insert into t3_512 values 4419(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 4420insert into t3_512 values 4421(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 4422insert into t3_512 values 4423(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 4424insert into t3_512 values 4425(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); 4426explain extended select left(a1,7), left(a2,7) 4427from t1_512 4428where a1 in (select b1 from t2_512 where b1 > '0'); 4429id select_type table partitions type possible_keys key key_len ref rows filtered Extra 44301 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 44311 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (Block Nested Loop) 4432Warnings: 4433Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4434Note 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')) 4435select left(a1,7), left(a2,7) 4436from t1_512 4437where a1 in (select b1 from t2_512 where b1 > '0'); 4438left(a1,7) left(a2,7) 44391 - 01x 2 - 01x 44401 - 02x 2 - 02x 4441explain extended select left(a1,7), left(a2,7) 4442from t1_512 4443where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); 4444id select_type table partitions type possible_keys key key_len ref rows filtered Extra 44451 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 44461 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (Block Nested Loop) 4447Warnings: 4448Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4449Note 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')) 4450select left(a1,7), left(a2,7) 4451from t1_512 4452where (a1,a2) in (select b1, b2 from t2_512 where b1 > '0'); 4453left(a1,7) left(a2,7) 44541 - 01x 2 - 01x 44551 - 02x 2 - 02x 4456explain extended select left(a1,7), left(a2,7) 4457from t1_512 4458where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); 4459id select_type table partitions type possible_keys key key_len ref rows filtered Extra 44601 SIMPLE t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 NULL 44611 SIMPLE t2_512 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_512); Using join buffer (Block Nested Loop) 4462Warnings: 4463Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4464Note 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))) 4465select left(a1,7), left(a2,7) 4466from t1_512 4467where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0'); 4468left(a1,7) left(a2,7) 44691 - 01x 2 - 01x 44701 - 02x 2 - 02x 4471explain extended select left(a1,7), left(a2,7) 4472from t1_512 4473where a1 in (select group_concat(b1) from t2_512 group by b2); 4474id select_type table partitions type possible_keys key key_len ref rows filtered Extra 44751 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 44762 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort 4477Warnings: 4478Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4479Note 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)`))))) 4480select left(a1,7), left(a2,7) 4481from t1_512 4482where a1 in (select group_concat(b1) from t2_512 group by b2); 4483left(a1,7) left(a2,7) 4484Warnings: 4485Warning 1260 Row 1 was cut by GROUP_CONCAT() 4486Warning 1260 Row 2 was cut by GROUP_CONCAT() 4487Warning 1260 Row 3 was cut by GROUP_CONCAT() 4488set @@group_concat_max_len = 256; 4489explain extended select left(a1,7), left(a2,7) 4490from t1_512 4491where a1 in (select group_concat(b1) from t2_512 group by b2); 4492id select_type table partitions type possible_keys key key_len ref rows filtered Extra 44931 PRIMARY t1_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 44942 SUBQUERY t2_512 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort 4495Warnings: 4496Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4497Note 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)`))))) 4498select left(a1,7), left(a2,7) 4499from t1_512 4500where a1 in (select group_concat(b1) from t2_512 group by b2); 4501left(a1,7) left(a2,7) 4502Warnings: 4503Warning 1260 Row 1 was cut by GROUP_CONCAT() 4504Warning 1260 Row 2 was cut by GROUP_CONCAT() 4505Warning 1260 Row 3 was cut by GROUP_CONCAT() 4506drop table t1_512, t2_512, t3_512; 4507set @blob_len = 513; 4508set @suffix_len = @blob_len - @prefix_len; 4509create table t1_513 (a1 blob(513), a2 blob(513)); 4510create table t2_513 (b1 blob(513), b2 blob(513)); 4511create table t3_513 (c1 blob(513), c2 blob(513)); 4512insert into t1_513 values 4513(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); 4514insert into t1_513 values 4515(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 4516insert into t1_513 values 4517(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 4518insert into t2_513 values 4519(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 4520insert into t2_513 values 4521(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 4522insert into t2_513 values 4523(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 4524insert into t3_513 values 4525(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 4526insert into t3_513 values 4527(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 4528insert into t3_513 values 4529(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 4530insert into t3_513 values 4531(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); 4532explain extended select left(a1,7), left(a2,7) 4533from t1_513 4534where a1 in (select b1 from t2_513 where b1 > '0'); 4535id select_type table partitions type possible_keys key key_len ref rows filtered Extra 45361 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 45371 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (Block Nested Loop) 4538Warnings: 4539Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4540Note 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')) 4541select left(a1,7), left(a2,7) 4542from t1_513 4543where a1 in (select b1 from t2_513 where b1 > '0'); 4544left(a1,7) left(a2,7) 45451 - 01x 2 - 01x 45461 - 02x 2 - 02x 4547explain extended select left(a1,7), left(a2,7) 4548from t1_513 4549where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); 4550id select_type table partitions type possible_keys key key_len ref rows filtered Extra 45511 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 45521 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (Block Nested Loop) 4553Warnings: 4554Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4555Note 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')) 4556select left(a1,7), left(a2,7) 4557from t1_513 4558where (a1,a2) in (select b1, b2 from t2_513 where b1 > '0'); 4559left(a1,7) left(a2,7) 45601 - 01x 2 - 01x 45611 - 02x 2 - 02x 4562explain extended select left(a1,7), left(a2,7) 4563from t1_513 4564where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); 4565id select_type table partitions type possible_keys key key_len ref rows filtered Extra 45661 SIMPLE t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 NULL 45671 SIMPLE t2_513 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_513); Using join buffer (Block Nested Loop) 4568Warnings: 4569Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4570Note 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))) 4571select left(a1,7), left(a2,7) 4572from t1_513 4573where a1 in (select substring(b1,1,513) from t2_513 where b1 > '0'); 4574left(a1,7) left(a2,7) 45751 - 01x 2 - 01x 45761 - 02x 2 - 02x 4577explain extended select left(a1,7), left(a2,7) 4578from t1_513 4579where a1 in (select group_concat(b1) from t2_513 group by b2); 4580id select_type table partitions type possible_keys key key_len ref rows filtered Extra 45811 PRIMARY t1_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 45822 SUBQUERY t2_513 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort 4583Warnings: 4584Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4585Note 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)`))))) 4586select left(a1,7), left(a2,7) 4587from t1_513 4588where a1 in (select group_concat(b1) from t2_513 group by b2); 4589left(a1,7) left(a2,7) 4590Warnings: 4591Warning 1260 Row 1 was cut by GROUP_CONCAT() 4592Warning 1260 Row 2 was cut by GROUP_CONCAT() 4593Warning 1260 Row 3 was cut by GROUP_CONCAT() 4594drop table t1_513, t2_513, t3_513; 4595set @blob_len = 1024; 4596set @suffix_len = @blob_len - @prefix_len; 4597create table t1_1024 (a1 blob(1024), a2 blob(1024)); 4598create table t2_1024 (b1 blob(1024), b2 blob(1024)); 4599create table t3_1024 (c1 blob(1024), c2 blob(1024)); 4600insert into t1_1024 values 4601(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); 4602insert into t1_1024 values 4603(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 4604insert into t1_1024 values 4605(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 4606insert into t2_1024 values 4607(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 4608insert into t2_1024 values 4609(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 4610insert into t2_1024 values 4611(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 4612insert into t3_1024 values 4613(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 4614insert into t3_1024 values 4615(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 4616insert into t3_1024 values 4617(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 4618insert into t3_1024 values 4619(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); 4620explain extended select left(a1,7), left(a2,7) 4621from t1_1024 4622where a1 in (select b1 from t2_1024 where b1 > '0'); 4623id select_type table partitions type possible_keys key key_len ref rows filtered Extra 46241 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 46251 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (Block Nested Loop) 4626Warnings: 4627Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4628Note 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')) 4629select left(a1,7), left(a2,7) 4630from t1_1024 4631where a1 in (select b1 from t2_1024 where b1 > '0'); 4632left(a1,7) left(a2,7) 46331 - 01x 2 - 01x 46341 - 02x 2 - 02x 4635explain extended select left(a1,7), left(a2,7) 4636from t1_1024 4637where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); 4638id select_type table partitions type possible_keys key key_len ref rows filtered Extra 46391 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 46401 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (Block Nested Loop) 4641Warnings: 4642Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4643Note 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')) 4644select left(a1,7), left(a2,7) 4645from t1_1024 4646where (a1,a2) in (select b1, b2 from t2_1024 where b1 > '0'); 4647left(a1,7) left(a2,7) 46481 - 01x 2 - 01x 46491 - 02x 2 - 02x 4650explain extended select left(a1,7), left(a2,7) 4651from t1_1024 4652where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); 4653id select_type table partitions type possible_keys key key_len ref rows filtered Extra 46541 SIMPLE t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 NULL 46551 SIMPLE t2_1024 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1024); Using join buffer (Block Nested Loop) 4656Warnings: 4657Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4658Note 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))) 4659select left(a1,7), left(a2,7) 4660from t1_1024 4661where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0'); 4662left(a1,7) left(a2,7) 46631 - 01x 2 - 01x 46641 - 02x 2 - 02x 4665explain extended select left(a1,7), left(a2,7) 4666from t1_1024 4667where a1 in (select group_concat(b1) from t2_1024 group by b2); 4668id select_type table partitions type possible_keys key key_len ref rows filtered Extra 46691 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 46702 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort 4671Warnings: 4672Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4673Note 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)`))))) 4674select left(a1,7), left(a2,7) 4675from t1_1024 4676where a1 in (select group_concat(b1) from t2_1024 group by b2); 4677left(a1,7) left(a2,7) 4678Warnings: 4679Warning 1260 Row 1 was cut by GROUP_CONCAT() 4680Warning 1260 Row 2 was cut by GROUP_CONCAT() 4681Warning 1260 Row 3 was cut by GROUP_CONCAT() 4682set @@group_concat_max_len = 256; 4683explain extended select left(a1,7), left(a2,7) 4684from t1_1024 4685where a1 in (select group_concat(b1) from t2_1024 group by b2); 4686id select_type table partitions type possible_keys key key_len ref rows filtered Extra 46871 PRIMARY t1_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 46882 SUBQUERY t2_1024 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort 4689Warnings: 4690Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4691Note 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)`))))) 4692select left(a1,7), left(a2,7) 4693from t1_1024 4694where a1 in (select group_concat(b1) from t2_1024 group by b2); 4695left(a1,7) left(a2,7) 4696Warnings: 4697Warning 1260 Row 1 was cut by GROUP_CONCAT() 4698Warning 1260 Row 2 was cut by GROUP_CONCAT() 4699Warning 1260 Row 3 was cut by GROUP_CONCAT() 4700drop table t1_1024, t2_1024, t3_1024; 4701set @blob_len = 1025; 4702set @suffix_len = @blob_len - @prefix_len; 4703create table t1_1025 (a1 blob(1025), a2 blob(1025)); 4704create table t2_1025 (b1 blob(1025), b2 blob(1025)); 4705create table t3_1025 (c1 blob(1025), c2 blob(1025)); 4706insert into t1_1025 values 4707(concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len))); 4708insert into t1_1025 values 4709(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 4710insert into t1_1025 values 4711(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 4712insert into t2_1025 values 4713(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 4714insert into t2_1025 values 4715(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 4716insert into t2_1025 values 4717(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 4718insert into t3_1025 values 4719(concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len))); 4720insert into t3_1025 values 4721(concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len))); 4722insert into t3_1025 values 4723(concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len))); 4724insert into t3_1025 values 4725(concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len))); 4726explain extended select left(a1,7), left(a2,7) 4727from t1_1025 4728where a1 in (select b1 from t2_1025 where b1 > '0'); 4729id select_type table partitions type possible_keys key key_len ref rows filtered Extra 47301 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 47311 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (Block Nested Loop) 4732Warnings: 4733Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4734Note 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')) 4735select left(a1,7), left(a2,7) 4736from t1_1025 4737where a1 in (select b1 from t2_1025 where b1 > '0'); 4738left(a1,7) left(a2,7) 47391 - 01x 2 - 01x 47401 - 02x 2 - 02x 4741explain extended select left(a1,7), left(a2,7) 4742from t1_1025 4743where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); 4744id select_type table partitions type possible_keys key key_len ref rows filtered Extra 47451 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 47461 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (Block Nested Loop) 4747Warnings: 4748Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4749Note 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')) 4750select left(a1,7), left(a2,7) 4751from t1_1025 4752where (a1,a2) in (select b1, b2 from t2_1025 where b1 > '0'); 4753left(a1,7) left(a2,7) 47541 - 01x 2 - 01x 47551 - 02x 2 - 02x 4756explain extended select left(a1,7), left(a2,7) 4757from t1_1025 4758where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); 4759id select_type table partitions type possible_keys key key_len ref rows filtered Extra 47601 SIMPLE t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 NULL 47611 SIMPLE t2_1025 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1_1025); Using join buffer (Block Nested Loop) 4762Warnings: 4763Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4764Note 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))) 4765select left(a1,7), left(a2,7) 4766from t1_1025 4767where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0'); 4768left(a1,7) left(a2,7) 47691 - 01x 2 - 01x 47701 - 02x 2 - 02x 4771explain extended select left(a1,7), left(a2,7) 4772from t1_1025 4773where a1 in (select group_concat(b1) from t2_1025 group by b2); 4774id select_type table partitions type possible_keys key key_len ref rows filtered Extra 47751 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 47762 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort 4777Warnings: 4778Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4779Note 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)`))))) 4780select left(a1,7), left(a2,7) 4781from t1_1025 4782where a1 in (select group_concat(b1) from t2_1025 group by b2); 4783left(a1,7) left(a2,7) 4784Warnings: 4785Warning 1260 Row 1 was cut by GROUP_CONCAT() 4786Warning 1260 Row 2 was cut by GROUP_CONCAT() 4787Warning 1260 Row 3 was cut by GROUP_CONCAT() 4788set @@group_concat_max_len = 256; 4789explain extended select left(a1,7), left(a2,7) 4790from t1_1025 4791where a1 in (select group_concat(b1) from t2_1025 group by b2); 4792id select_type table partitions type possible_keys key key_len ref rows filtered Extra 47931 PRIMARY t1_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 47942 SUBQUERY t2_1025 NULL ALL NULL NULL NULL NULL 3 100.00 Using filesort 4795Warnings: 4796Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 4797Note 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)`))))) 4798select left(a1,7), left(a2,7) 4799from t1_1025 4800where a1 in (select group_concat(b1) from t2_1025 group by b2); 4801left(a1,7) left(a2,7) 4802Warnings: 4803Warning 1260 Row 1 was cut by GROUP_CONCAT() 4804Warning 1260 Row 2 was cut by GROUP_CONCAT() 4805Warning 1260 Row 3 was cut by GROUP_CONCAT() 4806drop table t1_1025, t2_1025, t3_1025; 4807# 4808# WL#5561: Enable semi join transformation with outer join. 4809# 4810CREATE TABLE ot1(a INT); 4811CREATE TABLE ot2(a INT); 4812CREATE TABLE ot3(a INT); 4813CREATE TABLE it1(a INT); 4814CREATE TABLE it2(a INT); 4815CREATE TABLE it3(a INT); 4816INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); 4817INSERT INTO ot2 VALUES(0),(2),(4),(6); 4818INSERT INTO ot3 VALUES(0),(3),(6); 4819INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); 4820INSERT INTO it2 VALUES(0),(2),(4),(6); 4821INSERT INTO it3 VALUES(0),(3),(6); 4822# Test cases, Subquery Pattern 1 4823# Example SQ1.1: 4824explain SELECT * 4825FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4826WHERE ot1.a IN (SELECT a FROM it3); 4827id select_type table partitions type possible_keys key key_len ref rows filtered Extra 48281 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary 48291 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (Block Nested Loop) 48301 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (Block Nested Loop) 4831Warnings: 4832Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` semi join (`test`.`it3`) left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`it3`.`a`)) where (`test`.`ot1`.`a` = `test`.`it3`.`a`) 4833SELECT * 4834FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4835WHERE ot1.a IN (SELECT a FROM it3); 4836a a 48370 0 48383 NULL 48396 6 4840# Example SQ1.2: 4841explain SELECT * 4842FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4843WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); 4844id select_type table partitions type possible_keys key key_len ref rows filtered Extra 48451 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 100.00 NULL 48461 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Using join buffer (Block Nested Loop) 48471 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (Block Nested Loop) 48482 MATERIALIZED it3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL 4849Warnings: 4850Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` semi join (`test`.`it3`) left join `test`.`ot2` on((`test`.`ot2`.`a` = `test`.`ot1`.`a`)) where (coalesce(`test`.`ot2`.`a`,0) = `<subquery2>`.`a`) 4851SELECT * 4852FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4853WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); 4854a a 48550 0 48561 NULL 48573 NULL 48585 NULL 48596 6 48607 NULL 4861# Example SQ1.3: 4862explain SELECT * 4863FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4864WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); 4865id select_type table partitions type possible_keys key key_len ref rows filtered Extra 48661 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary 48671 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (Block Nested Loop) 48681 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (Block Nested Loop) 4869Warnings: 4870Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` semi join (`test`.`it3`) join `test`.`ot2` where ((`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`ot1`.`a` = `test`.`it3`.`a`)) 4871SELECT * 4872FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4873WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); 4874a a 48750 0 48766 6 4877# More test cases 4878SELECT * 4879FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 4880WHERE ot1.a IN (SELECT a FROM it3); 4881a a 48820 0 48833 NULL 48846 6 4885SELECT * 4886FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 4887WHERE ot1.a IN (SELECT a+0 FROM it3); 4888a a 48890 0 48903 NULL 48916 6 4892SELECT * 4893FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 4894WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); 4895a a 48960 0 48971 NULL 48983 NULL 48995 NULL 49006 6 49017 NULL 4902SELECT * 4903FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4904WHERE COALESCE(ot2.a,0) IN (SELECT a+0 FROM it3); 4905a a 49060 0 49071 NULL 49083 NULL 49095 NULL 49106 6 49117 NULL 4912SELECT * 4913FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 4914WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3); 4915a a 49160 0 49176 6 4918SELECT * 4919FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4920LEFT JOIN ot3 ON ot1.a=ot3.a 4921WHERE ot1.a IN (SELECT a FROM it3); 4922a a a 49230 0 0 49243 NULL 3 49256 6 6 4926SELECT * 4927FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4928LEFT JOIN ot3 ON ot1.a=ot3.a 4929WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); 4930a a a 49310 0 0 49321 NULL NULL 49333 NULL 3 49345 NULL NULL 49356 6 6 49367 NULL NULL 4937SELECT * 4938FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4939LEFT JOIN ot3 ON ot1.a=ot3.a 4940WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); 4941a a a 49420 0 0 49431 NULL NULL 49442 2 NULL 49453 NULL 3 49464 4 NULL 49475 NULL NULL 49486 6 6 49497 NULL NULL 4950SELECT * 4951FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4952LEFT JOIN ot3 ON ot2.a=ot3.a 4953WHERE ot1.a IN (SELECT a FROM it3); 4954a a a 49550 0 0 49563 NULL NULL 49576 6 6 4958SELECT * 4959FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4960LEFT JOIN ot3 ON ot2.a=ot3.a 4961WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3); 4962a a a 49630 0 0 49641 NULL NULL 49653 NULL NULL 49665 NULL NULL 49676 6 6 49687 NULL NULL 4969SELECT * 4970FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a 4971LEFT JOIN ot3 ON ot2.a=ot3.a 4972WHERE COALESCE(ot3.a,0) IN (SELECT a FROM it3); 4973a a a 49740 0 0 49751 NULL NULL 49762 2 NULL 49773 NULL NULL 49784 4 NULL 49795 NULL NULL 49806 6 6 49817 NULL NULL 4982# Test cases, Subquery Pattern 2 4983# Example SQ2.1: 4984explain SELECT * 4985FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); 4986id select_type table partitions type possible_keys key key_len ref rows filtered Extra 49871 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary 49881 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (Block Nested Loop) 49891 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (Block Nested Loop) 4990Warnings: 4991Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` semi join (`test`.`it3`) join `test`.`ot2` where ((`test`.`ot1`.`a` = `test`.`it3`.`a`) and (`test`.`ot2`.`a` = `test`.`it3`.`a`)) 4992SELECT * 4993FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); 4994a a 49950 0 49966 6 4997# Example SQ2.2: 4998explain SELECT * 4999FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) 5000AND ot2.a IN (SELECT a FROM it3); 5001id select_type table partitions type possible_keys key key_len ref rows filtered Extra 50021 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Start temporary 50031 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (Block Nested Loop) 50041 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; End temporary; Using join buffer (Block Nested Loop) 50051 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(ot2); Using join buffer (Block Nested Loop) 5006Warnings: 5007Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` semi join (`test`.`it2`) semi join (`test`.`it3`) join `test`.`ot2` where ((`test`.`ot1`.`a` = `test`.`it3`.`a`) and (`test`.`ot2`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`it3`.`a`)) 5008SELECT * 5009FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it2) 5010AND ot2.a IN (SELECT a FROM it3); 5011a a 50120 0 50136 6 5014# More test cases 5015SELECT * 5016FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); 5017a a 50180 0 50196 6 5020SELECT * 5021FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); 5022a a 50230 0 50246 6 5025SELECT * 5026FROM ot1 JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it3); 5027a a 50280 0 50296 6 5030SELECT * 5031FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it3); 5032a a 50330 0 50346 6 5035SELECT * 5036FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it2) 5037AND ot2.a IN (SELECT a+0 FROM it3); 5038a a 50390 0 50406 6 5041SELECT * 5042FROM ot1 JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) 5043JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); 5044a a a 50450 0 0 50466 6 6 5047# Test cases, Subquery Pattern 3 5048# Example SQ3.1: 5049explain SELECT * 5050FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); 5051id select_type table partitions type possible_keys key key_len ref rows filtered Extra 50521 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL 50531 SIMPLE it3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(ot1) 50541 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where 5055Warnings: 5056Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it3`)) on(((`test`.`it3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`) and 1)) where 1 5057SELECT * 5058FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3); 5059a a 50600 0 50611 NULL 50622 NULL 50633 NULL 50644 NULL 50655 NULL 50666 6 50677 NULL 5068# Example SQ3.2: 5069explain SELECT * 5070FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); 5071id select_type table partitions type possible_keys key key_len ref rows filtered Extra 50721 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL 50731 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where 50741 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; FirstMatch(ot2) 5075Warnings: 5076Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and 1)) where 1 5077SELECT * 5078FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a FROM it2); 5079a a 50800 0 50811 NULL 50822 2 50833 NULL 50844 4 50855 NULL 50866 6 50877 NULL 5088# Example SQ3.3 5089explain SELECT * 5090FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) 5091AND ot2.a IN (SELECT a FROM it2); 5092id select_type table partitions type possible_keys key key_len ref rows filtered Extra 50931 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL 50941 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot1) 50951 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where 50961 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; FirstMatch(ot2) 5097Warnings: 5098Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) semi join (`test`.`it2`)) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and 1 and 1)) where 1 5099SELECT * 5100FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) 5101AND ot2.a IN (SELECT a FROM it2); 5102a a 51030 0 51041 NULL 51052 2 51063 NULL 51074 4 51085 NULL 51096 6 51107 NULL 5111# Example SQ3.4 5112explain SELECT * 5113FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND 5114(ot1.a, ot2.a) IN (SELECT it1.a, it2.a 5115FROM it1 JOIN it2 ON it1.a=it2.a); 5116id select_type table partitions type possible_keys key key_len ref rows filtered Extra 51171 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 Start temporary 51181 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (Block Nested Loop) 51191 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (Block Nested Loop) 51201 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; End temporary; Using join buffer (Block Nested Loop) 5121Warnings: 5122Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1` join `test`.`it2`)) on(((`test`.`ot2`.`a` = `test`.`ot1`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`) and 1)) where 1 5123SELECT * 5124FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND 5125(ot1.a, ot2.a) IN (SELECT it1.a, it2.a 5126FROM it1 JOIN it2 ON it1.a=it2.a); 5127a a 51280 0 51291 NULL 51302 2 51313 NULL 51324 4 51335 NULL 51346 6 51357 NULL 5136# More test cases 5137SELECT * 5138FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3); 5139a a 51400 0 51411 NULL 51422 NULL 51433 NULL 51444 NULL 51455 NULL 51466 6 51477 NULL 5148SELECT * 5149FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it3); 5150a a 51510 0 51521 NULL 51532 NULL 51543 NULL 51554 NULL 51565 NULL 51576 6 51587 NULL 5159SELECT * 5160FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot2.a IN (SELECT a FROM it2); 5161a a 51620 0 51631 NULL 51642 2 51653 NULL 51664 4 51675 NULL 51686 6 51697 NULL 5170SELECT * 5171FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot2.a IN (SELECT a+0 FROM it2); 5172a a 51730 0 51741 NULL 51752 2 51763 NULL 51774 4 51785 NULL 51796 6 51807 NULL 5181SELECT * 5182FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a+0 FROM it1) 5183AND ot2.a IN (SELECT a+0 FROM it2); 5184a a 51850 0 51861 NULL 51872 2 51883 NULL 51894 4 51905 NULL 51916 6 51927 NULL 5193SELECT * 5194FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND 5195(ot1.a, ot2.a) IN (SELECT it1.a+0, it2.a+0 5196FROM it1 JOIN it2 ON it1.a=it2.a); 5197a a 51980 0 51991 NULL 52002 2 52013 NULL 52024 4 52035 NULL 52046 6 52057 NULL 5206SELECT * 5207FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it3) 5208LEFT JOIN ot3 ON ot2.a=ot3.a AND ot3.a IN (SELECT a FROM it3); 5209a a a 52100 0 0 52111 NULL NULL 52122 NULL NULL 52133 NULL NULL 52144 NULL NULL 52155 NULL NULL 52166 6 6 52177 NULL NULL 5218SELECT * 5219FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it3) 5220LEFT JOIN ot3 ON ot2.a=ot3.a+0 AND ot3.a IN (SELECT a FROM it3); 5221a a a 52220 0 0 52231 NULL NULL 52242 NULL NULL 52253 NULL NULL 52264 NULL NULL 52275 NULL NULL 52286 6 6 52297 NULL NULL 5230# Test cases, Subquery Pattern 4 5231# Example SQ4.1: 5232explain SELECT * 5233FROM ot1 5234LEFT JOIN 5235(ot2 JOIN ot3 ON ot2.a=ot3.a) 5236ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 5237id select_type table partitions type possible_keys key key_len ref rows filtered Extra 52381 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL 52391 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot1) 52401 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 52411 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where 5242Warnings: 5243Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) join `test`.`ot3`) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`) and 1)) where 1 5244SELECT * 5245FROM ot1 5246LEFT JOIN 5247(ot2 JOIN ot3 ON ot2.a=ot3.a) 5248ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 5249a a a 52500 0 0 52511 NULL NULL 52522 NULL NULL 52533 NULL NULL 52544 NULL NULL 52555 NULL NULL 52566 6 6 52577 NULL NULL 5258# Example SQ4.2: 5259explain SELECT * 5260FROM ot1 5261JOIN 5262(ot2 JOIN ot3 ON ot2.a=ot3.a) 5263ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 5264id select_type table partitions type possible_keys key key_len ref rows filtered Extra 52651 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 NULL 52661 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (Block Nested Loop) 52671 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (Block Nested Loop) 52681 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; FirstMatch(ot1); Using join buffer (Block Nested Loop) 5269Warnings: 5270Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` semi join (`test`.`it1`) join `test`.`ot2` join `test`.`ot3` where ((`test`.`ot2`.`a` = `test`.`ot3`.`a`) and (`test`.`ot1`.`a` = `test`.`ot3`.`a`) and (`test`.`it1`.`a` = `test`.`ot3`.`a`)) 5271SELECT * 5272FROM ot1 5273JOIN 5274(ot2 JOIN ot3 ON ot2.a=ot3.a) 5275ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 5276a a a 52770 0 0 52786 6 6 5279# Example SQ4.3: 5280explain SELECT * 5281FROM ot1 5282JOIN 5283(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 5284ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 5285id select_type table partitions type possible_keys key key_len ref rows filtered Extra 52861 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where 52871 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (Block Nested Loop) 52881 SIMPLE <subquery2> NULL eq_ref <auto_key> <auto_key> 5 test.ot2.a 1 100.00 NULL 52891 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (Block Nested Loop) 52902 MATERIALIZED it1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL 5291Warnings: 5292Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` semi join (`test`.`it1`) join `test`.`ot2` left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot2`.`a`)) where ((`test`.`ot1`.`a` = `test`.`ot2`.`a`) and (`<subquery2>`.`a` = `test`.`ot2`.`a`)) 5293SELECT * 5294FROM ot1 5295JOIN 5296(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 5297ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 5298a a a 52990 0 0 53002 2 NULL 53014 4 NULL 53026 6 6 5303# Example SQ4.4: 5304explain SELECT * 5305FROM ot1 5306LEFT JOIN 5307(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 5308ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 5309id select_type table partitions type possible_keys key key_len ref rows filtered Extra 53101 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL 53111 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot1) 53121 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where 53131 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 5314Warnings: 5315Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) left join `test`.`ot3` on((`test`.`ot3`.`a` = `test`.`ot1`.`a`))) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`) and 1)) where 1 5316SELECT * 5317FROM ot1 5318LEFT JOIN 5319(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 5320ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 5321a a a 53220 0 0 53231 NULL NULL 53242 2 NULL 53253 NULL NULL 53264 4 NULL 53275 NULL NULL 53286 6 6 53297 NULL NULL 5330# More test cases 5331SELECT * 5332FROM ot1 5333LEFT JOIN 5334(ot2 JOIN ot3 ON ot2.a=ot3.a+0) 5335ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 5336a a a 53370 0 0 53381 NULL NULL 53392 NULL NULL 53403 NULL NULL 53414 NULL NULL 53425 NULL NULL 53436 6 6 53447 NULL NULL 5345SELECT * 5346FROM ot1 5347LEFT JOIN 5348(ot2 JOIN ot3 ON ot2.a=ot3.a) 5349ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); 5350a a a 53510 0 0 53521 NULL NULL 53532 NULL NULL 53543 NULL NULL 53554 NULL NULL 53565 NULL NULL 53576 6 6 53587 NULL NULL 5359SELECT * 5360FROM ot1 5361LEFT JOIN 5362(ot2 JOIN ot3 ON ot2.a=ot3.a) 5363ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); 5364a a a 53650 0 0 53661 NULL NULL 53672 NULL NULL 53683 NULL NULL 53694 NULL NULL 53705 NULL NULL 53716 6 6 53727 NULL NULL 5373SELECT * 5374FROM ot1 5375JOIN 5376(ot2 JOIN ot3 ON ot2.a=ot3.a+0) 5377ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 5378a a a 53790 0 0 53806 6 6 5381SELECT * 5382FROM ot1 5383JOIN 5384(ot2 JOIN ot3 ON ot2.a=ot3.a) 5385ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); 5386a a a 53870 0 0 53886 6 6 5389SELECT * 5390FROM ot1 5391JOIN 5392(ot2 JOIN ot3 ON ot2.a=ot3.a) 5393ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); 5394a a a 53950 0 0 53966 6 6 5397SELECT * 5398FROM ot1 5399JOIN 5400(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) 5401ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 5402a a a 54030 0 0 54042 2 NULL 54054 4 NULL 54066 6 6 5407SELECT * 5408FROM ot1 5409JOIN 5410(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 5411ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); 5412a a a 54130 0 0 54142 2 NULL 54154 4 NULL 54166 6 6 5417SELECT * 5418FROM ot1 5419JOIN 5420(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 5421ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); 5422a a a 54230 0 0 54242 2 NULL 54254 4 NULL 54266 6 6 5427SELECT * 5428FROM ot1 5429LEFT JOIN 5430(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a+0) 5431ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 5432a a a 54330 0 0 54341 NULL NULL 54352 2 NULL 54363 NULL NULL 54374 4 NULL 54385 NULL NULL 54396 6 6 54407 NULL NULL 5441SELECT * 5442FROM ot1 5443LEFT JOIN 5444(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 5445ON ot1.a=ot2.a+0 AND ot1.a IN (SELECT a FROM it1); 5446a a a 54470 0 0 54481 NULL NULL 54492 2 NULL 54503 NULL NULL 54514 4 NULL 54525 NULL NULL 54536 6 6 54547 NULL NULL 5455SELECT * 5456FROM ot1 5457LEFT JOIN 5458(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 5459ON ot1.a=ot2.a AND ot1.a IN (SELECT a+0 FROM it1); 5460a a a 54610 0 0 54621 NULL NULL 54632 2 NULL 54643 NULL NULL 54654 4 NULL 54665 NULL NULL 54676 6 6 54687 NULL NULL 5469SELECT * 5470FROM ot1 5471LEFT JOIN 5472(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a) 5473ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1) 5474LEFT JOIN 5475ot1 AS ot4 5476ON ot2.a=ot4.a; 5477a a a a 54780 0 0 0 54791 NULL NULL NULL 54802 2 NULL 2 54813 NULL NULL NULL 54824 4 NULL 4 54835 NULL NULL NULL 54846 6 6 6 54857 NULL NULL NULL 5486SELECT * 5487FROM ot1 5488LEFT JOIN 5489(ot2 LEFT JOIN ot3 ON ot2.a=ot3.a 5490LEFT JOIN ot1 AS ot4 ON ot3.a=ot4.a) 5491ON ot1.a=ot2.a AND ot1.a IN (SELECT a FROM it1); 5492a a a a 54930 0 0 0 54941 NULL NULL NULL 54952 2 NULL NULL 54963 NULL NULL NULL 54974 4 NULL NULL 54985 NULL NULL NULL 54996 6 6 6 55007 NULL NULL NULL 5501DROP TABLE ot1,ot2,ot3,it1,it2,it3; 5502CREATE TABLE t ( 5503a INTEGER DEFAULT NULL 5504) ENGINE=InnoDB; 5505INSERT INTO t VALUES (1); 5506CREATE TABLE t2 ( 5507a INTEGER DEFAULT NULL 5508) ENGINE=InnoDB; 5509INSERT INTO t2 VALUES (1),(1); 5510CREATE TABLE t4 ( 5511a INTEGER DEFAULT NULL 5512) ENGINE=InnoDB; 5513INSERT INTO t4 VALUES (1),(1); 5514CREATE TABLE v ( 5515a INTEGER DEFAULT NULL 5516) ENGINE=InnoDB; 5517INSERT INTO v VALUES (1),(1); 5518explain SELECT * 5519FROM t AS t1 5520LEFT JOIN 5521(t2 5522LEFT JOIN t AS t3 5523ON t3.a IN (SELECT a FROM t AS it) 5524JOIN t4 5525ON t4.a=100 5526) 5527ON TRUE 5528WHERE t1.a IN (SELECT * FROM v AS it2); 5529id select_type table partitions type possible_keys key key_len ref rows filtered Extra 55301 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL 55311 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1); Using join buffer (Block Nested Loop) 55321 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where 55331 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 55341 SIMPLE it NULL ALL NULL NULL NULL NULL 1 100.00 Using where; FirstMatch(t3) 55351 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where 5536Warnings: 5537Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t` `t1` semi join (`test`.`v` `it2`) left join (`test`.`t2` left join (`test`.`t` `t3` semi join (`test`.`t` `it`)) on(((`test`.`it`.`a` = `test`.`t3`.`a`) and 1)) join `test`.`t4`) on(((`test`.`t4`.`a` = 100) and TRUE)) where (`test`.`it2`.`a` = `test`.`t1`.`a`) 5538SELECT * 5539FROM t AS t1 5540LEFT JOIN 5541(t2 5542LEFT JOIN t AS t3 5543ON t3.a IN (SELECT a FROM t AS it) 5544JOIN t4 5545ON t4.a=100 5546) 5547ON TRUE 5548WHERE t1.a IN (SELECT * FROM v AS it2); 5549a a a a 55501 NULL NULL NULL 5551DROP TABLE t,t2,t4,v; 5552# End of WL#5561 5553# 5554# Bug#48868: Left outer join in subquery causes segmentation fault in 5555# make_join_select. 5556# 5557CREATE TABLE t1 (i INTEGER); 5558INSERT INTO t1 VALUES (1); 5559INSERT INTO t1 VALUES (2); 5560CREATE TABLE t2 (i INTEGER); 5561INSERT INTO t2 VALUES(1); 5562CREATE TABLE t3 (i INTEGER); 5563INSERT INTO t3 VALUES (1); 5564INSERT INTO t3 VALUES (2); 5565SELECT * FROM t1 WHERE (t1.i) IN 5566(SELECT t2.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i); 5567i 55681 5569DROP TABLE t1, t2, t3; 5570 5571Bug#37899: Wrongly checked optimization prerequisite caused failed 5572assertion. 5573 5574CREATE TABLE t1 ( 5575`pk` int(11), 5576`varchar_nokey` varchar(5) 5577); 5578INSERT INTO t1 VALUES 5579(1,'qk'),(2,'j'),(3,'aew'); 5580SELECT * 5581FROM t1 5582WHERE varchar_nokey IN ( 5583SELECT 5584varchar_nokey 5585FROM 5586t1 5587) XOR pk = 30; 5588pk varchar_nokey 55891 qk 55902 j 55913 aew 5592drop table t1; 5593# 5594# BUG#41842: Semi-join materialization strategy crashes when the upper query has HAVING 5595# 5596CREATE TABLE t1 ( 5597pk int(11) NOT NULL AUTO_INCREMENT, 5598int_nokey int(11) NOT NULL, 5599time_key time NOT NULL, 5600datetime_key datetime NOT NULL, 5601datetime_nokey datetime NOT NULL, 5602varchar_key varchar(1) NOT NULL, 5603varchar_nokey varchar(1) NOT NULL, 5604PRIMARY KEY (pk), 5605KEY time_key (time_key), 5606KEY datetime_key (datetime_key), 5607KEY varchar_key (varchar_key) 5608) ENGINE=MyISaM; 5609INSERT INTO t1 VALUES 5610(1,0, '00:16:10','2008-09-03 14:25:40','2008-09-03 14:25:40','h','h'), 5611(2,7, '00:00:00','2001-01-13 00:00:00','2001-01-13 00:00:00','',''), 5612(3,0, '00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), 5613(4,2, '16:29:24','2000-10-16 01:39:08','2000-10-16 01:39:08','w','w'), 5614(5,1, '09:23:32','0000-00-00 00:00:00','0000-00-00 00:00:00','p','p'), 5615(6,3, '00:00:00','2007-12-02 00:00:00','2007-12-02 00:00:00','o','o'), 5616(7,3, '00:00:00','2008-09-11 00:00:00','2008-09-11 00:00:00','',''), 5617(8,0, '13:59:04','0000-00-00 00:00:00','0000-00-00 00:00:00','s','s'), 5618(9,7, '09:01:06','0000-00-00 00:00:00','0000-00-00 00:00:00','d','d'), 5619(10,5,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','n','n'), 5620(11,0,'21:06:46','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), 5621(12,2,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','',''), 5622(13,6,'14:45:34','2003-07-28 02:34:08','2003-07-28 02:34:08','w','w'), 5623(14,1,'15:04:12','0000-00-00 00:00:00','0000-00-00 00:00:00','o','o'), 5624(15,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','x','x'), 5625(16,0,'15:55:23','2004-03-17 00:32:27','2004-03-17 00:32:27','p','p'), 5626(17,1,'16:30:00','2004-12-27 19:20:00','2004-12-27 19:20:00','d','d'), 5627(18,0,'00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','h','h'), 5628(19,0,'14:13:26','2008-11-09 05:53:48','2008-11-09 05:53:48','o','o'), 5629(20,0,'00:00:00','2009-10-11 06:58:04','2009-10-11 06:58:04','k','k'); 5630Warnings: 5631Warning 1264 Out of range value for column 'datetime_key' at row 3 5632Warning 1264 Out of range value for column 'datetime_nokey' at row 3 5633Warning 1264 Out of range value for column 'datetime_key' at row 5 5634Warning 1264 Out of range value for column 'datetime_nokey' at row 5 5635Warning 1264 Out of range value for column 'datetime_key' at row 8 5636Warning 1264 Out of range value for column 'datetime_nokey' at row 8 5637Warning 1264 Out of range value for column 'datetime_key' at row 9 5638Warning 1264 Out of range value for column 'datetime_nokey' at row 9 5639Warning 1264 Out of range value for column 'datetime_key' at row 10 5640Warning 1264 Out of range value for column 'datetime_nokey' at row 10 5641Warning 1264 Out of range value for column 'datetime_key' at row 11 5642Warning 1264 Out of range value for column 'datetime_nokey' at row 11 5643Warning 1264 Out of range value for column 'datetime_key' at row 12 5644Warning 1264 Out of range value for column 'datetime_nokey' at row 12 5645Warning 1264 Out of range value for column 'datetime_key' at row 14 5646Warning 1264 Out of range value for column 'datetime_nokey' at row 14 5647Warning 1264 Out of range value for column 'datetime_key' at row 15 5648Warning 1264 Out of range value for column 'datetime_nokey' at row 15 5649Warning 1264 Out of range value for column 'datetime_key' at row 18 5650Warning 1264 Out of range value for column 'datetime_nokey' at row 18 5651CREATE TABLE t2 ( 5652pk int(11) NOT NULL AUTO_INCREMENT, 5653int_nokey int(11) NOT NULL, 5654time_key time NOT NULL, 5655datetime_key datetime NOT NULL, 5656datetime_nokey datetime NOT NULL, 5657varchar_key varchar(1) NOT NULL, 5658varchar_nokey varchar(1) NOT NULL, 5659PRIMARY KEY (pk), 5660KEY time_key (time_key), 5661KEY datetime_key (datetime_key), 5662KEY varchar_key (varchar_key) 5663); 5664INSERT IGNORE INTO t2 VALUES 5665(10,0,'19:39:13','0000-00-00 00:00:00','0000-00-00 00:00:00','g','g'), 5666(11,8,'03:43:53','0000-00-00 00:00:00','0000-00-00 00:00:00','b','b'); 5667Warnings: 5668Warning 1264 Out of range value for column 'datetime_key' at row 1 5669Warning 1264 Out of range value for column 'datetime_nokey' at row 1 5670Warning 1264 Out of range value for column 'datetime_key' at row 2 5671Warning 1264 Out of range value for column 'datetime_nokey' at row 2 5672SELECT OUTR.datetime_nokey AS X FROM t1 AS OUTR 5673WHERE 5674OUTR.varchar_nokey IN (SELECT 5675INNR . varchar_nokey AS Y 5676FROM t2 AS INNR 5677WHERE 5678INNR . datetime_key >= INNR . time_key OR 5679INNR . pk = INNR . int_nokey 5680) 5681AND OUTR . varchar_nokey <= 'w' 5682HAVING X > '2012-12-12'; 5683X 5684drop table t1, t2; 5685 5686Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order 5687with semijoin=on" 5688 5689CREATE TABLE t1 ( 5690varchar_key varchar(1) DEFAULT NULL, 5691KEY varchar_key (varchar_key) 5692); 5693CREATE TABLE t2 ( 5694varchar_key varchar(1) DEFAULT NULL, 5695KEY varchar_key (varchar_key) 5696); 5697INSERT INTO t2 VALUES 5698(NULL),(NULL),(NULL),(NULL),('a'),('a'),('a'),('b'),('b'),('b'),('b'),('c'), 5699('c'),('c'),('c'),('c'),('c'),('c'),('d'),('d'),('d'),('d'),('d'),('d'),('e'), 5700('e'),('e'),('e'),('e'),('e'),('f'),('f'),('f'),('g'),('g'),('h'),('h'),('h'), 5701('h'),('i'),('j'),('j'),('j'),('k'),('k'),('l'),('l'),('m'),('m'),('m'),('m'), 5702('n'),('n'),('n'),('o'),('o'),('o'),('p'),('p'),('p'),('q'),('q'),('q'),('r'), 5703('r'),('r'),('r'),('s'),('s'),('s'),('s'),('t'),('t'),('t'),('t'),('u'),('u'), 5704('u'),('u'),('v'),('v'),('v'),('v'),('w'),('w'),('w'),('w'),('w'),('w'),('x'), 5705('x'),('x'),('y'),('y'),('y'),('y'),('z'),('z'),('z'),('z'); 5706CREATE TABLE t3 ( 5707varchar_key varchar(1) DEFAULT NULL, 5708KEY varchar_key (varchar_key) 5709) ENGINE=MyISAM DEFAULT CHARSET=latin1; 5710INSERT INTO t3 VALUES 5711(NULL),('c'),('d'),('e'),('f'),('h'),('j'),('k'),('k'),('m'),('m'),('m'), 5712('n'),('o'),('r'),('t'),('t'),('u'),('w'),('y'); 5713SELECT varchar_key FROM t3 5714WHERE (SELECT varchar_key FROM t3 5715WHERE (varchar_key,varchar_key) 5716IN (SELECT t1.varchar_key, t2 .varchar_key 5717FROM t1 RIGHT JOIN t2 ON t1.varchar_key 5718) 5719); 5720varchar_key 5721DROP TABLE t1, t2, t3; 5722# 5723# Bug#46556 Returning incorrect, empty results for some IN subqueries 5724# w/semijoin=on 5725# 5726CREATE TABLE t0 ( 5727pk INTEGER, 5728vkey VARCHAR(1), 5729vnokey VARCHAR(1), 5730PRIMARY KEY (pk), 5731KEY vkey(vkey) 5732); 5733INSERT INTO t0 5734VALUES (1,'g','g'), (2,'v','v'), (3,'t','t'), (4,'u','u'), (5,'n','n'); 5735EXPLAIN EXTENDED SELECT vkey FROM t0 WHERE pk IN 5736(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); 5737id select_type table partitions type possible_keys key key_len ref rows filtered Extra 57381 SIMPLE t0 NULL ALL PRIMARY NULL NULL NULL 5 100.00 NULL 57391 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t0.pk 1 100.00 Using join buffer (Batched Key Access) 57401 SIMPLE t2 NULL index vkey vkey 4 NULL 5 20.00 Using where; Using index; FirstMatch(t1); Using join buffer (Block Nested Loop) 5741Warnings: 5742Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 5743Note 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`)) 5744SELECT vkey FROM t0 WHERE pk IN 5745(SELECT t1.pk FROM t0 t1 JOIN t0 t2 ON t2.vkey = t1.vnokey); 5746vkey 5747g 5748n 5749t 5750u 5751v 5752DROP TABLE t0; 5753# End of bug#46556 5754 5755Bug#48834: Procedure with view + subquery + semijoin=on 5756crashes on second call. 5757 5758CREATE TABLE t1 ( t1field integer, primary key (t1field)); 5759CREATE TABLE t2 ( t2field integer, primary key (t2field)); 5760CREATE VIEW v1 AS 5761SELECT t1field as v1field 5762FROM t1 A 5763WHERE A.t1field IN (SELECT t1field FROM t2 ); 5764CREATE VIEW v2 AS 5765SELECT t2field as v2field 5766FROM t2 A 5767WHERE A.t2field IN (SELECT t2field FROM t2 ); 5768CREATE PROCEDURE p1 () 5769BEGIN 5770SELECT v1field 5771FROM v1 5772WHERE v1field IN ( SELECT v2field as vf_inner FROM v2 ); 5773END| 5774INSERT INTO t1 VALUES (1),(2),(3); 5775INSERT INTO t2 VALUES (2),(3),(4); 5776CALL p1; 5777v1field 57782 57793 5780CALL p1; 5781v1field 57822 57833 5784DROP TABLE t1,t2; 5785DROP VIEW v1,v2; 5786DROP PROCEDURE p1; 5787# End of BUG#48834 5788# 5789# Bug#46692 "Crash occurring on queries with nested FROM subqueries 5790# using materialization." 5791# 5792CREATE TABLE t1 ( 5793pk INTEGER PRIMARY KEY, 5794int_key INTEGER, 5795KEY int_key(int_key) 5796); 5797INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1); 5798CREATE TABLE t2 ( 5799pk INTEGER PRIMARY KEY, 5800int_key INTEGER, 5801KEY int_key(int_key) 5802); 5803INSERT INTO t2 VALUES (1,7),(2,2); 5804SELECT * FROM t1 WHERE (140, 4) IN 5805(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key); 5806pk int_key 5807DROP TABLE t1, t2; 5808# 5809# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query 5810# causes crash." 5811# 5812CREATE TABLE t1 ( 5813pk INTEGER PRIMARY KEY, 5814int_nokey INTEGER, 5815int_key INTEGER, 5816date_key DATE, 5817datetime_nokey DATETIME, 5818varchar_nokey VARCHAR(1) 5819); 5820CREATE TABLE t2 ( 5821date_nokey DATE 5822); 5823CREATE TABLE t3 ( 5824pk INTEGER PRIMARY KEY, 5825int_nokey INTEGER, 5826date_key date, 5827varchar_key VARCHAR(1), 5828varchar_nokey VARCHAR(1), 5829KEY date_key (date_key) 5830); 5831SELECT date_key FROM t1 5832WHERE (int_key, int_nokey) 5833IN (SELECT t3.int_nokey, t3.pk 5834FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) 5835WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk 5836) 5837AND (varchar_nokey <> 'f' OR NOT int_key < 7); 5838date_key 5839# 5840# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery 5841# + AND in outer query". 5842# 5843INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'), 5844(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), 5845(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), 5846(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), 5847(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), 5848(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), 5849(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), 5850(29,9,1,'0000-00-00','2003-08-11 00:00:00','m'); 5851Warnings: 5852Warning 1264 Out of range value for column 'date_key' at row 2 5853Warning 1264 Out of range value for column 'datetime_nokey' at row 2 5854Warning 1264 Out of range value for column 'datetime_nokey' at row 4 5855Warning 1264 Out of range value for column 'datetime_nokey' at row 5 5856Warning 1264 Out of range value for column 'datetime_nokey' at row 6 5857Warning 1264 Out of range value for column 'date_key' at row 7 5858Warning 1264 Out of range value for column 'datetime_nokey' at row 7 5859Warning 1264 Out of range value for column 'date_key' at row 8 5860INSERT IGNORE INTO t3 VALUES (1,9,'0000-00-00','b','b'), 5861(2,2,'2002-09-17','h','h'); 5862Warnings: 5863Warning 1264 Out of range value for column 'date_key' at row 1 5864SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey 5865WHERE t1.varchar_nokey 5866IN (SELECT varchar_nokey FROM t1 5867WHERE (pk) 5868IN (SELECT t3.int_nokey 5869FROM t3 LEFT JOIN t1 ON t1.varchar_nokey 5870WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26' 5871 ) 5872); 5873varchar_nokey 5874DROP TABLE t1, t2, t3; 5875# 5876# Bug#45219 "Crash on SELECT DISTINCT query containing a 5877# LEFT JOIN in subquery" 5878# 5879CREATE TABLE t1 ( 5880pk INTEGER NOT NULL, 5881int_nokey INTEGER NOT NULL, 5882datetime_key DATETIME NOT NULL, 5883varchar_key VARCHAR(1) NOT NULL, 5884PRIMARY KEY (pk), 5885KEY datetime_key (datetime_key), 5886KEY varchar_key (varchar_key) 5887); 5888INSERT IGNORE INTO t1 VALUES 5889(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'), 5890(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'), 5891(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'), 5892(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'), 5893(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'), 5894(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'), 5895(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'), 5896(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'), 5897(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''), 5898(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u'); 5899Warnings: 5900Warning 1264 Out of range value for column 'datetime_key' at row 1 5901Warning 1264 Out of range value for column 'datetime_key' at row 4 5902Warning 1264 Out of range value for column 'datetime_key' at row 7 5903Warning 1264 Out of range value for column 'datetime_key' at row 8 5904Warning 1264 Out of range value for column 'datetime_key' at row 12 5905Warning 1264 Out of range value for column 'datetime_key' at row 17 5906Warning 1264 Out of range value for column 'datetime_key' at row 18 5907Warning 1264 Out of range value for column 'datetime_key' at row 20 5908CREATE TABLE t2 LIKE t1; 5909INSERT INTO t2 VALUES 5910(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'), 5911(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'), 5912(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''), 5913(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'), 5914(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'), 5915(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'), 5916(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''), 5917(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'), 5918(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'), 5919(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x'); 5920Warnings: 5921Warning 1264 Out of range value for column 'datetime_key' at row 3 5922Warning 1264 Out of range value for column 'datetime_key' at row 7 5923Warning 1264 Out of range value for column 'datetime_key' at row 9 5924Warning 1264 Out of range value for column 'datetime_key' at row 10 5925Warning 1264 Out of range value for column 'datetime_key' at row 13 5926Warning 1264 Out of range value for column 'datetime_key' at row 17 5927Warning 1264 Out of range value for column 'datetime_key' at row 19 5928CREATE TABLE t3 LIKE t1; 5929INSERT INTO t3 VALUES 5930(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51',''); 5931SELECT DISTINCT datetime_key FROM t1 5932WHERE (int_nokey, pk) 5933IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key) 5934AND pk = 9; 5935datetime_key 5936DROP TABLE t1, t2, t3; 5937# 5938# Bug#46550 Azalea returning duplicate results for some IN subqueries 5939# w/ semijoin=on 5940# 5941DROP TABLE IF EXISTS t0, t1, t2; 5942CREATE TABLE t0 ( 5943int_key int(11) DEFAULT NULL, 5944varchar_key varchar(1) DEFAULT NULL, 5945varchar_nokey varchar(1) DEFAULT NULL, 5946KEY int_key (int_key), 5947KEY varchar_key (varchar_key,int_key) 5948); 5949INSERT INTO t0 VALUES 5950(1,'m','m'), 5951(40,'h','h'), 5952(1,'r','r'), 5953(1,'h','h'), 5954(9,'x','x'), 5955(NULL,'q','q'), 5956(NULL,'k','k'), 5957(7,'l','l'), 5958(182,'k','k'), 5959(202,'a','a'), 5960(7,'x','x'), 5961(6,'j','j'), 5962(119,'z','z'), 5963(4,'d','d'), 5964(5,'h','h'), 5965(1,'u','u'), 5966(3,'q','q'), 5967(7,'a','a'), 5968(3,'e','e'), 5969(6,'l','l'); 5970CREATE TABLE t1 ( 5971int_key int(11) DEFAULT NULL, 5972varchar_key varchar(1) DEFAULT NULL, 5973varchar_nokey varchar(1) DEFAULT NULL, 5974KEY int_key (int_key), 5975KEY varchar_key (varchar_key,int_key) 5976); 5977INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x'); 5978CREATE TABLE t2 ( 5979int_key int(11) DEFAULT NULL, 5980varchar_key varchar(1) DEFAULT NULL, 5981varchar_nokey varchar(1) DEFAULT NULL, 5982KEY int_key (int_key), 5983KEY varchar_key (varchar_key,int_key) 5984); 5985INSERT INTO t2 VALUES (123,NULL,NULL); 5986SELECT int_key 5987FROM t0 5988WHERE varchar_nokey IN ( 5989SELECT t1 .varchar_key from t1 5990); 5991int_key 59929 59937 5994SELECT t0.int_key 5995FROM t0 5996WHERE t0.varchar_nokey IN ( 5997SELECT t1_1 .varchar_key 5998FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key 5999); 6000int_key 60019 60027 6003EXPLAIN 6004SELECT t0.int_key 6005FROM t0 6006WHERE t0.varchar_nokey IN ( 6007SELECT t1_1 .varchar_key 6008FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key 6009); 6010id select_type table partitions type possible_keys key key_len ref rows filtered Extra 60111 SIMPLE t1_1 NULL index varchar_key varchar_key 9 NULL 2 50.00 Using where; Using index; LooseScan 60121 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) 60131 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (Block Nested Loop) 6014Warnings: 6015Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and `test`.`t1_1`.`int_key`) 6016SELECT t0.int_key 6017FROM t0, t2 6018WHERE t0.varchar_nokey IN ( 6019SELECT t1_1 .varchar_key 6020FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key 6021); 6022int_key 60239 60247 6025EXPLAIN 6026SELECT t0.int_key 6027FROM t0, t2 6028WHERE t0.varchar_nokey IN ( 6029SELECT t1_1 .varchar_key 6030FROM t1 AS t1_1 JOIN t1 AS t1_2 ON t1_1 .int_key 6031); 6032id select_type table partitions type possible_keys key key_len ref rows filtered Extra 60331 SIMPLE t2 NULL system NULL NULL NULL NULL 1 100.00 NULL 60341 SIMPLE t1_1 NULL index varchar_key varchar_key 9 NULL 2 50.00 Using where; Using index; LooseScan 60351 SIMPLE t1_2 NULL index NULL int_key 5 NULL 2 100.00 Using index; FirstMatch(t1_1) 60361 SIMPLE t0 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (Block Nested Loop) 6037Warnings: 6038Note 1003 /* select#1 */ select `test`.`t0`.`int_key` AS `int_key` from `test`.`t0` semi join (`test`.`t1` `t1_1` join `test`.`t1` `t1_2`) where ((`test`.`t0`.`varchar_nokey` = `test`.`t1_1`.`varchar_key`) and `test`.`t1_1`.`int_key`) 6039DROP TABLE t0, t1, t2; 6040# End of bug#46550 6041 6042Bug #48073 Subquery on char columns from view crashes Mysql 6043 6044DROP TABLE IF EXISTS t1, t2; 6045DROP VIEW IF EXISTS v1; 6046CREATE TABLE t1 ( 6047city VARCHAR(50) NOT NULL, 6048country_id SMALLINT UNSIGNED NOT NULL 6049); 6050INSERT INTO t1 VALUES 6051('Batna',2), 6052('Bchar',2), 6053('Skikda',2), 6054('Tafuna',3), 6055('Algeria',2) ; 6056CREATE TABLE t2 ( 6057country_id SMALLINT UNSIGNED NOT NULL, 6058country VARCHAR(50) NOT NULL 6059); 6060INSERT INTO t2 VALUES 6061(2,'Algeria'), 6062(3,'American Samoa') ; 6063CREATE VIEW v1 AS 6064SELECT country_id, country 6065FROM t2 6066WHERE LEFT(country,1) = "A" 6067; 6068SELECT city, country_id 6069FROM t1 6070WHERE city IN ( 6071SELECT country 6072FROM t2 6073WHERE LEFT(country, 1) = "A" 6074); 6075city country_id 6076Algeria 2 6077SELECT city, country_id 6078FROM t1 6079WHERE city IN ( 6080SELECT country 6081FROM v1 6082); 6083city country_id 6084Algeria 2 6085drop table t1, t2; 6086drop view v1; 6087# End of bug#48073 6088 6089Bug#49097 subquery with view generates wrong result with 6090non-prepared statement 6091 6092DROP TABLE IF EXISTS t1, t2; 6093DROP VIEW IF EXISTS v1; 6094CREATE TABLE t1 ( 6095city VARCHAR(50) NOT NULL, 6096country_id SMALLINT UNSIGNED NOT NULL 6097); 6098INSERT INTO t1 VALUES 6099('Batna',2), 6100('Bchar',2), 6101('Skikda',2), 6102('Tafuna',3), 6103('Algeria',2) ; 6104CREATE TABLE t2 ( 6105country_id SMALLINT UNSIGNED NOT NULL, 6106country VARCHAR(50) NOT NULL 6107); 6108INSERT INTO t2 VALUES 6109(2,'Algeria'), 6110(3,'XAmerican Samoa') ; 6111CREATE VIEW v1 AS 6112SELECT country_id, country 6113FROM t2 6114WHERE LEFT(country,1) = "A" 6115; 6116SELECT city, country_id 6117FROM t1 6118WHERE country_id IN ( 6119SELECT country_id 6120FROM t2 6121WHERE LEFT(country,1) = "A" 6122); 6123city country_id 6124Batna 2 6125Bchar 2 6126Skikda 2 6127Algeria 2 6128SELECT city, country_id 6129FROM t1 6130WHERE country_id IN ( 6131SELECT country_id 6132FROM v1 6133); 6134city country_id 6135Batna 2 6136Bchar 2 6137Skikda 2 6138Algeria 2 6139PREPARE stmt FROM 6140" 6141SELECT city, country_id 6142FROM t1 6143WHERE country_id IN ( 6144 SELECT country_id 6145 FROM v1 6146); 6147"; 6148execute stmt; 6149city country_id 6150Batna 2 6151Bchar 2 6152Skikda 2 6153Algeria 2 6154deallocate prepare stmt; 6155drop table t1, t2; 6156drop view v1; 6157# End of Bug#49097 6158# 6159# Bug#49198 Wrong result for second call of procedure 6160# with view in subselect. 6161# 6162CREATE TABLE t1 (t1field integer, primary key (t1field)); 6163CREATE TABLE t2 (t2field integer, primary key (t2field)); 6164CREATE TABLE t3 (t3field integer, primary key (t3field)); 6165CREATE VIEW v2 AS SELECT * FROM t2; 6166CREATE VIEW v3 AS SELECT * FROM t3; 6167INSERT INTO t1 VALUES(1),(2); 6168INSERT INTO t2 VALUES(1),(2); 6169INSERT INTO t3 VALUES(1),(2); 6170PREPARE stmt FROM 6171" 6172SELECT t1field 6173FROM t1 6174WHERE t1field IN (SELECT * FROM v2); 6175"; 6176EXECUTE stmt; 6177t1field 61781 61792 6180EXECUTE stmt; 6181t1field 61821 61832 6184PREPARE stmt FROM 6185" 6186EXPLAIN 6187SELECT t1field 6188FROM t1 6189WHERE t1field IN (SELECT * FROM v2) 6190 AND t1field IN (SELECT * FROM v3) 6191"; 6192EXECUTE stmt; 6193id select_type table partitions type possible_keys key key_len ref rows filtered Extra 61941 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index 61951 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index 61961 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index 6197Warnings: 6198Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t3` join `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) 6199EXECUTE stmt; 6200id select_type table partitions type possible_keys key key_len ref rows filtered Extra 62011 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index 62021 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index 62031 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index 6204Warnings: 6205Note 1003 /* select#1 */ select `test`.`t1`.`t1field` AS `t1field` from `test`.`t3` join `test`.`t2` join `test`.`t1` where ((`test`.`t2`.`t2field` = `test`.`t1`.`t1field`) and (`test`.`t3`.`t3field` = `test`.`t1`.`t1field`)) 6206DROP TABLE t1, t2, t3; 6207DROP VIEW v2, v3; 6208# End of Bug#49198 6209# 6210# Bug#48623 Multiple subqueries are optimized incorrectly 6211# 6212CREATE TABLE ot(val VARCHAR(10)); 6213CREATE TABLE it1(val VARCHAR(10)); 6214CREATE TABLE it2(val VARCHAR(10)); 6215INSERT INTO ot VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); 6216INSERT INTO it1 VALUES('aaa'), ('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); 6217INSERT INTO it2 VALUES('aaa'), ('bbb'), ('eee'), ('mmm'), ('ppp'); 6218EXPLAIN 6219SELECT * 6220FROM ot 6221WHERE ot.val IN (SELECT it1.val FROM it1 6222WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') 6223AND ot.val IN (SELECT it2.val FROM it2 6224WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); 6225id select_type table partitions type possible_keys key key_len ref rows filtered Extra 62261 SIMPLE ot NULL ALL NULL NULL NULL NULL 5 100.00 NULL 62271 SIMPLE it2 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(ot); Using join buffer (Block Nested Loop) 62281 SIMPLE it1 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; FirstMatch(it2); Using join buffer (Block Nested Loop) 6229Warnings: 6230Note 1003 /* select#1 */ select `test`.`ot`.`val` AS `val` from `test`.`ot` semi join (`test`.`it1`) semi join (`test`.`it2`) where ((`test`.`it2`.`val` = `test`.`ot`.`val`) and (`test`.`it1`.`val` = `test`.`ot`.`val`) and ((`test`.`it1`.`val` like 'a%') or (`test`.`it1`.`val` like 'e%')) and ((`test`.`it2`.`val` like 'a%') or (`test`.`it2`.`val` like 'e%'))) 6231SELECT * 6232FROM ot 6233WHERE ot.val IN (SELECT it1.val FROM it1 6234WHERE it1.val LIKE 'a%' OR it1.val LIKE 'e%') 6235AND ot.val IN (SELECT it2.val FROM it2 6236WHERE it2.val LIKE 'a%' OR it2.val LIKE 'e%'); 6237val 6238aaa 6239eee 6240DROP TABLE ot; 6241DROP TABLE it1; 6242DROP TABLE it2; 6243# End of Bug#48623 6244# 6245# Bug #51487 Assertion failure when semi-join flattening occurs 6246# for a subquery in HAVING 6247# 6248CREATE TABLE t1 (a INT, b INT); 6249INSERT INTO t1 VALUES (1,10),(2,11),(1,13); 6250CREATE TABLE t2 AS SELECT * FROM t1; 6251CREATE TABLE t3 AS SELECT * FROM t1; 6252SELECT COUNT(*) FROM t1 6253GROUP BY t1.a 6254HAVING t1.a IN (SELECT t3.a FROM t3 6255WHERE t3.b IN (SELECT b FROM t2 WHERE t2.a=t1.a)); 6256COUNT(*) 62572 62581 6259DROP TABLE t1, t2, t3; 6260# End of Bug#51487 6261# 6262# BUG#38075: Wrong result: rows matching a subquery with outer join not returned 6263# 6264DROP TABLE IF EXISTS ot1, it1, it2; 6265CREATE TABLE it2 ( 6266int_key int(11) NOT NULL, 6267datetime_key datetime NOT NULL, 6268KEY int_key (int_key), 6269KEY datetime_key (datetime_key) 6270); 6271INSERT INTO it2 VALUES 6272(5,'2002-04-10 14:25:30'), (0,'0000-00-00 00:00:00'), 6273(0,'2006-09-14 04:01:02'), (4,'0000-00-00 00:00:00'), 6274(8,'0000-00-00 00:00:00'), (5,'0000-00-00 00:00:00'), 6275(9,'0000-00-00 00:00:00'), (8,'2007-04-01 11:04:17'), 6276(1,'0000-00-00 00:00:00'), (7,'2009-01-12 00:00:00'), 6277(0,'2009-06-05 00:00:00'), (3,'2006-02-14 18:06:35'), 6278(5,'2006-02-21 07:08:16'), (0,'0000-00-00 00:00:00'), 6279(7,'0000-00-00 00:00:00'), (0,'0000-00-00 00:00:00'), 6280(0,'2007-02-13 00:00:00'), (1,'0000-00-00 00:00:00'), 6281(0,'0000-00-00 00:00:00'), (1,'2003-08-11 00:00:00'); 6282Warnings: 6283Warning 1264 Out of range value for column 'datetime_key' at row 2 6284Warning 1264 Out of range value for column 'datetime_key' at row 4 6285Warning 1264 Out of range value for column 'datetime_key' at row 5 6286Warning 1264 Out of range value for column 'datetime_key' at row 6 6287Warning 1264 Out of range value for column 'datetime_key' at row 7 6288Warning 1264 Out of range value for column 'datetime_key' at row 9 6289Warning 1264 Out of range value for column 'datetime_key' at row 14 6290Warning 1264 Out of range value for column 'datetime_key' at row 15 6291Warning 1264 Out of range value for column 'datetime_key' at row 16 6292Warning 1264 Out of range value for column 'datetime_key' at row 18 6293Warning 1264 Out of range value for column 'datetime_key' at row 19 6294CREATE TABLE ot1 ( 6295int_nokey int(11) NOT NULL, 6296int_key int(11) NOT NULL, 6297KEY int_key (int_key) 6298); 6299INSERT INTO ot1 VALUES 6300(5,0), (3,0), (0,2), (3,0), (1,3), (0,0), (1,7), (7,0), (1,7), (0,7), 6301(0,9), (8,2), (4,4), (9,3), (0,9), (2,5), (0,5), (8,0), (5,8), (1,5); 6302CREATE TABLE it1 ( 6303int_nokey int(11) NOT NULL, 6304int_key int(11) NOT NULL, 6305KEY int_key (int_key) 6306); 6307INSERT INTO it1 VALUES 6308(9,5), (0,4); 6309SELECT int_key FROM ot1 6310WHERE int_nokey IN (SELECT it2.int_key 6311FROM it1 LEFT JOIN it2 ON it2.datetime_key); 6312int_key 63130 63140 63150 63160 63170 63180 63192 63202 63213 63225 63235 63247 63257 63267 63278 63289 63299 6330EXPLAIN 6331SELECT int_key FROM ot1 6332WHERE int_nokey IN (SELECT it2.int_key 6333FROM it1 LEFT JOIN it2 ON it2.datetime_key); 6334id select_type table partitions type possible_keys key key_len ref rows filtered Extra 63351 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 100.00 NULL 63361 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (Block Nested Loop) 63372 MATERIALIZED it1 NULL index NULL int_key 4 NULL 2 100.00 Using index 63382 MATERIALIZED it2 NULL ALL int_key NULL NULL NULL 20 90.00 Using where; Using join buffer (Block Nested Loop) 6339Warnings: 6340Note 1003 /* select#1 */ select `test`.`ot1`.`int_key` AS `int_key` from `test`.`ot1` semi join (`test`.`it1` join `test`.`it2`) where ((`test`.`ot1`.`int_nokey` = `<subquery2>`.`int_key`) and `test`.`it2`.`datetime_key`) 6341DROP TABLE ot1, it1, it2; 6342# End of BUG#38075 6343# 6344# BUG#50089: Second call of procedure with view in subselect crashes server 6345# 6346CREATE TABLE t1(t1field INTEGER, PRIMARY KEY(t1field)); 6347CREATE VIEW v1 AS 6348SELECT t1field AS v1field 6349FROM t1 a 6350WHERE a.t1field IN (SELECT t1field FROM t1); 6351INSERT INTO t1 VALUES(1),(2); 6352SELECT t1field 6353FROM t1 6354WHERE t1field IN (SELECT v1field FROM v1); 6355t1field 63561 63572 6358EXPLAIN 6359SELECT t1field 6360FROM t1 6361WHERE t1field IN (SELECT v1field FROM v1); 6362id select_type table partitions type possible_keys key key_len ref rows filtered Extra 63631 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index 63641 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index 63651 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index 6366Warnings: 6367Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` join `test`.`t1` `a` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) 6368SELECT t1.t1field 6369FROM t1 LEFT JOIN t1 AS t2 ON t1.t1field IN (SELECT v1field FROM v1); 6370t1field 63711 63721 63732 63742 6375EXPLAIN 6376SELECT t1field 6377FROM t1 6378WHERE t1field IN (SELECT v1field FROM v1); 6379id select_type table partitions type possible_keys key key_len ref rows filtered Extra 63801 SIMPLE t1 NULL index PRIMARY PRIMARY 4 NULL 2 100.00 Using index 63811 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index 63821 SIMPLE t1 NULL eq_ref PRIMARY PRIMARY 4 test.t1.t1field 1 100.00 Using index 6383Warnings: 6384Note 1003 /* select#1 */ select `t1`.`t1field` AS `t1field` from `test`.`t1` join `test`.`t1` `a` join `test`.`t1` where ((`test`.`a`.`t1field` = `t1`.`t1field`) and (`test`.`t1`.`t1field` = `t1`.`t1field`)) 6385CREATE PROCEDURE p1() 6386BEGIN 6387SELECT t1field 6388FROM t1 6389WHERE t1field IN (SELECT v1field FROM v1); 6390END| 6391CALL p1; 6392t1field 63931 63942 6395CALL p1; 6396t1field 63971 63982 6399PREPARE stmt FROM 6400" 6401SELECT t1field 6402FROM t1 6403WHERE t1field IN (SELECT v1field FROM v1); 6404"; 6405EXECUTE stmt; 6406t1field 64071 64082 6409EXECUTE stmt; 6410t1field 64111 64122 6413DROP PROCEDURE p1; 6414DROP VIEW v1; 6415DROP TABLE t1; 6416# End of BUG#50089 6417# 6418# Bug#45191: Incorrectly initialized semi-join led to a wrong result. 6419# 6420CREATE TABLE staff (EMPNUM CHAR(3) NOT NULL, 6421EMPNAME CHAR(20), GRADE DECIMAL(4), CITY CHAR(15)); 6422CREATE TABLE proj (PNUM CHAR(3) NOT NULL, 6423PNAME CHAR(20), PTYPE CHAR(6), 6424BUDGET DECIMAL(9), 6425CITY CHAR(15)); 6426CREATE TABLE works (EMPNUM CHAR(3) NOT NULL, 6427PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)); 6428INSERT INTO staff VALUES ('E1','Alice',12,'Deale'); 6429INSERT INTO staff VALUES ('E2','Betty',10,'Vienna'); 6430INSERT INTO staff VALUES ('E3','Carmen',13,'Vienna'); 6431INSERT INTO staff VALUES ('E4','Don',12,'Deale'); 6432INSERT INTO staff VALUES ('E5','Ed',13,'Akron'); 6433INSERT INTO proj VALUES ('P1','MXSS','Design',10000,'Deale'); 6434INSERT INTO proj VALUES ('P2','CALM','Code',30000,'Vienna'); 6435INSERT INTO proj VALUES ('P3','SDP','Test',30000,'Tampa'); 6436INSERT INTO proj VALUES ('P4','SDP','Design',20000,'Deale'); 6437INSERT INTO proj VALUES ('P5','IRM','Test',10000,'Vienna'); 6438INSERT INTO proj VALUES ('P6','PAYR','Design',50000,'Deale'); 6439INSERT INTO works VALUES ('E1','P1',40); 6440INSERT INTO works VALUES ('E1','P2',20); 6441INSERT INTO works VALUES ('E1','P3',80); 6442INSERT INTO works VALUES ('E1','P4',20); 6443INSERT INTO works VALUES ('E1','P5',12); 6444INSERT INTO works VALUES ('E1','P6',12); 6445INSERT INTO works VALUES ('E2','P1',40); 6446INSERT INTO works VALUES ('E2','P2',80); 6447INSERT INTO works VALUES ('E3','P2',20); 6448INSERT INTO works VALUES ('E4','P2',20); 6449INSERT INTO works VALUES ('E4','P4',40); 6450INSERT INTO works VALUES ('E4','P5',80); 6451explain SELECT EMPNUM, EMPNAME 6452FROM staff 6453WHERE EMPNUM IN 6454(SELECT EMPNUM FROM works 6455WHERE PNUM IN 6456(SELECT PNUM FROM proj)); 6457id select_type table partitions type possible_keys key key_len ref rows filtered Extra 64581 SIMPLE staff NULL ALL NULL NULL NULL NULL 5 100.00 Using where 64591 SIMPLE <subquery2> NULL eq_ref <auto_key> <auto_key> 3 test.staff.EMPNUM 1 100.00 NULL 64602 MATERIALIZED proj NULL ALL NULL NULL NULL NULL 6 100.00 NULL 64612 MATERIALIZED works NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (Block Nested Loop) 6462Warnings: 6463Note 1003 /* select#1 */ select `test`.`staff`.`EMPNUM` AS `EMPNUM`,`test`.`staff`.`EMPNAME` AS `EMPNAME` from `test`.`staff` semi join (`test`.`proj` join `test`.`works`) where ((`<subquery2>`.`EMPNUM` = `test`.`staff`.`EMPNUM`) and (`test`.`works`.`PNUM` = `test`.`proj`.`PNUM`)) 6464SELECT EMPNUM, EMPNAME 6465FROM staff 6466WHERE EMPNUM IN 6467(SELECT EMPNUM FROM works 6468WHERE PNUM IN 6469(SELECT PNUM FROM proj)); 6470EMPNUM EMPNAME 6471E1 Alice 6472E2 Betty 6473E3 Carmen 6474E4 Don 6475drop table staff,works,proj; 6476# End of bug#45191 6477# 6478# BUG#36896: Server crash on SELECT FROM DUAL 6479# 6480create table t1 (a int); 6481select 1 as res from dual where (1) in (select * from t1); 6482res 6483drop table t1; 6484 6485BUG#40118 Crash when running Batched Key Access and requiring one match for each key 6486 6487create table t0(a int); 6488insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 6489create table t1 (a int, key(a)); 6490insert into t1 select * from t0; 6491alter table t1 add b int not null, add filler char(200); 6492insert into t1 select * from t1; 6493insert into t1 select * from t1; 6494select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); 6495a 64960 64971 64982 64993 65004 65015 65026 65037 65048 65059 6506drop table t0, t1; 6507# 6508# BUG#32665 Query with dependent subquery is too slow 6509# 6510create table t1 ( 6511idIndividual int primary key 6512); 6513insert into t1 values (1),(2); 6514create table t2 ( 6515idContact int primary key, 6516contactType int, 6517idObj int 6518); 6519insert into t2 values (1,1,1),(2,2,2),(3,3,3); 6520create table t3 ( 6521idAddress int primary key, 6522idContact int, 6523postalStripped varchar(100) 6524); 6525insert into t3 values (1,1, 'foo'), (2,2,'bar'); 6526The following must be converted to a semi-join: 6527explain extended SELECT a.idIndividual FROM t1 a 6528WHERE a.idIndividual IN 6529( SELECT c.idObj FROM t3 cona 6530INNER JOIN t2 c ON c.idContact=cona.idContact 6531WHERE cona.postalStripped='T2H3B2' 6532 ); 6533id select_type table partitions type possible_keys key key_len ref rows filtered Extra 65341 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 100.00 Using where 65351 SIMPLE a NULL eq_ref PRIMARY PRIMARY 4 <subquery2>.idObj 1 100.00 Using index 65362 MATERIALIZED cona NULL ALL NULL NULL NULL NULL 2 50.00 Using where 65372 MATERIALIZED c NULL eq_ref PRIMARY PRIMARY 4 test.cona.idContact 1 100.00 Using join buffer (Batched Key Access) 6538Warnings: 6539Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 6540Note 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')) 6541drop table t1,t2,t3; 6542CREATE TABLE t1 (one int, two int, flag char(1)); 6543CREATE TABLE t2 (one int, two int, flag char(1)); 6544INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); 6545INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); 6546SELECT * FROM t1 6547WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); 6548one two flag 65495 6 N 65507 8 N 6551SELECT * FROM t1 6552WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); 6553one two flag 65545 6 N 65557 8 N 6556insert into t2 values (null,null,'N'); 6557insert into t2 values (null,3,'0'); 6558insert into t2 values (null,5,'0'); 6559insert into t2 values (10,null,'0'); 6560insert into t1 values (10,3,'0'); 6561insert into t1 values (10,5,'0'); 6562insert into t1 values (10,10,'0'); 6563SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; 6564one two test 65651 2 NULL 65662 3 NULL 65673 4 NULL 65685 6 1 65697 8 1 657010 3 NULL 657110 5 NULL 657210 10 NULL 6573SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); 6574one two 65755 6 65767 8 6577SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; 6578one two test 65791 2 NULL 65802 3 NULL 65813 4 NULL 65825 6 1 65837 8 1 658410 3 NULL 658510 5 NULL 658610 10 NULL 6587SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; 6588one two test 65891 2 0 65902 3 NULL 65913 4 0 65925 6 0 65937 8 0 659410 3 NULL 659510 5 NULL 659610 10 NULL 6597SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; 6598one two test 65991 2 0 66002 3 NULL 66013 4 0 66025 6 0 66037 8 0 660410 3 NULL 660510 5 NULL 660610 10 NULL 6607explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; 6608id select_type table partitions type possible_keys key key_len ref rows filtered Extra 66091 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL 66102 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where 6611Warnings: 6612Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 6613Note 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` 6614explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); 6615id select_type table partitions type possible_keys key key_len ref rows filtered Extra 66161 SIMPLE t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL 66171 SIMPLE t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where; FirstMatch(t1); Using join buffer (Block Nested Loop) 6618Warnings: 6619Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 6620Note 1003 /* select#1 */ select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`two` = `test`.`t1`.`two`) and (`test`.`t2`.`one` = `test`.`t1`.`one`) and (`test`.`t2`.`flag` = 'N')) 6621explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; 6622id select_type table partitions type possible_keys key key_len ref rows filtered Extra 66231 PRIMARY t1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL 66242 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 9 11.11 Using where 6625Warnings: 6626Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 6627Note 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` 6628DROP TABLE t1,t2; 6629CREATE TABLE t1 (a char(5), b char(5)); 6630INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); 6631SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); 6632a b 6633aaa aaa 6634DROP TABLE t1; 6635CREATE TABLE t1 (a CHAR(1), b VARCHAR(10)); 6636INSERT INTO t1 VALUES ('a', 'aa'); 6637INSERT INTO t1 VALUES ('a', 'aaa'); 6638SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); 6639a b 6640CREATE INDEX I1 ON t1 (a); 6641CREATE INDEX I2 ON t1 (b); 6642EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); 6643id select_type table partitions type possible_keys key key_len ref rows filtered Extra 66441 SIMPLE t1 NULL index I1 I1 2 NULL 2 100.00 Using index; LooseScan 66451 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 6646Warnings: 6647Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where (`test`.`t1`.`b` = `test`.`t1`.`a`) 6648SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1); 6649a b 6650CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10)); 6651INSERT INTO t2 SELECT * FROM t1; 6652CREATE INDEX I1 ON t2 (a); 6653CREATE INDEX I2 ON t2 (b); 6654EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); 6655id select_type table partitions type possible_keys key key_len ref rows filtered Extra 66561 SIMPLE t2 NULL index I1 I1 4 NULL 2 100.00 Using index; LooseScan 66571 SIMPLE t2 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 6658Warnings: 6659Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t2`) where (`test`.`t2`.`b` = `test`.`t2`.`a`) 6660SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2); 6661a b 6662EXPLAIN 6663SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); 6664id select_type table partitions type possible_keys key key_len ref rows filtered Extra 66651 SIMPLE t1 NULL index I1 I1 2 NULL 2 100.00 Using where; Using index; LooseScan 66661 SIMPLE t1 NULL ALL I2 NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 6667Warnings: 6668Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t1`) where ((length(`test`.`t1`.`a`) < 500) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) 6669SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500); 6670a b 6671DROP TABLE t1,t2; 6672# 6673# BUG#45928 "Differing query results depending on MRR and 6674# engine_condition_pushdown settings" 6675# 6676CREATE TABLE `t1` ( 6677`pk` int(11) NOT NULL AUTO_INCREMENT, 6678`time_nokey` time NOT NULL, 6679`varchar_key` varchar(1) NOT NULL, 6680`varchar_nokey` varchar(1) NOT NULL, 6681PRIMARY KEY (`pk`), 6682KEY `varchar_key` (`varchar_key`) 6683) AUTO_INCREMENT=12 DEFAULT CHARSET=latin1; 6684INSERT INTO `t1` VALUES (10,'00:00:00','i','i'),(11,'00:00:00','',''); 6685SELECT `time_nokey` G1 FROM t1 WHERE ( `varchar_nokey` , `varchar_key` ) IN ( 6686SELECT `varchar_nokey` , `varchar_nokey` ) AND `varchar_key` >= 'c' HAVING G1 ORDER 6687BY `pk` ; 6688G1 6689DROP TABLE t1; 6690# 6691# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(), 6692# file item.cc, line 4448" 6693# 6694DROP TABLE IF EXISTS C, BB; 6695CREATE TABLE C ( 6696varchar_nokey varchar(1) NOT NULL 6697); 6698INSERT INTO C VALUES 6699('k'),('a'),(''),('u'),('e'),('v'),('i'), 6700('t'),('u'),('f'),('u'),('m'),('j'),('f'), 6701('v'),('j'),('g'),('e'),('h'),('z'); 6702CREATE TABLE BB ( 6703varchar_nokey varchar(1) NOT NULL 6704); 6705INSERT INTO BB VALUES ('i'),('t'); 6706SELECT varchar_nokey FROM C 6707WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey 6708FROM BB); 6709ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' 6710SELECT varchar_nokey FROM C 6711WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey 6712FROM BB); 6713ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery' 6714DROP TABLE C,BB; 6715# 6716# During work with BUG#45863 I had problems with a query that was 6717# optimized differently in regular and prepared mode. 6718# Because there was a bug in one of the selected strategies, I became 6719# aware of the problem. Adding an EXPLAIN query to catch this. 6720DROP TABLE IF EXISTS t1, t2, t3; 6721CREATE TABLE t1 6722(EMPNUM CHAR(3) NOT NULL, 6723EMPNAME CHAR(20), 6724GRADE DECIMAL(4), 6725CITY CHAR(15)); 6726CREATE TABLE t2 6727(PNUM CHAR(3) NOT NULL, 6728PNAME CHAR(20), 6729PTYPE CHAR(6), 6730BUDGET DECIMAL(9), 6731CITY CHAR(15)); 6732CREATE TABLE t3 6733(EMPNUM CHAR(3) NOT NULL, 6734PNUM CHAR(3) NOT NULL, 6735HOURS DECIMAL(5)); 6736INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); 6737INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); 6738INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); 6739INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); 6740INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); 6741INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); 6742INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); 6743INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); 6744INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); 6745INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); 6746INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); 6747INSERT INTO t3 VALUES ('E1','P1',40); 6748INSERT INTO t3 VALUES ('E1','P2',20); 6749INSERT INTO t3 VALUES ('E1','P3',80); 6750INSERT INTO t3 VALUES ('E1','P4',20); 6751INSERT INTO t3 VALUES ('E1','P5',12); 6752INSERT INTO t3 VALUES ('E1','P6',12); 6753INSERT INTO t3 VALUES ('E2','P1',40); 6754INSERT INTO t3 VALUES ('E2','P2',80); 6755INSERT INTO t3 VALUES ('E3','P2',20); 6756INSERT INTO t3 VALUES ('E4','P2',20); 6757INSERT INTO t3 VALUES ('E4','P4',40); 6758INSERT INTO t3 VALUES ('E4','P5',80); 6759CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); 6760EXPLAIN SELECT EMPNAME 6761FROM t1 6762WHERE EMPNUM IN 6763(SELECT EMPNUM 6764FROM t3 6765WHERE PNUM IN 6766(SELECT PNUM 6767FROM t2 6768WHERE PTYPE = 'Design')); 6769id select_type table partitions type possible_keys key key_len ref rows filtered Extra 67701 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary 67711 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (Block Nested Loop) 67721 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary; Using join buffer (Batched Key Access) 6773Warnings: 6774Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) 6775PREPARE stmt FROM "EXPLAIN SELECT EMPNAME 6776FROM t1 6777WHERE EMPNUM IN 6778 (SELECT EMPNUM 6779 FROM t3 6780 WHERE PNUM IN 6781 (SELECT PNUM 6782 FROM t2 6783 WHERE PTYPE = 'Design'))"; 6784EXECUTE stmt; 6785id select_type table partitions type possible_keys key key_len ref rows filtered Extra 67861 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary 67871 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (Block Nested Loop) 67881 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary; Using join buffer (Batched Key Access) 6789Warnings: 6790Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) 6791EXECUTE stmt; 6792id select_type table partitions type possible_keys key key_len ref rows filtered Extra 67931 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary 67941 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (Block Nested Loop) 67951 SIMPLE t1 NULL eq_ref t1_IDX t1_IDX 3 test.t3.EMPNUM 1 100.00 End temporary; Using join buffer (Batched Key Access) 6796Warnings: 6797Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) 6798DEALLOCATE PREPARE stmt; 6799DROP INDEX t1_IDX ON t1; 6800CREATE INDEX t1_IDX ON t1(EMPNUM); 6801EXPLAIN SELECT EMPNAME 6802FROM t1 6803WHERE EMPNUM IN 6804(SELECT EMPNUM 6805FROM t3 6806WHERE PNUM IN 6807(SELECT PNUM 6808FROM t2 6809WHERE PTYPE = 'Design')); 6810id select_type table partitions type possible_keys key key_len ref rows filtered Extra 68111 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 100.00 NULL 68121 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 <subquery2>.EMPNUM 2 100.00 Using join buffer (Batched Key Access) 68132 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where 68142 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (Block Nested Loop) 6815Warnings: 6816Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`EMPNUM` = `<subquery2>`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) 6817PREPARE stmt FROM "EXPLAIN SELECT EMPNAME 6818FROM t1 6819WHERE EMPNUM IN 6820 (SELECT EMPNUM 6821 FROM t3 6822 WHERE PNUM IN 6823 (SELECT PNUM 6824 FROM t2 6825 WHERE PTYPE = 'Design'))"; 6826EXECUTE stmt; 6827id select_type table partitions type possible_keys key key_len ref rows filtered Extra 68281 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 100.00 NULL 68291 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 <subquery2>.EMPNUM 2 100.00 Using join buffer (Batched Key Access) 68302 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where 68312 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (Block Nested Loop) 6832Warnings: 6833Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`EMPNUM` = `<subquery2>`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) 6834EXECUTE stmt; 6835id select_type table partitions type possible_keys key key_len ref rows filtered Extra 68361 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 100.00 NULL 68371 SIMPLE t1 NULL ref t1_IDX t1_IDX 3 <subquery2>.EMPNUM 2 100.00 Using join buffer (Batched Key Access) 68382 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where 68392 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (Block Nested Loop) 6840Warnings: 6841Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`EMPNUM` = `<subquery2>`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) 6842DEALLOCATE PREPARE stmt; 6843DROP INDEX t1_IDX ON t1; 6844EXPLAIN SELECT EMPNAME 6845FROM t1 6846WHERE EMPNUM IN 6847(SELECT EMPNUM 6848FROM t3 6849WHERE PNUM IN 6850(SELECT PNUM 6851FROM t2 6852WHERE PTYPE = 'Design')); 6853id select_type table partitions type possible_keys key key_len ref rows filtered Extra 68541 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary 68551 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (Block Nested Loop) 68561 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (Block Nested Loop) 6857Warnings: 6858Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) 6859PREPARE stmt FROM "EXPLAIN SELECT EMPNAME 6860FROM t1 6861WHERE EMPNUM IN 6862 (SELECT EMPNUM 6863 FROM t3 6864 WHERE PNUM IN 6865 (SELECT PNUM 6866 FROM t2 6867 WHERE PTYPE = 'Design'))"; 6868EXECUTE stmt; 6869id select_type table partitions type possible_keys key key_len ref rows filtered Extra 68701 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary 68711 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (Block Nested Loop) 68721 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (Block Nested Loop) 6873Warnings: 6874Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) 6875EXECUTE stmt; 6876id select_type table partitions type possible_keys key key_len ref rows filtered Extra 68771 SIMPLE t2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Start temporary 68781 SIMPLE t3 NULL ALL NULL NULL NULL NULL 12 10.00 Using where; Using join buffer (Block Nested Loop) 68791 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; End temporary; Using join buffer (Block Nested Loop) 6880Warnings: 6881Note 1003 /* select#1 */ select `test`.`t1`.`EMPNAME` AS `EMPNAME` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t1`.`EMPNUM` = `test`.`t3`.`EMPNUM`) and (`test`.`t3`.`PNUM` = `test`.`t2`.`PNUM`) and (`test`.`t2`.`PTYPE` = 'Design')) 6882DEALLOCATE PREPARE stmt; 6883DROP TABLE t1, t2, t3; 6884# 6885# BUG#45221 Query SELECT pk FROM C WHERE pk IN (SELECT int_key) failing 6886# 6887CREATE TABLE t1 ( 6888i1_key INT, 6889i2 INT, 6890i3 INT, 6891KEY i1_index (i1_key) 6892); 6893INSERT INTO t1 VALUES (9,1,2), (9,2,1); 6894CREATE TABLE t2 ( 6895pk INT NOT NULL, 6896i1 INT, 6897PRIMARY KEY (pk) 6898); 6899INSERT INTO t2 VALUES (9,1); 6900SELECT pk 6901FROM t2 6902WHERE 6903pk IN ( 6904SELECT i1_key 6905FROM t1 6906WHERE t1.i2 < t1.i3 XOR t2.i1 > 1 6907ORDER BY t1.i2 desc); 6908pk 69099 6910DROP TABLE t1,t2; 6911# BUG#50361 Doublenested noncorrelated subquery with FirstMatch and join cache wrong result 6912# 6913CREATE TABLE t1( 6914id INTEGER 6915); 6916INSERT INTO t1 VALUES(10),(20); 6917create table t2 select * from t1; 6918create table t3 select * from t1; 6919SELECT * 6920FROM t1 6921WHERE 1 IN(SELECT 1 6922FROM t2 6923WHERE 1 IN(SELECT 1 6924FROM t3)); 6925id 692610 692720 6928explain extended SELECT * 6929FROM t1 6930WHERE 1 IN(SELECT 1 6931FROM t2 6932WHERE 1 IN(SELECT 1 6933FROM t3)); 6934id select_type table partitions type possible_keys key key_len ref rows filtered Extra 69351 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 69361 SIMPLE <subquery2> NULL const <auto_key> <auto_key> 4 const 1 100.00 NULL 69372 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 69382 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop) 6939Warnings: 6940Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 6941Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t3` join `test`.`t2`) where 1 6942delete from t2; 6943delete from t3; 6944INSERT INTO t1 VALUES(30),(40),(50),(60),(70),(80),(90); 6945insert into t2 select * from t1; 6946insert into t3 select * from t1; 6947create table t4 select * from t1; 6948SELECT * 6949FROM t1 6950WHERE 1 IN(SELECT 1 6951FROM t2 6952WHERE 1 IN(SELECT 1 6953FROM t3 6954WHERE 1 IN(SELECT 1 6955FROM t4))); 6956id 695710 695820 695930 696040 696150 696260 696370 696480 696590 6966explain SELECT * 6967FROM t1 6968WHERE 1 IN(SELECT 1 6969FROM t2 6970WHERE 1 IN(SELECT 1 6971FROM t3 6972WHERE 1 IN(SELECT 1 6973FROM t4))); 6974id select_type table partitions type possible_keys key key_len ref rows filtered Extra 69751 SIMPLE t1 NULL ALL NULL NULL NULL NULL 9 100.00 NULL 69761 SIMPLE <subquery2> NULL const <auto_key> <auto_key> 4 const 1 100.00 NULL 69772 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 9 100.00 NULL 69782 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (Block Nested Loop) 69792 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 9 100.00 Using join buffer (Block Nested Loop) 6980Warnings: 6981Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id` from `test`.`t1` semi join (`test`.`t4` join `test`.`t3` join `test`.`t2`) where 1 6982SELECT * 6983FROM t1 6984WHERE 1 IN(SELECT 1 6985FROM t1 6986WHERE 1 IN(SELECT 1 6987FROM t1 6988WHERE 1 IN(SELECT 1 6989FROM t1))); 6990id 699110 699220 699330 699440 699550 699660 699770 699880 699990 7000drop table t1,t2,t3,t4; 7001# 7002# Bug#53236 Segfault in DTCollation::set(DTCollation&) 7003# 7004CREATE TABLE t1 ( 7005pk INTEGER AUTO_INCREMENT, 7006col_varchar VARCHAR(1), 7007PRIMARY KEY (pk) 7008) 7009; 7010INSERT INTO t1 (col_varchar) 7011VALUES 7012('w'), 7013('m') 7014; 7015SELECT table1.pk 7016FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar = 7017table2.col_varchar) ) 7018WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1, 7019SUBQUERY1_t1.pk AS SUBQUERY1_field2 7020FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2 7021ON (SUBQUERY1_t2.col_varchar = 7022SUBQUERY1_t1.col_varchar) ) ) 7023; 7024pk 7025drop table t1; 7026# 7027# BUG#53298 "wrong result with semijoin (no semijoin strategy chosen)" 7028# 7029create table t1 (uid int, fid int); 7030insert into t1 values (1,1), (3,1); 7031create table t2 (uid int, name varchar(128)); 7032insert into t2 values (1, "A"), (2, "B"); 7033create table t3 (uid int, fid int, index(uid)); 7034insert into t3 values (1,3), (1,3); 7035create table t4 (uid int); 7036insert into t4 values (3); 7037explain select t2.uid from t2, t1 7038where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) 7039and t2.uid=t1.fid; 7040id select_type table partitions type possible_keys key key_len ref rows filtered Extra 70411 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 0.00 NULL 70421 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop) 70431 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 70442 MATERIALIZED t4 NULL ALL NULL NULL NULL NULL 1 100.00 NULL 70452 MATERIALIZED t3 NULL ref uid uid 5 const 1 50.00 Using where; Using join buffer (Batched Key Access) 7046Warnings: 7047Note 1003 /* select#1 */ select `test`.`t2`.`uid` AS `uid` from `test`.`t2` semi join (`test`.`t4` join `test`.`t3`) join `test`.`t1` where ((`test`.`t1`.`uid` = `<subquery2>`.`uid`) and (`test`.`t3`.`fid` = `test`.`t4`.`uid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t1`.`fid` = `test`.`t2`.`uid`)) 7048select t2.uid from t2, t1 7049where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) 7050and t2.uid=t1.fid; 7051uid 70521 7053drop table t1,t2,t3,t4; 7054CREATE TABLE t1 ( 7055pk int, 7056a varchar(1), 7057b varchar(4), 7058c varchar(4), 7059d varchar(4), 7060PRIMARY KEY (pk) 7061); 7062INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); 7063CREATE TABLE t2 LIKE t1; 7064INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); 7065EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); 7066id select_type table partitions type possible_keys key key_len ref rows filtered Extra 70671 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where 70681 SIMPLE <subquery2> NULL eq_ref <auto_key> <auto_key> 4 test.t1.a 1 100.00 NULL 70692 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using MRR 7070Warnings: 7071Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`<subquery2>`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) 7072SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); 7073pk 70742 7075SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); 7076pk 70772 7078DROP TABLE t1, t2; 7079CREATE TABLE t1 (f1 INT, f2 DECIMAL(5,3)) ENGINE=MyISAM; 7080INSERT INTO t1 (f1, f2) VALUES (1, 1.789); 7081INSERT INTO t1 (f1, f2) VALUES (13, 1.454); 7082INSERT INTO t1 (f1, f2) VALUES (10, 1.668); 7083CREATE TABLE t2 LIKE t1; 7084INSERT INTO t2 VALUES (1, 1.789); 7085INSERT INTO t2 VALUES (13, 1.454); 7086EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); 7087id select_type table partitions type possible_keys key key_len ref rows filtered Extra 70881 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary 70891 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; End temporary; Using join buffer (Block Nested Loop) 7090Warnings: 7091Note 1003 /* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`f2` = `test`.`t2`.`f2`) and (`test`.`t1`.`f1` = `test`.`t2`.`f1`)) 7092SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); 7093COUNT(*) 70942 7095DROP TABLE t1, t2; 7096CREATE TABLE t1 ( 7097ID int(11) NOT NULL auto_increment, 7098Name char(35) NOT NULL default '', 7099Country char(3) NOT NULL default '', 7100Population int(11) NOT NULL default '0', 7101PRIMARY KEY (ID), 7102INDEX (Population), 7103INDEX (Country) 7104); 7105CREATE TABLE t2 ( 7106Code char(3) NOT NULL default '', 7107Name char(52) NOT NULL default '', 7108SurfaceArea float(10,2) NOT NULL default '0.00', 7109Population int(11) NOT NULL default '0', 7110Capital int(11) default NULL, 7111PRIMARY KEY (Code), 7112UNIQUE INDEX (Name), 7113INDEX (Population) 7114); 7115CREATE TABLE t3 ( 7116Country char(3) NOT NULL default '', 7117Language char(30) NOT NULL default '', 7118Percentage float(3,1) NOT NULL default '0.0', 7119PRIMARY KEY (Country, Language), 7120INDEX (Percentage) 7121); 7122EXPLAIN SELECT Name FROM t2 7123WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) 7124AND 7125t2.Code IN (SELECT Country FROM t3 7126WHERE Language='English' AND Percentage > 10 AND 7127t2.Population > 100000); 7128id select_type table partitions type possible_keys key key_len ref rows filtered Extra 71291 SIMPLE t1 NULL range Population,Country Population 4 NULL 1 100.00 Using index condition; Using MRR; Start temporary 71301 SIMPLE t2 NULL eq_ref PRIMARY,Population PRIMARY 3 test.t1.Country 1 75.00 Using where; Using join buffer (Batched Key Access) 71311 SIMPLE t3 NULL eq_ref PRIMARY,Percentage PRIMARY 33 test.t1.Country,const 1 95.45 Using where; End temporary; Using join buffer (Batched Key Access) 7132Warnings: 7133Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 7134Note 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)) 7135EXPLAIN FORMAT=JSON SELECT Name FROM t2 7136WHERE t2.Code IN (SELECT Country FROM t1 WHERE Population > 5000000) 7137AND 7138t2.Code IN (SELECT Country FROM t3 7139WHERE Language='English' AND Percentage > 10 AND 7140t2.Population > 100000); 7141EXPLAIN 7142{ 7143 "query_block": { 7144 "select_id": 1, 7145 "cost_info": { 7146 "query_cost": "6.79" 7147 }, 7148 "duplicates_removal": { 7149 "using_temporary_table": true, 7150 "nested_loop": [ 7151 { 7152 "table": { 7153 "table_name": "t1", 7154 "access_type": "range", 7155 "possible_keys": [ 7156 "Population", 7157 "Country" 7158 ], 7159 "key": "Population", 7160 "used_key_parts": [ 7161 "Population" 7162 ], 7163 "key_length": "4", 7164 "rows_examined_per_scan": 1, 7165 "rows_produced_per_join": 1, 7166 "filtered": "100.00", 7167 "index_condition": "(`test`.`t1`.`Population` > 5000000)", 7168 "using_MRR": true, 7169 "cost_info": { 7170 "read_cost": "2.20", 7171 "eval_cost": "0.20", 7172 "prefix_cost": "2.40", 7173 "data_read_per_join": "48" 7174 }, 7175 "used_columns": [ 7176 "Country", 7177 "Population" 7178 ] 7179 } 7180 }, 7181 { 7182 "table": { 7183 "table_name": "t2", 7184 "access_type": "eq_ref", 7185 "possible_keys": [ 7186 "PRIMARY", 7187 "Population" 7188 ], 7189 "key": "PRIMARY", 7190 "used_key_parts": [ 7191 "Code" 7192 ], 7193 "key_length": "3", 7194 "ref": [ 7195 "test.t1.Country" 7196 ], 7197 "rows_examined_per_scan": 1, 7198 "rows_produced_per_join": 0, 7199 "filtered": "75.00", 7200 "using_join_buffer": "Batched Key Access", 7201 "cost_info": { 7202 "read_cost": "1.00", 7203 "eval_cost": "0.15", 7204 "prefix_cost": "5.90", 7205 "data_read_per_join": "54" 7206 }, 7207 "used_columns": [ 7208 "Code", 7209 "Name", 7210 "Population" 7211 ], 7212 "attached_condition": "(`test`.`t2`.`Population` > 100000)" 7213 } 7214 }, 7215 { 7216 "table": { 7217 "table_name": "t3", 7218 "access_type": "eq_ref", 7219 "possible_keys": [ 7220 "PRIMARY", 7221 "Percentage" 7222 ], 7223 "key": "PRIMARY", 7224 "used_key_parts": [ 7225 "Country", 7226 "Language" 7227 ], 7228 "key_length": "33", 7229 "ref": [ 7230 "test.t1.Country", 7231 "const" 7232 ], 7233 "rows_examined_per_scan": 1, 7234 "rows_produced_per_join": 0, 7235 "filtered": "95.45", 7236 "using_join_buffer": "Batched Key Access", 7237 "cost_info": { 7238 "read_cost": "0.75", 7239 "eval_cost": "0.14", 7240 "prefix_cost": "6.79", 7241 "data_read_per_join": "28" 7242 }, 7243 "used_columns": [ 7244 "Country", 7245 "Language", 7246 "Percentage" 7247 ], 7248 "attached_condition": "(`test`.`t3`.`Percentage` > 10)" 7249 } 7250 } 7251 ] 7252 } 7253 } 7254} 7255Warnings: 7256Note 1276 Field or reference 'test.t2.Population' of SELECT #3 was resolved in SELECT #1 7257Note 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)) 7258DROP TABLE t1,t2,t3; 7259CREATE TABLE t1 ( 7260Code char(3) NOT NULL DEFAULT '', 7261Name char(52) NOT NULL DEFAULT '', 7262Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia', 7263Region char(26) NOT NULL DEFAULT '', 7264SurfaceArea float(10,2) NOT NULL DEFAULT '0.00', 7265IndepYear smallint(6) DEFAULT NULL, 7266Population int(11) NOT NULL DEFAULT '0', 7267LifeExpectancy float(3,1) DEFAULT NULL, 7268GNP float(10,2) DEFAULT NULL, 7269GNPOld float(10,2) DEFAULT NULL, 7270LocalName char(45) NOT NULL DEFAULT '', 7271GovernmentForm char(45) NOT NULL DEFAULT '', 7272HeadOfState char(60) DEFAULT NULL, 7273Capital int(11) DEFAULT NULL, 7274Code2 char(2) NOT NULL DEFAULT '', 7275PRIMARY KEY (Code) 7276); 7277CREATE TABLE t2 ( 7278ID int(11) NOT NULL AUTO_INCREMENT, 7279Name char(35) NOT NULL DEFAULT '', 7280CountryCode char(3) NOT NULL DEFAULT '', 7281District char(20) NOT NULL DEFAULT '', 7282Population int(11) NOT NULL DEFAULT '0', 7283PRIMARY KEY (ID), 7284KEY CountryCode (CountryCode) 7285); 7286Fill the table with test data 7287This must not use LooseScan: 7288EXPLAIN SELECT Name FROM t1 7289WHERE t1.Code IN ( 7290SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); 7291id select_type table partitions type possible_keys key key_len ref rows filtered Extra 72921 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 31 100.00 Using where 72931 SIMPLE <subquery2> NULL eq_ref <auto_key> <auto_key> 3 test.t1.Code 1 100.00 NULL 72942 MATERIALIZED t2 NULL ALL CountryCode NULL NULL NULL 545 33.33 Using where 7295Warnings: 7296Note 1003 /* select#1 */ select `test`.`t1`.`Name` AS `Name` from `test`.`t1` semi join (`test`.`t2`) where ((`<subquery2>`.`CountryCode` = `test`.`t1`.`Code`) and (`test`.`t2`.`Population` > 5000000)) 7297SELECT Name FROM t1 7298WHERE t1.Code IN ( 7299SELECT t2.CountryCode FROM t2 WHERE Population > 5000000); 7300Name 7301Austria 7302Canada 7303China 7304Czech Republic 7305drop table t1, t2; 7306create table t0 (a int); 7307insert into t0 values (0),(1),(2),(3),(4); 7308create table t1 (a int, b int, key(a)); 7309insert into t1 select a,a from t0; 7310create table t2 (a int, b int, primary key(a)); 7311insert into t2 select * from t1; 7312Table t2, unlike table t1, should be displayed as pulled out 7313explain extended select * from t0 7314where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and 7315t1.b=t2.b); 7316id select_type table partitions type possible_keys key key_len ref rows filtered Extra 73171 SIMPLE t0 NULL ALL NULL NULL NULL NULL 5 100.00 Using where; Start temporary 73181 SIMPLE t1 NULL ref a a 5 test.t0.a 1 100.00 Using join buffer (Batched Key Access) 73191 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t0.a 1 20.00 Using where; End temporary; Using join buffer (Batched Key Access) 7320Warnings: 7321Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 7322Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 7323Note 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`)) 7324update t1 set a=3, b=11 where a=4; 7325update t2 set b=11 where a=3; 7326create temporary table tmp select * from t0 where t0.a in 7327(select t1.a from t1, t2 where t2.a=t0.a and t1.b=t2.b); 7328create temporary table tmp_as_ref (a int); 7329insert into tmp_as_ref values(0),(1),(2),(3); 7330select * from tmp; 7331a 73320 73331 73342 73353 7336drop table t0, t1, t2, tmp, tmp_as_ref; 7337CREATE TABLE t1 ( 7338id int(11) NOT NULL, 7339PRIMARY KEY (id)); 7340CREATE TABLE t2 ( 7341id int(11) NOT NULL, 7342fid int(11) NOT NULL, 7343PRIMARY KEY (id)); 7344insert into t1 values(1); 7345insert into t2 values(1,7503),(2,1); 7346explain select count(*) 7347from t1 7348where fid IN (select fid from t2 where (id between 7502 and 8420) order by fid ); 7349ERROR 42S22: Unknown column 'fid' in 'IN/ALL/ANY subquery' 7350drop table t1, t2; 7351create table t1 (a int, b int, key (a), key (b)); 7352insert into t1 values (2,4),(2,4),(2,4); 7353select t1.a from t1 7354where 7355t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by t1.a); 7356a 7357drop table t1; 7358create table t1(a int,b int,key(a),key(b)); 7359insert into t1 values (1,1),(2,2),(3,3); 7360select 1 from t1 7361where t1.a not in (select 1 from t1 7362where t1.a in (select 1 from t1) 7363group by t1.b); 73641 73651 73661 7367drop table t1; 7368CREATE TABLE t1 7369(EMPNUM CHAR(3) NOT NULL, 7370EMPNAME CHAR(20), 7371GRADE DECIMAL(4), 7372CITY CHAR(15)); 7373CREATE TABLE t2 7374(PNUM CHAR(3) NOT NULL, 7375PNAME CHAR(20), 7376PTYPE CHAR(6), 7377BUDGET DECIMAL(9), 7378CITY CHAR(15)); 7379CREATE TABLE t3 7380(EMPNUM CHAR(3) NOT NULL, 7381PNUM CHAR(3) NOT NULL, 7382HOURS DECIMAL(5)); 7383INSERT INTO t1 VALUES ('E1','Alice',12,'Deale'); 7384INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna'); 7385INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna'); 7386INSERT INTO t1 VALUES ('E4','Don',12,'Deale'); 7387INSERT INTO t1 VALUES ('E5','Ed',13,'Akron'); 7388INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale'); 7389INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna'); 7390INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa'); 7391INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale'); 7392INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna'); 7393INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale'); 7394INSERT INTO t3 VALUES ('E1','P1',40); 7395INSERT INTO t3 VALUES ('E1','P2',20); 7396INSERT INTO t3 VALUES ('E1','P3',80); 7397INSERT INTO t3 VALUES ('E1','P4',20); 7398INSERT INTO t3 VALUES ('E1','P5',12); 7399INSERT INTO t3 VALUES ('E1','P6',12); 7400INSERT INTO t3 VALUES ('E2','P1',40); 7401INSERT INTO t3 VALUES ('E2','P2',80); 7402INSERT INTO t3 VALUES ('E3','P2',20); 7403INSERT INTO t3 VALUES ('E4','P2',20); 7404INSERT INTO t3 VALUES ('E4','P4',40); 7405INSERT INTO t3 VALUES ('E4','P5',80); 7406SELECT * FROM t1; 7407EMPNUM EMPNAME GRADE CITY 7408E1 Alice 12 Deale 7409E2 Betty 10 Vienna 7410E3 Carmen 13 Vienna 7411E4 Don 12 Deale 7412E5 Ed 13 Akron 7413CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM); 7414SELECT EMPNAME 7415FROM t1 7416WHERE EMPNUM IN 7417(SELECT EMPNUM 7418FROM t3 7419WHERE PNUM IN 7420(SELECT PNUM 7421FROM t2 7422WHERE PTYPE = 'Design')); 7423EMPNAME 7424Alice 7425Betty 7426Don 7427DROP INDEX t1_IDX ON t1; 7428CREATE INDEX t1_IDX ON t1(EMPNUM); 7429SELECT EMPNAME 7430FROM t1 7431WHERE EMPNUM IN 7432(SELECT EMPNUM 7433FROM t3 7434WHERE PNUM IN 7435(SELECT PNUM 7436FROM t2 7437WHERE PTYPE = 'Design')); 7438EMPNAME 7439Alice 7440Betty 7441Don 7442DROP INDEX t1_IDX ON t1; 7443SELECT EMPNAME 7444FROM t1 7445WHERE EMPNUM IN 7446(SELECT EMPNUM 7447FROM t3 7448WHERE PNUM IN 7449(SELECT PNUM 7450FROM t2 7451WHERE PTYPE = 'Design')); 7452EMPNAME 7453Alice 7454Betty 7455Don 7456DROP TABLE t1, t2, t3; 7457CREATE TABLE t1 (f1 INT NOT NULL); 7458CREATE VIEW v1 (a) AS SELECT f1 IN (SELECT f1 FROM t1) FROM t1; 7459SELECT * FROM v1; 7460a 7461drop view v1; 7462drop table t1; 7463create table t0 (a int); 7464insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 7465create table t1(a int, b int); 7466insert into t1 values (0,0),(1,1),(2,2); 7467create table t2 as select * from t1; 7468create table t3 (pk int, a int, primary key(pk)); 7469insert into t3 select a,a from t0; 7470explain 7471select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t3)); 7472id select_type table partitions type possible_keys key key_len ref rows filtered Extra 74731 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL 74741 SIMPLE t3 NULL eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using where; Using index 74751 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 7476Warnings: 7477Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(((`test`.`t3`.`pk` = `test`.`t1`.`a`) and (`test`.`t2`.`a` = `test`.`t1`.`a`) and 1)) where 1 7478drop table t0, t1, t2, t3; 7479create table t0 (a int); 7480insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 7481create table t1 (a int) as select A.a + 10 *(B.a + 10*C.a) as a from t0 A, t0 B, t0 C; 7482create table t2 (id int, a int, primary key(id), key(a)) as select a as id, a as a from t1; 7483show create table t2; 7484Table Create Table 7485t2 CREATE TABLE `t2` ( 7486 `id` int(11) NOT NULL, 7487 `a` int(11) DEFAULT NULL, 7488 PRIMARY KEY (`id`), 7489 KEY `a` (`a`) 7490) ENGINE=MyISAM DEFAULT CHARSET=latin1 7491set @a=0; 7492create table t3 as select * from t2 limit 0; 7493insert into t3 select @a:=@a+1, t2.a from t2, t0; 7494insert into t3 select @a:=@a+1, t2.a from t2, t0; 7495insert into t3 select @a:=@a+1, t2.a from t2, t0; 7496alter table t3 add primary key(id), add key(a); 7497The following must use loose index scan over t3, key a: 7498explain select count(a) from t2 where a in ( SELECT a FROM t3); 7499id select_type table partitions type possible_keys key key_len ref rows filtered Extra 75001 SIMPLE t2 NULL index a a 5 NULL 1000 100.00 Using where; Using index 75011 SIMPLE t3 NULL ref a a 5 test.t2.a 30 100.00 Using index; FirstMatch(t2) 7502Warnings: 7503Note 1003 /* select#1 */ select count(`test`.`t2`.`a`) AS `count(a)` from `test`.`t2` semi join (`test`.`t3`) where (`test`.`t3`.`a` = `test`.`t2`.`a`) 7504select count(a) from t2 where a in ( SELECT a FROM t3); 7505count(a) 75061000 7507drop table t0,t1,t2,t3; 7508# 7509# Bug#33062: subquery in stored routine cause crash 7510# 7511CREATE TABLE t1(a INT); 7512CREATE TABLE t2(c INT); 7513CREATE PROCEDURE p1(v1 int) 7514BEGIN 7515SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2); 7516END 7517// 7518CREATE PROCEDURE p2(v1 int) 7519BEGIN 7520SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2); 7521END 7522// 7523CREATE PROCEDURE p3(v1 int) 7524BEGIN 7525SELECT 1 7526FROM 7527t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, 7528t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, 7529t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, 7530t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, 7531t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, 7532t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, 7533t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, 7534t1 t57,t1 t58,t1 t59,t1 t60 7535WHERE t01.a IN (SELECT c FROM t2); 7536END 7537// 7538CREATE PROCEDURE p4(v1 int) 7539BEGIN 7540SELECT 1 7541FROM 7542t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08, 7543t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16, 7544t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24, 7545t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32, 7546t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40, 7547t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48, 7548t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56, 7549t1 t57,t1 t58,t1 t59,t1 t60 7550WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2); 7551END 7552// 7553CALL p1(1); 75541 7555CALL p2(1); 75561 7557CALL p3(1); 75581 7559CALL p4(1); 75601 7561DROP TABLE t1, t2; 7562DROP PROCEDURE p1; 7563DROP PROCEDURE p2; 7564DROP PROCEDURE p3; 7565DROP PROCEDURE p4; 7566# 7567# Bug#48213 Materialized subselect crashes if using GEOMETRY type 7568# 7569CREATE TABLE t1 ( 7570pk int, 7571a varchar(1), 7572b varchar(4), 7573c tinyblob, 7574d blob, 7575e mediumblob, 7576f longblob, 7577g tinytext, 7578h text, 7579i mediumtext, 7580j longtext, 7581k geometry, 7582PRIMARY KEY (pk) 7583); 7584INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff', 'ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); 7585CREATE TABLE t2 LIKE t1; 7586INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii','iiii','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')), (2,'f','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff','ffff',ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))')); 7587EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); 7588id select_type table partitions type possible_keys key key_len ref rows filtered Extra 75891 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where 75901 SIMPLE <subquery2> NULL eq_ref <auto_key> <auto_key> 11 test.t1.a,test.t1.b 1 100.00 NULL 75912 MATERIALIZED t2 NULL range PRIMARY PRIMARY 4 NULL 2 100.00 Using index condition; Using MRR 7592Warnings: 7593Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 7594Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` semi join (`test`.`t2`) where ((`<subquery2>`.`b` = `test`.`t1`.`b`) and (`<subquery2>`.`a` = `test`.`t1`.`a`) and (`test`.`t2`.`pk` > 0)) 7595SELECT pk FROM t1 WHERE (a, b) IN (SELECT a, b FROM t2 WHERE pk > 0); 7596pk 75972 7598EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); 7599id select_type table partitions type possible_keys key key_len ref rows filtered Extra 76001 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 76011 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop) 7602Warnings: 7603Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 7604Note 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)) 7605SELECT pk FROM t1 WHERE (b, c) IN (SELECT b, c FROM t2 WHERE pk > 0); 7606pk 76071 76082 7609EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); 7610id select_type table partitions type possible_keys key key_len ref rows filtered Extra 76111 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 76121 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop) 7613Warnings: 7614Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 7615Note 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)) 7616SELECT pk FROM t1 WHERE (b, d) IN (SELECT b, d FROM t2 WHERE pk > 0); 7617pk 76182 7619EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); 7620id select_type table partitions type possible_keys key key_len ref rows filtered Extra 76211 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 76221 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop) 7623Warnings: 7624Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 7625Note 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)) 7626SELECT pk FROM t1 WHERE (b, e) IN (SELECT b, e FROM t2 WHERE pk > 0); 7627pk 76281 76292 7630EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); 7631id select_type table partitions type possible_keys key key_len ref rows filtered Extra 76321 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 76331 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop) 7634Warnings: 7635Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 7636Note 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)) 7637SELECT pk FROM t1 WHERE (b, f) IN (SELECT b, f FROM t2 WHERE pk > 0); 7638pk 76391 76402 7641EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); 7642id select_type table partitions type possible_keys key key_len ref rows filtered Extra 76431 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 76441 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop) 7645Warnings: 7646Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 7647Note 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)) 7648SELECT pk FROM t1 WHERE (b, g) IN (SELECT b, g FROM t2 WHERE pk > 0); 7649pk 76501 76512 7652EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); 7653id select_type table partitions type possible_keys key key_len ref rows filtered Extra 76541 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 76551 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop) 7656Warnings: 7657Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 7658Note 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)) 7659SELECT pk FROM t1 WHERE (b, h) IN (SELECT b, h FROM t2 WHERE pk > 0); 7660pk 76611 76622 7663EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); 7664id select_type table partitions type possible_keys key key_len ref rows filtered Extra 76651 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 76661 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop) 7667Warnings: 7668Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 7669Note 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)) 7670SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); 7671pk 76721 76732 7674EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); 7675id select_type table partitions type possible_keys key key_len ref rows filtered Extra 76761 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 76771 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop) 7678Warnings: 7679Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 7680Note 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)) 7681SELECT pk FROM t1 WHERE (b, j) IN (SELECT b, j FROM t2 WHERE pk > 0); 7682pk 76831 76842 7685EXPLAIN EXTENDED SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); 7686id select_type table partitions type possible_keys key key_len ref rows filtered Extra 76871 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 76881 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 2 50.00 Using index condition; Using where; Using MRR; FirstMatch(t1); Using join buffer (Block Nested Loop) 7689Warnings: 7690Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 7691Note 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)) 7692SELECT pk FROM t1 WHERE (b, k) IN (SELECT b, k FROM t2 WHERE pk > 0); 7693pk 76941 76952 7696DROP TABLE t1, t2; 7697# End of Bug#48213 7698# 7699# BUG#53060: LooseScan semijoin strategy does not return all rows 7700# 7701CREATE TABLE t1 (i INTEGER); 7702INSERT INTO t1 VALUES (1), (2), (3), (4), (5); 7703CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); 7704INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1); 7705EXPLAIN 7706SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); 7707id select_type table partitions type possible_keys key key_len ref rows filtered Extra 77081 SIMPLE t2 NULL index k k 10 NULL 4 33.33 Using where; Using index; LooseScan 77091 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 20.00 Using where; Using join buffer (Block Nested Loop) 7710Warnings: 7711Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t1`.`i` = `test`.`t2`.`i`) and (`test`.`t2`.`j` > 0)) 7712SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); 7713i 77141 77152 7716DROP TABLE t1, t2; 7717# End of BUG#53060 7718# 7719# Bug#53305 "Duplicate weedout + join buffer (join cache --level=7,8) loses rows" 7720# 7721create table t1 (uid int, fid int, index(uid)); 7722insert into t1 values 7723(1,1), (1,2), (1,3), (1,4), 7724(2,5), (2,6), (2,7), (2,8), 7725(3,1), (3,2), (3,9); 7726create table t2 (uid int primary key, name varchar(128), index(name)); 7727insert into t2 values 7728(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), 7729(6, "F"), (7, "G"), (8, "H"), (9, "I"); 7730create table t3 (uid int, fid int, index(uid)); 7731insert into t3 values 7732(1,1), (1,2), (1,3),(1,4), 7733(2,5), (2,6), (2,7), (2,8), 7734(3,1), (3,2), (3,9); 7735create table t4 (uid int primary key, name varchar(128), index(name)); 7736insert into t4 values 7737(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), 7738(6, "F"), (7, "G"), (8, "H"), (9, "I"); 7739explain select name from t2, t1 7740where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) 7741and t2.uid=t1.fid; 7742id select_type table partitions type possible_keys key key_len ref rows filtered Extra 77431 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary 77441 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index 77451 SIMPLE t1 NULL ref uid uid 5 test.t3.fid 2 100.00 Using where; Using join buffer (Batched Key Access) 77461 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 End temporary; Using join buffer (Batched Key Access) 7747Warnings: 7748Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` semi join (`test`.`t3`) join `test`.`t2` join `test`.`t1` where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) 7749select name from t2, t1 7750where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) 7751and t2.uid=t1.fid; 7752name 7753A 7754A 7755B 7756B 7757C 7758D 7759E 7760F 7761G 7762H 7763I 7764drop table t1,t2,t3,t4; 7765# 7766# Bug#43768 Prepared query with nested subqueries core dump on second execution 7767# 7768CREATE TABLE t1 ( 7769id INT PRIMARY KEY, 7770partner_id VARCHAR(35) 7771); 7772INSERT INTO t1 VALUES 7773(1, 'partner1'), (2, 'partner2'), 7774(3, 'partner3'), (4, 'partner4'); 7775CREATE TABLE t2 ( 7776id INT NOT NULL, 7777t1_line_id INT, 7778article_id VARCHAR(20), 7779PRIMARY KEY(id, t1_line_id) 7780); 7781INSERT INTO t2 VALUES 7782(1, 1, 'sup'), (2, 1, 'sup'), 7783(2, 2, 'sup'), (2, 3, 'sup'), 7784(2, 4, 'imp'), (3, 1, 'sup'), 7785(4, 1, 'sup'); 7786CREATE TABLE t3 ( 7787user_id VARCHAR(50), 7788article_id VARCHAR(20) NOT NULL, 7789PRIMARY KEY(user_id) 7790); 7791INSERT INTO t3 VALUES('nicke', 'imp'); 7792EXPLAIN 7793SELECT t1.partner_id 7794FROM t1 7795WHERE t1.id IN ( 7796SELECT t2.id 7797FROM t2 7798WHERE article_id IN ( 7799SELECT article_id FROM t3 7800WHERE user_id = 'nicke' 7801 ) 7802); 7803id select_type table partitions type possible_keys key key_len ref rows filtered Extra 78041 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL 78051 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL 78061 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; FirstMatch(t1); Using join buffer (Block Nested Loop) 7807Warnings: 7808Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) 7809SELECT t1.partner_id 7810FROM t1 7811WHERE t1.id IN ( 7812SELECT t2.id 7813FROM t2 7814WHERE article_id IN ( 7815SELECT article_id FROM t3 7816WHERE user_id = 'nicke' 7817 ) 7818); 7819partner_id 7820partner2 7821PREPARE stmt FROM 7822'EXPLAIN SELECT t1.partner_id 7823FROM t1 7824WHERE t1.id IN ( 7825 SELECT t2.id 7826 FROM t2 7827 WHERE article_id IN ( 7828 SELECT article_id FROM t3 7829 WHERE user_id = \'nicke\' 7830 ) 7831 )'; 7832EXECUTE stmt; 7833id select_type table partitions type possible_keys key key_len ref rows filtered Extra 78341 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL 78351 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL 78361 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; FirstMatch(t1); Using join buffer (Block Nested Loop) 7837Warnings: 7838Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) 7839EXECUTE stmt; 7840id select_type table partitions type possible_keys key key_len ref rows filtered Extra 78411 SIMPLE t3 NULL system PRIMARY NULL NULL NULL 1 100.00 NULL 78421 SIMPLE t1 NULL ALL PRIMARY NULL NULL NULL 4 100.00 NULL 78431 SIMPLE t2 NULL ALL PRIMARY NULL NULL NULL 7 14.29 Using where; FirstMatch(t1); Using join buffer (Block Nested Loop) 7844Warnings: 7845Note 1003 /* select#1 */ select `test`.`t1`.`partner_id` AS `partner_id` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`id` = `test`.`t1`.`id`) and (`test`.`t2`.`article_id` = 'imp')) 7846PREPARE stmt FROM 7847'SELECT t1.partner_id 7848FROM t1 7849WHERE t1.id IN ( 7850 SELECT t2.id 7851 FROM t2 7852 WHERE article_id IN ( 7853 SELECT article_id FROM t3 7854 WHERE user_id = \'nicke\' 7855 ) 7856 )'; 7857EXECUTE stmt; 7858partner_id 7859partner2 7860EXECUTE stmt; 7861partner_id 7862partner2 7863DROP TABLE t1,t2,t3; 7864# End of Bug#43768 7865# 7866# Bug#53058 - semijoin execution of subquery with outerjoin yields wrong result 7867# 7868CREATE TABLE t1 (i INTEGER); 7869CREATE TABLE t2 (i INTEGER); 7870CREATE TABLE t3 (i INTEGER); 7871INSERT INTO t1 VALUES (1), (2); 7872INSERT INTO t2 VALUES (6); 7873INSERT INTO t3 VALUES (1), (2); 7874explain extended SELECT * FROM t1 WHERE (t1.i) IN 7875(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); 7876id select_type table partitions type possible_keys key key_len ref rows filtered Extra 78771 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary 78781 SIMPLE t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (Block Nested Loop) 78791 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; End temporary; Using join buffer (Block Nested Loop) 7880Warnings: 7881Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 7882Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t3` left join `test`.`t2` on((`test`.`t2`.`i` = `test`.`t3`.`i`))) where (`test`.`t1`.`i` = `test`.`t3`.`i`) 7883SELECT * FROM t1 WHERE (t1.i) IN 7884(SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); 7885i 78861 78872 7888drop table t1,t2,t3; 7889# 7890# BUG#49453: re-execution of prepared statement with view 7891# and semijoin crashes 7892# 7893CREATE TABLE t1 (city VARCHAR(50), country_id INT); 7894CREATE TABLE t2 (country_id INT, country VARCHAR(50)); 7895INSERT INTO t1 VALUES 7896('Batna',2),('Bchar',2),('Skikda',2),('Tafuna',3),('Algeria',2) ; 7897INSERT INTO t2 VALUES (2,'Algeria'),(2,'AlgeriaDup'),(3,'XAmerican Samoa'); 7898CREATE VIEW v1 AS 7899SELECT country_id as vf_country_id 7900FROM t2 7901WHERE LEFT(country,1) = "A"; 7902PREPARE stmt FROM " 7903SELECT city, country_id 7904FROM t1 7905WHERE country_id IN (SELECT vf_country_id FROM v1); 7906"; 7907 7908EXECUTE stmt; 7909city country_id 7910Batna 2 7911Bchar 2 7912Skikda 2 7913Algeria 2 7914EXECUTE stmt; 7915city country_id 7916Batna 2 7917Bchar 2 7918Skikda 2 7919Algeria 2 7920DROP TABLE t1,t2; 7921DROP VIEW v1; 7922# 7923# Bug#54437 Extra rows with LEFT JOIN + semijoin (firstmatch 7924# and duplicates weedout) 7925# 7926create table t1 (a int); 7927create table t2 (a int); 7928create table t3 (a int); 7929insert into t1 values(1),(1); 7930insert into t2 values(1),(1),(1),(1); 7931insert into t3 values(2),(2); 7932explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); 7933id select_type table partitions type possible_keys key key_len ref rows filtered Extra 79341 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary 79351 SIMPLE t2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (Block Nested Loop) 79361 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (Block Nested Loop) 7937Warnings: 7938Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`test`.`t2`.`a` = `test`.`t1`.`a`) 7939select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); 7940a 79411 79421 7943drop table t1,t2,t3; 7944# 7945# Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) 7946# 7947CREATE TABLE t1 (a INT); 7948CREATE TABLE t2 (a INT); 7949CREATE TABLE t3 (a INT); 7950INSERT INTO t1 VALUES(1),(1); 7951INSERT INTO t2 VALUES(1),(1); 7952INSERT INTO t3 VALUES(2),(2); 7953explain SELECT * FROM t1 7954WHERE t1.a IN (SELECT t2.a 7955FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); 7956id select_type table partitions type possible_keys key key_len ref rows filtered Extra 79571 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where 79581 SIMPLE <subquery2> NULL eq_ref <auto_key> <auto_key> 5 test.t1.a 1 100.00 NULL 79592 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 79602 MATERIALIZED t2inner NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop) 79612 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (Block Nested Loop) 7962Warnings: 7963Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2` left join (`test`.`t2` `t2inner` join `test`.`t3`) on((`test`.`t2`.`a` = `test`.`t3`.`a`))) where (`<subquery2>`.`a` = `test`.`t1`.`a`) 7964SELECT * FROM t1 7965WHERE t1.a IN (SELECT t2.a 7966FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); 7967a 79681 79691 7970DROP TABLE t1,t2,t3; 7971# 7972# BUG#52329 - Wrong result: subquery materialization, IN, 7973# non-null field followed by nullable 7974# 7975CREATE TABLE t1 (a1 CHAR(8) NOT NULL, a2 char(8) NOT NULL); 7976CREATE TABLE t2a (b1 char(8), b2 char(8)); 7977CREATE TABLE t2b (b1 CHAR(8), b2 char(8) NOT NULL); 7978CREATE TABLE t2c (b1 CHAR(8) NOT NULL, b2 char(8)); 7979INSERT INTO t1 VALUES ('1 - 12', '2 - 22'); 7980INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), 7981('1 - 11', '2 - 21'), 7982('1 - 12', '2 - 22'), 7983('1 - 12', '2 - 22'), 7984('1 - 13', '2 - 23'); 7985INSERT INTO t2b SELECT * FROM t2a; 7986INSERT INTO t2c SELECT * FROM t2a; 7987SELECT * FROM t1 7988WHERE (a1, a2) IN ( 7989SELECT b1, b2 FROM t2c WHERE b1 > '0' GROUP BY b1, b2); 7990a1 a2 79911 - 12 2 - 22 7992SELECT * FROM t1 7993WHERE (a1, a2) IN ( 7994SELECT b1, b2 FROM t2a WHERE b1 > '0'); 7995a1 a2 79961 - 12 2 - 22 7997SELECT * FROM t1 7998WHERE (a1, a2) IN ( 7999SELECT b1, b2 FROM t2b WHERE b1 > '0'); 8000a1 a2 80011 - 12 2 - 22 8002SELECT * FROM t1 8003WHERE (a1, a2) IN ( 8004SELECT b1, b2 FROM t2c WHERE b1 > '0'); 8005a1 a2 80061 - 12 2 - 22 8007DROP TABLE t1,t2a,t2b,t2c; 8008# End BUG#52329 8009# 8010# Bug#45174: Incorrectly applied equality propagation caused wrong 8011# result on a query with a materialized semi-join. 8012# 8013CREATE TABLE t1 ( 8014varchar_nokey varchar(1) NOT NULL 8015); 8016INSERT INTO t1 VALUES 8017('v'), ('u'), ('n'), ('l'), ('h'), ('u'), ('n'), ('j'), ('k'), 8018('e'), ('i'), ('u'), ('n'), ('b'), ('x'), (''), ('q'), ('u'); 8019CREATE TABLE t2 ( 8020pk int NOT NULL, 8021varchar_key varchar(1) NOT NULL, 8022varchar_nokey varchar(1) NOT NULL, 8023PRIMARY KEY(pk), 8024KEY varchar_key(varchar_key) 8025); 8026INSERT INTO t2 VALUES 8027(11,'m','m'), (12,'j','j'), (13,'z','z'), (14,'a','a'), (15,'',''), 8028(16,'e','e'), (17,'t','t'), (19,'b','b'), (20,'w','w'), (21,'m','m'), 8029(23,'',''), (24,'w','w'), (26,'e','e'), (27,'e','e'), (28,'p','p'); 8030SELECT varchar_nokey 8031FROM t1 8032WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey 8033FROM t2 8034WHERE varchar_nokey < 'n' XOR pk); 8035varchar_nokey 8036explain SELECT varchar_nokey 8037FROM t1 8038WHERE (varchar_nokey, varchar_nokey) IN (SELECT varchar_key, varchar_nokey 8039FROM t2 8040WHERE varchar_nokey < 'n' XOR pk); 8041id select_type table partitions type possible_keys key key_len ref rows filtered Extra 80421 SIMPLE t1 NULL ALL NULL NULL NULL NULL 18 100.00 Using where 80431 SIMPLE <subquery2> NULL eq_ref <auto_key> <auto_key> 6 test.t1.varchar_nokey,test.t1.varchar_nokey 1 100.00 NULL 80442 MATERIALIZED t2 NULL ALL varchar_key NULL NULL NULL 15 63.34 Using where 8045Warnings: 8046Note 1003 /* select#1 */ select `test`.`t1`.`varchar_nokey` AS `varchar_nokey` from `test`.`t1` semi join (`test`.`t2`) where ((`<subquery2>`.`varchar_key` = `test`.`t1`.`varchar_nokey`) and (`<subquery2>`.`varchar_nokey` = `test`.`t1`.`varchar_nokey`) and (`test`.`t2`.`varchar_nokey` = `test`.`t2`.`varchar_key`) and ((`test`.`t2`.`varchar_nokey` < 'n') xor `test`.`t2`.`pk`)) 8047DROP TABLE t1, t2; 8048# End of the test for bug#45174. 8049# 8050# Bug#50019: Wrong result for IN-query with materialization 8051# 8052CREATE TABLE t1(i INT); 8053INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); 8054CREATE TABLE t2(i INT); 8055INSERT INTO t2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); 8056CREATE TABLE t3(i INT); 8057INSERT INTO t3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); 8058SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i 8059FROM t2 JOIN t3 8060WHERE t2.i + t3.i = 5); 8061i 80621 80632 80643 80654 8066explain SELECT * FROM t1 WHERE t1.i IN (SELECT t2.i 8067FROM t2 JOIN t3 8068WHERE t2.i + t3.i = 5); 8069id select_type table partitions type possible_keys key key_len ref rows filtered Extra 80701 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 Using where 80711 SIMPLE <subquery2> NULL eq_ref <auto_key> <auto_key> 5 test.t1.i 1 100.00 NULL 80722 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 10 100.00 NULL 80732 MATERIALIZED t3 NULL ALL NULL NULL NULL NULL 10 100.00 Using where; Using join buffer (Block Nested Loop) 8074Warnings: 8075Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`<subquery2>`.`i` = `test`.`t1`.`i`) and ((`test`.`t2`.`i` + `test`.`t3`.`i`) = 5)) 8076DROP TABLE t1,t2,t3; 8077# End of the test for bug#50019. 8078# 8079# Bug#52068: Optimizer generates invalid semijoin materialization plan 8080# 8081CREATE TABLE ot1(a INTEGER); 8082INSERT INTO ot1 VALUES(5), (8); 8083CREATE TABLE it2(a INTEGER); 8084INSERT INTO it2 VALUES(9), (5), (1), (8); 8085CREATE TABLE it3(a INTEGER); 8086INSERT INTO it3 VALUES(7), (1), (0), (5), (1), (4); 8087CREATE TABLE ot4(a INTEGER); 8088INSERT INTO ot4 VALUES(1), (3), (5), (7), (9), (7), (3), (1); 8089SELECT * FROM ot1,ot4 8090WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a 8091FROM it2,it3); 8092a a 80935 1 80948 1 80955 5 80968 5 80975 7 80988 7 80995 7 81008 7 81015 1 81028 1 8103explain SELECT * FROM ot1,ot4 8104WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a 8105FROM it2,it3); 8106id select_type table partitions type possible_keys key key_len ref rows filtered Extra 81071 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary 81081 SIMPLE it2 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (Block Nested Loop) 81091 SIMPLE it3 NULL ALL NULL NULL NULL NULL 6 100.00 Using join buffer (Block Nested Loop) 81101 SIMPLE ot4 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; End temporary; Using join buffer (Block Nested Loop) 8111Warnings: 8112Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot4`.`a` AS `a` from `test`.`ot1` semi join (`test`.`it2` join `test`.`it3`) join `test`.`ot4` where ((`test`.`ot4`.`a` = `test`.`it3`.`a`) and (`test`.`it2`.`a` = `test`.`ot1`.`a`)) 8113DROP TABLE IF EXISTS ot1, ot4, it2, it3; 8114# End of the test for bug#52068. 8115# 8116# Bug#57623: subquery within before insert trigger causes crash (sj=on) 8117# 8118CREATE TABLE ot1(a INT); 8119CREATE TABLE ot2(a INT); 8120CREATE TABLE ot3(a INT); 8121CREATE TABLE it1(a INT); 8122INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); 8123INSERT INTO ot2 VALUES(0),(2),(4),(6); 8124INSERT INTO ot3 VALUES(0),(3),(6); 8125INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); 8126explain SELECT * 8127FROM ot1 8128LEFT JOIN 8129(ot2 JOIN ot3 on ot2.a=ot3.a) 8130ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); 8131id select_type table partitions type possible_keys key key_len ref rows filtered Extra 81321 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 8 100.00 NULL 81331 SIMPLE it1 NULL ALL NULL NULL NULL NULL 8 100.00 Using where; FirstMatch(ot1) 81341 SIMPLE ot3 NULL ALL NULL NULL NULL NULL 3 100.00 Using where 81351 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where 8136Warnings: 8137Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a`,`test`.`ot3`.`a` AS `a` from `test`.`ot1` left join (`test`.`ot2` semi join (`test`.`it1`) join `test`.`ot3`) on(((`test`.`it1`.`a` = `test`.`ot1`.`a`) and (`test`.`ot3`.`a` = `test`.`ot1`.`a`) and (`test`.`ot2`.`a` = `test`.`ot1`.`a`) and 1)) where 1 8138SELECT * 8139FROM ot1 8140LEFT JOIN 8141(ot2 JOIN ot3 on ot2.a=ot3.a) 8142ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); 8143a a a 81440 0 0 81451 NULL NULL 81462 NULL NULL 81473 NULL NULL 81484 NULL NULL 81495 NULL NULL 81506 6 6 81517 NULL NULL 8152prepare s from 'SELECT * 8153FROM ot1 8154LEFT JOIN 8155(ot2 JOIN ot3 on ot2.a=ot3.a) 8156ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1)'; 8157execute s; 8158a a a 81590 0 0 81601 NULL NULL 81612 NULL NULL 81623 NULL NULL 81634 NULL NULL 81645 NULL NULL 81656 6 6 81667 NULL NULL 8167execute s; 8168a a a 81690 0 0 81701 NULL NULL 81712 NULL NULL 81723 NULL NULL 81734 NULL NULL 81745 NULL NULL 81756 6 6 81767 NULL NULL 8177deallocate prepare s; 8178DROP TABLE ot1, ot2, ot3, it1; 8179# End of the test for bug#57623. 8180# 8181# Bug#11766739: Crash in tmp_table_param::init() with semijoin=on 8182# 8183CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; 8184CREATE TABLE t2 (f1 INTEGER, f2 INTEGER) ENGINE=MyISAM; 8185INSERT INTO t1 VALUES (1); 8186INSERT INTO t2 VALUES (1,1), (2,1); 8187EXPLAIN SELECT * FROM t2 8188WHERE f2 IN (SELECT t1.f1 8189FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); 8190id select_type table partitions type possible_keys key key_len ref rows filtered Extra 81911 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Start temporary 81921 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 81931 SIMPLE b1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (Block Nested Loop) 81941 SIMPLE b2 NULL ALL NULL NULL NULL NULL 2 100.00 End temporary; Using join buffer (Block Nested Loop) 8195Warnings: 8196Note 1003 /* select#1 */ select `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2` from `test`.`t2` semi join (`test`.`t1` left join (`test`.`t2` `b1` join `test`.`t2` `b2`) on((TRUE and TRUE))) where (`test`.`t2`.`f2` = `test`.`t1`.`f1`) 8197SELECT * FROM t2 8198WHERE f2 IN (SELECT t1.f1 8199FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); 8200f1 f2 82011 1 82022 1 8203DROP TABLE t1, t2; 8204# End of the test for bug#11766739. 8205# 8206# Bug#11766642: crash in Item_field::register_field_in_read_map with view 8207# 8208CREATE TABLE t1(a INT); 8209CREATE VIEW v1 AS SELECT a FROM t1; 8210INSERT INTO t1 VALUES (0),(1),(2); 8211SELECT a FROM t1 WHERE a IN 8212(SELECT a XOR a FROM v1) 8213ORDER BY a; 8214a 82150 8216DROP TABLE t1; 8217DROP VIEW v1; 8218# 8219# Bug#12546542 MISSING ROW WHEN USING OPTIMIZER_JOIN_CACHE_LEVEL>=3 8220# 8221CREATE TABLE t1 ( 8222f2 varchar(1024) 8223); 8224INSERT INTO t1 VALUES ('v'),('we'); 8225CREATE TABLE t2 ( 8226col_varchar_1024_utf8 varchar(1024) CHARACTER SET utf8 DEFAULT NULL, 8227col_int_key int, 8228col_int int 8229); 8230INSERT INTO t2 VALUES ('we',4,NULL),('v',1305673728,6); 8231CREATE TABLE t3 ( 8232col_int_key int, 8233col_int int 8234); 8235INSERT INTO t3 VALUES (4,4); 8236SELECT * 8237FROM t1 8238WHERE f2 IN (SELECT a1.col_varchar_1024_utf8 AS f2 8239FROM t2 AS a1 LEFT JOIN t3 AS a2 8240ON a1.col_int_key = a2.col_int_key 8241WHERE a1.col_int BETWEEN 1 AND 10 OR a2.col_int IS NOT NULL); 8242f2 8243we 8244v 8245DROP TABLE t1,t2,t3; 8246# 8247# BUG#12616344 - JCL: DIFFERENT RESULT SET AND DIFFERENT AMOUNT 8248# OF ROWS WHEN JCL>=3 8249# 8250CREATE TABLE t1 (col_int_nokey int, col_int_key int, col_varchar_key varchar(1)); 8251INSERT INTO t1 VALUES (0,4,'c'),(1,6,'u'); 8252CREATE TABLE t2 (pk int, col_int_nokey int, col_varchar_nokey varchar(1)); 8253INSERT INTO t2 VALUES (1,4,'b'),(94,6,'u'); 8254CREATE TABLE t3 (pk int, col_int_nokey int, col_varchar_key varchar(1)); 8255INSERT INTO t3 VALUES (1,4,'j'),(2,6,'v'); 8256SELECT table2.col_int_key 8257from t3 as table1 join t1 as table2 on table2.col_int_nokey 8258where table1.col_int_nokey in 8259( 8260select subquery2_t2.col_int_nokey 8261from t3 as subquery2_t1 8262right join 8263t2 as subquery2_t2 8264join t1 as subquery2_t3 8265on subquery2_t3.col_int_key = subquery2_t2.col_int_nokey 8266on subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_nokey 8267where subquery2_t1.col_varchar_key != table1.col_varchar_key 8268or subquery2_t2.pk <= table1.pk 8269); 8270col_int_key 82716 82726 8273DROP TABLE t1,t2,t3; 8274# 8275# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE 8276# 8277CREATE TABLE t1 (i1 int); 8278INSERT INTO t1 VALUES (1); 8279CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory; 8280INSERT INTO t2 VALUES (1, 2),(7, 3); 8281SELECT GRANDPARENT1.i1 8282FROM t2 AS GRANDPARENT1 8283WHERE GRANDPARENT1.i2 8284IN ( SELECT PARENT1.i2 8285FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1) 8286WHERE 8287GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 ) 8288ORDER BY PARENT1.i1) 8289ORDER BY GRANDPARENT1.i2 ; 8290i1 82911 8292DROP TABLE t1,t2; 8293# 8294# Bug#12640083: Same query executed as WHERE subquery gives different 8295# results on IN() compare 8296# 8297CREATE TABLE t1 ( 8298pk int NOT NULL, 8299col_varchar_1024_utf8_key varchar(1024) CHARACTER SET utf8 DEFAULT NULL, 8300col_varchar_10_latin1_key varchar(10) DEFAULT NULL, 8301PRIMARY KEY (pk), 8302KEY col_varchar_1024_utf8_key(col_varchar_1024_utf8_key(333)), 8303KEY col_varchar_10_latin1_key(col_varchar_10_latin1_key) 8304); 8305INSERT INTO t1 VALUES 8306(1, 'a', 'a'), 8307(2, 'ab', 'ab'), 8308(3, 'abc', 'abc'), 8309(4, 'abcd', 'abcd'); 8310CREATE TABLE t2 ( 8311pk int NOT NULL AUTO_INCREMENT, 8312PRIMARY KEY (pk) 8313) ENGINE=Innodb; 8314CREATE TABLE t3 8315SELECT alias1.col_varchar_10_latin1_key 8316FROM t1 AS alias1 8317LEFT JOIN t1 AS alias2 8318JOIN t2 AS alias3 8319ON alias2.col_varchar_10_latin1_key 8320ON alias1.col_varchar_1024_utf8_key 8321WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk; 8322EXPLAIN SELECT * 8323FROM t3 8324WHERE col_varchar_10_latin1_key IN ( 8325SELECT alias1.col_varchar_10_latin1_key 8326FROM t1 AS alias1 8327LEFT JOIN t1 AS alias2 8328JOIN t2 AS alias3 8329ON alias2.col_varchar_10_latin1_key 8330ON alias1.col_varchar_1024_utf8_key 8331WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); 8332id select_type table partitions type possible_keys key key_len ref rows filtered Extra 83331 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary 83341 SIMPLE alias1 NULL ALL PRIMARY,col_varchar_10_latin1_key NULL NULL NULL 4 25.00 Using where; Using join buffer (Block Nested Loop) 83351 SIMPLE alias3 NULL index NULL PRIMARY 4 NULL 1 100.00 Using where; Using index; Using join buffer (Block Nested Loop) 83361 SIMPLE alias2 NULL index NULL col_varchar_10_latin1_key 13 NULL 4 100.00 Using where; Using index; End temporary; Using join buffer (Block Nested Loop) 8337Warnings: 8338Note 1003 /* select#1 */ select `test`.`t3`.`col_varchar_10_latin1_key` AS `col_varchar_10_latin1_key` from `test`.`t3` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias2` join `test`.`t2` `alias3`) on((`test`.`alias1`.`col_varchar_1024_utf8_key` and `test`.`alias2`.`col_varchar_10_latin1_key`))) where ((`test`.`alias1`.`col_varchar_10_latin1_key` = `test`.`t3`.`col_varchar_10_latin1_key`) and ((`test`.`alias1`.`pk` and (`test`.`alias1`.`pk` < 3)) or (`test`.`alias1`.`pk` and `test`.`alias3`.`pk`))) 8339SELECT * 8340FROM t3 8341WHERE col_varchar_10_latin1_key IN ( 8342SELECT alias1.col_varchar_10_latin1_key 8343FROM t1 AS alias1 8344LEFT JOIN t1 AS alias2 8345JOIN t2 AS alias3 8346ON alias2.col_varchar_10_latin1_key 8347ON alias1.col_varchar_1024_utf8_key 8348WHERE alias1.pk AND alias1.pk < 3 OR alias1.pk AND alias3.pk); 8349col_varchar_10_latin1_key 8350a 8351ab 8352DROP TABLE t1, t2, t3; 8353# End of the test for bug#12640083. 8354# 8355# Bug#12603200 - Assert in QUICK_INDEX_MERGE_SELECT::need_sorted_output 8356# 8357CREATE TABLE t1 ( 8358pk int NOT NULL, 8359col_int_key int NOT NULL, 8360col_varchar_nokey varchar(1) NOT NULL, 8361col_varchar_key varchar(1) NOT NULL, 8362PRIMARY KEY(pk), 8363KEY col_int_key(col_int_key), 8364KEY col_varchar_key(col_varchar_key, col_int_key) 8365) engine=innodb; 8366INSERT INTO t1 VALUES 8367(1,7,'a','a'), 8368(2,0,'v','v'), 8369(3,9,'c','c'), 8370(4,3,'m','m'), 8371(5,2,'a','a'), 8372(6,1,'d','d'), 8373(7,8,'y','y'), 8374(8,6,'t','t'), 8375(11,7,'a','x'), 8376(12,0,'v','v'), 8377(13,9,'c','c'), 8378(14,3,'m','m'), 8379(15,2,'a','x'), 8380(16,1,'d','d'), 8381(17,8,'y','y'), 8382(18,6,'t','u'), 8383(19,6,'t','u'); 8384CREATE TABLE t2 ( 8385pk int NOT NULL, 8386col_int_key int NOT NULL, 8387col_varchar_key varchar(1) NOT NULL, 8388PRIMARY KEY(pk), 8389KEY col_varchar_key(col_varchar_key, col_int_key) 8390) engine=innodb; 8391INSERT INTO t2(pk,col_int_key,col_varchar_key) VALUES 8392(8,7,'c'), 8393(11,4,'l'), 8394(12,7,'b'), 8395(13,0,'c'), 8396(14,2,'i'), 8397(15,9,'h'), 8398(16,4,'q'), 8399(17,1,'m'), 8400(18,9,'b'), 8401(19,2,'e'), 8402(20,1,'c'), 8403(21,7,'z'), 8404(22,4,'l'), 8405(23,7,'z'), 8406(24,0,'c'), 8407(25,2,'i'), 8408(26,9,'h'), 8409(27,4,'q'), 8410(28,0,'a'), 8411(29,1,'d'); 8412EXPLAIN SELECT outr.col_varchar_key AS x, outr.pk AS y 8413FROM t1 AS outr 8414WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key 8415FROM t2 AS innr 8416WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) 8417AND outr.col_varchar_nokey < 't' 8418ORDER BY outr.col_varchar_key, outr.pk; 8419id select_type table partitions type possible_keys key key_len ref rows filtered Extra 84201 SIMPLE innr NULL index_merge PRIMARY,col_varchar_key col_varchar_key,PRIMARY 3,4 NULL 2 100.00 Using sort_union(col_varchar_key,PRIMARY); Using where; Using temporary; Using filesort; Start temporary 84211 SIMPLE outr NULL ref col_varchar_key col_varchar_key 3 test.innr.col_varchar_key 1 33.33 Using where; End temporary; Using join buffer (Batched Key Access) 8422Warnings: 8423Note 1003 /* select#1 */ select `test`.`outr`.`col_varchar_key` AS `x`,`test`.`outr`.`pk` AS `y` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_key` = `test`.`innr`.`col_varchar_key`) and (`test`.`outr`.`col_varchar_nokey` < 't') and ((`test`.`innr`.`col_varchar_key` = 'a') or (`test`.`innr`.`pk` = 8))) order by `test`.`outr`.`col_varchar_key`,`test`.`outr`.`pk` 8424SELECT outr.col_varchar_key AS x, outr.pk AS y 8425FROM t1 AS outr 8426WHERE outr.col_varchar_key IN (SELECT innr.col_varchar_key 8427FROM t2 AS innr 8428WHERE innr.col_varchar_key = 'a' OR innr.pk = 8) 8429AND outr.col_varchar_nokey < 't' 8430ORDER BY outr.col_varchar_key, outr.pk; 8431x y 8432a 1 8433a 5 8434c 3 8435c 13 8436DROP TABLE t1, t2; 8437# End of bug#12603200 8438# 8439# Bug#12603183: Segfault in hp_movelink 8440# 8441CREATE TABLE t1 ( 8442col_varchar_key varchar(1) , 8443col_varchar_nokey varchar(1) , 8444KEY col_varchar_key(col_varchar_key) 8445); 8446INSERT INTO t1 VALUES 8447('i','i'), 8448('h','h'), 8449('q','q'), 8450('a','a'), 8451('v','v'), 8452('u','u'), 8453('s','s'), 8454('y','y'), 8455('z','z'), 8456('h','h'), 8457('p','p'), 8458('e','e'), 8459('i','i'), 8460('y','y'), 8461('w','w'); 8462CREATE TABLE t2 ( 8463col_varchar_nokey varchar(1) 8464); 8465INSERT INTO t2 VALUES 8466('b'); 8467EXPLAIN SELECT grandparent1.col_varchar_nokey 8468FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) 8469WHERE (grandparent1.col_varchar_key) IN 8470(SELECT parent1.col_varchar_nokey 8471FROM t1 AS parent1 8472WHERE parent1.col_varchar_key IN 8473(SELECT child1.col_varchar_nokey AS c1 8474FROM t1 AS child1 LEFT JOIN t2 AS child2 8475ON (child1.col_varchar_key > child2.col_varchar_nokey))); 8476id select_type table partitions type possible_keys key key_len ref rows filtered Extra 84771 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 100.00 Using where 84781 SIMPLE grandparent1 NULL ref col_varchar_key col_varchar_key 4 <subquery2>.col_varchar_nokey 2 100.00 Using join buffer (Batched Key Access) 84791 SIMPLE grandparent2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (Block Nested Loop) 84802 MATERIALIZED child1 NULL ALL NULL NULL NULL NULL 15 100.00 Using where 84812 MATERIALIZED child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (Block Nested Loop) 84822 MATERIALIZED parent1 NULL ref col_varchar_key col_varchar_key 4 test.child1.col_varchar_nokey 2 100.00 Using join buffer (Batched Key Access) 8483Warnings: 8484Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` semi join (`test`.`t1` `child1` left join `test`.`t2` `child2` on((`test`.`child1`.`col_varchar_key` > `test`.`child2`.`col_varchar_nokey`)) join `test`.`t1` `parent1`) left join `test`.`t2` `grandparent2` on((`test`.`grandparent2`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_nokey`)) where ((`test`.`grandparent1`.`col_varchar_key` = `<subquery2>`.`col_varchar_nokey`) and (`test`.`parent1`.`col_varchar_key` = `test`.`child1`.`col_varchar_nokey`)) 8485SELECT grandparent1.col_varchar_nokey 8486FROM t1 AS grandparent1 LEFT JOIN t2 AS grandparent2 USING (col_varchar_nokey) 8487WHERE (grandparent1.col_varchar_key) IN 8488(SELECT parent1.col_varchar_nokey 8489FROM t1 AS parent1 8490WHERE parent1.col_varchar_key IN 8491(SELECT child1.col_varchar_nokey AS c1 8492FROM t1 AS child1 LEFT JOIN t2 AS child2 8493ON (child1.col_varchar_key > child2.col_varchar_nokey))); 8494col_varchar_nokey 8495a 8496e 8497h 8498h 8499i 8500i 8501p 8502q 8503s 8504u 8505v 8506w 8507y 8508y 8509z 8510DROP TABLE t1, t2; 8511# End of test for bug#12603183. 8512# 8513# Bug#12818569: Diff nr of rows returned when using IN/ALL+subquery 8514# 8515CREATE TABLE t1 ( 8516col_int_key INT NOT NULL, 8517col_datetime_key DATETIME NOT NULL, 8518col_varchar_key VARCHAR(1) NOT NULL, 8519KEY col_int_key (col_int_key), 8520KEY col_datetime_key(col_datetime_key), 8521KEY col_varchar_key (col_varchar_key,col_int_key) 8522) ENGINE=InnoDB; 8523INSERT INTO t1 VALUES 8524(7,'2004-06-06 04:22:12','v'), (0,'2005-11-13 01:12:31','s'), 8525(9,'2002-05-04 01:50:00','l'), (3,'2004-10-27 10:28:45','y'), 8526(4,'2006-07-22 05:24:23','c'), (2,'2002-05-16 21:34:03','i'), 8527(5,'2008-04-17 10:45:30','h'), (3,'2009-04-21 02:58:02','q'), 8528(1,'2008-01-11 11:01:51','a'), (3,'1900-01-01 00:00:00','v'), 8529(6,'2007-05-17 18:24:57','u'), (7,'2007-08-07 00:00:00','s'), 8530(5,'2001-08-28 00:00:00','y'), (1,'2004-04-16 00:27:28','z'), 8531(204,'2005-05-03 07:06:22','h'), (224,'2009-03-11 17:09:50','p'), 8532(9,'2007-12-08 01:54:28','e'), (5,'2009-07-28 18:19:54','i'), 8533(0,'2008-06-08 00:00:00','y'), (3,'2005-02-09 09:20:26','w'); 8534CREATE TABLE t2 ( 8535col_varchar_nokey VARCHAR(1) NOT NULL 8536) ENGINE=InnoDB; 8537INSERT INTO t2 VALUES ('v'), ('y'), ('j'), ('c'), ('d'), ('r'); 8538explain SELECT col_varchar_key 8539FROM t1 8540WHERE col_varchar_key IN (SELECT col_varchar_nokey 8541FROM t2) 8542ORDER BY col_datetime_key LIMIT 4; 8543id select_type table partitions type possible_keys key key_len ref rows filtered Extra 85441 SIMPLE t1 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where; Using filesort 85451 SIMPLE <subquery2> NULL eq_ref <auto_key> <auto_key> 3 test.t1.col_varchar_key 1 100.00 NULL 85462 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 6 100.00 NULL 8547Warnings: 8548Note 1003 /* select#1 */ select `test`.`t1`.`col_varchar_key` AS `col_varchar_key` from `test`.`t1` semi join (`test`.`t2`) where (`<subquery2>`.`col_varchar_nokey` = `test`.`t1`.`col_varchar_key`) order by `test`.`t1`.`col_datetime_key` limit 4 8549SELECT col_varchar_key 8550FROM t1 8551WHERE col_varchar_key IN (SELECT col_varchar_nokey 8552FROM t2) 8553ORDER BY col_datetime_key LIMIT 4; 8554col_varchar_key 8555v 8556y 8557v 8558y 8559DROP TABLE t1, t2; 8560# End of test for bug#12818569. 8561# 8562# Bug#12803439: Assert in replace_subcondition() on update query 8563# 8564CREATE TABLE t1(a INTEGER); 8565INSERT INTO t1 values(1), (2); 8566CREATE TABLE t2(a INTEGER); 8567INSERT INTO t2 VALUES(1), (3); 8568SELECT * 8569FROM t1 8570WHERE a IN (SELECT a 8571FROM t2 8572HAVING a IN (SELECT a 8573FROM t2) 8574) 8575HAVING a IN (SELECT a 8576FROM t2); 8577a 85781 8579DROP TABLE t1, t2; 8580# End of test for bug#12803439. 8581# 8582# Bug#12797534: Segfault in hp_movelink still exists 8583# 8584CREATE TABLE t1 ( 8585g1 VARCHAR(1) NOT NULL 8586) ENGINE=InnoDB; 8587INSERT INTO t1 VALUES ('d'), ('s'); 8588CREATE TABLE t2 ( 8589pk INT NOT NULL, 8590col_int_key INT NOT NULL, 8591col_varchar_key VARCHAR(1) NOT NULL, 8592col_varchar_nokey VARCHAR(1) NOT NULL, 8593PRIMARY KEY (pk), 8594KEY col_varchar_key(col_varchar_key, col_int_key) 8595) ENGINE=InnoDB; 8596INSERT INTO t2 VALUES 8597(1,4,'j','j'), (2,6,'v','v'), (3,3,'c','c'), (4,5,'m','m'), 8598(5,3,'d','d'), (6,246,'d','d'), (7,2,'y','y'), (8,9,'t','t'), 8599(9,3,'d','d'), (10,8,'s','s'), (11,1,'r','r'), (12,8,'m','m'), 8600(13,8,'b','b'), (14,5,'x','x'), (15,7,'g','g'), (16,5,'p','p'), 8601(17,1,'q','q'), (18,6,'w','w'), (19,2,'d','d'), (20,9,'e','e'); 8602CREATE TABLE t3 ( 8603pk INTEGER NOT NULL, 8604PRIMARY KEY (pk) 8605) ENGINE=InnoDB; 8606INSERT INTO t3 VALUES (10); 8607EXPLAIN SELECT * 8608FROM t1 8609WHERE g1 NOT IN 8610(SELECT grandparent1.col_varchar_nokey AS g1 8611FROM t2 AS grandparent1 8612WHERE grandparent1.col_varchar_key IN 8613(SELECT parent1.col_varchar_nokey AS p1 8614FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) 8615) 8616AND grandparent1.col_varchar_key IS NOT NULL 8617); 8618id select_type table partitions type possible_keys key key_len ref rows filtered Extra 86191 PRIMARY t1 NULL ALL NULL NULL NULL NULL ROWS 100.00 Using where 86202 SUBQUERY <subquery3> NULL ALL NULL NULL NULL NULL ROWS 100.00 NULL 86212 SUBQUERY grandparent1 NULL ref col_varchar_key col_varchar_key 3 <subquery3>.p1 ROWS 100.00 Using index condition; Using join buffer (Batched Key Access) 86223 MATERIALIZED parent1 NULL ALL NULL NULL NULL NULL ROWS 100.00 NULL 86233 MATERIALIZED parent2 NULL eq_ref PRIMARY PRIMARY 4 test.parent1.pk ROWS 100.00 Using index 8624Warnings: 8625Note 1003 /* select#1 */ select `test`.`t1`.`g1` AS `g1` from `test`.`t1` where (not(<in_optimizer>(`test`.`t1`.`g1`,`test`.`t1`.`g1` in ( <materialize> (/* select#2 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `g1` from `test`.`t2` `grandparent1` semi join (`test`.`t2` `parent1` left join `test`.`t3` `parent2` on((`test`.`parent1`.`pk` = `test`.`parent2`.`pk`))) where ((`test`.`grandparent1`.`col_varchar_key` = `<subquery3>`.`p1`) and (`test`.`grandparent1`.`col_varchar_key` is not null)) ), <primary_index_lookup>(`test`.`t1`.`g1` in <temporary table> on <auto_key> where ((`test`.`t1`.`g1` = `materialized-subquery`.`g1`))))))) 8626SELECT * 8627FROM t1 8628WHERE g1 NOT IN 8629(SELECT grandparent1.col_varchar_nokey AS g1 8630FROM t2 AS grandparent1 8631WHERE grandparent1.col_varchar_key IN 8632(SELECT parent1.col_varchar_nokey AS p1 8633FROM t2 AS parent1 LEFT JOIN t3 AS parent2 USING (pk) 8634) 8635AND grandparent1.col_varchar_key IS NOT NULL 8636); 8637g1 8638DROP TABLE t1, t2, t3; 8639CREATE TABLE t1 ( 8640pk INTEGER AUTO_INCREMENT, 8641col_int_key INTEGER , 8642col_varchar_key VARCHAR(1) , 8643col_varchar_nokey VARCHAR(1) , 8644PRIMARY KEY (pk), 8645KEY (col_varchar_key,col_int_key) 8646) ENGINE=INNODB; 8647INSERT INTO t1 (col_int_key,col_varchar_key,col_varchar_nokey) VALUES 8648(0,'x','x'), (1,'j','j'), (1,'r','r'), (9,'v','v'), (5,'r','r'); 8649CREATE TABLE t2 ( 8650pk INTEGER AUTO_INCREMENT, 8651col_int_key INTEGER , 8652col_varchar_key VARCHAR(1) , 8653col_varchar_nokey VARCHAR(1) , 8654PRIMARY KEY (pk), 8655KEY (col_int_key), 8656KEY (col_varchar_key,col_int_key) 8657) AUTO_INCREMENT=10 ENGINE=INNODB; 8658INSERT INTO t2 (col_int_key, col_varchar_key, col_varchar_nokey) VALUES 8659(NULL,'x','x'), (NULL,'j','j'), (8,'c','c'); 8660CREATE TABLE t3 8661SELECT outr.col_varchar_nokey AS x 8662FROM t1 AS outr 8663WHERE outr.col_varchar_nokey IN 8664(SELECT innr.col_varchar_nokey AS y 8665FROM t2 AS innr 8666WHERE innr.col_int_key IS NULL) 8667AND outr.col_varchar_nokey IS NOT NULL 8668AND NOT col_varchar_key IS NULL; 8669SELECT * 8670FROM t3 8671WHERE x NOT IN 8672(SELECT outr.col_varchar_nokey AS x 8673FROM t1 AS outr 8674WHERE outr.col_varchar_nokey IN 8675(SELECT innr.col_varchar_nokey AS y 8676FROM t2 AS innr 8677WHERE innr.col_int_key IS NULL) 8678AND outr.col_varchar_nokey IS NOT NULL 8679AND NOT col_varchar_key IS NULL); 8680x 8681DROP TABLE t1, t2, t3; 8682# End of test for bug#12797534. 8683# 8684# Bug#12714094: Assert in optimize_semijoin_nests() 8685# 8686CREATE TABLE it ( 8687pk int NOT NULL, 8688col_varchar VARCHAR(10) DEFAULT NULL, 8689PRIMARY KEY (pk) 8690) ENGINE=MyISAM; 8691INSERT INTO it VALUES (1, 'g'); 8692CREATE TABLE ot 8693SELECT alias1.pk AS field1 8694FROM it AS alias1 8695LEFT JOIN it AS alias2 8696ON alias1.col_varchar = alias2.col_varchar 8697; 8698SELECT * 8699FROM ot 8700WHERE field1 IN ( 8701SELECT alias1.pk 8702FROM it AS alias1 8703LEFT JOIN it AS alias2 8704ON alias1.col_varchar = alias2.col_varchar 8705); 8706field1 87071 8708DROP TABLE it, ot; 8709# End of test for bug#12714094 8710# 8711# Bug#12867557: Valgrind: conditional jump/move at key_cmp 8712# 8713CREATE TABLE t1 ( 8714pk INTEGER AUTO_INCREMENT, 8715col_int_key INTEGER, 8716PRIMARY KEY (pk), 8717KEY (col_int_key) 8718) AUTO_INCREMENT=10; 8719INSERT INTO t1 (col_int_key) VALUES (8); 8720CREATE TABLE t2 ( 8721pk INTEGER AUTO_INCREMENT, 8722col_int_key INTEGER, 8723col_time_key TIME, 8724PRIMARY KEY (pk), 8725KEY (col_int_key), 8726KEY (col_time_key) 8727) AUTO_INCREMENT=10; 8728INSERT INTO t2 (col_int_key, col_time_key) 8729VALUES 8730(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'), 8731(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'), 8732(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'), 8733(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'), 8734(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'), 8735(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'), 8736(NULL, '08:46:48.042388'), (8, '14:11:27.044095'); 8737CREATE TABLE t0 8738SELECT DISTINCT grandparent1.col_time_key AS g1 8739FROM t2 AS grandparent1 8740WHERE grandparent1.col_int_key IN 8741(SELECT parent1.col_int_key AS p1 8742FROM t1 AS parent1) 8743AND grandparent1.pk > 9; 8744UPDATE t0 8745SET g1 = g1 8746WHERE g1 IN 8747(SELECT grandparent1.col_time_key AS g1 8748FROM t2 AS grandparent1 8749WHERE grandparent1.col_int_key IN 8750(SELECT parent1.col_int_key AS p1 8751FROM t1 AS parent1) 8752AND grandparent1.pk > 9); 8753DROP TABLE t0, t1, t2; 8754# End of test for bug#12867557 8755# 8756# Bug#12711441: crash in fix_after_pullout 8757# 8758CREATE TABLE t1 ( 8759pk int NOT NULL, 8760col_int_nokey int DEFAULT NULL, 8761col_int_key int DEFAULT NULL, 8762col_time_key time DEFAULT NULL, 8763col_varchar_key varchar(1) DEFAULT NULL, 8764PRIMARY KEY (pk) 8765); 8766CREATE VIEW v1 AS SELECT * FROM t1; 8767CREATE TABLE t2 ( 8768col_int_key int DEFAULT NULL, 8769col_varchar_key varchar(1) DEFAULT NULL, 8770col_varchar_nokey varchar(1) DEFAULT NULL, 8771KEY col_varchar_key(col_varchar_key, col_int_key) 8772); 8773CREATE TABLE t3 ( 8774pk int NOT NULL, 8775col_int_key INT DEFAULT NULL, 8776PRIMARY KEY (pk) 8777); 8778CREATE TABLE t4 ( 8779col_int_nokey INT DEFAULT NULL, 8780col_varchar_key varchar(1) DEFAULT NULL, 8781col_varchar_nokey varchar(1) DEFAULT NULL, 8782KEY col_varchar_key(col_varchar_key) 8783); 8784CREATE TABLE ts 8785SELECT alias1.col_time_key AS field1 8786FROM v1 AS alias1 8787RIGHT JOIN t3 AS alias2 8788ON alias2.col_int_key = alias1.col_int_nokey 8789WHERE alias1.pk >= SOME( 8790SELECT SQ1_alias1.pk AS SQ1_field1 8791FROM t3 AS SQ1_alias1 8792INNER JOIN (t2 AS SQ1_alias2 8793INNER JOIN t4 AS SQ1_alias3 8794ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) 8795ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key 8796WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key 8797AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) 8798; 8799SELECT * FROM ts WHERE field1 IN ( 8800SELECT alias1.col_time_key AS field1 8801FROM v1 AS alias1 8802RIGHT JOIN t3 AS alias2 8803ON alias2.col_int_key = alias1.col_int_nokey 8804WHERE alias1.pk >= SOME( 8805SELECT SQ1_alias1.pk AS SQ1_field1 8806FROM t3 AS SQ1_alias1 8807INNER JOIN (t2 AS SQ1_alias2 8808INNER JOIN t4 AS SQ1_alias3 8809ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey) 8810ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key 8811WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key 8812AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key) 8813); 8814field1 8815DROP TABLE t1, t2, t3, t4, ts; 8816DROP VIEW v1; 8817# End of test for bug#12711441. 8818# 8819# Bug#12664936: Same query executed as where subquery ... 8820# 8821CREATE TABLE t1 ( 8822col_varchar_key VARCHAR(1), 8823KEY col_varchar_key (col_varchar_key) 8824); 8825INSERT INTO t1 VALUES 8826('o'), ('w'), ('m'), ('q'), 8827('f'), ('p'), ('j'), ('c'); 8828CREATE TABLE t2 ( 8829col_int_nokey INTEGER, 8830col_int_key INTEGER, 8831col_varchar_key varchar(1), 8832KEY col_int_key (col_int_key) 8833); 8834INSERT INTO t2 VALUES 8835(8,5,'u'),(4,5,'p'),(8,1,'o'),(NULL,7,'v'), 8836(1,2,'g'),(2,1,'q'),(NULL,7,'l'),(3,1,'n'); 8837CREATE TABLE t4 8838SELECT t2.col_int_nokey, t2.col_varchar_key 8839FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key 8840WHERE t2.col_int_key = 1; 8841EXPLAIN SELECT * 8842FROM t4 8843WHERE (col_int_nokey, col_varchar_key) IN 8844(SELECT t2.col_int_nokey, t2.col_varchar_key 8845FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key 8846WHERE t2.col_int_key = 1 8847); 8848id select_type table partitions type possible_keys key key_len ref rows filtered Extra 88491 SIMPLE t4 NULL ALL NULL NULL NULL NULL 2 100.00 Using where 88501 SIMPLE t2 NULL ref col_int_key col_int_key 5 const 3 12.50 Using where 88511 SIMPLE t1 NULL ref col_varchar_key col_varchar_key 4 test.t4.col_varchar_key 2 100.00 Using index; FirstMatch(t4) 8852Warnings: 8853Note 1003 /* select#1 */ select `test`.`t4`.`col_int_nokey` AS `col_int_nokey`,`test`.`t4`.`col_varchar_key` AS `col_varchar_key` from `test`.`t4` semi join (`test`.`t1` join `test`.`t2`) where ((`test`.`t2`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t1`.`col_varchar_key` = `test`.`t4`.`col_varchar_key`) and (`test`.`t2`.`col_int_nokey` = `test`.`t4`.`col_int_nokey`) and (`test`.`t2`.`col_int_key` = 1)) 8854SELECT * 8855FROM t4 8856WHERE (col_int_nokey, col_varchar_key) IN 8857(SELECT t2.col_int_nokey, t2.col_varchar_key 8858FROM t1 JOIN t2 ON t2.col_varchar_key = t1.col_varchar_key 8859WHERE t2.col_int_key = 1 8860); 8861col_int_nokey col_varchar_key 88628 o 88632 q 8864DROP TABLE t1, t2, t4; 8865# End of test for bug#12664936. 8866# 8867# Bug#13340270: assertion table->sort.record_pointers == __null 8868# 8869CREATE TABLE t1 ( 8870pk int NOT NULL, 8871col_int_key int DEFAULT NULL, 8872col_varchar_key varchar(1) DEFAULT NULL, 8873col_varchar_nokey varchar(1) DEFAULT NULL, 8874PRIMARY KEY (pk), 8875KEY col_int_key (col_int_key), 8876KEY col_varchar_key (col_varchar_key, col_int_key) 8877) ENGINE=InnoDB; 8878INSERT INTO t1 VALUES 8879(10,8,'x','x'), 8880(11,7,'d','d'), 8881(12,1,'r','r'), 8882(13,7,'f','f'), 8883(14,9,'y','y'), 8884(15,NULL,'u','u'), 8885(16,1,'m','m'), 8886(17,9,NULL,NULL), 8887(18,2,'o','o'), 8888(19,9,'w','w'), 8889(20,2,'m','m'), 8890(21,4,'q','q'); 8891CREATE TABLE t2 8892SELECT alias1.col_varchar_nokey AS field1 8893FROM t1 AS alias1 JOIN t1 AS alias2 8894ON alias2.col_int_key = alias1.pk OR 8895alias2.col_int_key = alias1.col_int_key 8896WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' 8897 8898; 8899EXPLAIN SELECT * 8900FROM t2 8901WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 8902FROM t1 AS alias1 JOIN t1 AS alias2 8903ON alias2.col_int_key = alias1.pk OR 8904alias2.col_int_key = alias1.col_int_key 8905WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' 8906); 8907id select_type table partitions type possible_keys key key_len ref rows filtered Extra 89081 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 89091 SIMPLE alias1 NULL index_merge PRIMARY,col_int_key,col_varchar_key col_varchar_key,PRIMARY 4,4 NULL 2 10.00 Using sort_union(col_varchar_key,PRIMARY); Using where 89101 SIMPLE alias2 NULL ALL col_int_key NULL NULL NULL 12 19.00 Range checked for each record (index map: 0x2); FirstMatch(t2) 8911Warnings: 8912Note 1003 /* select#1 */ select `test`.`t2`.`field1` AS `field1` from `test`.`t2` semi join (`test`.`t1` `alias1` join `test`.`t1` `alias2`) where ((`test`.`alias1`.`col_varchar_nokey` = `test`.`t2`.`field1`) and ((`test`.`alias1`.`pk` = 58) or (`test`.`alias1`.`col_varchar_key` = 'o')) and ((`test`.`alias2`.`col_int_key` = `test`.`alias1`.`pk`) or (`test`.`alias2`.`col_int_key` = `test`.`alias1`.`col_int_key`))) 8913SELECT * 8914FROM t2 8915WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1 8916FROM t1 AS alias1 JOIN t1 AS alias2 8917ON alias2.col_int_key = alias1.pk OR 8918alias2.col_int_key = alias1.col_int_key 8919WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o' 8920); 8921field1 8922o 8923o 8924DROP TABLE t1, t2; 8925# End of test for bug#13340270. 8926# 8927# Bug#13335319: Seg fault when analyzing FirstMatch semi-join strategy 8928# 8929CREATE TABLE ot1(a INTEGER); 8930INSERT INTO ot1 VALUES(1), (2), (3); 8931CREATE TABLE ot2(a INTEGER); 8932INSERT INTO ot2 VALUES(1), (2), (4), (6), (8), (10); 8933CREATE TABLE it1(a INTEGER); 8934INSERT INTO it1 VALUES(1), (3), (5), (7); 8935CREATE TABLE it2(a INTEGER); 8936INSERT INTO it2 VALUES(1), (3), (5), (7), (9); 8937explain SELECT ot1.a, ot2.a 8938FROM ot1, ot2 8939WHERE ot1.a IN (SELECT a FROM it1) AND 8940ot2.a IN (SELECT a FROM it2); 8941id select_type table partitions type possible_keys key key_len ref rows filtered Extra 89421 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 3 100.00 NULL 89431 SIMPLE it1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(ot1); Using join buffer (Block Nested Loop) 89441 SIMPLE <subquery3> NULL ALL NULL NULL NULL NULL NULL 100.00 Using join buffer (Block Nested Loop) 89451 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (Block Nested Loop) 89463 MATERIALIZED it2 NULL ALL NULL NULL NULL NULL 5 100.00 NULL 8947Warnings: 8948Note 1003 /* select#1 */ select `test`.`ot1`.`a` AS `a`,`test`.`ot2`.`a` AS `a` from `test`.`ot1` semi join (`test`.`it1`) semi join (`test`.`it2`) join `test`.`ot2` where ((`test`.`ot2`.`a` = `<subquery3>`.`a`) and (`test`.`it1`.`a` = `test`.`ot1`.`a`)) 8949SELECT ot1.a, ot2.a 8950FROM ot1, ot2 8951WHERE ot1.a IN (SELECT a FROM it1) AND 8952ot2.a IN (SELECT a FROM it2); 8953a a 89541 1 89553 1 8956DROP TABLE ot1, ot2, it1, it2; 8957# End of test for bug#13335319. 8958# 8959# Bug#13334882: Assertion keypart_map failed in MyIsam function 8960# 8961CREATE TABLE t1 ( 8962pk int NOT NULL, 8963col_int_nokey INT NOT NULL, 8964col_int_key INT NOT NULL, 8965PRIMARY KEY (pk), 8966KEY col_int_key (col_int_key) 8967) ENGINE=MyISAM; 8968INSERT INTO t1 VALUES 8969(1,4,0), 8970(2,6,8), 8971(3,3,1), 8972(7,2,6), 8973(8,9,1), 8974(9,3,6), 8975(10,8,2), 8976(11,1,4), 8977(12,8,8), 8978(13,8,4), 8979(14,5,4); 8980CREATE TABLE t2 ( 8981pk int NOT NULL, 8982col_int_nokey int NOT NULL, 8983col_int_key int NOT NULL, 8984PRIMARY KEY (pk), 8985KEY col_int_key (col_int_key) 8986) ENGINE=MyISAM; 8987INSERT INTO t2 VALUES 8988(10,8,7); 8989CREATE TABLE t3 8990SELECT grandparent1.col_int_nokey AS g1 8991FROM t1 AS grandparent1 8992WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN 8993(SELECT parent1.col_int_key AS p1, 8994parent1.col_int_key AS p2 8995FROM t1 AS parent1 8996LEFT JOIN t2 AS parent2 8997ON parent1.col_int_nokey = parent2.col_int_key 8998) 8999AND grandparent1.col_int_key <> 3 9000; 9001explain SELECT * FROM t3 9002WHERE g1 NOT IN 9003(SELECT grandparent1.col_int_nokey AS g1 9004FROM t1 AS grandparent1 9005WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN 9006(SELECT parent1.col_int_key AS p1, 9007parent1.col_int_key AS p2 9008FROM t1 AS parent1 9009LEFT JOIN t2 AS parent2 9010ON parent1.col_int_nokey = parent2.col_int_key 9011) 9012AND grandparent1.col_int_key <> 3 9013); 9014id select_type table partitions type possible_keys key key_len ref rows filtered Extra 90151 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 90162 DEPENDENT SUBQUERY grandparent1 NULL ref col_int_key col_int_key 4 func 2 9.09 Using index condition; Using where 90172 DEPENDENT SUBQUERY parent1 NULL ref col_int_key col_int_key 4 func 2 100.00 Using index condition 90182 DEPENDENT SUBQUERY parent2 NULL ref col_int_key col_int_key 4 test.parent1.col_int_nokey 2 100.00 Using index; FirstMatch(grandparent1) 9019Warnings: 9020Note 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 (`test`.`parent1`.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`grandparent1`.`col_int_key` <> 3) and (<cache>('8') = `test`.`grandparent1`.`col_int_nokey`)))))) 9021explain format=json SELECT * FROM t3 9022WHERE g1 NOT IN 9023(SELECT grandparent1.col_int_nokey AS g1 9024FROM t1 AS grandparent1 9025WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN 9026(SELECT parent1.col_int_key AS p1, 9027parent1.col_int_key AS p2 9028FROM t1 AS parent1 9029LEFT JOIN t2 AS parent2 9030ON parent1.col_int_nokey = parent2.col_int_key 9031) 9032AND grandparent1.col_int_key <> 3 9033); 9034EXPLAIN 9035{ 9036 "query_block": { 9037 "select_id": 1, 9038 "message": "Impossible WHERE noticed after reading const tables", 9039 "optimized_away_subqueries": [ 9040 { 9041 "dependent": true, 9042 "cacheable": false, 9043 "query_block": { 9044 "select_id": 2, 9045 "cost_info": { 9046 "query_cost": "3.35" 9047 }, 9048 "nested_loop": [ 9049 { 9050 "table": { 9051 "table_name": "grandparent1", 9052 "access_type": "ref", 9053 "possible_keys": [ 9054 "col_int_key" 9055 ], 9056 "key": "col_int_key", 9057 "used_key_parts": [ 9058 "col_int_key" 9059 ], 9060 "key_length": "4", 9061 "ref": [ 9062 "func" 9063 ], 9064 "rows_examined_per_scan": 2, 9065 "rows_produced_per_join": 0, 9066 "filtered": "9.09", 9067 "index_condition": "(`test`.`grandparent1`.`col_int_key` <> 3)", 9068 "cost_info": { 9069 "read_cost": "2.00", 9070 "eval_cost": "0.04", 9071 "prefix_cost": "2.40", 9072 "data_read_per_join": "2" 9073 }, 9074 "used_columns": [ 9075 "col_int_nokey", 9076 "col_int_key" 9077 ], 9078 "attached_condition": "((`test`.`grandparent1`.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`) and (<cache>('8') = `test`.`grandparent1`.`col_int_nokey`))" 9079 } 9080 }, 9081 { 9082 "table": { 9083 "table_name": "parent1", 9084 "access_type": "ref", 9085 "possible_keys": [ 9086 "col_int_key" 9087 ], 9088 "key": "col_int_key", 9089 "used_key_parts": [ 9090 "col_int_key" 9091 ], 9092 "key_length": "4", 9093 "ref": [ 9094 "func" 9095 ], 9096 "rows_examined_per_scan": 2, 9097 "rows_produced_per_join": 0, 9098 "filtered": "100.00", 9099 "index_condition": "(`test`.`parent1`.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`)", 9100 "cost_info": { 9101 "read_cost": "0.36", 9102 "eval_cost": "0.07", 9103 "prefix_cost": "2.84", 9104 "data_read_per_join": "5" 9105 }, 9106 "used_columns": [ 9107 "col_int_nokey", 9108 "col_int_key" 9109 ] 9110 } 9111 }, 9112 { 9113 "table": { 9114 "table_name": "parent2", 9115 "access_type": "ref", 9116 "possible_keys": [ 9117 "col_int_key" 9118 ], 9119 "key": "col_int_key", 9120 "used_key_parts": [ 9121 "col_int_key" 9122 ], 9123 "key_length": "4", 9124 "ref": [ 9125 "test.parent1.col_int_nokey" 9126 ], 9127 "rows_examined_per_scan": 2, 9128 "rows_produced_per_join": 0, 9129 "filtered": "100.00", 9130 "using_index": true, 9131 "first_match": "grandparent1", 9132 "cost_info": { 9133 "read_cost": "0.37", 9134 "eval_cost": "0.04", 9135 "prefix_cost": "3.35", 9136 "data_read_per_join": "2" 9137 }, 9138 "used_columns": [ 9139 "col_int_key" 9140 ] 9141 } 9142 } 9143 ] 9144 } 9145 } 9146 ] 9147 } 9148} 9149Warnings: 9150Note 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 (`test`.`parent1`.`col_int_key` = `test`.`grandparent1`.`col_int_nokey`) and (`test`.`grandparent1`.`col_int_key` <> 3) and (<cache>('8') = `test`.`grandparent1`.`col_int_nokey`)))))) 9151SELECT * FROM t3 9152WHERE g1 NOT IN 9153(SELECT grandparent1.col_int_nokey AS g1 9154FROM t1 AS grandparent1 9155WHERE (grandparent1.col_int_nokey, grandparent1.col_int_key) IN 9156(SELECT parent1.col_int_key AS p1, 9157parent1.col_int_key AS p2 9158FROM t1 AS parent1 9159LEFT JOIN t2 AS parent2 9160ON parent1.col_int_nokey = parent2.col_int_key 9161) 9162AND grandparent1.col_int_key <> 3 9163); 9164g1 9165DROP TABLE t1, t2, t3; 9166# End of test for bug#13334882. 9167# 9168# Bug#13339643: Assertion on JOIN::flatten_subqueries on second execution 9169# 9170CREATE TABLE t1 ( 9171col_int_nokey INT, 9172col_varchar_nokey VARCHAR(1) 9173); 9174INSERT INTO t1 VALUES 9175(1,'o'), 9176(2,'t'); 9177CREATE TABLE t2 LIKE t1; 9178INSERT INTO t2 VALUES 9179(1,'o'), 9180(4,'f'); 9181CREATE VIEW v_t2 AS SELECT * FROM t2; 9182CREATE TABLE t3 LIKE t1; 9183INSERT INTO t3 VALUES 9184(1,'o'), 9185(4,'f'); 9186explain SELECT alias1.col_varchar_nokey 9187FROM t1 AS alias1 9188INNER JOIN v_t2 AS alias2 9189ON alias2.col_int_nokey = alias1.col_int_nokey AND 9190'o' IN (SELECT col_varchar_nokey 9191FROM t3); 9192id select_type table partitions type possible_keys key key_len ref rows filtered Extra 91931 SIMPLE t3 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch 91941 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using join buffer (Block Nested Loop) 91951 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (Block Nested Loop) 9196Warnings: 9197Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias1` semi join (`test`.`t3`) join `test`.`t2` where ((`test`.`t3`.`col_varchar_nokey` = 'o') and (`test`.`t2`.`col_int_nokey` = `test`.`alias1`.`col_int_nokey`)) 9198SELECT alias1.col_varchar_nokey 9199FROM t1 AS alias1 9200INNER JOIN v_t2 AS alias2 9201ON alias2.col_int_nokey = alias1.col_int_nokey AND 9202'o' IN (SELECT col_varchar_nokey 9203FROM t3); 9204col_varchar_nokey 9205o 9206PREPARE stmt FROM "SELECT alias1.col_varchar_nokey 9207FROM t1 AS alias1 9208INNER JOIN v_t2 AS alias2 9209ON alias2.col_int_nokey = alias1.col_int_nokey AND 9210'o' IN (SELECT col_varchar_nokey 9211FROM t3)"; 9212EXECUTE stmt; 9213col_varchar_nokey 9214o 9215DROP VIEW v_t2; 9216DROP TABLE t1, t2, t3; 9217# End of test for bug#13339643. 9218# 9219# Bug#13424134: Wrong result on JOIN + nested WHERE ... IN clauses 9220# 9221CREATE TABLE t1 ( 9222pk int NOT NULL, 9223col_int_nokey int NOT NULL, 9224col_int_key int NOT NULL, 9225PRIMARY KEY (pk), 9226KEY col_int_key (col_int_key) 9227) ENGINE=MyIsam; 9228INSERT INTO t1 VALUES 9229(10,1,7), (13,7,3), (18,0,1), (23,8,1); 9230CREATE TABLE t2 ( 9231pk int NOT NULL, 9232col_int_key int NOT NULL, 9233PRIMARY KEY (pk), 9234KEY col_int_key (col_int_key) 9235) ENGINE=MyIsam; 9236INSERT INTO t2 VALUES (1,7); 9237EXPLAIN SELECT t1a.* 9238FROM t1 AS t1a 9239JOIN t1 AS t1b USING ( col_int_nokey ) 9240WHERE t1a.col_int_key IN ( 9241SELECT pk 9242FROM t2 9243WHERE col_int_key IN ( 9244SELECT col_int_nokey 9245FROM t1 9246) 9247); 9248id select_type table partitions type possible_keys key key_len ref rows filtered Extra 92491 SIMPLE t2 NULL system PRIMARY,col_int_key NULL NULL NULL 1 100.00 NULL 92501 SIMPLE t1a NULL ref col_int_key col_int_key 4 const 1 100.00 NULL 92511 SIMPLE t1b NULL ALL NULL NULL NULL NULL 4 25.00 Using where; Using join buffer (Block Nested Loop) 92521 SIMPLE t1 NULL ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t1b); Using join buffer (Block Nested Loop) 9253Warnings: 9254Note 1003 /* select#1 */ select `test`.`t1a`.`pk` AS `pk`,`test`.`t1a`.`col_int_nokey` AS `col_int_nokey`,`test`.`t1a`.`col_int_key` AS `col_int_key` from `test`.`t1` `t1a` semi join (`test`.`t1`) join `test`.`t1` `t1b` where ((`test`.`t1b`.`col_int_nokey` = `test`.`t1a`.`col_int_nokey`) and (`test`.`t1a`.`col_int_key` = '1') and (`test`.`t1`.`col_int_nokey` = '7')) 9255SELECT t1a.* 9256FROM t1 AS t1a 9257JOIN t1 AS t1b USING ( col_int_nokey ) 9258WHERE t1a.col_int_key IN ( 9259SELECT pk 9260FROM t2 9261WHERE col_int_key IN ( 9262SELECT col_int_nokey 9263FROM t1 9264) 9265); 9266pk col_int_nokey col_int_key 926718 0 1 926823 8 1 9269ALTER TABLE t1 ENGINE=Innodb; 9270ALTER TABLE t2 ENGINE=Innodb; 9271SELECT t1a.* 9272FROM t1 AS t1a 9273JOIN t1 AS t1b USING ( col_int_nokey ) 9274WHERE t1a.col_int_key IN ( 9275SELECT pk 9276FROM t2 9277WHERE col_int_key IN ( 9278SELECT col_int_nokey 9279FROM t1 9280) 9281); 9282pk col_int_nokey col_int_key 928318 0 1 928423 8 1 9285DROP TABLE t1, t2; 9286# End of test for bug#13424134. 9287# 9288# Bug#13414014: Extra rows in result on semijoin query with where ... 9289# 9290CREATE TABLE t1 ( 9291c INT, 9292d INT, 9293a VARCHAR(1), 9294b VARCHAR(1), 9295KEY a (a) 9296); 9297INSERT INTO t1 VALUES 9298(NULL,8,'x','x'), (7,4,'q','q'), (6,8,'c','c'); 9299CREATE TABLE t2 ( 9300a VARCHAR(1), 9301KEY a (a) 9302); 9303INSERT INTO t2 VALUES 9304('c'), (NULL), ('x'), ('q'); 9305explain SELECT * 9306FROM t2 AS ot 9307WHERE (a, a) IN 9308(SELECT a, b 9309FROM t1 AS it 9310WHERE it.a = 'x' OR it.c > it.d 9311) 9312; 9313id select_type table partitions type possible_keys key key_len ref rows filtered Extra 93141 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 100.00 Using where 93151 SIMPLE ot NULL ref a a 4 <subquery2>.a 2 100.00 Using index 93162 MATERIALIZED it NULL ALL a NULL NULL NULL 3 40.74 Using where 9317Warnings: 9318Note 1003 /* select#1 */ select `test`.`ot`.`a` AS `a` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`<subquery2>`.`b` = `<subquery2>`.`a`) and (`test`.`ot`.`a` = `<subquery2>`.`a`) and (`test`.`it`.`b` = `test`.`it`.`a`) and (((`<subquery2>`.`a` = 'x') and (`test`.`it`.`a` = 'x') and (`test`.`it`.`b` = 'x')) or (`test`.`it`.`c` > `test`.`it`.`d`))) 9319SELECT * 9320FROM t2 AS ot 9321WHERE (a, a) IN 9322(SELECT a, b 9323FROM t1 AS it 9324WHERE it.a = 'x' OR it.c > it.d 9325) 9326; 9327a 9328x 9329q 9330DROP TABLE t1, t2; 9331# End of test for bug#13414014. 9332# 9333# Bug#13545215: Missing rows on nested in-subquery with materialization 9334# 9335CREATE TABLE t1 ( 9336col_int_key int, 9337col_varchar_key varchar(1), 9338col_varchar_nokey varchar(1), 9339KEY col_int_key (col_int_key), 9340KEY col_varchar_key (col_varchar_key,col_int_key) 9341) ; 9342INSERT INTO t1 VALUES 9343(8,'x','x'), (0,'p','p'), (8,'c','c'); 9344CREATE TABLE t2 ( 9345pk int NOT NULL, 9346col_varchar_key varchar(1), 9347col_varchar_nokey varchar(1), 9348PRIMARY KEY (pk), 9349KEY col_varchar_key (col_varchar_key) 9350); 9351INSERT INTO t2 VALUES 9352(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL), 9353(5,'x','x'), (6,'i','i'), (7,'e','e'), (8,'p','p'); 9354CREATE TABLE t3 ( 9355col_int_nokey int 9356); 9357INSERT INTO t3 VALUES (7); 9358explain SELECT grandparent1.col_varchar_nokey 9359FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) 9360WHERE grandparent1.col_varchar_key IN ( 9361SELECT col_varchar_nokey 9362FROM t2 AS parent1 9363WHERE col_varchar_key IN ( 9364SELECT child1.col_varchar_nokey 9365FROM t2 AS child1 LEFT JOIN t3 AS child2 9366ON child1.pk < child2.col_int_nokey 9367) 9368); 9369id select_type table partitions type possible_keys key key_len ref rows filtered Extra 93701 SIMPLE grandparent1 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 3 100.00 Start temporary 93711 SIMPLE parent1 NULL ALL col_varchar_key NULL NULL NULL 8 12.50 Using where; Using join buffer (Block Nested Loop) 93721 SIMPLE child1 NULL ALL NULL NULL NULL NULL 8 12.50 Using where; Using join buffer (Block Nested Loop) 93731 SIMPLE child2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where; End temporary; Using join buffer (Block Nested Loop) 93741 SIMPLE grandparent2 NULL index col_int_key col_int_key 5 NULL 3 33.33 Using where; Using index; Using join buffer (Block Nested Loop) 9375Warnings: 9376Note 1003 /* select#1 */ select `test`.`grandparent1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `grandparent1` semi join (`test`.`t2` `child1` left join `test`.`t3` `child2` on((`test`.`child1`.`pk` < `test`.`child2`.`col_int_nokey`)) join `test`.`t2` `parent1`) join `test`.`t1` `grandparent2` where ((`test`.`grandparent2`.`col_int_key` = `test`.`grandparent1`.`col_int_key`) and (`test`.`parent1`.`col_varchar_nokey` = `test`.`grandparent1`.`col_varchar_key`) and (`test`.`child1`.`col_varchar_nokey` = `test`.`parent1`.`col_varchar_key`)) 9377SELECT grandparent1.col_varchar_nokey 9378FROM t1 AS grandparent1 JOIN t1 AS grandparent2 USING (col_int_key) 9379WHERE grandparent1.col_varchar_key IN ( 9380SELECT col_varchar_nokey 9381FROM t2 AS parent1 9382WHERE col_varchar_key IN ( 9383SELECT child1.col_varchar_nokey 9384FROM t2 AS child1 LEFT JOIN t3 AS child2 9385ON child1.pk < child2.col_int_nokey 9386) 9387); 9388col_varchar_nokey 9389c 9390c 9391p 9392x 9393x 9394DROP TABLE t1, t2, t3; 9395# End of test for bug#13545215. 9396# 9397# BUG#13553211 - MISSING ROWS ON SELECT WITH IN-SUBQUERY AND 9398# MATERIALIZATION + SEMIJOIN ON 9399# 9400CREATE TABLE t1 ( 9401col_int_key int(11) DEFAULT NULL, 9402col_varchar_key varchar(1) DEFAULT NULL, 9403col_varchar_nokey varchar(1) DEFAULT NULL, 9404KEY col_int_key (col_int_key), 9405KEY col_varchar_key (col_varchar_key,col_int_key) 9406); 9407INSERT INTO t1 VALUES (4,'v','v'); 9408INSERT INTO t1 VALUES (62,'v','v'); 9409INSERT INTO t1 VALUES (7,'c','c'); 9410INSERT INTO t1 VALUES (1,NULL,NULL); 9411EXPLAIN SELECT 9412alias1.col_varchar_nokey AS a1_nokey, 9413alias1.col_varchar_key AS a1_key, 9414alias2.col_varchar_nokey AS a2_nokey 9415FROM 9416t1 AS alias1, t1 AS alias2 9417WHERE 9418(alias1.col_varchar_nokey,alias2.col_varchar_nokey) 9419IN 9420( 9421SELECT 9422sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key 9423FROM 9424t1 AS sq2_alias1, t1 AS sq2_alias2 9425) 9426; 9427id select_type table partitions type possible_keys key key_len ref rows filtered Extra 94281 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 4 100.00 Using where 94291 SIMPLE alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (Block Nested Loop) 94301 SIMPLE <subquery2> NULL eq_ref <auto_key> <auto_key> 8 test.alias1.col_varchar_nokey,test.alias2.col_varchar_nokey 1 100.00 NULL 94312 MATERIALIZED sq2_alias1 NULL index col_varchar_key col_varchar_key 9 NULL 4 100.00 Using index 94322 MATERIALIZED sq2_alias2 NULL ALL NULL NULL NULL NULL 4 100.00 Using join buffer (Block Nested Loop) 9433Warnings: 9434Note 1003 /* select#1 */ select `test`.`alias1`.`col_varchar_nokey` AS `a1_nokey`,`test`.`alias1`.`col_varchar_key` AS `a1_key`,`test`.`alias2`.`col_varchar_nokey` AS `a2_nokey` from `test`.`t1` `alias1` semi join (`test`.`t1` `sq2_alias1` join `test`.`t1` `sq2_alias2`) join `test`.`t1` `alias2` where ((`<subquery2>`.`col_varchar_key` = `test`.`alias2`.`col_varchar_nokey`) and (`<subquery2>`.`col_varchar_nokey` = `test`.`alias1`.`col_varchar_nokey`)) 9435SELECT 9436alias1.col_varchar_nokey AS a1_nokey, 9437alias1.col_varchar_key AS a1_key, 9438alias2.col_varchar_nokey AS a2_nokey 9439FROM 9440t1 AS alias1, t1 AS alias2 9441WHERE 9442(alias1.col_varchar_nokey,alias2.col_varchar_nokey) 9443IN 9444( 9445SELECT 9446sq2_alias2.col_varchar_nokey, sq2_alias1.col_varchar_key 9447FROM 9448t1 AS sq2_alias1, t1 AS sq2_alias2 9449) 9450; 9451a1_nokey a1_key a2_nokey 9452c c c 9453c c v 9454c c v 9455v v c 9456v v c 9457v v v 9458v v v 9459v v v 9460v v v 9461DROP TABLE t1; 9462# 9463# Bug#13541406: Wrong result with loosescan on select .. where .. in 9464# 9465CREATE TABLE t1 ( 9466col_int_key INT NOT NULL, 9467col_varchar_nokey VARCHAR(1) NOT NULL, 9468KEY col_int_key (col_int_key) 9469) ENGINE=InnoDB; 9470INSERT INTO t1 VALUES 9471(7,'v'), (0,'s'), (9,'l'), (3,'y'), (4,'c'), (2,'i'), (5,'h'), (3,'q'), 9472(1,'a'), (3,'v'), (6,'u'), (7,'s'), (5,'y'), (1,'z'), (204,'h'), (224,'p'), 9473(9,'e'), (5,'i'), (0,'y'), (3,'w'); 9474CREATE TABLE t2 ( 9475pk INT NOT NULL, 9476col_int_key INT NOT NULL, 9477col_varchar_key VARCHAR(1) NOT NULL, 9478col_varchar_nokey VARCHAR(1) NOT NULL, 9479PRIMARY KEY (pk), 9480KEY col_int_key (col_int_key), 9481KEY col_varchar_key (col_varchar_key,col_int_key) 9482) ENGINE=InnoDB; 9483INSERT INTO t2 VALUES 9484(1,0,'j','j'), (2,8,'v','v'), (3,1,'c','c'), (4,8,'m','m'), 9485(5,9,'d','d'), (6,24,'d','d'), (7,6,'y','y'), (8,1,'t','t'), 9486(9,6,'d','d'), (10,2,'s','s'), (11,4,'r','r'), (12,8,'m','m'), 9487(13,4,'b','b'), (14,4,'x','x'), (15,7,'g','g'), (16,4,'p','p'), 9488(17,1,'q','q'), (18,9,'w','w'), (19,4,'d','d'), (20,8,'e','e'); 9489# This query should never use a LooseScan strategy 9490explain SELECT ot1.col_int_key AS field1 9491FROM t2 AS ot1, t2 AS ot2 9492WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( 9493SELECT it2.col_varchar_nokey, it1.col_varchar_key 9494FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); 9495id select_type table partitions type possible_keys key key_len ref rows filtered Extra 94961 SIMPLE <subquery2> NULL ALL NULL NULL NULL NULL NULL 100.00 NULL 94971 SIMPLE ot1 NULL ref col_varchar_key col_varchar_key 3 <subquery2>.col_varchar_nokey 1 100.00 Using index 94981 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (Block Nested Loop) 94992 MATERIALIZED it2 NULL ALL col_int_key NULL NULL NULL 20 100.00 NULL 95002 MATERIALIZED it1 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.it2.col_int_key 1 100.00 NULL 9501Warnings: 9502Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `field1` from `test`.`t2` `ot1` semi join (`test`.`t2` `it1` join `test`.`t1` `it2`) join `test`.`t2` `ot2` where ((`test`.`it1`.`pk` = `test`.`it2`.`col_int_key`) and (`test`.`ot2`.`col_varchar_nokey` = `<subquery2>`.`col_varchar_key`) and (`test`.`ot1`.`col_varchar_key` = `<subquery2>`.`col_varchar_nokey`)) 9503SELECT ot1.col_int_key AS field1 9504FROM t2 AS ot1, t2 AS ot2 9505WHERE (ot1.col_varchar_key, ot2.col_varchar_nokey) IN ( 9506SELECT it2.col_varchar_nokey, it1.col_varchar_key 9507FROM t2 AS it1 JOIN t1 AS it2 ON it2.col_int_key = it1.pk); 9508field1 95091 95101 95111 95122 95136 95146 95156 95166 95176 95188 95198 95208 95218 95228 95238 95249 9525DROP TABLE t1, t2; 9526# End of test for bug#13541406. 9527# 9528# Bug#13576391: Missing rows on select with in-subquery and 9529# batched-key-access=on and semijoin 9530# 9531CREATE TABLE t1 ( 9532col_int_nokey int NOT NULL, 9533col_varchar_key varchar(1) NOT NULL, 9534KEY col_varchar_key (col_varchar_key) 9535) engine=InnoDB; 9536INSERT INTO t1 VALUES 9537(1,'v'), (7,'s'), (4,'l'), (7,'y'), (0,'c'), (2,'i'), (9,'h'), (4,'q'), 9538(0,'a'), (9,'v'), (1,'u'), (3,'s'), (8,'y'), (8,'z'), (18,'h'), (84,'p'), 9539(6,'e'), (3,'i'), (6,'y'), (6,'w'); 9540CREATE TABLE t2 ( 9541col_int_nokey int NOT NULL, 9542col_varchar_nokey varchar(1) NOT NULL 9543) engine=InnoDB; 9544INSERT INTO t2 VALUES 9545(4,'j'), (6,'v'), (3,'c'), (5,'m'), (3,'d'), (246,'d'), (2,'y'), (9,'t'), 9546(3,'d'), (8,'s'), (1,'r'), (8,'m'), (8,'b'), (5,'x'), (7,'g'), (5,'p'), 9547(1,'q'), (6,'w'), (2,'d'), (9,'e'); 9548explain SELECT col_varchar_nokey 9549FROM t2 AS ot 9550WHERE col_varchar_nokey IN ( 9551SELECT col_varchar_key 9552FROM t1 AS it 9553WHERE it.col_int_nokey <= it.col_int_nokey 9554AND NOT ot.col_int_nokey < 2 9555) 9556ORDER BY col_varchar_nokey; 9557id select_type table partitions type possible_keys key key_len ref rows filtered Extra 95581 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using temporary; Using filesort 95591 SIMPLE it NULL ref col_varchar_key col_varchar_key 3 test.ot.col_varchar_nokey 1 100.00 FirstMatch(ot); Using join buffer (Batched Key Access) 9560Warnings: 9561Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 9562Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` 9563SELECT col_varchar_nokey 9564FROM t2 AS ot 9565WHERE col_varchar_nokey IN ( 9566SELECT col_varchar_key 9567FROM t1 AS it 9568WHERE it.col_int_nokey <= it.col_int_nokey 9569AND NOT ot.col_int_nokey < 2 9570) 9571ORDER BY col_varchar_nokey; 9572col_varchar_nokey 9573c 9574e 9575p 9576s 9577v 9578w 9579y 9580ALTER TABLE t1 ENGINE=MyISAM; 9581ALTER TABLE t2 ENGINE=MyISAM; 9582explain SELECT col_varchar_nokey 9583FROM t2 AS ot 9584WHERE col_varchar_nokey IN ( 9585SELECT col_varchar_key 9586FROM t1 AS it 9587WHERE it.col_int_nokey <= it.col_int_nokey 9588AND NOT ot.col_int_nokey < 2 9589) 9590ORDER BY col_varchar_nokey; 9591id select_type table partitions type possible_keys key key_len ref rows filtered Extra 95921 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using temporary; Using filesort 95931 SIMPLE it NULL ref col_varchar_key col_varchar_key 3 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot); Using join buffer (Batched Key Access) 9594Warnings: 9595Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 9596Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` 9597SELECT col_varchar_nokey 9598FROM t2 AS ot 9599WHERE col_varchar_nokey IN ( 9600SELECT col_varchar_key 9601FROM t1 AS it 9602WHERE it.col_int_nokey <= it.col_int_nokey 9603AND NOT ot.col_int_nokey < 2 9604) 9605ORDER BY col_varchar_nokey; 9606col_varchar_nokey 9607c 9608e 9609p 9610s 9611v 9612w 9613y 9614ALTER TABLE t1 ENGINE=Memory; 9615ALTER TABLE t2 ENGINE=Memory; 9616explain SELECT col_varchar_nokey 9617FROM t2 AS ot 9618WHERE col_varchar_nokey IN ( 9619SELECT col_varchar_key 9620FROM t1 AS it 9621WHERE it.col_int_nokey <= it.col_int_nokey 9622AND NOT ot.col_int_nokey < 2 9623) 9624ORDER BY col_varchar_nokey; 9625id select_type table partitions type possible_keys key key_len ref rows filtered Extra 96261 SIMPLE ot NULL ALL NULL NULL NULL NULL 20 33.33 Using where; Using filesort 96271 SIMPLE it NULL ref col_varchar_key col_varchar_key 3 test.ot.col_varchar_nokey 2 100.00 FirstMatch(ot) 9628Warnings: 9629Note 1276 Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1 9630Note 1003 /* select#1 */ select `test`.`ot`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `ot` semi join (`test`.`t1` `it`) where ((`test`.`it`.`col_varchar_key` = `test`.`ot`.`col_varchar_nokey`) and (`test`.`ot`.`col_int_nokey` >= 2)) order by `test`.`ot`.`col_varchar_nokey` 9631SELECT col_varchar_nokey 9632FROM t2 AS ot 9633WHERE col_varchar_nokey IN ( 9634SELECT col_varchar_key 9635FROM t1 AS it 9636WHERE it.col_int_nokey <= it.col_int_nokey 9637AND NOT ot.col_int_nokey < 2 9638) 9639ORDER BY col_varchar_nokey; 9640col_varchar_nokey 9641c 9642e 9643p 9644s 9645v 9646w 9647y 9648DROP TABLE t1, t2; 9649# End of test for bug#13576391. 9650# 9651# Bug #13589848 "MISSING ROW ON SELECT WITH NESTED IN CLAUSES WHEN LOOSESCAN=ON" 9652# 9653CREATE TABLE t1 ( 9654id INT, 9655col_varchar_key VARCHAR(1), 9656col_varchar_nokey VARCHAR(1), 9657KEY (col_varchar_key) 9658); 9659INSERT INTO t1 VALUES (100,'m','m'), 9660(200,'b','b'), (300,'x','x'); 9661CREATE TABLE t2 ( 9662col_varchar_key VARCHAR(1), 9663col_varchar_nokey VARCHAR(1), 9664KEY (col_varchar_key) 9665); 9666INSERT INTO t2 VALUES ('b','b'); 9667CREATE TABLE t3 ( 9668col_varchar_key VARCHAR(1), 9669col_varchar_nokey VARCHAR(1), 9670KEY (col_varchar_key) 9671); 9672INSERT INTO t3 VALUES ('k','k'); 9673EXPLAIN SELECT gp1.id 9674FROM t1 AS gp1 JOIN t3 AS gp2 9675ON gp2.col_varchar_key <> gp1.col_varchar_nokey 9676WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) 9677IN ( 9678SELECT col_varchar_nokey, col_varchar_nokey 9679FROM t1 9680WHERE col_varchar_nokey 9681IN ( SELECT col_varchar_key 9682FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) 9683) 9684; 9685id select_type table partitions type possible_keys key key_len ref rows filtered Extra 96861 SIMPLE gp2 NULL system NULL NULL NULL NULL 1 100.00 NULL 96871 SIMPLE t2 NULL index col_varchar_key col_varchar_key 4 NULL 1 100.00 Using where; Using index; Start temporary 96881 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (Block Nested Loop) 96891 SIMPLE gp1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (Block Nested Loop) 96901 SIMPLE t3 NULL ref col_varchar_key col_varchar_key 4 test.t2.col_varchar_key 2 100.00 Using index; End temporary 9691Warnings: 9692Note 1003 /* select#1 */ select `test`.`gp1`.`id` AS `id` from `test`.`t1` `gp1` semi join (`test`.`t2` left join `test`.`t3` on((`test`.`t2`.`col_varchar_key` = `test`.`t3`.`col_varchar_key`)) join `test`.`t1`) where ((`test`.`t1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and (`test`.`gp1`.`col_varchar_nokey` = `test`.`t2`.`col_varchar_key`) and ('k' <> `test`.`t2`.`col_varchar_key`)) 9693SELECT gp1.id 9694FROM t1 AS gp1 JOIN t3 AS gp2 9695ON gp2.col_varchar_key <> gp1.col_varchar_nokey 9696WHERE (gp1.col_varchar_nokey, gp1.col_varchar_nokey) 9697IN ( 9698SELECT col_varchar_nokey, col_varchar_nokey 9699FROM t1 9700WHERE col_varchar_nokey 9701IN ( SELECT col_varchar_key 9702FROM t2 LEFT JOIN t3 USING (col_varchar_key) ) 9703) 9704; 9705id 9706200 9707DROP TABLE t1,t2,t3; 9708# 9709# Bug #13596176: Missing row on select with nested in clause when 9710# matr=on and bnl=off + MyISAM 9711# 9712CREATE TABLE t1 ( 9713int_key int DEFAULT NULL, 9714vc_key varchar(1) DEFAULT NULL, 9715vc_nokey varchar(1) DEFAULT NULL, 9716KEY int_key (int_key), 9717KEY vc_key (vc_key, int_key) 9718) ENGINE=MyISAM; 9719INSERT INTO t1 VALUES 9720(8,'x','x'), (7,'d','d'), (1,'r','r'), (7,'f','f'), 9721(9,'y','y'), (NULL,'u','u'), (1,'m','m'), (9,NULL,NULL), 9722(2,'o','o'), (9,'w','w'), (2,'m','m'), (4,'q','q'), 9723(0,NULL,NULL), (4,'d','d'), (8,'g','g'), (NULL,'x','x'), 9724(NULL,'f','f'), (0,'p','p'), (NULL,'j','j'), (8,'c','c'); 9725CREATE TABLE t2 ( 9726int_key int DEFAULT NULL, 9727vc_key varchar(1) DEFAULT NULL, 9728KEY int_key (int_key), 9729KEY vc_key (vc_key, int_key) 9730) ENGINE=MyISAM; 9731INSERT INTO t2 VALUES (8,'g'); 9732explain SELECT vc_key 9733FROM t1 as outr 9734WHERE (vc_nokey, vc_key ) IN 9735(SELECT vc_nokey, vc_nokey 9736FROM t1 middle 9737WHERE vc_nokey IN 9738(SELECT child1.vc_key 9739FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) 9740) 9741); 9742id select_type table partitions type possible_keys key key_len ref rows filtered Extra 97431 SIMPLE child1 NULL index int_key,vc_key vc_key 9 NULL 1 100.00 Using where; Using index; Start temporary 97441 SIMPLE outr NULL ref vc_key vc_key 4 test.child1.vc_key 3 10.00 Using where; Using join buffer (Batched Key Access) 97451 SIMPLE middle NULL ALL NULL NULL NULL NULL 20 10.00 Using where; Using join buffer (Block Nested Loop) 97461 SIMPLE child2 NULL ref int_key int_key 5 test.child1.int_key 3 100.00 Using index; End temporary 9747Warnings: 9748Note 1003 /* select#1 */ select `test`.`outr`.`vc_key` AS `vc_key` from `test`.`t1` `outr` semi join (`test`.`t2` `child1` join `test`.`t1` `child2` join `test`.`t1` `middle`) where ((`test`.`child2`.`int_key` = `test`.`child1`.`int_key`) and (`test`.`outr`.`vc_nokey` = `test`.`child1`.`vc_key`) and (`test`.`outr`.`vc_key` = `test`.`child1`.`vc_key`) and (`test`.`middle`.`vc_nokey` = `test`.`child1`.`vc_key`)) 9749SELECT vc_key 9750FROM t1 as outr 9751WHERE (vc_nokey, vc_key ) IN 9752(SELECT vc_nokey, vc_nokey 9753FROM t1 middle 9754WHERE vc_nokey IN 9755(SELECT child1.vc_key 9756FROM t2 AS child1 JOIN t1 AS child2 USING (int_key) 9757) 9758); 9759vc_key 9760g 9761DROP TABLE t1, t2; 9762# End of test for bug#13596176. 9763# 9764# BUG#11754478: MAX/MIN + SUBQUERY + AND FAILS TO RETURN ANY ROWS 9765# BUG#13599013: MAX/MIN + SUBQUERY IN WHERE CLAUSE MATCHING NO 9766# ROWS + INDEX DOES NOT RETURN NULL 9767# 9768CREATE TABLE t1 ( 9769pk int(11) PRIMARY KEY, 9770int_key int(11), 9771KEY int_key (int_key) 9772); 9773INSERT INTO t1 VALUES (1,0),(2,0),(3,2),(4,0),(5,3),(6,0); 9774SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 1, 2); 9775MIN(int_key) 9776NULL 9777SELECT MIN(int_key) FROM t1 WHERE (4, 4) IN (SELECT 4, 4); 9778MIN(int_key) 97790 9780SELECT MIN(pk) FROM t1 WHERE pk IN (SELECT int_key FROM t1) AND pk = 6; 9781MIN(pk) 9782NULL 9783DROP TABLE t1; 9784# BUG#13726217: Crash in Item_ident::fix_after_pullout() 9785CREATE TABLE t1(a INTEGER) engine=innodb; 9786INSERT INTO t1 VALUES (0); 9787SELECT 0 9788FROM t1 9789WHERE 0 IN 9790(SELECT 0 9791FROM t1 9792WHERE 0 LIKE 9793(SELECT elt(a, 0) AS b 9794FROM t1 9795GROUP BY a 9796HAVING b 9797) 9798); 97990 9800DROP TABLE t1; 9801# End of test for bug#13726217. 9802# BUG#13773979: Missing rows on second execution of prepared statement 9803CREATE TABLE t1 ( 9804col_int_nokey INT, 9805col_int_key INT, 9806col_varchar_key VARCHAR(1) 9807); 9808INSERT INTO t1 VALUES 9809(1,7,'v'), (7,0,'s'), (4,9,'l'), (7,3,'y'), 9810(2,2,'i'), (9,5,'h'), (0,1,'a'), (9,3,'v'); 9811CREATE VIEW v1 AS SELECT * FROM t1; 9812SELECT * 9813FROM t1 9814WHERE col_int_key IN ( 9815SELECT alias1.col_int_nokey AS field1 9816FROM v1 AS alias1 9817WHERE alias1.col_varchar_key < 'v' 9818); 9819col_int_nokey col_int_key col_varchar_key 98201 7 v 98212 2 i 98224 9 l 98237 0 s 9824prepare stmt FROM "SELECT * 9825FROM t1 9826WHERE col_int_key IN ( 9827SELECT alias1.col_int_nokey AS field1 9828FROM v1 AS alias1 9829WHERE alias1.col_varchar_key < 'v' 9830)"; 9831execute stmt; 9832col_int_nokey col_int_key col_varchar_key 98331 7 v 98342 2 i 98354 9 l 98367 0 s 9837execute stmt; 9838col_int_nokey col_int_key col_varchar_key 98391 7 v 98402 2 i 98414 9 l 98427 0 s 9843DEALLOCATE PREPARE stmt; 9844DROP VIEW v1; 9845DROP TABLE t1; 9846# End of test for bug#13773979. 9847# 9848# BUG#13685026 ASSERTION CUR_SJ_INNER_TABLES == 0 IN 9849# --OPTIMIZE_TABLE_ORDER::CHOOSE_TABLE_ORDER 9850# 9851CREATE TABLE t1 ( 9852col_int_key INT(11) NOT NULL, 9853col_datetime_key DATETIME NOT NULL, 9854col_varchar_key VARCHAR(1) NOT NULL, 9855col_varchar_nokey VARCHAR(1) NOT NULL, 9856KEY col_int_key (col_int_key), 9857KEY col_datetime_key (col_datetime_key), 9858KEY col_varchar_key (col_varchar_key,col_int_key) 9859); 9860INSERT INTO t1 VALUES (0,'2002-02-13 17:30:06','j','j'); 9861INSERT INTO t1 VALUES (8,'2008-09-27 00:34:58','v','v'); 9862CREATE TABLE t2 ( 9863col_int_key INT(11) NOT NULL, 9864col_datetime_key DATETIME NOT NULL, 9865col_varchar_key VARCHAR(1) NOT NULL, 9866col_varchar_nokey VARCHAR(1) NOT NULL, 9867KEY col_int_key (col_int_key), 9868KEY col_datetime_key (col_datetime_key), 9869KEY col_varchar_key (col_varchar_key,col_int_key) 9870); 9871INSERT INTO t2 VALUES (7,'2003-08-21 00:00:00','b','b'); 9872ANALYZE TABLE t1, t2; 9873Table Op Msg_type Msg_text 9874test.t1 analyze status OK 9875test.t2 analyze status OK 9876SET @old_depth=@@optimizer_search_depth; 9877SET optimizer_search_depth=4; 9878EXPLAIN SELECT col_datetime_key 9879FROM t1 as outr 9880WHERE col_datetime_key IN ( 9881SELECT alias1.col_datetime_key 9882FROM t1 AS alias1 9883LEFT JOIN t1 as alias3 9884STRAIGHT_JOIN ( t2 AS alias4 9885JOIN t1 AS alias5 9886ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) 9887ON alias5.col_int_key < alias4.col_int_key 9888ON alias5.col_varchar_key = alias4.col_varchar_key 9889); 9890id select_type table partitions type possible_keys key key_len ref rows filtered Extra 98911 SIMPLE outr NULL index col_datetime_key col_datetime_key 5 NULL 2 100.00 Using index 98921 SIMPLE alias1 NULL ref col_datetime_key col_datetime_key 5 test.outr.col_datetime_key 1 100.00 Using index; Start temporary 98931 SIMPLE alias4 NULL ALL col_int_key,col_varchar_key NULL NULL NULL 1 100.00 NULL 98941 SIMPLE alias5 NULL ref col_int_key,col_varchar_key col_varchar_key 3 test.alias4.col_varchar_key 1 100.00 Using where; Using index 98951 SIMPLE alias3 NULL index NULL col_int_key 4 NULL 2 100.00 Using index; End temporary 9896Warnings: 9897Note 1003 /* select#1 */ select `test`.`outr`.`col_datetime_key` AS `col_datetime_key` from `test`.`t1` `outr` semi join (`test`.`t1` `alias1` left join (`test`.`t1` `alias3` join `test`.`t2` `alias4` join `test`.`t1` `alias5`) on(((`test`.`alias5`.`col_varchar_key` = `test`.`alias4`.`col_varchar_key`) and (`test`.`alias5`.`col_int_key` < `test`.`alias4`.`col_int_key`) and (`test`.`alias5`.`col_varchar_key` <= `test`.`alias4`.`col_varchar_nokey`)))) where (`test`.`alias1`.`col_datetime_key` = `test`.`outr`.`col_datetime_key`) 9898SELECT col_datetime_key 9899FROM t1 as outr 9900WHERE col_datetime_key IN ( 9901SELECT alias1.col_datetime_key 9902FROM t1 AS alias1 9903LEFT JOIN t1 as alias3 9904STRAIGHT_JOIN ( t2 AS alias4 9905JOIN t1 AS alias5 9906ON alias5.col_varchar_key <= alias4.col_varchar_nokey ) 9907ON alias5.col_int_key < alias4.col_int_key 9908ON alias5.col_varchar_key = alias4.col_varchar_key 9909); 9910col_datetime_key 99112002-02-13 17:30:06 99122008-09-27 00:34:58 9913DROP TABLE t1,t2; 9914SET @@optimizer_search_depth=@old_depth; 9915# 9916# BUG#13848789: SEGFAULT IN JOIN_READ_NEXT_SAME AT 9917# SQL/SQL_EXECUTOR.CC ON HAVING...IN...JOIN 9918# 9919CREATE TABLE t1 ( 9920col_int_key INT, 9921col_varchar_key VARCHAR(1), 9922KEY col_int_key (col_int_key), 9923KEY col_varchar_key (col_varchar_key) 9924); 9925INSERT INTO t1 VALUES (8,'x'); 9926CREATE TABLE t2 ( 9927col_varchar_key VARCHAR(1), 9928KEY col_varchar_key (col_varchar_key) 9929); 9930INSERT INTO t2 VALUES ('x'), ('y'); 9931explain SELECT MIN(col_int_key) 9932FROM t1 as t1_outer 9933HAVING (1, 2) IN ( 9934SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) 9935FROM t1 as t1_inner JOIN t2 9936ON t2.col_varchar_key = t1_inner.col_varchar_key 9937); 9938id select_type table partitions type possible_keys key key_len ref rows filtered Extra 99391 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away 99402 SUBQUERY t1_inner NULL system col_varchar_key NULL NULL NULL 1 100.00 NULL 99412 SUBQUERY t2 NULL ref col_varchar_key col_varchar_key 4 const 1 100.00 Using index 9942Warnings: 9943Note 1003 /* select#1 */ select min(`test`.`t1_outer`.`col_int_key`) AS `MIN(col_int_key)` from `test`.`t1` `t1_outer` having <in_optimizer>((1,2),(1,2) in ( <materialize> (/* select#2 */ select '8',max('8') from `test`.`t2` where (`test`.`t2`.`col_varchar_key` = 'x') having 1 ), <primary_index_lookup>(1 in <temporary table> on <auto_key> where ((1 = `materialized-subquery`.`col_int_key`) and (2 = `materialized-subquery`.`MAX(t1_inner.col_int_key)`))))) 9944SELECT MIN(col_int_key) 9945FROM t1 as t1_outer 9946HAVING (1, 2) IN ( 9947SELECT t1_inner.col_int_key, MAX(t1_inner.col_int_key) 9948FROM t1 as t1_inner JOIN t2 9949ON t2.col_varchar_key = t1_inner.col_varchar_key 9950); 9951MIN(col_int_key) 9952DROP TABLE t1,t2; 9953# Bug#13838810: Segfault in evaluate_null_complemented_join_record 9954CREATE TABLE t1 ( 9955pk int NOT NULL, 9956col_int_nokey int DEFAULT NULL, 9957col_int_key int DEFAULT NULL, 9958col_varchar_key varchar(1) DEFAULT NULL, 9959PRIMARY KEY (pk), 9960KEY col_int_key (col_int_key), 9961KEY col_varchar_key (col_varchar_key,col_int_key) 9962) ENGINE=InnoDB; 9963INSERT INTO t1 VALUES (10,NULL,8,'x'); 9964CREATE TABLE t2 ( 9965pk int NOT NULL, 9966col_varchar_nokey varchar(1) DEFAULT NULL, 9967PRIMARY KEY (pk) 9968) ENGINE=InnoDB; 9969INSERT INTO t2 VALUES (1,'x'); 9970CREATE TABLE t3 ( 9971pk int NOT NULL, 9972col_varchar_key varchar(1) DEFAULT NULL, 9973col_varchar_nokey varchar(1) DEFAULT NULL, 9974PRIMARY KEY (pk), 9975KEY col_varchar_key (col_varchar_key) 9976) ENGINE=InnoDB; 9977INSERT INTO t3 VALUES 9978(1,'v','v'), (2,'v','v'), (3,'c','c'), (4,NULL,NULL); 9979EXPLAIN SELECT table1.pk,table2.pk, table3.pk 9980FROM t2 AS table1 9981LEFT JOIN t1 AS table2 9982LEFT JOIN t1 AS table3 9983ON table3.col_int_key = table2.col_int_key 9984ON table3.pk = table2.col_int_nokey AND 9985table1.col_varchar_nokey IN ( 9986SELECT subquery3_t1.col_varchar_nokey 9987FROM t3 AS subquery3_t1 9988LEFT JOIN t1 AS subquery3_t2 9989ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key 9990WHERE subquery3_t2.col_int_nokey <> 9 9991) 9992; 9993id select_type table partitions type possible_keys key key_len ref rows filtered Extra 99941 SIMPLE table1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL 99951 SIMPLE table2 NULL ALL col_int_key NULL NULL NULL 1 100.00 Using where 99961 SIMPLE table3 NULL eq_ref PRIMARY,col_int_key PRIMARY 4 test.table2.col_int_nokey 1 100.00 Using where 99971 SIMPLE subquery3_t2 NULL ALL col_varchar_key NULL NULL NULL 1 100.00 Using where 99981 SIMPLE subquery3_t1 NULL ref col_varchar_key col_varchar_key 4 test.subquery3_t2.col_varchar_key 1 100.00 Using where; FirstMatch(table3) 9999Warnings: 10000Note 1003 /* select#1 */ select `test`.`table1`.`pk` AS `pk`,`test`.`table2`.`pk` AS `pk`,`test`.`table3`.`pk` AS `pk` from `test`.`t2` `table1` left join (`test`.`t1` `table2` semi join (`test`.`t3` `subquery3_t1` join `test`.`t1` `subquery3_t2`) join `test`.`t1` `table3`) on(((`test`.`subquery3_t1`.`col_varchar_key` = `test`.`subquery3_t2`.`col_varchar_key`) and (`test`.`table3`.`col_int_key` = `test`.`table2`.`col_int_key`) and (`test`.`subquery3_t1`.`col_varchar_nokey` = `test`.`table1`.`col_varchar_nokey`) and (`test`.`table3`.`pk` = `test`.`table2`.`col_int_nokey`) and 1 and (`test`.`subquery3_t2`.`col_int_nokey` <> 9))) where 1 10001SELECT table1.pk,table2.pk, table3.pk 10002FROM t2 AS table1 10003LEFT JOIN t1 AS table2 10004LEFT JOIN t1 AS table3 10005ON table3.col_int_key = table2.col_int_key 10006ON table3.pk = table2.col_int_nokey AND 10007table1.col_varchar_nokey IN ( 10008SELECT subquery3_t1.col_varchar_nokey 10009FROM t3 AS subquery3_t1 10010LEFT JOIN t1 AS subquery3_t2 10011ON subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_key 10012WHERE subquery3_t2.col_int_nokey <> 9 10013) 10014; 10015pk pk pk 100161 NULL NULL 10017DROP TABLE t1, t2, t3; 10018Extra test case for specific code coverage 10019CREATE TABLE t1(pk INTEGER); 10020INSERT INTO t1 VALUES(1), (2); 10021explain SELECT * 10022FROM t1 AS ot1 LEFT JOIN t1 AS ot2 10023ON ot1.pk=ot2.pk AND 10024ot2.pk IN 10025(SELECT it1.pk 10026FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); 10027id select_type table partitions type possible_keys key key_len ref rows filtered Extra 100281 SIMPLE ot1 NULL ALL NULL NULL NULL NULL 2 100.00 Start temporary 100291 SIMPLE ot2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (Block Nested Loop) 100301 SIMPLE it1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (Block Nested Loop) 100311 SIMPLE it2 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; End temporary; Using join buffer (Block Nested Loop) 10032Warnings: 10033Note 1003 /* select#1 */ select `test`.`ot1`.`pk` AS `pk`,`test`.`ot2`.`pk` AS `pk` from `test`.`t1` `ot1` left join (`test`.`t1` `ot2` semi join (`test`.`t1` `it1` left join `test`.`t1` `it2` on((`test`.`it1`.`pk` = `test`.`it2`.`pk`)))) on(((`test`.`ot2`.`pk` = `test`.`ot1`.`pk`) and (`test`.`it1`.`pk` = `test`.`ot1`.`pk`) and 1)) where 1 10034SELECT * 10035FROM t1 AS ot1 LEFT JOIN t1 AS ot2 10036ON ot1.pk=ot2.pk AND 10037ot2.pk IN 10038(SELECT it1.pk 10039FROM t1 AS it1 LEFT JOIN t1 AS it2 ON it1.pk=it2.pk); 10040pk pk 100411 1 100422 2 10043DROP TABLE t1; 10044# End of test for bug#13838810. 10045# 10046# Bug#13845930: Segfault in st_join_table::and_with_condition 10047# 10048CREATE TABLE t1 ( 10049col_int INTEGER 10050); 10051CREATE TABLE t2 ( 10052col_varchar_1 VARCHAR(1), 10053col_varchar_2 VARCHAR(1) 10054); 10055INSERT INTO t2 VALUES ('x','x'), ('c','c'); 10056PREPARE stmt FROM ' 10057SELECT alias2.col_varchar_2 AS field1 10058FROM t2 AS alias1 10059 JOIN 10060 (t2 AS alias2 10061 LEFT JOIN t2 AS alias3 10062 ON (8, 92) IN 10063 (SELECT sq1_alias1.col_int, 10064 sq1_alias2.col_int 10065 FROM t1 AS sq1_alias1 JOIN t1 AS sq1_alias2 10066 ) 10067 ) 10068 ON alias3.col_varchar_1 = alias2.col_varchar_2 10069'; 10070EXECUTE stmt; 10071field1 10072EXECUTE stmt; 10073field1 10074DEALLOCATE prepare stmt; 10075DROP TABLE t1, t2; 10076# End of test for bug#13845930. 10077# 10078# Bug#13855925: Assert 'prebuilt->search_tuple->n_fields > 0' 10079# in ha_innobase::index_read 10080# 10081CREATE TABLE t1 ( 10082pk INTEGER AUTO_INCREMENT, 10083col_int_nokey INT, 10084col_int_key INT, 10085col_varchar_key VARCHAR(1), 10086col_varchar_nokey VARCHAR(1), 10087PRIMARY KEY (pk), 10088KEY (col_varchar_key) 10089) ENGINE=INNODB; 10090INSERT INTO t1 ( 10091col_int_key, col_int_nokey, 10092col_varchar_key, col_varchar_nokey 10093) VALUES 10094(4, 2, 'v','v'), (62, 150, 'v','v'), (7, NULL, 'c','c'), (1, 2, NULL, NULL), 10095(0, 5, 'x','x'), (7, 3, 'i','i'), (7, 1, 'e','e'), (1, 4, 'p','p'), 10096(7, NULL, 's','s'), (1, 2, 'j','j'), (5, 6, 'z','z'), (2, 6, 'c','c'), 10097(0, 8, 'a','a'), (1, 2, 'q','q'), (8, 6, 'y','y'), (1, 8, NULL, NULL), 10098(1, 3, 'r','r'), (9, 3, 'v','v'), (1, 9, NULL, NULL), (5, 6, 'r','r'); 10099CREATE TABLE t2 ( 10100pk INT AUTO_INCREMENT, 10101col_int_nokey INT, 10102col_int_key INT, 10103PRIMARY KEY (pk), 10104KEY (col_int_key) 10105) AUTO_INCREMENT=10 ENGINE=INNODB; 10106INSERT INTO t2 (col_int_key, col_int_nokey) VALUES 10107(8, NULL), (7, 8), (1, 1), (7, 9), (9, 4), (NULL, 3), (1, 2), (9, NULL), 10108(2, 2), (9, NULL), (2, 6), (4, 7), (0, 2), (4, 5), (8, 7), (NULL, 6), 10109(NULL, 6), (0, 2), (NULL, 9), (8, 6); 10110CREATE TABLE t3 ( 10111pk INT AUTO_INCREMENT, 10112col_varchar_key VARCHAR(1), 10113PRIMARY KEY (pk), 10114KEY (col_varchar_key) 10115) ENGINE=INNODB; 10116INSERT INTO t3 (col_varchar_key) VALUES 10117('c'), ('c'), ('q'), ('g'), ('e'), ('l'), (NULL), ('c'), ('h'), ('d'), 10118('c'), ('i'), ('t'), ('g'), ('q'), ('l'), ('n'), ('z'), ('n'), ('r'), ('p'); 10119CREATE VIEW v1 AS 10120SELECT table2.col_varchar_nokey AS field1 10121FROM t2 AS table1 10122INNER JOIN (t1 AS table2 10123STRAIGHT_JOIN t2 AS table3 10124ON table3.col_int_key = table2.pk AND 10125table3.col_int_nokey = ANY 10126(SELECT subquery1_t2.col_int_nokey AS subquery1_field1 10127FROM t2 AS subquery1_t1 10128RIGHT OUTER JOIN t1 AS subquery1_t2 10129INNER JOIN t1 AS subquery1_t3 10130ON subquery1_t3.col_int_key = subquery1_t2.pk 10131ON subquery1_t3.col_varchar_key=subquery1_t2.col_varchar_nokey 10132WHERE subquery1_t1.pk > 1 10133) 10134) 10135ON table3.col_int_key IN 10136(SELECT subquery2_t1.col_int_key AS subquery2_field1 10137FROM t2 AS subquery2_t1 10138RIGHT OUTER JOIN t3 AS subquery2_t2 10139LEFT OUTER JOIN t1 AS subquery2_t3 10140ON subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key 10141ON subquery2_t3.pk = subquery2_t2.pk 10142) 10143; 10144explain SELECT * FROM v1; 10145id select_type table partitions type possible_keys key key_len ref rows filtered Extra 101461 SIMPLE table1 NULL index NULL col_int_key 5 NULL 20 100.00 Using index 101471 SIMPLE table2 NULL ALL PRIMARY NULL NULL NULL 20 100.00 Using where; Using join buffer (Block Nested Loop) 101481 SIMPLE table3 NULL ref col_int_key col_int_key 5 test.table2.pk 2 100.00 Using where; Using join buffer (Batched Key Access) 101491 SIMPLE <subquery4> NULL eq_ref <auto_key> <auto_key> 5 test.table3.col_int_nokey 1 100.00 NULL 101501 SIMPLE <subquery3> NULL eq_ref <auto_key> <auto_key> 5 test.table2.pk 1 100.00 NULL 101514 MATERIALIZED subquery1_t3 NULL ALL col_varchar_key NULL NULL NULL 20 100.00 Using where 101524 MATERIALIZED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t3.col_int_key 1 10.00 Using where 101534 MATERIALIZED subquery1_t1 NULL index PRIMARY col_int_key 5 NULL 20 100.00 Using where; Using index; Using join buffer (Block Nested Loop) 101543 MATERIALIZED subquery2_t3 NULL index PRIMARY,col_varchar_key col_varchar_key 4 NULL 20 100.00 Using where; Using index 101553 MATERIALIZED subquery2_t2 NULL eq_ref PRIMARY,col_varchar_key PRIMARY 4 test.subquery2_t3.pk 1 7.14 Using where 101563 MATERIALIZED subquery2_t1 NULL index col_int_key col_int_key 5 NULL 20 100.00 Using index; Using join buffer (Block Nested Loop) 10157Warnings: 10158Note 1003 /* select#1 */ select `table2`.`col_varchar_nokey` AS `field1` from `test`.`t2` `table1` semi join (`test`.`t3` `subquery2_t2` join `test`.`t1` `subquery2_t3` join `test`.`t2` `subquery2_t1`) semi join (`test`.`t1` `subquery1_t2` join `test`.`t1` `subquery1_t3` join `test`.`t2` `subquery1_t1`) join `test`.`t1` `table2` straight_join `test`.`t2` `table3` where ((`subquery2_t2`.`col_varchar_key` = `subquery2_t3`.`col_varchar_key`) and (`subquery2_t2`.`pk` = `subquery2_t3`.`pk`) and (`subquery1_t2`.`pk` = `subquery1_t3`.`col_int_key`) and (`subquery1_t2`.`col_varchar_nokey` = `subquery1_t3`.`col_varchar_key`) and (`table3`.`col_int_key` = `table2`.`pk`) and (`<subquery3>`.`subquery2_field1` = `table2`.`pk`) and (`<subquery4>`.`subquery1_field1` = `table3`.`col_int_nokey`) and (`subquery1_t1`.`pk` > 1)) 10159SELECT * FROM v1; 10160field1 10161v 10162v 10163v 10164v 10165v 10166v 10167v 10168v 10169v 10170v 10171v 10172v 10173v 10174v 10175v 10176v 10177v 10178v 10179v 10180v 10181DROP VIEW v1; 10182DROP TABLE t1,t2,t3; 10183# End of test for bug#13855925. 10184# 10185# Bug#13897959: Segfault in setup_semijoin_dups_elimination() 10186# 10187CREATE TABLE t1 ( 10188col_datetime_key DATETIME DEFAULT NULL, 10189KEY col_datetime_key (col_datetime_key) 10190) ENGINE=MyISAM; 10191INSERT INTO t1 VALUES 10192('2001-04-18 00:00:00'), ('2008-12-18 19:39:55'), 10193('2000-08-01 12:19:39'), ('2004-09-25 21:29:06'), 10194('2009-09-20 09:11:48'), ('2004-03-27 09:32:04'); 10195CREATE TABLE t2 ( 10196col_date_nokey date DEFAULT NULL, 10197col_time_key time DEFAULT NULL, 10198col_datetime_key datetime DEFAULT NULL, 10199col_varchar_key varchar(1) DEFAULT NULL, 10200col_varchar_nokey varchar(1) DEFAULT NULL, 10201KEY col_time_key (col_time_key), 10202KEY col_datetime_key (col_datetime_key), 10203KEY col_varchar_key(col_varchar_key) 10204) ENGINE=MyISAM; 10205INSERT INTO t2 VALUES ('1900-01-01',NULL,'2001-11-04 19:07:55','x','x'); 10206SELECT grandparent1.col_varchar_nokey 10207FROM t2 AS grandparent1 LEFT JOIN t1 USING (col_datetime_key) 10208WHERE grandparent1.col_varchar_nokey IN ( 10209SELECT col_varchar_nokey 10210FROM t2 AS parent1 10211WHERE parent1.col_time_key > grandparent1.col_date_nokey 10212); 10213col_varchar_nokey 10214DROP TABLE t1, t2; 10215# End of test for bug#13897959. 10216# 10217# Bug#13898625 ASSERT `(REMAINING_TABLES_AFTER != 0) ...' IN 10218# BEST_EXTENSION_BY_LIMITED_SEARCH 10219# 10220CREATE TABLE t1 ( 10221pk int(11) NOT NULL, 10222col_int_nokey INT, 10223col_int_key INT, 10224col_varchar_key VARCHAR(1), 10225col_varchar_nokey VARCHAR(1), 10226PRIMARY KEY (pk), 10227KEY col_int_key (col_int_key), 10228KEY col_varchar_key (col_varchar_key,col_int_key) 10229); 10230INSERT INTO t1 VALUES (26,6,NULL,'f','f'); 10231INSERT INTO t1 VALUES (29,6,8,'c','c'); 10232CREATE TABLE t2 ( 10233pk INT NOT NULL, 10234col_int_nokey INT, 10235col_int_key INT, 10236col_varchar_key VARCHAR(1), 10237col_varchar_nokey VARCHAR(1), 10238PRIMARY KEY (pk), 10239KEY col_int_key (col_int_key), 10240KEY col_varchar_key (col_varchar_key,col_int_key) 10241); 10242INSERT INTO t2 VALUES (1,2,4,'v','v'); 10243INSERT INTO t2 VALUES (2,150,62,'v','v'); 10244INSERT INTO t2 VALUES (5,5,0,'x','x'); 10245INSERT INTO t2 VALUES (6,3,7,'i','i'); 10246INSERT INTO t2 VALUES (7,1,7,'e','e'); 10247CREATE VIEW view_c AS SELECT * FROM t2; 10248PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 10249FROM t1 AS alias1 10250RIGHT JOIN t2 AS alias2 10251INNER JOIN t1 AS alias3 10252ON (alias3.col_varchar_key = alias2.col_varchar_key ) 10253ON ( "v" ) IN ( 10254SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 10255FROM t1 AS sq1_alias1 10256) 10257WHERE alias3.pk IN ( 10258SELECT sq2_alias1.col_int_key AS sq2_field1 10259FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) 10260) 10261'; 10262EXECUTE prep_stmt_7430; 10263field1 10264NULL 10265EXECUTE prep_stmt_7430; 10266field1 10267NULL 10268EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 10269FROM t1 AS alias1 10270RIGHT JOIN t2 AS alias2 10271INNER JOIN t1 AS alias3 10272ON (alias3.col_varchar_key = alias2.col_varchar_key ) 10273ON ( "v" ) IN ( 10274SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 10275FROM t1 AS sq1_alias1 10276) 10277WHERE alias3.pk IN ( 10278SELECT sq2_alias1.col_int_key AS sq2_field1 10279FROM ( view_c AS sq2_alias1, t1 AS sq2_alias2 ) 10280) 10281; 10282id select_type table partitions type possible_keys key key_len ref rows filtered Extra 102831 SIMPLE <subquery3> NULL ALL NULL NULL NULL NULL NULL 100.00 NULL 102841 SIMPLE alias3 NULL range PRIMARY,col_varchar_key col_varchar_key 4 NULL 2 50.00 Using index condition; Using where; Using MRR; Using join buffer (Block Nested Loop) 102851 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 4 test.alias3.col_varchar_key 2 100.00 Using index 102861 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(alias2) 102871 SIMPLE alias1 NULL index NULL col_varchar_key 9 NULL 2 100.00 Using index 102883 MATERIALIZED sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index 102893 MATERIALIZED t2 NULL index col_int_key col_int_key 5 NULL 5 100.00 Using index; Using join buffer (Block Nested Loop) 10290Warnings: 10291Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v') and 1)) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`alias3`.`pk` = `<subquery3>`.`sq2_field1`)) 10292PREPARE prep_stmt_7430 FROM 'SELECT SUM( alias1.col_varchar_key ) AS field1 10293FROM t1 AS alias1 10294RIGHT JOIN t2 AS alias2 10295INNER JOIN t1 AS alias3 10296ON (alias3.col_varchar_key = alias2.col_varchar_key ) 10297ON ( "v" ) IN ( 10298SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 10299FROM t1 AS sq1_alias1 10300) 10301WHERE alias3.pk IN ( 10302SELECT sq2_alias1.col_int_key AS sq2_field1 10303FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) 10304WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key 10305AND sq2_alias1.col_varchar_key < "l" 10306 ) 10307'; 10308EXECUTE prep_stmt_7430; 10309field1 10310NULL 10311EXECUTE prep_stmt_7430; 10312field1 10313NULL 10314EXPLAIN SELECT SUM( alias1.col_varchar_key ) AS field1 10315FROM t1 AS alias1 10316RIGHT JOIN t2 AS alias2 10317INNER JOIN t1 AS alias3 10318ON (alias3.col_varchar_key = alias2.col_varchar_key ) 10319ON ( "v" ) IN ( 10320SELECT sq1_alias1.col_varchar_nokey AS sq1_field1 10321FROM t1 AS sq1_alias1 10322) 10323WHERE alias3.pk IN ( 10324SELECT sq2_alias1.col_int_key AS sq2_field1 10325FROM ( view_c AS sq2_alias1 , t1 AS sq2_alias2 ) 10326WHERE sq2_alias1.col_varchar_nokey <> alias2.col_varchar_key 10327AND sq2_alias1.col_varchar_key < "l" 10328 ) 10329; 10330id select_type table partitions type possible_keys key key_len ref rows filtered Extra 103311 SIMPLE alias3 NULL ALL PRIMARY,col_varchar_key NULL NULL NULL 2 100.00 Using where; Start temporary 103321 SIMPLE t2 NULL ref col_int_key,col_varchar_key col_int_key 5 test.alias3.pk 2 40.00 Using where; Using join buffer (Batched Key Access) 103331 SIMPLE alias2 NULL ref col_varchar_key col_varchar_key 4 test.alias3.col_varchar_key 2 100.00 Using index 103341 SIMPLE sq2_alias2 NULL index NULL PRIMARY 4 NULL 2 100.00 Using index; End temporary; Using join buffer (Block Nested Loop) 103351 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(sq2_alias2) 103361 SIMPLE alias1 NULL index NULL col_varchar_key 9 NULL 2 100.00 Using index 10337Warnings: 10338Note 1276 Field or reference 'test.alias2.col_varchar_key' of SELECT #3 was resolved in SELECT #1 10339Note 1003 /* select#1 */ select sum(`test`.`alias1`.`col_varchar_key`) AS `field1` from `test`.`t2` `alias2` semi join (`test`.`t2` join `test`.`t1` `sq2_alias2`) join `test`.`t1` `alias3` left join (`test`.`t1` `alias1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_varchar_nokey` = 'v') and 1)) where ((`test`.`alias2`.`col_varchar_key` = `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_int_key` = `test`.`alias3`.`pk`) and (`test`.`t2`.`col_varchar_nokey` <> `test`.`alias3`.`col_varchar_key`) and (`test`.`t2`.`col_varchar_key` < 'l')) 10340DROP TABLE t1,t2; 10341DROP VIEW view_c; 10342# 10343# Bug#13902463 SEGFAULT IN BITMAP<64U>::MERGE OR ADD_KEY_FIELD 10344# ON SECOND EXEC OF PREP STMT 10345# 10346CREATE TABLE t1 ( 10347pk INT, 10348col_int_nokey INT, 10349col_int_key INT, 10350col_varchar_key VARCHAR(1), 10351col_varchar_nokey VARCHAR(1), 10352KEY col_varchar_key (col_varchar_key) 10353); 10354CREATE VIEW view_b AS SELECT * FROM t1; 10355PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 10356FROM t1 AS alias1 10357INNER JOIN t1 AS alias2 10358ON (alias1.col_varchar_key = alias2.col_varchar_nokey 10359AND ( alias1.col_int_key ) IN ( 10360SELECT t1.col_int_nokey 10361FROM t1 10362) 10363) 10364WHERE alias1.col_varchar_key IN ( 10365SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 10366FROM view_b AS sq2_alias1 10367INNER JOIN t1 AS sq2_alias2 10368ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) 10369WHERE sq2_alias1.pk > alias2.pk 10370) 10371'; 10372EXECUTE prep_stmt_20421; 10373field1 10374EXECUTE prep_stmt_20421; 10375field1 10376EXPLAIN SELECT alias2.col_varchar_nokey AS field1 10377FROM t1 AS alias1 10378INNER JOIN t1 AS alias2 10379ON (alias1.col_varchar_key = alias2.col_varchar_nokey 10380AND ( alias1.col_int_key ) IN ( 10381SELECT t1.col_int_nokey 10382FROM t1 10383) 10384) 10385WHERE alias1.col_varchar_key IN ( 10386SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 10387FROM view_b AS sq2_alias1 10388INNER JOIN t1 AS sq2_alias2 10389ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) 10390WHERE sq2_alias1.pk > alias2.pk 10391) 10392; 10393id select_type table partitions type possible_keys key key_len ref rows filtered Extra 103941 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 10395Warnings: 10396Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 10397Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) join `test`.`t1` `alias2` where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`)) 10398ALTER TABLE t1 DROP INDEX col_varchar_key; 10399PREPARE prep_stmt_20421 FROM 'SELECT alias2.col_varchar_nokey AS field1 10400FROM t1 AS alias1 10401INNER JOIN t1 AS alias2 10402ON (alias1.col_varchar_key = alias2.col_varchar_nokey 10403AND ( alias1.col_int_key ) IN ( 10404SELECT t1.col_int_nokey 10405FROM t1 10406) 10407) 10408WHERE alias1.col_varchar_key IN ( 10409SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 10410FROM view_b AS sq2_alias1 10411INNER JOIN t1 AS sq2_alias2 10412ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) 10413WHERE sq2_alias1.pk > alias2.pk 10414) 10415'; 10416EXECUTE prep_stmt_20421; 10417field1 10418EXECUTE prep_stmt_20421; 10419field1 10420EXPLAIN SELECT alias2.col_varchar_nokey AS field1 10421FROM t1 AS alias1 10422INNER JOIN t1 AS alias2 10423ON (alias1.col_varchar_key = alias2.col_varchar_nokey 10424AND ( alias1.col_int_key ) IN ( 10425SELECT t1.col_int_nokey 10426FROM t1 10427) 10428) 10429WHERE alias1.col_varchar_key IN ( 10430SELECT sq2_alias2.col_varchar_nokey AS sq2_field1 10431FROM view_b AS sq2_alias1 10432INNER JOIN t1 AS sq2_alias2 10433ON (sq2_alias2.col_varchar_key = sq2_alias1.col_varchar_key ) 10434WHERE sq2_alias1.pk > alias2.pk 10435) 10436; 10437id select_type table partitions type possible_keys key key_len ref rows filtered Extra 104381 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 10439Warnings: 10440Note 1276 Field or reference 'test.alias2.pk' of SELECT #3 was resolved in SELECT #1 10441Note 1003 /* select#1 */ select NULL AS `field1` from `test`.`t1` `alias1` semi join (`test`.`t1`) semi join (`test`.`t1` join `test`.`t1` `sq2_alias2`) join `test`.`t1` `alias2` where ((`test`.`t1`.`pk` > NULL) and multiple equal(NULL, `test`.`sq2_alias2`.`col_varchar_nokey`, NULL) and multiple equal(NULL, `test`.`t1`.`col_int_nokey`) and multiple equal(`test`.`sq2_alias2`.`col_varchar_key`, `test`.`t1`.`col_varchar_key`)) 10442DROP TABLE t1; 10443DROP VIEW view_b; 10444# 10445# Bug#13907277: Segfault in evaluate_null_complemented_join_record 10446# 10447CREATE TABLE t1 ( 10448pk INTEGER, 10449col_varchar_nokey VARCHAR(1), 10450col_varchar_key VARCHAR(1), 10451PRIMARY KEY (pk) 10452); 10453INSERT INTO t1 VALUES (1, 'x', 'x'); 10454CREATE TABLE t2 ( 10455pk INTEGER, 10456PRIMARY KEY (pk) 10457); 10458INSERT INTO t2 VALUES (1); 10459CREATE TABLE t3 ( 10460pk INTEGER, 10461col_int_nokey INTEGER, 10462col_int_key INTEGER, 10463col_varchar_nokey VARCHAR(1), 10464PRIMARY KEY (pk) 10465); 10466INSERT INTO t3 VALUES (1, 6, 5, 'r'); 10467explain SELECT outer_t1.pk, outer_t2.pk 10468FROM t3 AS outer_t1 10469RIGHT JOIN t2 AS outer_t2 10470ON outer_t1.col_int_nokey IN 10471(SELECT inner_t1.col_int_nokey 10472FROM t3 AS inner_t1 10473LEFT JOIN t1 AS inner_t2 10474INNER JOIN t1 AS inner_t3 10475ON inner_t3.pk = inner_t2.pk 10476ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key 10477); 10478id select_type table partitions type possible_keys key key_len ref rows filtered Extra 104791 SIMPLE outer_t2 NULL system NULL NULL NULL NULL 1 100.00 NULL 104801 SIMPLE outer_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 104811 SIMPLE inner_t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 104821 SIMPLE inner_t2 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL 104831 SIMPLE inner_t3 NULL eq_ref PRIMARY PRIMARY 4 test.inner_t2.pk 1 100.00 Using where; FirstMatch(outer_t1) 10484Warnings: 10485Note 1003 /* select#1 */ select `test`.`outer_t1`.`pk` AS `pk`,'1' AS `pk` from (`test`.`t3` `outer_t1` semi join (`test`.`t3` `inner_t1` left join (`test`.`t1` `inner_t2` join `test`.`t1` `inner_t3`) on(((`test`.`inner_t3`.`col_varchar_nokey` = `test`.`inner_t2`.`col_varchar_key`) and (`test`.`inner_t3`.`pk` = `test`.`inner_t2`.`pk`))))) where 1 10486SELECT outer_t1.pk, outer_t2.pk 10487FROM t3 AS outer_t1 10488RIGHT JOIN t2 AS outer_t2 10489ON outer_t1.col_int_nokey IN 10490(SELECT inner_t1.col_int_nokey 10491FROM t3 AS inner_t1 10492LEFT JOIN t1 AS inner_t2 10493INNER JOIN t1 AS inner_t3 10494ON inner_t3.pk = inner_t2.pk 10495ON inner_t3.col_varchar_nokey = inner_t2.col_varchar_key 10496); 10497pk pk 104981 1 10499DROP TABLE t1, t2, t3; 10500# End of test for bug#13907277. 10501# 10502# Bug#13955713: Assert 'JOIN->best_read < ...' on second execution 10503# 10504CREATE TABLE t1 ( 10505pk INTEGER, 10506col_varchar_key VARCHAR(1), 10507col_varchar_nokey VARCHAR(1) 10508); 10509PREPARE stmt FROM " 10510SELECT MIN(alias2.col_varchar_key) AS field1 10511FROM t1 AS alias1 10512 INNER JOIN (t1 AS alias2 10513 INNER JOIN t1 AS alias3 10514 ON 8 IN 10515 (SELECT sq1_alias1.pk AS sq1_field2 10516 FROM t1 AS sq1_alias1 10517 WHERE 9 IN 10518 (SELECT SUM(t1_sq1_alias1.pk) AS t1_sq1_field2 10519 FROM t1 AS t1_sq1_alias1 10520 ) 10521 ) 10522 ) 10523 ON alias3.col_varchar_nokey = alias2.col_varchar_key 10524WHERE EXISTS 10525 (SELECT sq2_alias1.pk AS sq2_field1 10526 FROM t1 AS sq2_alias1 10527 WHERE sq2_alias1.col_varchar_key < alias1.col_varchar_nokey 10528 ) 10529"; 10530EXECUTE stmt; 10531field1 10532NULL 10533EXECUTE stmt; 10534field1 10535NULL 10536DEALLOCATE PREPARE stmt; 10537DROP TABLE t1; 10538# End of test for bug#13955713. 10539# 10540# Bug#13956813: Segfault in memcpy from Join_cache::write_record_data() 10541# 10542CREATE TABLE t1 ( 10543pk INT, 10544col_varchar_key VARCHAR(1), 10545col_varchar_nokey VARCHAR(1) 10546); 10547CREATE TABLE t2 ( 10548pk INT, 10549col_varchar_key VARCHAR(1), 10550col_varchar_nokey VARCHAR(1) 10551); 10552INSERT INTO t2 VALUES 10553(10,'j','j'), (11,'z','z'), (12,'c','c'), (13,'a','a'), 10554(14,'q','q'), (15,'y','y'), (16,NULL,NULL), (17,'r','r'), 10555(18,'v','v'), (19,NULL,NULL), (20,'r','r'); 10556CREATE TABLE t3 ( 10557pk INT, 10558col_int_key INT, 10559col_varchar_key VARCHAR(1), 10560KEY col_int_key (col_int_key) 10561); 10562INSERT INTO t3 VALUES 10563(15,NULL,'u'), (16,1,'m'), (17,9,NULL), (18,2,'o'), 10564(19,9,'w'), (20,2,'m'), (21,4,'q'), (22,0,NULL), 10565(23,4,'d'), (24,8,'g'), (25,NULL,'x'), (26,NULL,'f'), 10566(27,0,'p'), (28,NULL,'j'), (29,8,'c'); 10567CREATE VIEW view_inline_0 AS 10568SELECT t1.* 10569FROM t1 INNER JOIN t3 10570ON t1.pk = t3.pk; 10571CREATE VIEW view_inline_1 AS 10572SELECT sq2_alias2.col_varchar_key AS sq2_field1, 10573sq2_alias1.col_varchar_key AS sq2_field2 10574FROM t3 AS sq2_alias1 LEFT OUTER JOIN t3 AS sq2_alias2 10575ON sq2_alias1.pk = sq2_alias2.col_int_key; 10576CREATE VIEW view_inline_2 AS 10577SELECT 'p', 'p' UNION SELECT 'k', 's'; 10578SET @optimizer_switch_saved= @@optimizer_switch; 10579SET @@optimizer_switch="derived_merge=off"; 10580explain SELECT SUM(alias1.col_varchar_nokey) AS field2 10581FROM t2 AS alias2 10582LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 10583ON alias2.col_varchar_key = alias1.col_varchar_key AND 10584(alias2.col_varchar_nokey, alias2.col_varchar_key) IN 10585(SELECT * FROM view_inline_1 10586) 10587WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN 10588(SELECT * FROM view_inline_2 10589); 10590id select_type table partitions type possible_keys key key_len ref rows filtered Extra 105911 PRIMARY <subquery4> NULL ALL NULL NULL NULL NULL NULL 100.00 NULL 105921 PRIMARY <derived2> NULL ref <auto_key0> <auto_key0> 8 <subquery4>.p,<subquery4>.My_exp_p 2 100.00 NULL 105931 PRIMARY alias2 NULL ALL NULL NULL NULL NULL 11 10.00 Using where; Using join buffer (Block Nested Loop) 105941 PRIMARY <derived6> NULL ref <auto_key0> <auto_key0> 8 test.alias2.col_varchar_nokey,<subquery4>.p 3 100.00 Using index; FirstMatch(alias2) 105954 MATERIALIZED <derived7> NULL ALL NULL NULL NULL NULL 2 100.00 NULL 105967 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used 105978 UNION NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used 10598NULL UNION RESULT <union7,8> NULL ALL NULL NULL NULL NULL NULL NULL Using temporary 105996 DERIVED sq2_alias1 NULL ALL NULL NULL NULL NULL 15 100.00 NULL 106006 DERIVED sq2_alias2 NULL ref col_int_key col_int_key 5 test.sq2_alias1.pk 2 100.00 Using join buffer (Batched Key Access) 106012 DERIVED <derived5> NULL ALL NULL NULL NULL NULL 15 100.00 NULL 106025 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 10603Warnings: 10604Note 1003 /* select#1 */ select sum(`alias1`.`col_varchar_nokey`) AS `field2` from `test`.`t2` `alias2` semi join (`test`.`view_inline_2`) semi join (`test`.`view_inline_1`) join (/* select#2 */ select `view_inline_0`.`pk` AS `pk`,`view_inline_0`.`col_varchar_key` AS `col_varchar_key`,`view_inline_0`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`view_inline_0`) `alias1` where ((`view_inline_1`.`sq2_field1` = `test`.`alias2`.`col_varchar_nokey`) and (`alias1`.`col_varchar_nokey` = `<subquery4>`.`My_exp_p`) and (`alias1`.`col_varchar_key` = `<subquery4>`.`p`) and (`test`.`alias2`.`col_varchar_key` = `<subquery4>`.`p`) and (`view_inline_1`.`sq2_field2` = `<subquery4>`.`p`)) 10605SELECT SUM(alias1.col_varchar_nokey) AS field2 10606FROM t2 AS alias2 10607LEFT JOIN (SELECT * FROM view_inline_0) AS alias1 10608ON alias2.col_varchar_key = alias1.col_varchar_key AND 10609(alias2.col_varchar_nokey, alias2.col_varchar_key) IN 10610(SELECT * FROM view_inline_1 10611) 10612WHERE (alias1.col_varchar_key, alias1.col_varchar_nokey) IN 10613(SELECT * FROM view_inline_2 10614); 10615field2 10616NULL 10617SET @@optimizer_switch= @optimizer_switch_saved; 10618DROP VIEW view_inline_0, view_inline_1, view_inline_2; 10619DROP TABLE t1, t2, t3; 10620# End of test for bug#13956813. 10621# 10622# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize... 10623# 10624CREATE TABLE t1 ( 10625pk INTEGER AUTO_INCREMENT, 10626col_int_nokey INTEGER, 10627col_int_key INTEGER, 10628col_varchar_key VARCHAR(1), 10629col_varchar_nokey VARCHAR(1), 10630PRIMARY KEY (pk), 10631KEY (col_int_key), 10632KEY (col_varchar_key, col_int_key) 10633); 10634INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey) 10635VALUES 10636(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'), 10637(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'), 10638(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'), 10639(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'), 10640(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e'); 10641CREATE TABLE t2 ( 10642pk INTEGER AUTO_INCREMENT, 10643col_int_nokey INTEGER NOT NULL, 10644col_time_key TIME NOT NULL, 10645col_time_nokey TIME NOT NULL, 10646PRIMARY KEY (pk), 10647KEY (col_time_key) 10648) ENGINE=InnoDB; 10649INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES 10650(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'), 10651(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'), 10652(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'), 10653(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'), 10654(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'), 10655(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'), 10656(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'), 10657(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'), 10658(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'), 10659(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22'); 10660explain SELECT ot1.col_int_key AS x 10661FROM t1 AS ot2 10662LEFT JOIN t1 AS ot1 10663ON ot2.col_varchar_nokey > ot1.col_varchar_key 10664WHERE (ot1.col_int_nokey, ot1.pk) IN 10665(SELECT it1.pk AS x, 10666it1.col_int_nokey AS y 10667FROM t2 AS it2 10668LEFT JOIN t2 AS it1 10669ON it2.col_time_nokey = it1.col_time_key 10670) AND ot1.pk IS NULL 10671; 10672id select_type table partitions type possible_keys key key_len ref rows filtered Extra 106731 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 10674Warnings: 10675Note 1003 /* select#1 */ select `test`.`ot1`.`col_int_key` AS `x` from `test`.`t2` `it1` semi join (`test`.`t2` `it2`) join `test`.`t1` `ot2` join `test`.`t1` `ot1` where (isnull(`test`.`ot1`.`pk`) and (`test`.`ot2`.`col_varchar_nokey` > `test`.`ot1`.`col_varchar_key`) and multiple equal(`test`.`ot1`.`col_int_nokey`, `test`.`it1`.`pk`) and multiple equal(`test`.`ot1`.`pk`, `test`.`it1`.`col_int_nokey`) and multiple equal(`test`.`it2`.`col_time_nokey`, `test`.`it1`.`col_time_key`)) 10676SELECT ot1.col_int_key AS x 10677FROM t1 AS ot2 10678LEFT JOIN t1 AS ot1 10679ON ot2.col_varchar_nokey > ot1.col_varchar_key 10680WHERE (ot1.col_int_nokey, ot1.pk) IN 10681(SELECT it1.pk AS x, 10682it1.col_int_nokey AS y 10683FROM t2 AS it2 10684LEFT JOIN t2 AS it1 10685ON it2.col_time_nokey = it1.col_time_key 10686) AND ot1.pk IS NULL 10687; 10688x 10689DROP TABLE t1, t2; 10690# End of test for bug#13974177. 10691# 10692# Bug#13971022: Assert 'keyparts > 0' failed in create_ref_for_key... 10693# 10694CREATE TABLE t1 ( 10695pk INT, 10696col_int_key INT, 10697col_varchar_key VARCHAR(1), 10698PRIMARY KEY (pk), 10699KEY col_varchar_key (col_varchar_key,col_int_key) 10700); 10701CREATE TABLE t2 ( 10702pk INT, 10703col_int_key INT, 10704col_varchar_key VARCHAR(1), 10705col_varchar_nokey VARCHAR(1), 10706PRIMARY KEY (pk) 10707) ENGINE=InnoDB; 10708CREATE TABLE t3 ( 10709i INT 10710); 10711SET @optimizer_switch_saved= @@optimizer_switch; 10712SET @@optimizer_switch="derived_merge=off"; 10713explain SELECT table1.pk AS field1 10714FROM ( SELECT subquery1_t1. * 10715FROM t2 AS subquery1_t1 10716JOIN t2 AS subquery1_t2 10717ON subquery1_t2.pk = subquery1_t1.pk) AS table1 10718STRAIGHT_JOIN t2 AS table2 10719ON table1.col_int_key IN (SELECT 7 FROM t3) 10720WHERE table1.col_varchar_nokey IN 10721(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 10722FROM t1 AS subquery3_t1 10723) 10724; 10725id select_type table partitions type possible_keys key key_len ref rows filtered Extra 107261 PRIMARY subquery3_t1 NULL index col_varchar_key col_varchar_key 9 NULL 0 0.00 Using where; Using index; LooseScan 107271 PRIMARY <derived2> NULL ref <auto_key0> <auto_key0> 9 const,test.subquery3_t1.col_varchar_key 2 100.00 NULL 107281 PRIMARY t3 NULL ALL NULL NULL NULL NULL 0 0.00 FirstMatch(<derived2>); Using join buffer (Block Nested Loop) 107291 PRIMARY table2 NULL index NULL PRIMARY 4 NULL 1 100.00 Using index; Using join buffer (Block Nested Loop) 107302 DERIVED subquery1_t1 NULL ALL PRIMARY NULL NULL NULL 1 100.00 NULL 107312 DERIVED subquery1_t2 NULL eq_ref PRIMARY PRIMARY 4 test.subquery1_t1.pk 1 100.00 Using index 10732Warnings: 10733Note 1003 /* select#1 */ select `table1`.`pk` AS `field1` from (/* select#2 */ select `test`.`subquery1_t1`.`pk` AS `pk`,`test`.`subquery1_t1`.`col_int_key` AS `col_int_key`,`test`.`subquery1_t1`.`col_varchar_key` AS `col_varchar_key`,`test`.`subquery1_t1`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t2` `subquery1_t1` join `test`.`t2` `subquery1_t2` where (`test`.`subquery1_t2`.`pk` = `test`.`subquery1_t1`.`pk`)) `table1` semi join (`test`.`t3`) semi join (`test`.`t1` `subquery3_t1`) straight_join `test`.`t2` `table2` where ((`table1`.`col_int_key` = 7) and (`table1`.`col_varchar_nokey` = `test`.`subquery3_t1`.`col_varchar_key`)) 10734SELECT table1.pk AS field1 10735FROM ( SELECT subquery1_t1. * 10736FROM t2 AS subquery1_t1 10737JOIN t2 AS subquery1_t2 10738ON subquery1_t2.pk = subquery1_t1.pk) AS table1 10739STRAIGHT_JOIN t2 AS table2 10740ON table1.col_int_key IN (SELECT 7 FROM t3) 10741WHERE table1.col_varchar_nokey IN 10742(SELECT subquery3_t1.col_varchar_key AS subquery3_field1 10743FROM t1 AS subquery3_t1 10744) 10745; 10746field1 10747SET @@optimizer_switch= @optimizer_switch_saved; 10748DROP TABLE t1, t2, t3; 10749# End of test for bug#13971022. 10750# 10751# Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH 10752# TIME/DATETIME COMPARE" - Subquery part of test. 10753# 10754SET TIMESTAMP=UNIX_TIMESTAMP('2012-01-31 10:14:35'); 10755CREATE TABLE t1 ( 10756pk INT NOT NULL, 10757col_int_nokey INT, 10758col_int_key INT NOT NULL, 10759PRIMARY KEY (pk), 10760KEY col_int_key (col_int_key) 10761) ENGINE=InnoDB; 10762INSERT INTO t1 VALUES (10,1,7), (11,7,0), (12,4,9), (13,7,3), 10763(14,0,4), (15,2,2), (16,9,5), (17,4,3), (18,0,1), (19,9,3), (20,1,6), 10764(21,3,7), (22,8,5), (23,8,1), (24,18,204), (25,84,224), (26,6,9), 10765(27,3,5), (28,6,0), (29,6,3); 10766CREATE TABLE t2 ( 10767col_int_nokey INT NOT NULL, 10768col_datetime_key DATETIME NOT NULL, 10769col_varchar_key VARCHAR(1) NOT NULL, 10770KEY col_datetime_key (col_datetime_key), 10771KEY col_varchar_key (col_varchar_key) 10772) ENGINE=InnoDB; 10773INSERT INTO t2 VALUES (1,'2001-11-04 19:07:55','k'); 10774CREATE TABLE t3 ( 10775col_time_key TIME, 10776KEY col_time_key (col_time_key) 10777) ENGINE=InnoDB; 10778INSERT INTO t3 VALUES ('21:22:34'), ('10:50:38'), ('00:21:38'), 10779('04:08:02'), ('16:25:11'), ('10:14:58'), ('19:47:59'), ('11:14:24'), 10780('00:00:00'), ('00:00:00'), ('15:57:25'), ('07:05:51'), ('19:22:21'), 10781('03:53:16'), ('09:16:38'), ('15:37:26'), ('00:00:00'), ('05:03:03'), 10782('02:59:24'), ('00:01:58'); 10783EXPLAIN EXTENDED SELECT outr.col_int_nokey 10784FROM t2 as outr 10785STRAIGHT_JOIN t3 AS outr2 10786ON outr2.col_time_key > outr.col_datetime_key 10787WHERE outr.col_int_nokey IN ( 10788SELECT col_int_key 10789FROM t1 AS innr 10790WHERE innr.pk >= innr.col_int_nokey 10791) AND ( 10792outr.col_int_nokey <= 6 10793OR 10794outr.col_varchar_key IS NULL 10795); 10796id select_type table partitions type possible_keys key key_len ref rows filtered Extra 107971 SIMPLE outr NULL ALL col_datetime_key NULL NULL NULL 1 100.00 Using where 107981 SIMPLE innr NULL ref col_int_key col_int_key 4 test.outr.col_int_nokey 1 33.33 Using where; FirstMatch(outr); Using join buffer (Batched Key Access) 107991 SIMPLE outr2 NULL index col_time_key col_time_key 4 NULL 20 33.33 Using where; Using index; Using join buffer (Block Nested Loop) 10800Warnings: 10801Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 10802Warning 1739 Cannot use range access on index 'col_time_key' due to type or collation conversion on field 'col_time_key' 10803Note 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`)) 10804SELECT outr.col_int_nokey 10805FROM t2 as outr 10806STRAIGHT_JOIN t3 AS outr2 10807ON outr2.col_time_key > outr.col_datetime_key 10808WHERE outr.col_int_nokey IN ( 10809SELECT col_int_key 10810FROM t1 AS innr 10811WHERE innr.pk >= innr.col_int_nokey 10812) AND ( 10813outr.col_int_nokey <= 6 10814OR 10815outr.col_varchar_key IS NULL 10816); 10817col_int_nokey 108181 108191 108201 108211 108221 108231 108241 108251 108261 108271 108281 108291 108301 108311 108321 108331 108341 108351 108361 108371 10838DROP TABLE t1,t2,t3; 10839SET TIMESTAMP = DEFAULT; 10840# End of test for bug#13623473. 10841# 10842# Bug#13980954: Missing data on left join + null value + where..in 10843# 10844CREATE TABLE t1 ( 10845ik INT, 10846vc varchar(1) 10847); 10848INSERT INTO t1 VALUES (8, 'x'), (NULL, 'x'); 10849CREATE TABLE t2 ( 10850ik INT, 10851vc varchar(1) 10852); 10853INSERT INTO t2 VALUES 10854(0, 'x'), (7, 'i'), (7, 'e'), (1, 'p'), (7, 's'), (1, 'j'); 10855explain format=json SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik 10856FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc 10857WHERE t2.vc IN (SELECT vc FROM t2 AS t3); 10858EXPLAIN 10859{ 10860 "query_block": { 10861 "select_id": 1, 10862 "cost_info": { 10863 "query_cost": "15.27" 10864 }, 10865 "nested_loop": [ 10866 { 10867 "table": { 10868 "table_name": "t2", 10869 "access_type": "ALL", 10870 "rows_examined_per_scan": 6, 10871 "rows_produced_per_join": 6, 10872 "filtered": "100.00", 10873 "cost_info": { 10874 "read_cost": "2.03", 10875 "eval_cost": "1.20", 10876 "prefix_cost": "3.23", 10877 "data_read_per_join": "48" 10878 }, 10879 "used_columns": [ 10880 "ik", 10881 "vc" 10882 ], 10883 "attached_condition": "(`test`.`t2`.`vc` is not null)" 10884 } 10885 }, 10886 { 10887 "table": { 10888 "table_name": "<subquery2>", 10889 "access_type": "eq_ref", 10890 "key": "<auto_key>", 10891 "key_length": "4", 10892 "ref": [ 10893 "test.t2.vc" 10894 ], 10895 "rows_examined_per_scan": 1, 10896 "materialized_from_subquery": { 10897 "using_temporary_table": true, 10898 "query_block": { 10899 "table": { 10900 "table_name": "t3", 10901 "access_type": "ALL", 10902 "rows_examined_per_scan": 6, 10903 "rows_produced_per_join": 6, 10904 "filtered": "100.00", 10905 "cost_info": { 10906 "read_cost": "2.03", 10907 "eval_cost": "1.20", 10908 "prefix_cost": "3.23", 10909 "data_read_per_join": "48" 10910 }, 10911 "used_columns": [ 10912 "vc" 10913 ] 10914 } 10915 } 10916 } 10917 } 10918 }, 10919 { 10920 "table": { 10921 "table_name": "t1", 10922 "access_type": "ALL", 10923 "rows_examined_per_scan": 2, 10924 "rows_produced_per_join": 12, 10925 "filtered": "100.00", 10926 "using_join_buffer": "Block Nested Loop", 10927 "cost_info": { 10928 "read_cost": "2.01", 10929 "eval_cost": "2.40", 10930 "prefix_cost": "15.27", 10931 "data_read_per_join": "96" 10932 }, 10933 "used_columns": [ 10934 "ik", 10935 "vc" 10936 ], 10937 "attached_condition": "<if>(is_not_null_compl(t1), (`test`.`t1`.`vc` = `test`.`t2`.`vc`), true)" 10938 } 10939 } 10940 ] 10941 } 10942} 10943Warnings: 10944Note 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`) 10945SELECT t2.vc, t2.ik AS t2_ik, t1.ik AS t1_ik 10946FROM t2 LEFT JOIN t1 ON t2.vc=t1.vc 10947WHERE t2.vc IN (SELECT vc FROM t2 AS t3); 10948vc t2_ik t1_ik 10949x 0 8 10950x 0 NULL 10951i 7 NULL 10952e 7 NULL 10953p 1 NULL 10954s 7 NULL 10955j 1 NULL 10956DROP TABLE t1, t2; 10957# End of test for bug#13980954. 10958# 10959# Bug#14048292: Segfault in Item_field::result_type on 2nd execution 10960# of prep stmt with join of view 10961# 10962CREATE TABLE t1 ( 10963col_int INT 10964); 10965INSERT INTO t1 VALUES (0), (1); 10966CREATE VIEW view_t1 AS SELECT * FROM t1; 10967explain SELECT alias1.col_int 10968FROM t1 AS alias1 10969LEFT JOIN view_t1 AS alias2 10970ON alias1.col_int IN 10971(SELECT sq1_alias1.col_int 10972FROM t1 AS sq1_alias1 10973); 10974id select_type table partitions type possible_keys key key_len ref rows filtered Extra 109751 SIMPLE alias1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 109761 SIMPLE sq1_alias1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(alias1) 109771 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL 10978Warnings: 10979Note 1003 /* select#1 */ select `test`.`alias1`.`col_int` AS `col_int` from `test`.`t1` `alias1` left join (`test`.`t1` semi join (`test`.`t1` `sq1_alias1`)) on(((`test`.`sq1_alias1`.`col_int` = `test`.`alias1`.`col_int`) and 1)) where 1 10980PREPARE stmt FROM "SELECT alias1.col_int 10981FROM t1 AS alias1 10982LEFT JOIN view_t1 AS alias2 10983ON alias1.col_int IN 10984(SELECT sq1_alias1.col_int 10985FROM t1 AS sq1_alias1 10986)"; 10987EXECUTE stmt; 10988col_int 109890 109900 109911 109921 10993EXECUTE stmt; 10994col_int 109950 109960 109971 109981 10999DEALLOCATE PREPARE stmt; 11000DROP VIEW view_t1; 11001DROP TABLE t1; 11002# End of test for bug#14048292. 11003# 11004# Bug#14064201: Missing data on join of derived table + WHERE .. IN 11005# with two operands 11006# 11007CREATE TABLE t1 ( 11008col_varchar_nokey VARCHAR(1) 11009); 11010INSERT INTO t1 VALUES 11011('v'), ('s'), ('l'), ('y'), ('c'), ('i'), ('h'), ('q'), ('a'), ('v'), 11012('u'), ('s'), ('y'), ('z'), ('h'), ('p'), ('e'), ('i'), ('y'), ('w'); 11013CREATE TABLE t2 ( 11014col_varchar_key VARCHAR(1), 11015col_varchar_nokey VARCHAR(1), 11016KEY col_varchar_key(col_varchar_key) 11017); 11018INSERT INTO t2 VALUES 11019('j','j'), ('v','v'), ('c','c'), ('m','m'), ('d','d'), ('d','d'), ('y','y'); 11020SET @optimizer_switch_saved= @@optimizer_switch; 11021SET @@optimizer_switch="derived_merge=off"; 11022explain format=json SELECT * 11023FROM (SELECT * FROM t2) AS derived1 11024LEFT JOIN t1 11025USING (col_varchar_nokey) 11026WHERE (col_varchar_nokey, col_varchar_nokey) IN 11027(SELECT col_varchar_nokey, col_varchar_key 11028FROM t2 AS derived2 11029); 11030EXPLAIN 11031{ 11032 "query_block": { 11033 "select_id": 1, 11034 "cost_info": { 11035 "query_cost": "35.13" 11036 }, 11037 "nested_loop": [ 11038 { 11039 "table": { 11040 "table_name": "<subquery3>", 11041 "access_type": "ALL", 11042 "attached_condition": "((`<subquery3>`.`col_varchar_key` = `<subquery3>`.`col_varchar_nokey`) and (`<subquery3>`.`col_varchar_nokey` is not null))", 11043 "materialized_from_subquery": { 11044 "using_temporary_table": true, 11045 "query_block": { 11046 "table": { 11047 "table_name": "derived2", 11048 "access_type": "ALL", 11049 "possible_keys": [ 11050 "col_varchar_key" 11051 ], 11052 "rows_examined_per_scan": 7, 11053 "rows_produced_per_join": 7, 11054 "filtered": "100.00", 11055 "cost_info": { 11056 "read_cost": "2.03", 11057 "eval_cost": "1.40", 11058 "prefix_cost": "3.43", 11059 "data_read_per_join": "56" 11060 }, 11061 "used_columns": [ 11062 "col_varchar_key", 11063 "col_varchar_nokey" 11064 ], 11065 "attached_condition": "(`test`.`derived2`.`col_varchar_key` = `test`.`derived2`.`col_varchar_nokey`)" 11066 } 11067 } 11068 } 11069 } 11070 }, 11071 { 11072 "table": { 11073 "table_name": "derived1", 11074 "access_type": "ref", 11075 "possible_keys": [ 11076 "<auto_key0>" 11077 ], 11078 "key": "<auto_key0>", 11079 "used_key_parts": [ 11080 "col_varchar_nokey" 11081 ], 11082 "key_length": "4", 11083 "ref": [ 11084 "<subquery3>.col_varchar_nokey" 11085 ], 11086 "rows_examined_per_scan": 2, 11087 "rows_produced_per_join": 2, 11088 "filtered": "100.00", 11089 "cost_info": { 11090 "read_cost": "14.00", 11091 "eval_cost": "0.40", 11092 "prefix_cost": "25.03", 11093 "data_read_per_join": "32" 11094 }, 11095 "used_columns": [ 11096 "col_varchar_key", 11097 "col_varchar_nokey" 11098 ], 11099 "materialized_from_subquery": { 11100 "using_temporary_table": true, 11101 "dependent": false, 11102 "cacheable": true, 11103 "query_block": { 11104 "select_id": 2, 11105 "cost_info": { 11106 "query_cost": "3.43" 11107 }, 11108 "table": { 11109 "table_name": "t2", 11110 "access_type": "ALL", 11111 "rows_examined_per_scan": 7, 11112 "rows_produced_per_join": 7, 11113 "filtered": "100.00", 11114 "cost_info": { 11115 "read_cost": "2.03", 11116 "eval_cost": "1.40", 11117 "prefix_cost": "3.43", 11118 "data_read_per_join": "56" 11119 }, 11120 "used_columns": [ 11121 "col_varchar_key", 11122 "col_varchar_nokey" 11123 ] 11124 } 11125 } 11126 } 11127 } 11128 }, 11129 { 11130 "table": { 11131 "table_name": "t1", 11132 "access_type": "ALL", 11133 "rows_examined_per_scan": 20, 11134 "rows_produced_per_join": 40, 11135 "filtered": "100.00", 11136 "using_join_buffer": "Block Nested Loop", 11137 "cost_info": { 11138 "read_cost": "2.10", 11139 "eval_cost": "8.00", 11140 "prefix_cost": "35.13", 11141 "data_read_per_join": "320" 11142 }, 11143 "used_columns": [ 11144 "col_varchar_nokey" 11145 ], 11146 "attached_condition": "<if>(is_not_null_compl(t1), (`test`.`t1`.`col_varchar_nokey` = `derived1`.`col_varchar_nokey`), true)" 11147 } 11148 } 11149 ] 11150 } 11151} 11152Warnings: 11153Note 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`)) 11154SELECT * 11155FROM (SELECT * FROM t2) AS derived1 11156LEFT JOIN t1 11157USING (col_varchar_nokey) 11158WHERE (col_varchar_nokey, col_varchar_nokey) IN 11159(SELECT col_varchar_nokey, col_varchar_key 11160FROM t2 AS derived2 11161); 11162col_varchar_nokey col_varchar_key 11163v v 11164y y 11165c c 11166v v 11167y y 11168y y 11169j j 11170m m 11171d d 11172d d 11173SET @@optimizer_switch= @optimizer_switch_saved; 11174DROP TABLE t1, t2; 11175CREATE TABLE t1 ( 11176col_int_nokey int NOT NULL, 11177col_int_key int NOT NULL, 11178KEY col_int_key (col_int_key) 11179); 11180INSERT INTO t1 VALUES 11181(1,7), (7,0), (4,9), (7,3), (0,4), (2,2), (9,5), (4,3), (0,1), (9,3), 11182(1,6), (3,7), (8,5), (8,1), (18,204), (84,224), (6,9), (3,5), (6,0), (6,3); 11183CREATE TABLE t2 ( 11184col_int_nokey int NOT NULL, 11185col_int_key int NOT NULL, 11186KEY col_int_key (col_int_key) 11187); 11188INSERT INTO t2 VALUES 11189(4,0), (6,8), (3,1), (5,8), (3,9), (246,24), (2,6), (9,1), (3,6), (8,2), 11190(1,4), (8,8), (8,4), (5,4), (7,7), (5,4), (1,1), (6,9), (2,4), (9,8); 11191explain format=json SELECT grandparent1.* 11192FROM t1 AS grandparent1 11193LEFT JOIN t1 USING (col_int_nokey) 11194WHERE (col_int_nokey, col_int_nokey) IN 11195(SELECT col_int_nokey, col_int_key 11196FROM t2 11197); 11198EXPLAIN 11199{ 11200 "query_block": { 11201 "select_id": 1, 11202 "cost_info": { 11203 "query_cost": "104.13" 11204 }, 11205 "nested_loop": [ 11206 { 11207 "table": { 11208 "table_name": "grandparent1", 11209 "access_type": "ALL", 11210 "rows_examined_per_scan": 20, 11211 "rows_produced_per_join": 20, 11212 "filtered": "100.00", 11213 "cost_info": { 11214 "read_cost": "2.04", 11215 "eval_cost": "4.00", 11216 "prefix_cost": "6.04", 11217 "data_read_per_join": "320" 11218 }, 11219 "used_columns": [ 11220 "col_int_nokey", 11221 "col_int_key" 11222 ], 11223 "attached_condition": "((`test`.`grandparent1`.`col_int_nokey` is not null) and (`test`.`grandparent1`.`col_int_nokey` is not null))" 11224 } 11225 }, 11226 { 11227 "table": { 11228 "table_name": "<subquery2>", 11229 "access_type": "eq_ref", 11230 "key": "<auto_key>", 11231 "key_length": "8", 11232 "ref": [ 11233 "test.grandparent1.col_int_nokey", 11234 "test.grandparent1.col_int_nokey" 11235 ], 11236 "rows_examined_per_scan": 1, 11237 "materialized_from_subquery": { 11238 "using_temporary_table": true, 11239 "query_block": { 11240 "table": { 11241 "table_name": "t2", 11242 "access_type": "ALL", 11243 "possible_keys": [ 11244 "col_int_key" 11245 ], 11246 "rows_examined_per_scan": 20, 11247 "rows_produced_per_join": 20, 11248 "filtered": "100.00", 11249 "cost_info": { 11250 "read_cost": "2.04", 11251 "eval_cost": "4.00", 11252 "prefix_cost": "6.04", 11253 "data_read_per_join": "320" 11254 }, 11255 "used_columns": [ 11256 "col_int_nokey", 11257 "col_int_key" 11258 ], 11259 "attached_condition": "(`test`.`t2`.`col_int_key` = `test`.`t2`.`col_int_nokey`)" 11260 } 11261 } 11262 } 11263 } 11264 }, 11265 { 11266 "table": { 11267 "table_name": "t1", 11268 "access_type": "ALL", 11269 "rows_examined_per_scan": 20, 11270 "rows_produced_per_join": 400, 11271 "filtered": "100.00", 11272 "using_join_buffer": "Block Nested Loop", 11273 "cost_info": { 11274 "read_cost": "2.05", 11275 "eval_cost": "80.00", 11276 "prefix_cost": "104.13", 11277 "data_read_per_join": "6K" 11278 }, 11279 "used_columns": [ 11280 "col_int_nokey" 11281 ], 11282 "attached_condition": "<if>(is_not_null_compl(t1), (`test`.`t1`.`col_int_nokey` = `test`.`grandparent1`.`col_int_nokey`), true)" 11283 } 11284 } 11285 ] 11286 } 11287} 11288Warnings: 11289Note 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`)) 11290SELECT grandparent1.* 11291FROM t1 AS grandparent1 11292LEFT JOIN t1 USING (col_int_nokey) 11293WHERE (col_int_nokey, col_int_nokey) IN 11294(SELECT col_int_nokey, col_int_key 11295FROM t2 11296); 11297col_int_nokey col_int_key 112981 7 112991 6 113007 0 113017 3 113027 0 113037 3 113041 7 113051 6 113068 5 113078 1 113088 5 113098 1 11310DROP TABLE t1, t2; 11311CREATE TABLE t1 ( 11312pk int, 11313col_int_key int, 11314col_datetime_key datetime, 11315col_varchar_key varchar(1), 11316col_varchar_nokey varchar(1), 11317PRIMARY KEY (pk), 11318KEY col_int_key (col_int_key), 11319KEY col_datetime_key (col_datetime_key), 11320KEY col_varchar_key (col_varchar_key,col_int_key) 11321) engine=MyISAM; 11322INSERT INTO t1 VALUES 11323(10,7,'2004-06-06 04:22:12','v','v'), (11,0,'2005-11-13 01:12:31','s','s'), 11324(12,9,'2002-05-04 01:50:00','l','l'), (13,3,'2004-10-27 10:28:45','y','y'), 11325(14,4,'2006-07-22 05:24:23','c','c'), (15,2,'2002-05-16 21:34:03','i','i'), 11326(16,5,'2008-04-17 10:45:30','h','h'), (17,3,'2009-04-21 02:58:02','q','q'), 11327(18,1,'2008-01-11 11:01:51','a','a'), (19,3,'1900-01-01 00:00:00','v','v'), 11328(20,6,'2007-05-17 18:24:57','u','u'), (21,7,'2007-08-07 00:00:00','s','s'), 11329(22,5,'2001-08-28 00:00:00','y','y'), (23,1,'2004-04-16 00:27:28','z','z'), 11330(24,204,'2005-05-03 07:06:22','h','h'), (25,224,'2009-03-11 17:09:50','p','p'), 11331(26,9,'2007-12-08 01:54:28','e','e'), (27,5,'2009-07-28 18:19:54','i','i'), 11332(28,0,'2008-06-08 00:00:00','y','y'), (29,3,'2005-02-09 09:20:26','w','w'); 11333CREATE TABLE t2 ( 11334pk int, 11335col_int_key int, 11336col_datetime_key datetime, 11337col_varchar_key varchar(1), 11338col_varchar_nokey varchar(1), 11339PRIMARY KEY (pk), 11340KEY col_int_key (col_int_key), 11341KEY col_datetime_key (col_datetime_key), 11342KEY col_varchar_key (col_varchar_key,col_int_key) 11343) engine=MyISAM; 11344INSERT INTO t2 VALUES 11345(1,0,'2002-02-13 17:30:06','j','j'), (2,8,'2008-09-27 00:34:58','v','v'), 11346(3,1,'2007-05-28 00:00:00','c','c'), (4,8,'2009-07-25 09:21:20','m','m'), 11347(5,9,'2002-01-16 00:00:00','d','d'), (6,24,'2006-10-12 04:32:53','d','d'), 11348(7,6,'2001-02-15 03:08:38','y','y'), (8,1,'2004-10-02 20:31:15','t','t'), 11349(9,6,'2002-08-20 22:48:00','d','d'), (10,2,'1900-01-01 00:00:00','s','s'), 11350(11,4,'2005-08-15 00:00:00','r','r'), (12,8,'1900-01-01 00:00:00','m','m'), 11351(13,4,'2008-05-16 08:09:06','b','b'), (14,4,'2001-01-20 12:47:23','x','x'), 11352(15,7,'2008-07-02 00:00:00','g','g'), (16,4,'1900-01-01 00:00:00','p','p'), 11353(17,1,'2002-12-08 11:34:58','q','q'), (18,9,'1900-01-01 00:00:00','w','w'), 11354(19,4,'1900-01-01 00:00:00','d','d'), (20,8,'2002-08-25 20:35:06','e','e'); 11355SELECT alias1.col_datetime_key 11356FROM t2 AS alias1 11357RIGHT JOIN t2 AS alias2 11358JOIN t2 AS alias3 11359ON alias3.pk = alias2.pk 11360ON alias3.col_varchar_nokey = alias2.col_varchar_key OR 11361alias2.col_varchar_nokey 11362WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN 11363(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey 11364FROM t1 AS sq2_alias1, t1 AS sq2_alias2 11365WHERE sq2_alias2.col_int_key < 2); 11366col_datetime_key 113671900-01-01 00:00:00 113681900-01-01 00:00:00 113691900-01-01 00:00:00 113701900-01-01 00:00:00 113711900-01-01 00:00:00 113721900-01-01 00:00:00 113731900-01-01 00:00:00 113741900-01-01 00:00:00 113751900-01-01 00:00:00 113761900-01-01 00:00:00 113772001-01-20 12:47:23 113782001-01-20 12:47:23 113792001-02-15 03:08:38 113802001-02-15 03:08:38 113812002-01-16 00:00:00 113822002-01-16 00:00:00 113832002-02-13 17:30:06 113842002-02-13 17:30:06 113852002-08-20 22:48:00 113862002-08-20 22:48:00 113872002-08-25 20:35:06 113882002-08-25 20:35:06 113892002-12-08 11:34:58 113902002-12-08 11:34:58 113912004-10-02 20:31:15 113922004-10-02 20:31:15 113932005-08-15 00:00:00 113942005-08-15 00:00:00 113952006-10-12 04:32:53 113962006-10-12 04:32:53 113972007-05-28 00:00:00 113982007-05-28 00:00:00 113992008-05-16 08:09:06 114002008-05-16 08:09:06 114012008-07-02 00:00:00 114022008-07-02 00:00:00 114032008-09-27 00:34:58 114042008-09-27 00:34:58 114052009-07-25 09:21:20 114062009-07-25 09:21:20 11407ALTER TABLE t1 DISABLE KEYS; 11408ALTER TABLE t2 DISABLE KEYS; 11409explain format=json SELECT alias1.col_datetime_key 11410FROM t2 AS alias1 11411RIGHT JOIN t2 AS alias2 11412JOIN t2 AS alias3 11413ON alias3.pk = alias2.pk 11414ON alias3.col_varchar_nokey = alias2.col_varchar_key OR 11415alias2.col_varchar_nokey 11416WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN 11417(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey 11418FROM t1 AS sq2_alias1, t1 AS sq2_alias2 11419WHERE sq2_alias2.col_int_key < 2); 11420EXPLAIN 11421{ 11422 "query_block": { 11423 "select_id": 1, 11424 "cost_info": { 11425 "query_cost": "110.19" 11426 }, 11427 "nested_loop": [ 11428 { 11429 "table": { 11430 "table_name": "<subquery2>", 11431 "access_type": "ALL", 11432 "attached_condition": "(`<subquery2>`.`col_varchar_nokey` = `<subquery2>`.`col_varchar_key`)", 11433 "materialized_from_subquery": { 11434 "using_temporary_table": true, 11435 "query_block": { 11436 "nested_loop": [ 11437 { 11438 "table": { 11439 "table_name": "sq2_alias2", 11440 "access_type": "ALL", 11441 "rows_examined_per_scan": 20, 11442 "rows_produced_per_join": 6, 11443 "filtered": "33.33", 11444 "cost_info": { 11445 "read_cost": "4.78", 11446 "eval_cost": "1.33", 11447 "prefix_cost": "6.12", 11448 "data_read_per_join": "159" 11449 }, 11450 "used_columns": [ 11451 "col_int_key", 11452 "col_varchar_key" 11453 ], 11454 "attached_condition": "(`test`.`sq2_alias2`.`col_int_key` < 2)" 11455 } 11456 }, 11457 { 11458 "table": { 11459 "table_name": "sq2_alias1", 11460 "access_type": "ALL", 11461 "rows_examined_per_scan": 20, 11462 "rows_produced_per_join": 13, 11463 "filtered": "10.00", 11464 "using_join_buffer": "Block Nested Loop", 11465 "cost_info": { 11466 "read_cost": "2.12", 11467 "eval_cost": "2.67", 11468 "prefix_cost": "34.89", 11469 "data_read_per_join": "319" 11470 }, 11471 "used_columns": [ 11472 "col_varchar_nokey" 11473 ], 11474 "attached_condition": "(`test`.`sq2_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)" 11475 } 11476 } 11477 ] 11478 } 11479 } 11480 } 11481 }, 11482 { 11483 "table": { 11484 "table_name": "alias2", 11485 "access_type": "ALL", 11486 "possible_keys": [ 11487 "PRIMARY" 11488 ], 11489 "rows_examined_per_scan": 20, 11490 "rows_produced_per_join": 2, 11491 "filtered": "10.00", 11492 "using_join_buffer": "Block Nested Loop", 11493 "cost_info": { 11494 "read_cost": "2.12", 11495 "eval_cost": "0.40", 11496 "prefix_cost": "97.67", 11497 "data_read_per_join": "48" 11498 }, 11499 "used_columns": [ 11500 "pk", 11501 "col_varchar_key", 11502 "col_varchar_nokey" 11503 ], 11504 "attached_condition": "(`test`.`alias2`.`col_varchar_key` = `<subquery2>`.`col_varchar_key`)" 11505 } 11506 }, 11507 { 11508 "table": { 11509 "table_name": "alias3", 11510 "access_type": "eq_ref", 11511 "possible_keys": [ 11512 "PRIMARY" 11513 ], 11514 "key": "PRIMARY", 11515 "used_key_parts": [ 11516 "pk" 11517 ], 11518 "key_length": "4", 11519 "ref": [ 11520 "test.alias2.pk" 11521 ], 11522 "rows_examined_per_scan": 1, 11523 "rows_produced_per_join": 2, 11524 "filtered": "100.00", 11525 "using_join_buffer": "Batched Key Access", 11526 "cost_info": { 11527 "read_cost": "2.00", 11528 "eval_cost": "0.40", 11529 "prefix_cost": "100.07", 11530 "data_read_per_join": "48" 11531 }, 11532 "used_columns": [ 11533 "pk", 11534 "col_varchar_nokey" 11535 ] 11536 } 11537 }, 11538 { 11539 "table": { 11540 "table_name": "alias1", 11541 "access_type": "ALL", 11542 "rows_examined_per_scan": 20, 11543 "rows_produced_per_join": 40, 11544 "filtered": "100.00", 11545 "using_join_buffer": "Block Nested Loop", 11546 "cost_info": { 11547 "read_cost": "2.12", 11548 "eval_cost": "8.00", 11549 "prefix_cost": "110.19", 11550 "data_read_per_join": "960" 11551 }, 11552 "used_columns": [ 11553 "col_datetime_key" 11554 ], 11555 "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)" 11556 } 11557 } 11558 ] 11559 } 11560} 11561Warnings: 11562Note 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_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`)) 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_alias1`.`col_varchar_nokey` = `test`.`sq2_alias2`.`col_varchar_key`) and (`test`.`sq2_alias2`.`col_int_key` < 2)) 11563SELECT alias1.col_datetime_key 11564FROM t2 AS alias1 11565RIGHT JOIN t2 AS alias2 11566JOIN t2 AS alias3 11567ON alias3.pk = alias2.pk 11568ON alias3.col_varchar_nokey = alias2.col_varchar_key OR 11569alias2.col_varchar_nokey 11570WHERE (alias2.col_varchar_key, alias2.col_varchar_key) IN 11571(SELECT sq2_alias2.col_varchar_key, sq2_alias1.col_varchar_nokey 11572FROM t1 AS sq2_alias1, t1 AS sq2_alias2 11573WHERE sq2_alias2.col_int_key < 2); 11574col_datetime_key 115752002-02-13 17:30:06 115762002-02-13 17:30:06 115772008-09-27 00:34:58 115782008-09-27 00:34:58 115792007-05-28 00:00:00 115802007-05-28 00:00:00 115812009-07-25 09:21:20 115822009-07-25 09:21:20 115832002-01-16 00:00:00 115842002-01-16 00:00:00 115852006-10-12 04:32:53 115862006-10-12 04:32:53 115872001-02-15 03:08:38 115882001-02-15 03:08:38 115892004-10-02 20:31:15 115902004-10-02 20:31:15 115912002-08-20 22:48:00 115922002-08-20 22:48:00 115931900-01-01 00:00:00 115941900-01-01 00:00:00 115952005-08-15 00:00:00 115962005-08-15 00:00:00 115971900-01-01 00:00:00 115981900-01-01 00:00:00 115992008-05-16 08:09:06 116002008-05-16 08:09:06 116012001-01-20 12:47:23 116022001-01-20 12:47:23 116032008-07-02 00:00:00 116042008-07-02 00:00:00 116051900-01-01 00:00:00 116061900-01-01 00:00:00 116072002-12-08 11:34:58 116082002-12-08 11:34:58 116091900-01-01 00:00:00 116101900-01-01 00:00:00 116111900-01-01 00:00:00 116121900-01-01 00:00:00 116132002-08-25 20:35:06 116142002-08-25 20:35:06 11615DROP TABLE t1, t2; 11616# End of test for bug#14064201. 11617# 11618# Bug#18223655:ASSERTION FAILED: (INT)IDX >= 0 11619# && IDX < PARENT_JOIN->TABLES 11620# 11621CREATE TABLE b (d INT); 11622CREATE TABLE c (a INT, b INT,c INT,d BLOB NOT NULL); 11623SELECT(SELECT 1 11624FROM b WHERE(SELECT 1 IN (SELECT 1 FROM b WHERE 1 NOT BETWEEN d AND 1) 11625FROM b) IN (SELECT d FROM c)) as cc FROM b; 11626cc 11627INSERT INTO b VALUE(1); 11628INSERT INTO c VALUES(1,2,3,'1'),(2,3,4,'1'),(3,4,5,'C'); 11629SELECT(SELECT d FROM b WHERE(SELECT d IN 11630(SELECT d FROM b WHERE 1 NOT BETWEEN d AND 1) FROM b) IN 11631(SELECT d FROM c)) as cc FROM c; 11632cc 116331 116341 116351 11636DROP TABLE b,c; 11637# 11638# Bug#18447874:WRONG RESULT COMING FROM SEMI-JOIN 11639# 11640CREATE TABLE b ( 11641d INT(11) 11642); 11643CREATE TABLE c ( 11644d BLOB 11645) ; 11646CREATE TABLE d ( 11647b INT(11) 11648); 11649INSERT INTO b VALUES(1),(2),(4); 11650INSERT INTO c VALUES(1),(2),(3); 11651SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; 116521 11653INSERT INTO d VALUES(2); 11654SELECT 1 FROM b WHERE (SELECT 1 FROM d ) IN (SELECT d FROM c) ; 116551 116561 116571 116581 11659DROP TABLE b,c,d; 11660# 11661# Bug#17292723:INCORRECT RESULT FOR (SELECT...) IN (SELECT...) STATEMENT 11662# 11663CREATE TABLE t1 ( 11664ID int(11) NOT NULL AUTO_INCREMENT, 11665id2 int(11) DEFAULT NULL, 11666id3 int(11) DEFAULT NULL, 11667id4 varchar(150) COLLATE utf8_spanish_ci NOT NULL, 11668id5 int(11) DEFAULT NULL, 11669PRIMARY KEY (ID), 11670KEY id2 (id2), 11671KEY id3 (id3), 11672KEY id5 (id5) 11673) ENGINE=InnoDB; 11674INSERT INTO t1 VALUES 11675(123,1,1,'1',NULL), 11676(124,1,1,'2',NULL), 11677(125,1,1,'4',NULL), 11678(126,1,1,'3',NULL), 11679(127,1,1,'6',NULL), 11680(128,1,1,'8',NULL); 11681CREATE TABLE t2 ( 11682id6 int(11) NOT NULL, 11683id7 int(11) NOT NULL, 11684PRIMARY KEY (id6,id7), 11685KEY id7 (id7) 11686) ENGINE=InnoDB; 11687INSERT INTO t2 VALUES (126,123),(130,123),(135,123); 11688SELECT ID 11689FROM t1 p0 11690WHERE p0.id3=1 11691AND ( (SELECT p1.id FROM t1 p1 WHERE p1.id=123) IN (SELECT p3.id FROM t2 11692p2, t1 p3 WHERE p0.id=p2.id6 AND p2.id7=p3.id)); 11693ID 11694126 11695DROP TABLE t1,t2; 11696set @@optimizer_switch=@old_opt_switch; 11697# End of 5.6 tests 11698# 11699# Bug#19336348 DEBUG CRASH AT SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC 11700# 11701CREATE TABLE t1 ( 11702col_varchar_nokey varchar(1) 11703) ENGINE=InnoDB; 11704INSERT INTO t1 VALUES ('c'),(NULL),('x'); 11705CREATE TABLE t2 ( 11706pk int, 11707col_varchar_key varchar(1), 11708PRIMARY KEY (pk), 11709KEY col_varchar_key (col_varchar_key) 11710) ENGINE=InnoDB; 11711INSERT INTO t2 VALUES (10,'l'),(11,'p'); 11712ANALYZE TABLE t1,t2; 11713Table Op Msg_type Msg_text 11714test.t1 analyze status OK 11715test.t2 analyze status OK 11716EXPLAIN SELECT 1 11717FROM t1 AS outr 11718WHERE outr.col_varchar_nokey IN 11719( 11720SELECT innr.col_varchar_key 11721FROM t2 AS innr 11722WHERE innr.pk <= 7 11723) 11724; 11725id select_type table partitions type possible_keys key key_len ref rows filtered Extra 117261 SIMPLE innr NULL index PRIMARY,col_varchar_key col_varchar_key 4 NULL 2 100.00 Using where; Using index; LooseScan 117271 SIMPLE outr NULL ALL NULL NULL NULL NULL 3 33.33 Using where; Using join buffer (Block Nested Loop) 11728Warnings: 11729Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` `outr` semi join (`test`.`t2` `innr`) where ((`test`.`outr`.`col_varchar_nokey` = `test`.`innr`.`col_varchar_key`) and (`test`.`innr`.`pk` <= 7)) 11730SELECT 1 11731FROM t1 AS outr 11732WHERE outr.col_varchar_nokey IN 11733( 11734SELECT innr.col_varchar_key 11735FROM t2 AS innr 11736WHERE innr.pk <= 7 11737) 11738; 117391 11740DROP TABLE t1,t2; 11741# 11742# Bug#18174394 BLOBS: CRASH AFTER UNINITIALIZED VALUES IN ITEM_FIELD::STR_RESULT 11743# 11744CREATE TABLE t1(d BLOB, b BLOB); 11745INSERT INTO t1(d,b) VALUES ('aaaa',''),('bnbb',''); 11746SELECT 1 FROM t1 11747WHERE (SELECT b FROM t1) IN (SELECT (d>=1) FROM t1); 11748ERROR 21000: Subquery returns more than 1 row 11749DROP TABLE t1; 11750# 11751# Bug#19779600: ASSERT FAILED IN REPLACE_SUBCONDITION WITH IN 11752# PREDICATE INSIDE IN PREDICATE 11753# 11754CREATE TABLE t(X INT) ENGINE=InnoDB; 11755INSERT INTO t VALUES (1); 11756ANALYZE TABLE t; 11757Table Op Msg_type Msg_text 11758test.t analyze status OK 11759EXPLAIN SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); 11760id select_type table partitions type possible_keys key key_len ref rows filtered Extra 117611 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL 117621 PRIMARY t NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t); Using join buffer (Block Nested Loop) 117632 SUBQUERY t NULL ALL NULL NULL NULL NULL 1 100.00 NULL 11764Warnings: 11765Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t` semi join (`test`.`t`) where 1 11766SELECT 1 FROM t WHERE (1 IN (SELECT 1 FROM t)) IN (SELECT 1 FROM t); 117671 117681 11769DROP TABLE t; 11770# 11771# Bug#19465034 ASSERT ON SETUP_SEMIJOIN_DUPS_ELIMINATION IN SQL/SQL_SELECT.CC 11772# 11773CREATE TABLE t1 ( 11774pk INTEGER NOT NULL, 11775i1 INTEGER NOT NULL, 11776PRIMARY KEY (pk) 11777) ENGINE=InnoDB; 11778INSERT INTO t1 VALUES (1,1); 11779CREATE TABLE t2 ( 11780pk INTEGER NOT NULL, 11781c1 VARCHAR(1) NOT NULL, 11782PRIMARY KEY (pk), 11783KEY c1_key (c1) 11784) ENGINE=InnoDB; 11785INSERT INTO t2 VALUES (1,'j'),(2,'v'),(3,'c'); 11786CREATE TABLE t3 ( 11787pk INTEGER NOT NULL, 11788c1 VARCHAR(1) NOT NULL, 11789PRIMARY KEY (pk), 11790KEY c1_key (c1) 11791) ENGINE=InnoDB; 11792INSERT INTO t3 VALUES (10,'v'),(11,'s'); 11793ANALYZE TABLE t1, t2, t3; 11794Table Op Msg_type Msg_text 11795test.t1 analyze status OK 11796test.t2 analyze status OK 11797test.t3 analyze status OK 11798EXPLAIN SELECT * 11799FROM t1 JOIN t2 ON t1.i1 >= t2.pk 11800WHERE t2.c1 IN ( 11801SELECT t3.c1 11802FROM t3 11803WHERE t3.pk < 3 11804); 11805id select_type table partitions type possible_keys key key_len ref rows filtered Extra 118061 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL 118071 SIMPLE t3 NULL index PRIMARY,c1_key c1_key 3 NULL 2 100.00 Using where; Using index; LooseScan 118081 SIMPLE t2 NULL ref PRIMARY,c1_key c1_key 3 test.t3.c1 1 33.33 Using where; Using index 11809Warnings: 11810Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`i1` AS `i1`,`test`.`t2`.`pk` AS `pk`,`test`.`t2`.`c1` AS `c1` from `test`.`t1` semi join (`test`.`t3`) join `test`.`t2` where ((`test`.`t2`.`c1` = `test`.`t3`.`c1`) and (`test`.`t3`.`pk` < 3) and (`test`.`t1`.`i1` >= `test`.`t2`.`pk`)) 11811SELECT * 11812FROM t1 JOIN t2 ON t1.i1 >= t2.pk 11813WHERE t2.c1 IN ( 11814SELECT t3.c1 11815FROM t3 11816WHERE t3.pk < 3 11817); 11818pk i1 pk c1 11819DROP TABLE t1,t2,t3; 11820# 11821# Bug#19586047: CRASH IN ARG_COMPARATOR::SET_CMP_FUNC 11822# 11823CREATE TABLE t1(x INT) ENGINE=InnoDB; 11824INSERT INTO t1 VALUES (1); 11825ANALYZE TABLE t1; 11826Table Op Msg_type Msg_text 11827test.t1 analyze status OK 11828EXPLAIN SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); 11829id select_type table partitions type possible_keys key key_len ref rows filtered Extra 118301 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL 118311 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (Block Nested Loop) 118322 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL No tables used 11833Warnings: 11834Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where 1 11835SELECT 1 FROM t1 WHERE EXISTS(SELECT 1) IN (SELECT 1 FROM t1); 118361 118371 11838EXPLAIN SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); 11839id select_type table partitions type possible_keys key key_len ref rows filtered Extra 118401 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL 118411 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t1); Using join buffer (Block Nested Loop) 118422 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL 11843Warnings: 11844Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where 1 11845SELECT 1 FROM t1 WHERE (SELECT 1, 2 FROM t1) IN (SELECT 1, 2 FROM t1); 118461 118471 11848EXPLAIN SELECT 1 FROM t1 WHERE 11849(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); 11850id select_type table partitions type possible_keys key key_len ref rows filtered Extra 118511 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 118522 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 11853Warnings: 11854Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t1`) where 0 11855SELECT 1 FROM t1 WHERE 11856(SELECT 1, 2 FROM t1 WHERE x = 2) IN (SELECT 1, 2 FROM t1); 118571 11858DROP TABLE t1; 11859# 11860#Bug#20119743 ASSERTIONQEP_TAB->USE_ORDER() IN ENUM_NESTED_LOOP_STATE 11861# EVALUATE_JOIN_RECORD 11862# 11863CREATE TABLE t1 ( 11864pk int(11) NOT NULL, 11865col_varchar_nokey varchar(1) DEFAULT NULL, 11866PRIMARY KEY (pk) 11867); 11868INSERT INTO t1 VALUES (1,'x'); 11869CREATE TABLE t2 ( 11870col_date_key date DEFAULT NULL, 11871col_int_key int(11) DEFAULT NULL, 11872col_varchar_key varchar(1) DEFAULT NULL, 11873col_varchar_nokey varchar(1) DEFAULT NULL, 11874KEY col_int_key (col_int_key), 11875KEY col_date_key (col_date_key), 11876KEY col_varchar_key (col_varchar_key,col_int_key) 11877); 11878INSERT INTO t2 VALUES ('2000-12-03', 8, 'x', 'x'),('2008-05-03', 7, 'd', 'd'), 11879('2005-12-06', 1, 'r', 'r'),('2000-04-10', 7, 'f', 'f'), 11880('2002-11-05', 9, 'y', 'y'),('2000-09-06', NULL, 'u', 'u'), 11881(NULL, 1, 'm', 'm'),('2007-06-14', 9, NULL, NULL), 11882('2007-11-17', 2, 'o', 'o'),('2009-02-23', 9, 'w', 'w'), 11883('2007-01-08', 2, 'm', 'm'), ('2008-06-10', 4, 'q', 'q'), 11884('2002-10-20', 0, NULL, NULL),('2008-09-12', 4, 'd', 'd'), 11885('2006-06-16', 8, 'g', 'g'),('2004-09-18', NULL, 'x', 'x'), 11886('1900-01-01', NULL, 'f', 'f'),('2005-09-13', 0, 'p', 'p'), 11887('2007-04-09', NULL, 'j', 'j'),('2000-09-20', 8, 'c', 'c'); 11888CREATE TABLE t3 ( 11889pk int(11) NOT NULL, 11890col_varchar_nokey varchar(1) DEFAULT NULL, 11891PRIMARY KEY (pk) 11892); 11893INSERT INTO t3 VALUES (1, 'c'),(2, 'c'),(3, 'q'),(4, 'g'),(5, 'e'),(6, 'l'), 11894(7, NULL),(8, 'v'),(9, 'c'),(10, 'u'),(11, 'x'),(12, 'x'),(13, 'x'),(14, 'l'), 11895(15, 'e'),(16, 's'),(17, 'k'),(18, 'm'),(19, 'x'),(20, 's'); 11896ANALYZE TABLE t1,t2,t3; 11897Table Op Msg_type Msg_text 11898test.t1 analyze status OK 11899test.t2 analyze status OK 11900test.t3 analyze status OK 11901EXPLAIN SELECT r1.col_date_key 11902FROM t2 AS r1 11903WHERE r1.col_int_key NOT IN 11904(SELECT ir2.pk 11905FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 11906ON ir2.col_varchar_nokey = ir1.col_varchar_key 11907WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey 11908AND ir2.pk IN 11909(SELECT iir2.pk 11910FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 11911ON iir2.col_varchar_nokey = iir1.col_varchar_key)) 11912ORDER BY r1.col_date_key; 11913id select_type table partitions type possible_keys key key_len ref rows filtered Extra 119141 PRIMARY r1 NULL ALL NULL NULL NULL NULL 20 100.00 Using where; Using filesort 119152 DEPENDENT SUBQUERY iir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; LooseScan; Full scan on NULL key 119162 DEPENDENT SUBQUERY iir1 NULL ref col_varchar_key col_varchar_key 4 test.iir2.col_varchar_nokey 1 100.00 Using index; FirstMatch(iir2) 119172 DEPENDENT SUBQUERY ir1 NULL index col_varchar_key col_varchar_key 9 NULL 20 100.00 Using where; Using index; Using join buffer (Block Nested Loop) 119182 DEPENDENT SUBQUERY ir2 NULL eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Full scan on NULL key 11919SELECT r1.col_date_key 11920FROM t2 AS r1 11921WHERE r1.col_int_key NOT IN 11922(SELECT ir2.pk 11923FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 11924ON ir2.col_varchar_nokey = ir1.col_varchar_key 11925WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey 11926AND ir2.pk IN 11927(SELECT iir2.pk 11928FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 11929ON iir2.col_varchar_nokey = iir1.col_varchar_key)) 11930ORDER BY r1.col_date_key; 11931col_date_key 119322000-04-10 119332000-09-20 119342000-12-03 119352002-10-20 119362002-11-05 119372004-09-18 119382005-09-13 119392006-06-16 119402007-01-08 119412007-06-14 119422007-11-17 119432008-05-03 119442008-06-10 119452008-09-12 119462009-02-23 11947SELECT COUNT(r1.col_date_key) AS COUNT_NUM 11948FROM t2 AS r1 11949WHERE r1.col_int_key NOT IN 11950(SELECT ir2.pk 11951FROM t2 AS ir1 STRAIGHT_JOIN t1 AS ir2 11952ON ir2.col_varchar_nokey = ir1.col_varchar_key 11953WHERE ir2.col_varchar_nokey > r1.col_varchar_nokey 11954AND ir2.pk IN 11955(SELECT iir2.pk 11956FROM t2 AS iir1 RIGHT JOIN t3 AS iir2 11957ON iir2.col_varchar_nokey = iir1.col_varchar_key 11958WHERE iir2.pk<3)); 11959COUNT_NUM 1196015 11961DROP TABLE t1,t2,t3; 11962# 11963# Bug#20554585 ASSERT JOIN()->TABLES == 0... IN JOIN_TAB::GET_SJ_STRATEGY ON SUBQUERY + VAR 11964# 11965CREATE TABLE t1 ( 11966pk int NOT NULL, 11967PRIMARY KEY (pk) 11968); 11969CREATE TABLE t2 ( 11970pk int NOT NULL, 11971col_int_key int, 11972col_varchar_key varchar(1), 11973PRIMARY KEY (pk), 11974KEY col_int_key (col_int_key), 11975KEY col_varchar_key (col_varchar_key) 11976); 11977CREATE TABLE t3 ( 11978pk int NOT NULL, 11979col_int_key int, 11980col_varchar_key varchar(1), 11981col_varchar varchar(1), 11982PRIMARY KEY (pk), 11983KEY col_int_key (col_int_key), 11984KEY col_varchar_key (col_varchar_key) 11985); 11986INSERT INTO t3 VALUES (1,4,'c','g'),(20,1,'i','p'); 11987CREATE TABLE t4 ( 11988col_int int 11989); 11990CREATE TABLE t5 ( 11991col_varchar_key varchar(1), 11992pk int NOT NULL, 11993col_int int, 11994PRIMARY KEY (pk), 11995KEY col_varchar_key (col_varchar_key) 11996); 11997SELECT table1.col_varchar_key AS field1 11998FROM (t3 AS table1 11999INNER JOIN ( 12000SELECT SUBQUERY1_t1.* 12001FROM (t1 AS SUBQUERY1_t1 12002RIGHT JOIN (t2 AS SUBQUERY1_t2 12003INNER JOIN t3 AS SUBQUERY1_t3 12004ON (SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key) 12005) ON (SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk) 12006) 12007WHERE SUBQUERY1_t2.col_varchar_key >= ANY ( 12008SELECT CHILD_SUBQUERY1_t2.col_varchar AS CHILD_SUBQUERY1_field1 12009FROM (t2 AS CHILD_SUBQUERY1_t1 12010LEFT OUTER JOIN t3 AS CHILD_SUBQUERY1_t2 12011ON (CHILD_SUBQUERY1_t2.col_int_key = CHILD_SUBQUERY1_t1.col_int_key) 12012) 12013WHERE CHILD_SUBQUERY1_t1.pk >= SUBQUERY1_t2.pk 12014) 12015) AS table2 12016ON (table2.pk = table1.pk) 12017) 12018WHERE (EXISTS (( 12019SELECT DISTINCT SUBQUERY2_t2.col_int AS SUBQUERY2_field1 12020FROM (t4 AS SUBQUERY2_t1 12021LEFT OUTER JOIN t5 AS SUBQUERY2_t2 12022ON (SUBQUERY2_t2.pk = SUBQUERY2_t1.col_int) 12023) 12024WHERE SUBQUERY2_t2.col_varchar_key != @var4 12025))) 12026AND table1.col_int_key < (35 + 192) 12027ORDER BY field1 12028; 12029field1 12030DROP TABLE t1, t2, t3, t4, t5; 12031# 12032# Bug#18892055: MISSING DATA ON SELECT ... IN WITH JOINS AND INNODB 12033# ENGINE 12034# 12035CREATE TABLE t1 ( 12036col_int_key INT, 12037pk INT NOT NULL, 12038PRIMARY KEY (pk), 12039KEY col_int_key (col_int_key) 12040) ENGINE = INNODB; 12041INSERT INTO t1 VALUES 12042( 0, 3 ), 12043( 0, 4 ), 12044( 3, 1 ), 12045( 900000000, 2 ), 12046( 1368719360, 5 ), 12047( 1922236416, 6 ), 12048( 8,7 ); 12049CREATE TABLE t2 ( 12050pk INT NOT NULL, 12051col_int INT, 12052PRIMARY KEY (pk) 12053) ENGINE = INNODB; 12054INSERT INTO t2 VALUES 12055( 1, 3 ), 12056( 2, 2 ), 12057( 3, 8 ), 12058( 4, 7 ); 12059CREATE TABLE t3 ( 12060col_int_key INT, 12061col_int INT, 12062KEY (col_int_key) 12063) ENGINE = INNODB; 12064INSERT INTO t3 VALUES 12065( 5, 1 ), 12066( -1, -1 ), 12067( 300000000, 1 ), 12068( 8, 1 ); 12069CREATE TABLE t4 ( col_int_key INT ) ENGINE = INNODB; 12070INSERT INTO t4 VALUES 12071(0), 12072(3), 12073(8), 12074(900000000), 12075(1368719360), 12076(1922236416); 12077ANALYZE TABLE t1, t2, t3, t4; 12078Table Op Msg_type Msg_text 12079test.t1 analyze status OK 12080test.t2 analyze status OK 12081test.t3 analyze status OK 12082test.t4 analyze status OK 12083explain SELECT * 12084FROM t4 12085WHERE (col_int_key) IN ( 12086SELECT t1.col_int_key 12087FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) 12088WHERE t3.col_int IS NULL 12089) 12090ORDER BY col_int_key 12091; 12092id select_type table partitions type possible_keys key key_len ref rows filtered Extra 120931 SIMPLE t1 NULL index col_int_key col_int_key 5 NULL 7 85.71 Using index; Using temporary; Using filesort; LooseScan 120941 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.pk 1 100.00 NULL 120951 SIMPLE t3 NULL ref col_int_key col_int_key 5 test.t2.col_int 1 25.00 Using where; FirstMatch(t1) 120961 SIMPLE t4 NULL ALL NULL NULL NULL NULL 6 16.67 Using where; Using join buffer (Block Nested Loop) 12097Warnings: 12098Note 1003 /* select#1 */ select `test`.`t4`.`col_int_key` AS `col_int_key` from `test`.`t4` semi join (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t1`.`pk` = `test`.`t2`.`pk`) and (`test`.`t3`.`col_int_key` = `test`.`t2`.`col_int`)))) where ((`test`.`t4`.`col_int_key` = `test`.`t1`.`col_int_key`) and isnull(`test`.`t3`.`col_int`)) order by `test`.`t4`.`col_int_key` 12099SELECT * 12100FROM t4 12101WHERE (col_int_key) IN ( 12102SELECT t1.col_int_key 12103FROM t1 LEFT JOIN ( t2 JOIN t3 ON t3.col_int_key = t2.col_int ) USING ( pk ) 12104WHERE t3.col_int IS NULL 12105) 12106ORDER BY col_int_key 12107; 12108col_int_key 121090 121103 121118 12112900000000 121131368719360 121141922236416 12115DROP TABLE t1, t2, t3, t4; 12116# 12117# Bug#20835095 CRASH AT CREATE_REF_FOR_KEY IN SQL/SQL_SELECT.CC 12118# 12119CREATE TABLE t1 ( 12120pk INTEGER, 12121var_10_latin1 VARCHAR(10) CHARACTER SET latin1, 12122var_255_utf8 VARCHAR(255) CHARACTER SET utf8, 12123var_255_latin1 VARCHAR(255) CHARACTER SET latin1, 12124var_10_utf8 VARCHAR(10) CHARACTER SET utf8, 12125PRIMARY KEY (pk) 12126); 12127CREATE VIEW v1 AS SELECT * FROM t1; 12128INSERT INTO t1 VALUES 12129(1,'FROCJ','korrhrspki','UAYVL','BPZIS'), 12130(2,'him','a','CHYKN','OZZQT'), 12131(3,'WBITK','ULWBF','have','rhrh'), 12132(4,'or','right','up','it'), 12133(5,'GGDCP','x','who','as'), 12134(6,'j','i','e','w'); 12135CREATE TABLE tv 12136SELECT var_255_utf8 AS field1 12137FROM t1; 12138EXPLAIN SELECT * FROM tv 12139WHERE field1 IN ( 12140SELECT tv1.var_255_utf8 12141FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); 12142id select_type table partitions type possible_keys key key_len ref rows filtered Extra 121431 SIMPLE tv NULL ALL NULL NULL NULL NULL 6 100.00 Using where 121441 SIMPLE <subquery2> NULL eq_ref <auto_key> <auto_key> 768 test.tv.field1 1 100.00 NULL 121452 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 NULL 121462 MATERIALIZED t1 NULL ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (Block Nested Loop) 12147Warnings: 12148Note 1003 /* select#1 */ select `test`.`tv`.`field1` AS `field1` from `test`.`tv` semi join (`test`.`t1` left join (`test`.`t1`) on((convert(`test`.`t1`.`var_10_latin1` using utf8) = `test`.`t1`.`var_10_utf8`))) where (`<subquery2>`.`var_255_utf8` = `test`.`tv`.`field1`) 12149SELECT * FROM tv 12150WHERE field1 IN ( 12151SELECT tv1.var_255_utf8 12152FROM v1 AS tv1 LEFT JOIN v1 AS tv2 ON tv1.var_10_latin1=tv2.var_10_utf8); 12153field1 12154korrhrspki 12155a 12156ULWBF 12157right 12158x 12159i 12160DROP VIEW v1; 12161DROP TABLE t1, tv; 12162# 17832047 Crash in calculate_materialization_costs 12163CREATE TABLE t1(a INTEGER PRIMARY KEY); 12164INSERT INTO t1 VALUES (0),(1),(2); 12165SELECT 1 FROM t1 12166WHERE 1 IN 12167(SELECT 1 BETWEEN (LENGTH(a) IN (SELECT 1 FROM t1)) AND 1 12168FROM t1 12169); 121701 121711 121721 121731 12174DROP TABLE t1; 12175# 17845989 Assertion failed: !(used_tables() & ... 12176CREATE TABLE a(b INTEGER) engine=innodb; 12177CREATE TABLE c(a INTEGER) engine=innodb; 12178SELECT 1 12179FROM a 12180WHERE 1 IN (SELECT (a.b IS NULL) IN (SELECT 1 FROM c) FROM c) 12181; 121821 12183DROP TABLE a, c; 12184# 12185# Bug#18194196: OPTIMIZER EXECUTES STATEMENT INPERFORMANT 12186# 12187CREATE TABLE t1 (uid INTEGER, fid INTEGER, INDEX(uid)); 12188INSERT INTO t1 VALUES 12189(1,1), (1,2), (1,3), (1,4), 12190(2,5), (2,6), (2,7), (2,8), 12191(3,1), (3,2), (3,9); 12192CREATE TABLE t2 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); 12193INSERT INTO t2 VALUES 12194(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), 12195(6, "F"), (7, "G"), (8, "H"), (9, "I"); 12196CREATE TABLE t3 (uid INT, fid INT, INDEX(uid)); 12197INSERT INTO t3 VALUES 12198(1,1), (1,2), (1,3),(1,4), 12199(2,5), (2,6), (2,7), (2,8), 12200(3,1), (3,2), (3,9); 12201CREATE TABLE t4 (uid INT PRIMARY KEY, name VARCHAR(128), INDEX(name)); 12202INSERT INTO t4 VALUES 12203(1, "A"), (2, "B"), (3, "C"), (4, "D"), (5, "E"), 12204(6, "F"), (7, "G"), (8, "H"), (9, "I"); 12205ANALYZE TABLE t1,t2,t3,t4; 12206Table Op Msg_type Msg_text 12207test.t1 analyze status OK 12208test.t2 analyze status OK 12209test.t3 analyze status OK 12210test.t4 analyze status OK 12211EXPLAIN SELECT name FROM t2, t1 12212WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) 12213AND t2.uid=t1.fid; 12214id select_type table partitions type possible_keys key key_len ref rows filtered Extra 122151 SIMPLE t3 NULL ref uid uid 5 const 4 100.00 Using where; Start temporary 122161 SIMPLE t4 NULL eq_ref PRIMARY PRIMARY 4 test.t3.fid 1 100.00 Using index 122171 SIMPLE t1 NULL ALL uid NULL NULL NULL 11 36.36 Using where; End temporary; Using join buffer (Block Nested Loop) 122181 SIMPLE t2 NULL eq_ref PRIMARY PRIMARY 4 test.t1.fid 1 100.00 Using join buffer (Batched Key Access) 12219Warnings: 12220Note 1003 /* select#1 */ select `test`.`t2`.`name` AS `name` from `test`.`t4` semi join (`test`.`t3`) join `test`.`t2` join `test`.`t1` where ((`test`.`t4`.`uid` = `test`.`t3`.`fid`) and (`test`.`t1`.`uid` = `test`.`t3`.`fid`) and (`test`.`t3`.`uid` = 1) and (`test`.`t2`.`uid` = `test`.`t1`.`fid`)) 12221FLUSH STATUS; 12222SELECT name FROM t2, t1 12223WHERE t1.uid IN (SELECT t4.uid FROM t4, t3 WHERE t3.uid=1 AND t4.uid=t3.fid) 12224AND t2.uid=t1.fid; 12225name 12226A 12227A 12228B 12229B 12230C 12231D 12232E 12233F 12234G 12235H 12236I 12237SHOW STATUS LIKE '%handler_read%'; 12238Variable_name Value 12239Handler_read_first 0 12240Handler_read_key 16 12241Handler_read_last 0 12242Handler_read_next 15 12243Handler_read_prev 0 12244Handler_read_rnd 11 12245Handler_read_rnd_next 12 12246DROP TABLE t1,t2,t3,t4; 12247# End of test for Bug#18194196 12248# 12249# Bug#21184091 ASSERT `READ_ROWS >= 0.0' AT 12250# COST_MODEL_SERVER::TMPTABLE_READWRITE_COST() 12251# 12252CREATE TABLE t1 ( 12253pk INTEGER, 12254col_varchar varchar(1), 12255col_int INTEGER, 12256PRIMARY KEY (pk) 12257) ENGINE=MyISAM; 12258CREATE TABLE t2 ( 12259col_int INTEGER, 12260col_varchar varchar(1) 12261) ENGINE=MyISAM; 12262INSERT INTO t2 VALUES (7,'x'); 12263INSERT INTO t2 VALUES (4,'z'); 12264SELECT t2.col_varchar 12265FROM t2 STRAIGHT_JOIN t1 ON t2.col_varchar = t1.col_varchar 12266JOIN t2 AS table3 ON t1.pk = table3.col_int 12267WHERE t1.pk IN (SELECT col_int FROM t1); 12268col_varchar 12269DROP TABLE t1,t2; 12270# End of test for Bug#21184091 12271# Bug#21139722: Assertion failed: !(used_tables() & ((table_map) 1) ... 12272CREATE TABLE t1(a INTEGER) engine=innodb; 12273CREATE TABLE t2(b INTEGER) engine=innodb; 12274explain SELECT 1 12275FROM (SELECT 1 IN (SELECT 1 12276FROM t1 12277WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) 12278) 12279FROM t2 12280) AS z; 12281id select_type table partitions type possible_keys key key_len ref rows filtered Extra 122821 PRIMARY <derived2> NULL ALL NULL NULL NULL NULL 2 100.00 NULL 122832 DERIVED t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL 122843 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 122855 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 122864 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 NULL 12287Warnings: 12288Note 1276 Field or reference 'b' of SELECT #4 was resolved in SELECT #2 12289Note 1003 /* select#1 */ select 1 AS `1` from (/* select#2 */ select <in_optimizer>(1,<exists>(/* select#3 */ select 1 from `test`.`t1` where (not(<in_optimizer>((/* select#4 */ select 1 from `test`.`t2` having `test`.`t2`.`b`),<exists>(/* select#5 */ select 1 from `test`.`t2` where <if>(outer_field_is_not_null, (<cache>((/* select#4 */ select 1 from `test`.`t2` having `test`.`t2`.`b`)) = 1), true))))))) AS `1 IN (SELECT 1 12290FROM t1 12291WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) 12292)` from `test`.`t2`) `z` 12293SELECT 1 12294FROM (SELECT 1 IN (SELECT 1 12295FROM t1 12296WHERE (SELECT 1 FROM t2 HAVING b) NOT IN (SELECT 1 FROM t2) 12297) 12298FROM t2 12299) AS z; 123001 12301DROP TABLE t1, t2; 12302CREATE TABLE t1(a INTEGER) engine=innodb; 12303explain SELECT (SELECT a FROM t1 AS t2 12304WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) 12305FROM t1 AS t1; 12306id select_type table partitions type possible_keys key key_len ref rows filtered Extra 123071 PRIMARY t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL 123082 DEPENDENT SUBQUERY t2 NULL ALL NULL NULL NULL NULL 1 100.00 Using where 123092 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 1 100.00 FirstMatch(t2); Using join buffer (Block Nested Loop) 12310Warnings: 12311Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1 12312Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #2 12313Note 1003 /* select#1 */ select (/* select#2 */ select `test`.`t2`.`a` from `test`.`t1` `t2` semi join (`test`.`t1` `t3`) where (`test`.`t2`.`a` = (`test`.`t1`.`a` + `test`.`t2`.`a`))) AS `(SELECT a FROM t1 AS t2 12314WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3))` from `test`.`t1` 12315SELECT (SELECT a FROM t1 AS t2 12316WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) 12317FROM t1 AS t1; 12318(SELECT a FROM t1 AS t2 12319WHERE a IN (SELECT t1.a+t2.a FROM t1 AS t3)) 12320DROP TABLE t1; 12321# End of test for Bug#21139722 12322SET DEFAULT_STORAGE_ENGINE=INNODB; 12323# 12324# Bug#21139402 ASSERTION FAILED: LENGTH > 0 && KEYPARTS != 0, CRASH IN JOIN::OPTIMIZE_KEYUSE 12325# 12326CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a)); 12327CREATE TABLE t2 (c INT PRIMARY KEY); 12328EXPLAIN SELECT 1 FROM t1 12329WHERE 1 IN 12330(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); 12331id select_type table partitions type possible_keys key key_len ref rows filtered Extra 123321 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 123333 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 12334Warnings: 12335Note 1003 /* select#1 */ select 1 AS `1` from `test`.`t1` semi join (`test`.`t2`) where 0 12336SELECT 1 FROM t1 12337WHERE 1 IN 12338(SELECT (c IS NULL) IN (SELECT a FROM t1 WHERE b) FROM t2); 123391 12340DROP TABLE t1,t2; 12341# 12342# Bug#21619634 ACCESS OF DEALLOCATED ITEM_OUTER_REF CAUSES CRASH: PREPARED STMT 12343# 12344create table cc (i int) engine="innodb"; 12345insert into cc values (1); 12346select (select count(i) from cc as cc_alias 12347where (cc.i in (select cc_alias.i from cc))) 12348from cc group by i; 12349(select count(i) from cc as cc_alias 12350where (cc.i in (select cc_alias.i from cc))) 123511 12352prepare stmt from 12353"select (select count(i) from cc as cc_alias 12354 where (cc.i in (select cc_alias.i from cc))) 12355 from cc group by i"; 12356execute stmt; 12357(select count(i) from cc as cc_alias 12358 where (cc.i in (select cc_alias.i from cc))) 123591 12360execute stmt; 12361(select count(i) from cc as cc_alias 12362 where (cc.i in (select cc_alias.i from cc))) 123631 12364drop table cc; 12365# 12366# Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS INCORRECT 12367# RESULTS IN 5.6 12368# 12369CREATE TABLE t(a INT,b INT); 12370INSERT INTO t VALUES (1,0),(1,0),(1,0),(1,0),(1,1); 12371ANALYZE TABLE t; 12372Table Op Msg_type Msg_text 12373test.t analyze status OK 12374EXPLAIN extended SELECT * 12375FROM t AS t1 12376WHERE t1.a IN (SELECT t2.a 12377FROM t AS t2 12378WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a 12379FROM t AS t3 12380WHERE t3.b=1)); 12381id select_type table partitions type possible_keys key key_len ref rows filtered Extra 123821 PRIMARY t1 NULL ALL NULL NULL NULL NULL 5 100.00 Using where 123831 PRIMARY <subquery2> NULL eq_ref <auto_key> <auto_key> 5 test.t1.a 1 100.00 NULL 123842 MATERIALIZED t2 NULL ALL NULL NULL NULL NULL 5 100.00 Using where 123853 DEPENDENT SUBQUERY t3 NULL ALL NULL NULL NULL NULL 5 20.00 Using where 12386Warnings: 12387Warning 1681 'EXTENDED' is deprecated and will be removed in a future release. 12388Note 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)))))) 12389SELECT * 12390FROM t AS t1 12391WHERE t1.a IN (SELECT t2.a 12392FROM t AS t2 12393WHERE CONCAT(t2.a,'') NOT IN (SELECT t3.a 12394FROM t AS t3 12395WHERE t3.b=1)); 12396a b 12397DROP TABLE t; 12398set optimizer_switch=default; 12399set optimizer_switch=default; 12400