oceanbase
534 строки · 20.7 Кб
1--disable_query_log
2set @@session.explicit_defaults_for_timestamp=off;
3--enable_query_log
4# owner: link.zt
5# owner group: sql4
6# tags: optimizer
7# description: 子查询结果集
8--disable_info
9--disable_metadata
10--disable_warnings
11create database if not exists test;
12use test;
13drop table if exists t1, t2, t3;
14--enable_warnings
15create table t1(c1 int primary key, c2 int);
16create table t2(c1 int primary key, c2 int);
17create table t3(c1 int primary key, c2 int);
18insert into t1 values(1, 1), (2, 2), (3, 3), (4, 3), (5, 2);
19insert into t2 values(1, 1), (2, 2);
20insert into t3 values(5, 5), (6, 6);
21
22###where subquery
23select * from t1 where c1>ANY(select c1 from t2);
24select * from t1 where c1<ALL(select c1 from t2);
25--error 1242
26select * from t1 where c1=(select c1 from t2);
27select * from t1 where c1=(select c1 from t2 limit 1);
28select * from t1 where c1=ANY(select c1 from t2 where t1.c2>t2.c2);
29select * from t1 where exists(select c1 from t2 where t1.c2>t2.c2);
30select * from t1 where 1<ANY(select c1 from t2);
31select c2 from t1 where exists(select c2 from t2 where t1.c1>t2.c1);
32select * from t1 where c1>(select c1 from t2 where t2.c1=1);
33select * from t1 where exists(select * from t2 where t1.c1=t2.c2);
34select * from t1 where c1 in (select c1 from t1);
35select * from t1 where c1 not in (select c1 from t1);
36select c1 from t1 where c1 not in (select c1 from t2 where c2 not in (select c2 from t2));
37
38#from-subquery
39select * from (select * from t1 limit 1) t;
40select c from (select c1 as c from t1) tt;
41select c1 from t1 where c1 in (select c1 from t2 where c2 >= some(select max(c1) from (select c1 from t3 where t1.c2=t3.c1 order by c1 limit 1) as tt));
42
43
44#select subquery
45--error 1241
46select (select c1, c2 from t1) from t1;
47--error 1242
48select (select c1 from t1) from t1;
49select (select c1 from t1 where c1=1) from t1;
50select (select 1)=ANY(select 1);
51SELECT (SELECT 1)>ALL(SELECT 1);
52SELECT (SELECT 1,2,3) = ROW(1,2,3);
53SELECT (SELECT 1,2,3) = ROW(1,2,1);
54SELECT (SELECT 1,2,3) < ROW(1,2,1);
55SELECT (SELECT 1,2,3) > ROW(1,2,1);
56SELECT (SELECT 1,2,3) = ROW(1,2,NULL);
57SELECT ROW(1,2,3) = (SELECT 1,2,3);
58SELECT ROW(1,2,3) = (SELECT 1,2,1);
59SELECT ROW(1,2,3) < (SELECT 1,2,1);
60SELECT ROW(1,2,3) > (SELECT 1,2,1);
61SELECT ROW(1,2,3) = (SELECT 1,2,NULL);
62SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'a');
63SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'b');
64SELECT (SELECT 1.5,2,'a') = ROW(1.5,'2','a');
65SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a');
66#row compare
67#greater than
68select (select 3, 2, 1)>row(1, 2, 1);
69select (select 1, 2, 3)>row(1, 2, 1);
70select (select 1, 2, 3)>row(1, 2, 3);
71select (select 1, 3, 2)>row(1, 2, 3);
72select (select 1, 2, 3)>row(1, 3, 2);
73select (select 1, null, 2)>row(1, 2, 2);
74select (select 1, 2, null)>row(1, 1, 2);
75#greater equal
76select (select 3, 2, 1)>=row(1, 2, 1);
77select (select 1, 2, 3)>=row(1, 2, 1);
78select (select 1, 2, 3)>=row(1, 2, 3);
79select (select 1, 3, 2)>=row(1, 2, 3);
80select (select 1, 2, 3)>=row(1, 3, 2);
81select (select 1, null, 2)>=row(1, 2, 2);
82select (select 1, 2, null)>=row(1, 1, 2);
83#less than
84select (select 1, 2, 3)<row(3, 2, 1);
85select (select 1, 2, 3)<row(1, 3, 2);
86select (select 1, 2, 1)<row(1, 2, 3);
87select (select 1, 2, 3)<row(1, 2, 3);
88select (select 1, 3, 2)<row(1, 2, 3);
89select (select 1, null, 2)<row(1, 2, 2);
90select (select 1, 2, null)<row(1, 1, 2);
91#less equal
92select (select 1, 2, 3)<=row(3, 2, 1);
93select (select 1, 2, 3)<=row(1, 3, 2);
94select (select 1, 2, 1)<=row(1, 2, 3);
95select (select 1, 2, 3)<=row(1, 2, 3);
96select (select 1, 3, 2)<=row(1, 2, 3);
97select (select 1, null, 2)<=row(1, 2, 2);
98select (select 1, 2, null)<=row(1, 1, 2);
99#equal
100select (select 1, 2, 3)=row(1, 2, 3);
101select (select 1, 2, 3)=row(1, 2, 1);
102select (select 1, 2, 1)=row(3, 2, 1);
103select (select 1, null, 1)=row(1, 2, 1);
104#ns equal
105select (select 1, 2, 3)<=>row(1, 2, 3);
106select (select 1, 2, 3)<=>row(1, 2, 1);
107select (select 1, null, 1)<=>row(1, 2, 1);
108select (select 1, null, 3)<=>row(1, null, 3);
109#not equal
110select (select 1, 2, 3)!=row(1, 2, 3);
111select (select 1, 2, 3)!=row(1, 2, 1);
112select (select 1, null, 1)!=row(1, 2, 1);
113select (select 1, null, 3)!=row(1, null, 3);
114
115#group by subquery
116--sorted_result
117select * from t1 group by (select c1 from t1 limit 1);
118--error 1241
119select * from t1 group by (select c1, c2 from t1);
120
121#test ANY/SOME/ALL keywords
122delete from t1;
123insert into t1 values(1, NULL), (2, NULL), (3, NULL), (4, NULL);
124select NULL=ANY(select c1 from t1);
125select NULL=ALL(select c1 from t1);
126delete from t1;
127insert into t1 values(1, NULL), (2, 2), (3, 3), (4, 4);
128select 2=ANY(select c2 from t1);
129select 2=ALL(select c2 from t1);
130#return NULL
131select 5=ANY(select c2 from t1);
132#return NULL
133select 5!=ANY(select c2 from t1);
134delete from t1;
135insert into t1 values(1, 1), (2, NULL), (3, 3), (4, 4);
136select 1=ANY(select c1 from t1);
137select 1!=ANY(select c1 from t1);
138select 1=ALL(select c1 from t1);
139select 1!=ALL(select c1 from t1);
140select 5=ANY(select c1 from t1);
141select 5!=ANY(select c1 from t1);
142select 5=ALL(select c1 from t1);
143select 5!=ALL(select c1 from t1);
144delete from t1;
145insert into t1 values(1, 1), (2, 2), (3, 3), (4, NULL);
146select 1!=ANY(select c1 from t1);
147select 1=ANY(select c1 from t1);
148select 1!=ALL(select c1 from t1);
149select 1=ALL(select c1 from t1);
150select 5!=ANY(select c1 from t1);
151select 5=ANY(select c1 from t1);
152select 5!=ALL(select c1 from t1);
153select 5=ALL(select c1 from t1);
154
155### test for related subquery with one column expr ###
156select * from t1 where c1 > (select t2.c1 from t2 where t1.c1 limit 1);
157select t1.c1 from t1 left join t3 on t1.c1 = t3.c1 where t3.c1 < (select t2.c1 from t2 where t3.c1 limit 1);
158select * from t1 where c1 > (select t2.c1 from t2 where t1.c1 > 1 limit 1);
159
160#
161drop table if exists t1, t2;
162create table t1 (a int not null, b int not null, index it1a(a), index iab(a, b));
163create table t2 (c int not null, d int not null);
164insert into t1 values (1,10);
165insert into t1 values (1,20);
166insert into t1 values (2,10);
167insert into t1 values (2,20);
168insert into t1 values (2,30);
169insert into t1 values (3,20);
170insert into t1 values (4,40);
171insert into t2 values (2,10);
172insert into t2 values (2,20);
173insert into t2 values (2,40);
174insert into t2 values (3,20);
175insert into t2 values (4,10);
176insert into t2 values (5,10);
177--sorted_result
178select a from t1 group by a having a in (select c from t2 where d >= 20);
179
180drop table if exists t1;
181create table t1(c1 int);
182select count(1) from t1 where false;
183select count(1) from t1 having false;
184--sorted_result
185select count(1) from t1 group by c1 having false;
186--sorted_result
187select count(1) from t1 where false group by c1;
188insert into t1 values(1);
189select * from t1 where c1 in (trim((select 1)), 2);
190select * from t1 where c1 in ((select c1 from t1), 2);
191select * from t1 where c1 in ((select t1.c1 from t1 t), 2);
192
193#clean tables
194--disable_warnings
195drop table if exists t1, t2;
196--enable_warnings
197
198#project/81079/issue/11488676?akProjectId=81079&akProjectId=81079&
199--disable_warnings
200drop table if exists DD,AA,J,CC,GG;
201--enable_warnings
202CREATE TABLE DD ( col_int int, pk int, col_varchar_20 varchar(20), col_int_key int, primary key (pk));
203CREATE TABLE AA ( pk int, col_int_key int, col_varchar_20 varchar(20), col_int int, primary key (pk));
204CREATE TABLE J ( col_varchar_20 varchar(20), pk int primary key);
205CREATE TABLE CC ( col_int_key int, pk int, col_int int, col_varchar_20 varchar(20), primary key (pk));
206CREATE TABLE GG (col_varchar_20 varchar(20), pk int primary key);
207insert into DD (pk, col_varchar_20, col_int, col_int_key) value(1, "YYY", 5,3);
208insert into AA (pk, col_varchar_20, col_int, col_int_key) value(2, 'me', 4, 3);
209insert into CC (pk, col_varchar_20, col_int) value(3, 'you', 4);
210SELECT GRANDPARENT1 . col_varchar_20 AS G1 FROM DD AS GRANDPARENT1 WHERE GRANDPARENT1 . `col_int_key` IN ( SELECT DISTINCT PARENT1 . `col_int_key` AS P1 FROM AA AS PARENT1 LEFT JOIN J AS PARENT2 USING ( col_varchar_20 ) WHERE PARENT1 . `col_int` IN ( SELECT CHILD1 . `col_int` AS C1 FROM CC AS CHILD1 LEFT JOIN GG AS CHILD2 USING ( col_varchar_20 ) ) AND ( GRANDPARENT1 . `col_int` >= 1 ));
211--disable_warnings
212drop table if exists DD,AA,J,CC,GG;
213--enable_warnings
214
215#extract query range from push-down filter
216#
217--disable_warnings
218drop table if exists t1, t2, t3;
219--enable_warnings
220create table t1(c1 int primary key, c2 int, c3 int);
221create table t2(c1 int primary key, c2 int, c3 int);
222create table t3(c1 int primary key, c2 int, c3 int);
223insert into t1 values(1, 2, 3);
224insert into t1 values(2, 2, 3);
225insert into t2 values(1, 2, 3);
226insert into t2 values(2, 2, 3);
227insert into t3 values(1, 2, 3);
228insert into t3 values(2, 2, 3);
229explain select * from t1 where t1.c2 = 5 or exists (select 1 from t2 where t1.c1 = t2.c1);
230explain select * from t1 where t1.c2 = 5 or exists (select 1 from t2 where t1.c1 > t2.c1);
231explain select * from t1 where t1.c2 = 5 or exists (select 1 from t2 where t1.c1 < t2.c1);
232explain select * from t1, t2 where t1.c1 > exists(select c1 from t2 where t2.c1 = t1.c1);
233explain select * from t1 where (select c1 from t2 limit 1)+1 in (select 2 from t3 where t1.c1=t3.c1);
234explain select * from t1 having count(*) > (select c1 from t2 where t1.c1=t2.c1);
235explain select * from t1, t2 where t2.c1 = t1.c1 and t2.c1 = (select c1 from t3 where t3.c1 = t1.c1);
236explain select * from (select c1+1 as a1 from t1 where t1.c2 = 2) a, t2 where a.a1 = t2.c2 or t2.c1 = ANY(select c3 from t3 where t3.c1 > a.a1);
237select * from t1 where t1.c2 = 5 or exists (select 1 from t2 where t1.c1 = t2.c1);
238select * from t1 where t1.c2 = 5 or exists (select 1 from t2 where t1.c1 > t2.c1);
239select * from t1 where t1.c2 = 5 or exists (select 1 from t2 where t1.c1 < t2.c1);
240select * from t1, t2 where t1.c1 > exists(select c1 from t2 where t2.c1 = t1.c1);
241select * from t1 where (select c1 from t2 limit 1)+1 in (select 2 from t3 where t1.c1=t3.c1);
242select * from t1 having count(*) > (select c1 from t2 where t1.c1=t2.c1);
243select * from t1, t2 where t2.c1 = t1.c1 and t2.c1 = (select c1 from t3 where t3.c1 = t1.c1);
244select * from (select c1+1 as a1 from t1 where t1.c2 = 2) a, t2 where a.a1 = t2.c2 or t2.c1 = ANY(select c3 from t3 where t3.c1 > a.a1);
245#extract query range for multi plan operators
246explain select * from t1 where t1.c1 > (select sum(c1) from t2 where t2.c1 = t1.c1);
247explain select * from t1 where t1.c1 > (select sum(c1) from t2 where t2.c1 = t1.c1 and t2.c2 > (select max(c2) from t3 where t3.c1 = t2.c1));
248explain select * from t1 where t1.c2 in (select avg(c1) from t2 where t2.c1 = t1.c1 union select count(1) from t3 where t3.c1 = t1.c1);
249explain select * from t1 where t1.c1 != (select c2 from t2 where t2.c1 = (select max(c2) from t3 where t3.c1 = t1.c1) order by t2.c2 limit 1);
250select * from t1 where t1.c1 > (select sum(c1) from t2 where t2.c1 = t1.c1);
251select * from t1 where t1.c1 > (select sum(c1) from t2 where t2.c1 = t1.c1 and t2.c2 > (select max(c2) from t3 where t3.c1 = t2.c1));
252select * from t1 where t1.c2 in (select avg(c1) from t2 where t2.c1 = t1.c1 union select count(1) from t3 where t3.c1 = t1.c1);
253select * from t1 where t1.c1 != (select c2 from t2 where t2.c1 = (select max(c2) from t3 where t3.c1 = t1.c1) order by t2.c2 limit 1);
254--disable_warnings
255drop table if exists t1, t2, t3;
256
257#issue/9168337
258#subquery in [not]exists could be eliminated or refined
259--disable_warnings
260drop table if exists t1,t2,t3;
261--enable_warnings
262create table t1(a int, b int);
263create table t2(a int, b int);
264create table t3(a int, b int);
265#basic exists subquery with aggr, group by, having
266explain select * from t1 where exists (select 1, round(1.1) from dual);
267explain select * from t1 where exists (select max(a) from t2);
268explain select * from t1 where exists (select group_concat(a, b) from t2 group by a);
269explain select * from t1 where exists (select max(a), sum(a), count(a) from t2);
270explain select * from t1 where exists (select max(a), sum(a), count(a) from t2 group by a);
271explain select * from t1 where exists (select max(a), sum(a), count(a) from t2 group by a having a > 1);
272explain select * from t1 where exists (select max(a), sum(a), count(a) from t2 group by a having sum(a) > 1);
273explain select * from t1 where exists (select max(a), sum(a), count(a) from t2 group by a having sum(a) > 1 and count(a) > 0);
274#basic not exists subquery with aggr, group by, having
275explain select * from t1 where not exists (select 1, round(1.1) from dual);
276explain select * from t1 where not exists (select max(a) from t2);
277explain select * from t1 where not exists (select group_concat(a, b) from t2 group by a);
278explain select * from t1 where not exists (select max(a), sum(a), count(a) from t2);
279explain select * from t1 where not exists (select max(a), sum(a), count(a) from t2 group by a);
280explain select * from t1 where not exists (select max(a), sum(a), count(a) from t2 group by a having a > 1);
281explain select * from t1 where not exists (select max(a), sum(a), count(a) from t2 group by a having sum(a) > 1);
282explain select * from t1 where not exists (select max(a), sum(a), count(a) from t2 group by a having sum(a) > 1 and count(a) > 0);
283#mixed situations
284explain select * from t1, (select * from t2 where exists(select sum(a) from t3)) t4 where t1.a = t4.a;
285explain select * from t1 where t1.a in (select a from t2 where exists(select count(a) from t3));
286explain select * from t1 where exists(select max(a) from t2 group by a having max(a) > 1);
287explain select * from t1, (select * from t2 having a > 1) t4 where t1.a = t4.a;
288explain select * from t1, (select * from t2 where exists(select sum(a) from t3 group by a having a > 1)) t4 where t1.a = t4.a;
289explain select * from t1 where exists ( select max(a) from t2 group by a having exists (select * from t3 where t3.a > max(t2.a)));
290explain select * from t1 where exists ( select sum(a) from t2 group by a having exists (select * from t3 where t3.a > sum(t2.a)));
291#eliminate exists subquery in params
292explain select * from t1 where b > exists(select b from t2 where b > exists(select b from t3));
293explain select * from t1 where b > exists(select a from t2 where b > exists(select sum(a) from t3));
294explain select * from t1 where b > exists(select sum(a) from t2 where t2.b > exists(select sum(a) from t3));
295
296## bug:
297--disable_warnings
298drop table if exists T;
299--enable_warnings
300create table T (pk int);
301explain select pk from t table1 where (table1.pk >= (select 1 from T limit 1)) AND ((1,9) in (select 1,9));
302
303## bug:
304explain select (select 1 except select pk),
305(select 1 except select pk),
306(select 1 except select pk),
307(select 1 except select pk),
308(select 1 except select pk),
309(select 1 except select pk),
310(select 1 except select pk),
311(select 1 except select pk),
312(select 1 except select pk),
313(select 1 except select pk),
314(select 1 except select pk),
315(select 1 except select pk),
316(select 1 except select pk),
317(select 1 except select pk),
318(select 1 except select pk),
319(select 1 except select pk),
320(select 1 except select pk),
321(select 1 except select pk),
322(select 1 except select pk),
323(select 1 except select pk),
324(select 1 except select pk),
325(select 1 except select pk),
326(select 1 except select pk),
327(select 1 except select pk),
328(select 1 except select pk),
329(select 1 except select pk),
330(select 1 except select pk),
331(select 1 except select pk)
332from t;
333select (select 1 except select pk),
334(select 1 except select pk),
335(select 1 except select pk),
336(select 1 except select pk),
337(select 1 except select pk),
338(select 1 except select pk),
339(select 1 except select pk),
340(select 1 except select pk),
341(select 1 except select pk),
342(select 1 except select pk),
343(select 1 except select pk),
344(select 1 except select pk),
345(select 1 except select pk),
346(select 1 except select pk),
347(select 1 except select pk),
348(select 1 except select pk),
349(select 1 except select pk),
350(select 1 except select pk),
351(select 1 except select pk),
352(select 1 except select pk),
353(select 1 except select pk),
354(select 1 except select pk),
355(select 1 except select pk),
356(select 1 except select pk),
357(select 1 except select pk),
358(select 1 except select pk),
359(select 1 except select pk),
360(select 1 except select pk)
361from t;
362
363--disable_warnings
364drop table if exists t1,t2,t3;
365--enable_warnings
366
367--echo #
368CREATE TABLE `t1` (
369`c1` varbinary(20) DEFAULT NULL
370) DEFAULT CHARSET = utf8mb4 ROW_FORMAT = DYNAMIC COMPRESSION = 'zstd_1.3.8' REPLICA_NUM = 2 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0;
371CREATE TABLE `t2` (
372`a` int(11) NOT NULL,
373`b` varchar(20) DEFAULT NULL,
374`c` decimal(20,10) DEFAULT NULL,
375PRIMARY KEY (`a`)
376) DEFAULT CHARSET = utf8mb4 ROW_FORMAT = DYNAMIC COMPRESSION = 'zstd_1.3.8' REPLICA_NUM = 2 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0
377partition by hash(a) partitions 2;
378
379insert into t1 values(1), (2);
380insert into t2 values(1,2,1);
381
382select /*+no_rewrite*/(select sum(b) from t2) as temp from t1 group by temp having temp > 4 and temp > (select sum(b) from t2);
383
384drop table t1;
385drop table t2;
386--echo #
387CREATE TABLE `t1` (
388`pk1` int(11) NOT NULL,
389`pk2` varchar(10) NOT NULL,
390`c1` int(11) DEFAULT NULL,
391`c2` int(11) DEFAULT NULL,
392`c3` varchar(20) DEFAULT NULL,
393`c4` timestamp(6) NULL DEFAULT '2012-01-01 04:00:00.000000',
394`c5` int(11) DEFAULT NULL,
395PRIMARY KEY (`pk1`, `pk2`)
396) DEFAULT CHARSET = utf8mb4 ROW_FORMAT = DYNAMIC COMPRESSION = 'zstd_1.3.8' REPLICA_NUM = 2 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0;
397insert into t1 values(1, '2', 3, 3, null, null, null);
398select /*+no_rewrite*/ c1, (select max(c2) FROM t1 ) a FROM t1 order by (select c1 FROM t1 where c2 in (select c1 FROM t1 where c2 = a)) + 1;
399drop table t1 ;
400
401# bug:
402--disable_warnings
403drop table if exists table0_hash_pk_parts_1_bigint;
404drop table if exists s;
405drop table if exists ff;
406--enable_warnings
407
408CREATE TABLE table0_hash_pk_parts_1_bigint (
409col_timestamp_6_index timestamp(6) NULL DEFAULT NULL,
410col_varchar_20 varchar(20),
411col_char_20 char(20),
412col_decimal_20_0_key decimal(20,0),
413pk bigint,
414col_char_20_index char(20),
415col_bigint_key bigint,
416col_bigint bigint,
417col_timestamp_6 timestamp(6) NULL DEFAULT NULL,
418col_varchar_20_key varchar(20),
419col_bigint_index bigint,
420col_decimal_20_0_index decimal(20,0),
421col_decimal_20_0 decimal(20,0),
422col_char_20_key char(20),
423col_varchar_20_index varchar(20),
424col_timestamp_6_key timestamp(6) NULL DEFAULT NULL,
425/*Indices*/
426index idx14(pk, col_timestamp_6_index ),
427key idx1(pk, col_decimal_20_0_key ),
428primary key (pk) ,
429index idx8(pk, col_char_20_index ),
430key idx4(pk, col_bigint_key ),
431key idx10(pk, col_varchar_20_key ),
432index idx5(pk, col_bigint_index ),
433index idx2(pk, col_decimal_20_0_index ),
434key idx7(pk, col_char_20_key ),
435index idx11(pk, col_varchar_20_index ),
436key idx13(pk, col_timestamp_6_key )) PARTITION BY hash (pk) partitions 1;
437
438CREATE TABLE S (
439col_varchar_20_key varchar(20),
440col_varchar_10 varchar(10),
441col_varchar_20 varchar(20),
442col_date date,
443col_datetime datetime,
444col_int int,
445col_date_key date,
446col_int_key int,
447pk int,
448col_datetime_key datetime,
449col_varchar_10_key varchar(10),
450/*Indices*/
451key idx5(pk, col_varchar_20_key ),
452key idx7(pk, col_date_key ),
453key idx1(pk, col_int_key ),
454primary key (pk) ,
455key idx9(pk, col_datetime_key ),
456key idx3(pk, col_varchar_10_key ));
457
458CREATE TABLE FF (
459col_varchar_20 varchar(20),
460col_varchar_10_key varchar(10),
461col_int int,
462col_datetime datetime,
463col_date_key date,
464col_varchar_20_key varchar(20),
465col_varchar_10 varchar(10),
466col_datetime_key datetime,
467pk int,
468col_int_key int,
469col_date date,
470/*Indices*/
471key idx3(pk, col_varchar_10_key ),
472key idx7(pk, col_date_key ),
473key idx5(pk, col_varchar_20_key ),
474key idx9(pk, col_datetime_key ),
475primary key (pk) ,
476key idx1(pk, col_int_key ));
477
478explain
479SELECT 1
480FROM table0_hash_pk_parts_1_bigint
481WHERE
482(SELECT
483(SELECT MIN(
484(SELECT MAX(-100)
485FROM ff
486WHERE (col_timestamp_6 >= '2015-01-01')))
487FROM s
488WHERE pk IN
489(SELECT col_bigint
490FROM table0_hash_pk_parts_1_bigint))) < 1;
491
492SELECT 1
493FROM table0_hash_pk_parts_1_bigint
494WHERE
495(SELECT
496(SELECT MIN(
497(SELECT MAX(-100)
498FROM ff
499WHERE (col_timestamp_6 >= '2015-01-01')))
500FROM s
501WHERE pk IN
502(SELECT col_bigint
503FROM table0_hash_pk_parts_1_bigint))) < 1;
504
505explain
506SELECT 1
507FROM table0_hash_pk_parts_1_bigint
508WHERE
509(SELECT
510(SELECT MIN(
511(SELECT 1
512FROM ff
513WHERE (col_timestamp_6 >= '2015-01-01'))) + 1 AS tmp
514FROM s
515WHERE pk IN
516(SELECT col_bigint
517FROM table0_hash_pk_parts_1_bigint)));
518
519SELECT 1
520FROM table0_hash_pk_parts_1_bigint
521WHERE
522(SELECT
523(SELECT MIN(
524(SELECT 1
525FROM ff
526WHERE (col_timestamp_6 >= '2015-01-01'))) + 1 AS tmp
527FROM s
528WHERE pk IN
529(SELECT col_bigint
530FROM table0_hash_pk_parts_1_bigint)));
531
532drop table s;
533drop table table0_hash_pk_parts_1_bigint;
534drop table ff;
535