2 # DuplicateElimination strategy test
7 SET GLOBAL innodb_stats_persistent=0;
11 create
table t0 (a
int);
12 insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
14 # First test simple cases: I20 order, no join buffering.
20 insert into t1 values (1,1),(1,1),(2,2);
27 insert into t2 select a, a/2 from t0;
31 explain select * from t2 where b in (select a from t1);
32 select * from t2 where b in (select a from t1);
34 # Try an InnoDB table with very long rowid
39 pk1
char(200), pk2
char(200), pk3
char(200),
40 primary key(pk1, pk2, pk3)
42 insert into t3 select a,a, a,a,a from t0;
44 explain select * from t3 where b in (select a from t1);
45 select * from t3 where b in (select a from t1);
47 # Test overflow to MyISAM:
48 set @save_max_heap_table_size= @@max_heap_table_size;
49 set max_heap_table_size=16384;
50 set @save_join_buffer_size = @@join_buffer_size;
51 set join_buffer_size= 8192;
58 pk1
char(200), pk2
char(200),
62 A.a + 10*B.a,
A.a + 10*B.a,
A.a + 10*B.a,
A.a + 10*B.a
63 from t0
A, t0 B where B.a <5;
66 explain select * from t3 where b in (select a from t0);
68 select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5);
70 set join_buffer_size= @save_join_buffer_size;
71 set max_heap_table_size= @save_max_heap_table_size;
73 # O2I join orders, with shortcutting:
74 explain select * from t1 where a in (select b from t2);
76 select * from t1 where a in (select b from t2);
78 drop
table t0, t1, t2, t3;
79 # (no need for anything in range/index_merge/DS-MRR)
82 # BUG#34799: crash or/and memory overrun with dependant subquery and some joins
84 create
table t1 (a
int);
85 insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
87 create
table t2 (a
char(200), b
char(200), c
char(200), primary key (a,b,c)) engine=innodb;
88 insert into t2 select concat(a, repeat('X',198)),repeat('B',200),repeat('B',200) from t1;
89 insert into t2 select concat(a, repeat('Y',198)),repeat('B',200),repeat('B',200) from t1;
90 alter
table t2 add filler1
int;
92 insert into t1 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C;
94 set @save_join_buffer_size=@@join_buffer_size;
96 set join_buffer_size=1;
99 select * from t2 where filler1 in ( select a from t1);
100 set join_buffer_size=default;
106 --echo BUG
#42740: crash in optimize_semijoin_nests
108 create
table t1 (c6 timestamp,key (c6)) engine=innodb;
109 create
table t2 (c2
double) engine=innodb;
110 explain select 1 from t2 where c2 = any (select log10(null) from t1 where c6 <null) ;
114 --echo # BUG#42742: crash in setup_sj_materialization, Copy_field::set
116 create
table t3 ( c1 year) engine=innodb;
117 insert into t3 values (2135),(2142);
118 create
table t2 (c1 tinytext,c2 text,c6 timestamp) engine=innodb;
119 -- echo # The following must not crash, EXPLAIN should show one SJ strategy, not a mix:
120 explain select 1 from t2 where
121 c2 in (select 1 from t3, t2) and
122 c1 in (select convert(c6,
char(1)) from t2);
125 --echo # BUG#57431: subquery returns wrong result (semijoin=on) with pred AND
130 INSERT INTO t1 VALUES (2),(4);
136 INSERT INTO t2 VALUES (8,NULL);
140 WHERE
i IN (SELECT innr.
i
141 FROM t2 LEFT
JOIN t2 innr ON innr.vc)
147 -- disable_result_log
148 SET GLOBAL innodb_stats_persistent=default;