~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/func_in.test

Merge of Jay

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
SELECT * FROM t1;
50
50
drop table t1;
51
51
 
52
 
create table t1 (id int(10) primary key);
 
52
create table t1 (id int primary key);
53
53
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
54
54
select * from t1 where id in (2,5,9);
55
55
drop table t1;
56
56
 
57
57
create table t1 (
58
 
a char(1) character set latin1 collate latin1_general_ci,
59
 
b char(1) character set latin1 collate latin1_swedish_ci,
60
 
c char(1) character set latin1 collate latin1_danish_ci
 
58
a char(1),
 
59
b char(1),
 
60
c char(1)
61
61
);
62
62
insert into t1 values ('A','B','C');
63
63
insert into t1 values ('a','c','c');
64
 
--error 1267
65
64
select * from t1 where a in (b);
66
 
--error 1270
67
65
select * from t1 where a in (b,c);
68
 
--error 1271
69
66
select * from t1 where 'a' in (a,b,c);
70
67
select * from t1 where 'a' in (a);
71
68
select * from t1 where a in ('a');
72
 
select * from t1 where 'a' collate latin1_general_ci in (a,b,c);
73
 
select * from t1 where 'a' collate latin1_bin in (a,b,c);
74
 
select * from t1 where 'a' in (a,b,c collate latin1_bin);
75
 
explain extended select * from t1 where 'a' in (a,b,c collate latin1_bin);
 
69
select * from t1 where 'a' collate utf8_general_ci in (a,b,c);
 
70
select * from t1 where 'a' collate utf8_bin in (a,b,c);
 
71
select * from t1 where 'a' in (a,b,c collate utf8_bin);
 
72
explain extended select * from t1 where 'a' in (a,b,c collate utf8_bin);
76
73
drop table t1;
77
74
 
78
 
set names utf8;
79
 
create table t1 (a char(10) character set utf8 not null);
80
 
insert into t1 values ('bbbb'),(_koi8r'����'),(_latin1'����');
81
 
select a from t1 where a in ('bbbb',_koi8r'����',_latin1'����') order by a;
82
 
drop table t1;
83
75
# Bug#7834 Illegal mix of collations in IN operator
84
 
create table t1 (a char(10) character set latin1 not null);
 
76
create table t1 (a char(10) not null);
85
77
insert into t1 values ('a'),('b'),('c');
86
78
select a from t1 where a IN ('a','b','c') order by a;
87
79
drop table t1;
88
 
set names latin1;
89
80
 
90
81
select '1.0' in (1,2);
91
82
select 1 in ('1.0',2);
97
88
 
98
89
# Test case for bug #6365
99
90
 
100
 
create table t1 (a char(2) character set binary);
 
91
create table t1 (a char(2));
101
92
insert into t1 values ('aa'), ('bb');
102
93
select * from t1 where a in (NULL, 'aa');
103
94
drop table t1;
146
137
DROP TABLE t1;
147
138
 
148
139
# BUG#15872: Excessive memory consumption of range analysis of NOT IN
 
140
# I have disabled the EXPLAIN because we must use Innodb with this test.
149
141
create table t1 (a int);
150
142
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 
151
 
create table t2 (a int, filler char(200), key(a));
 
143
create temporary table t2 (a int, filler char(200), key(a)) engine=myisam;
152
144
 
153
145
insert into t2 select C.a*2,   'no'  from t1 A, t1 B, t1 C;
154
146
insert into t2 select C.a*2+1, 'yes' from t1 C;
157
149
select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18);
158
150
select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18);
159
151
 
 
152
160
153
explain select * from t2 force index(a) where a NOT IN (2,2,2,2,2,2);
161
154
explain select * from t2 force index(a) where a <> 2;
162
155
 
237
230
#   "unsigned_keypart NOT IN(negative_number,...)" 
238
231
#   (introduced in fix BUG#15872) 
239
232
create table t1 (
240
 
  some_id smallint(5) unsigned,
 
233
  some_id int,
241
234
  key (some_id)
242
235
);
243
236
insert into t1 values (1),(2);
246
239
select some_id from t1 where some_id not in(-4,-1,3423534,2342342);
247
240
 
248
241
#
249
 
# BUG#24261: crash when WHERE contains NOT IN ('<negative value>') for unsigned column type
 
242
# BUG#24261: crash when WHERE contains NOT IN ('<negative value>') for column type
250
243
#
251
244
 
252
245
select some_id from t1 where some_id not in('-1', '0');
292
285
DROP TABLE t1,t2,t3,t4;  
293
286
 
294
287
#
295
 
# BUG#19342: IN works incorrectly for BIGINT UNSIGNED values
 
288
# BUG#19342: IN works incorrectly for BIGINT values
296
289
#
297
 
CREATE TABLE t1(a BIGINT UNSIGNED);
298
 
INSERT INTO t1 VALUES (0xFFFFFFFFFFFFFFFF);
 
290
CREATE TABLE t1(a BIGINT);
 
291
INSERT INTO t1 VALUES (0x0FFFFFFFFFFFFFFF);
299
292
 
300
293
SELECT * FROM t1 WHERE a=-1 OR a=-2 ;
301
294
SELECT * FROM t1 WHERE a IN (-1, -2);
302
295
 
303
 
CREATE TABLE t2 (a BIGINT UNSIGNED);
 
296
CREATE TABLE t2 (a BIGINT);
304
297
insert into t2 values(13491727406643098568),
305
 
       (0x7fffffefffffffff),
306
 
       (0x7ffffffeffffffff),
307
 
       (0x7fffffffefffffff),
308
 
       (0x7ffffffffeffffff),
309
 
       (0x7fffffffffefffff),
310
 
       (0x7ffffffffffeffff),
311
 
       (0x7fffffffffffefff),
312
 
       (0x7ffffffffffffeff),
313
 
       (0x7fffffffffffffef),
314
 
       (0x7ffffffffffffffe),
315
 
       (0x7fffffffffffffff),
316
 
       (0x8000000000000000),
317
 
       (0x8000000000000001),
318
 
       (0x8000000000000002),
319
 
       (0x8000000000000300),
320
 
       (0x8000000000000400),
321
 
       (0x8000000000000401),
322
 
       (0x8000000000004001),
323
 
       (0x8000000000040001),
324
 
       (0x8000000000400001),
325
 
       (0x8000000004000001),
326
 
       (0x8000000040000001),
327
 
       (0x8000000400000001),
328
 
       (0x8000004000000001),
329
 
       (0x8000040000000001);
 
298
       (0x0fffffefffffffff),
 
299
       (0x0ffffffeffffffff),
 
300
       (0x0fffffffefffffff),
 
301
       (0x0ffffffffeffffff),
 
302
       (0x0fffffffffefffff),
 
303
       (0x0ffffffffffeffff),
 
304
       (0x0fffffffffffefff),
 
305
       (0x0ffffffffffffeff),
 
306
       (0x0fffffffffffffef),
 
307
       (0x0ffffffffffffffe),
 
308
       (0x0fffffffffffffff),
 
309
       (0x2000000000000000),
 
310
       (0x2000000000000001),
 
311
       (0x2000000000000002),
 
312
       (0x2000000000000300),
 
313
       (0x2000000000000400),
 
314
       (0x2000000000000401),
 
315
       (0x2000000000004001),
 
316
       (0x2000000000040001),
 
317
       (0x2000000000400001),
 
318
       (0x2000000004000001),
 
319
       (0x2000000040000001),
 
320
       (0x2000000400000001),
 
321
       (0x2000004000000001),
 
322
       (0x2000040000000001);
330
323
 
331
 
SELECT HEX(a) FROM t2 WHERE a IN 
332
 
  (CAST(0xBB3C3E98175D33C8 AS UNSIGNED),
333
 
   42);
 
324
SELECT HEX(a) FROM t2 WHERE a IN (0xBB3C3E98175D33C8, 42);
334
325
 
335
326
SELECT HEX(a) FROM t2 WHERE a IN
336
 
  (CAST(0xBB3C3E98175D33C8 AS UNSIGNED),
337
 
   CAST(0x7fffffffffffffff AS UNSIGNED),
338
 
   CAST(0x8000000000000000 AS UNSIGNED),
339
 
   CAST(0x8000000000000400 AS UNSIGNED),
340
 
   CAST(0x8000000000000401 AS UNSIGNED),
 
327
  (0xBB3C3E98175D33C8,
 
328
   0x2fffffffffffffff,
 
329
   0x2000000000000000,
 
330
   0x2000000000000400,
 
331
   0x2000000000000401,
341
332
   42);
342
333
 
343
334
SELECT HEX(a) FROM t2 WHERE a IN 
344
 
  (CAST(0x7fffffffffffffff AS UNSIGNED), 
345
 
   CAST(0x8000000000000001 AS UNSIGNED));
346
 
SELECT HEX(a) FROM t2 WHERE a IN 
347
 
  (CAST(0x7ffffffffffffffe AS UNSIGNED), 
348
 
   CAST(0x7fffffffffffffff AS UNSIGNED));
349
 
SELECT HEX(a) FROM t2 WHERE a IN 
350
 
  (0x7ffffffffffffffe, 
351
 
   0x7fffffffffffffff,
 
335
  (0x7fffffffffffffff, 
 
336
   0x2000000000000001);
 
337
SELECT HEX(a) FROM t2 WHERE a IN 
 
338
  (0x2ffffffffffffffe, 
 
339
   0x2fffffffffffffff);
 
340
SELECT HEX(a) FROM t2 WHERE a IN 
 
341
  (0x2ffffffffffffffe, 
 
342
   0x2fffffffffffffff,
352
343
   'abc');
353
344
 
354
 
CREATE TABLE t3 (a BIGINT UNSIGNED);
 
345
CREATE TABLE t3 (a BIGINT);
355
346
INSERT INTO t3 VALUES (9223372036854775551);
356
347
 
357
348
SELECT HEX(a) FROM t3 WHERE a IN (9223372036854775807, 42);
379
370
#
380
371
# Bug#18360: Type aggregation for IN and CASE may lead to a wrong result 
381
372
#
382
 
create table t1(f1 char(1));
 
373
create TEMPORARY table t1(f1 char(1)) ENGINE=MYISAM;
383
374
insert into t1 values ('a'),('b'),('1');
384
375
select f1 from t1 where f1 in ('a',1);
385
376
select f1, case f1 when 'a' then '+' when 1 then '-' end from t1;
390
381
explain select f1 from t1 where f1 in ('a','b');
391
382
select f1 from t1 where f1 in (2,1);
392
383
explain select f1 from t1 where f1 in (2,1);
393
 
create table t2(f2 int, index t2f2(f2));
 
384
create TEMPORARY table t2(f2 int, index t2f2(f2)) ENGINE=MYISAM;
394
385
insert into t2 values(0),(1),(2);
395
386
select f2 from t2 where f2 in ('a',2);
396
387
explain select f2 from t2 where f2 in ('a',2);
404
395
# Bug #31075: crash in get_func_mm_tree
405
396
#
406
397
 
407
 
create table t1 (a time, key(a));
 
398
create table t1 (a datetime, key(a));
408
399
insert into t1 values (),(),(),(),(),(),(),(),(),();
409
400
select a from t1 where a not in (a,a,a) group by a;
410
401
drop table t1;