~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/func_in.test

  • Committer: Monty
  • Date: 2008-10-02 05:41:33 UTC
  • mfrom: (398.1.10 codestyle)
  • Revision ID: mordred@scylla.inaugust.com-20081002054133-tyxv5bmqpazfaqqi
Merged up to 408 of stdint-includes-fix.

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 primary key);
 
52
create table t1 (id int(10) 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),
59
 
b char(1),
60
 
c char(1)
 
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
61
61
);
62
62
insert into t1 values ('A','B','C');
63
63
insert into t1 values ('a','c','c');
 
64
--error 1267
64
65
select * from t1 where a in (b);
 
66
--error 1270
65
67
select * from t1 where a in (b,c);
 
68
--error 1271
66
69
select * from t1 where 'a' in (a,b,c);
67
70
select * from t1 where 'a' in (a);
68
71
select * from t1 where a in ('a');
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);
 
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);
73
76
drop table t1;
74
77
 
 
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;
75
83
# Bug#7834 Illegal mix of collations in IN operator
76
 
create table t1 (a char(10) not null);
 
84
create table t1 (a char(10) character set latin1 not null);
77
85
insert into t1 values ('a'),('b'),('c');
78
86
select a from t1 where a IN ('a','b','c') order by a;
79
87
drop table t1;
 
88
set names latin1;
80
89
 
81
90
select '1.0' in (1,2);
82
91
select 1 in ('1.0',2);
88
97
 
89
98
# Test case for bug #6365
90
99
 
91
 
create table t1 (a char(2));
 
100
create table t1 (a char(2) character set binary);
92
101
insert into t1 values ('aa'), ('bb');
93
102
select * from t1 where a in (NULL, 'aa');
94
103
drop table t1;
137
146
DROP TABLE t1;
138
147
 
139
148
# 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.
141
149
create table t1 (a int);
142
150
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 
143
 
create temporary table t2 (a int, filler char(200), key(a)) engine=myisam;
 
151
create table t2 (a int, filler char(200), key(a));
144
152
 
145
 
insert into t2 select C.a*2,   'no'  from t1 A, t1 B, t1 C where A.a < 10;
 
153
insert into t2 select C.a*2,   'no'  from t1 A, t1 B, t1 C;
146
154
insert into t2 select C.a*2+1, 'yes' from t1 C;
147
155
 
148
156
explain 
149
157
select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18);
150
158
select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18);
151
159
 
152
 
153
160
explain select * from t2 force index(a) where a NOT IN (2,2,2,2,2,2);
154
161
explain select * from t2 force index(a) where a <> 2;
155
162
 
180
187
#
181
188
create table t2 (a varchar(10), filler char(200), key(a));
182
189
 
183
 
insert into t2 select 'foo', 'no' from t1 A, t1 B where A.a < 10;
184
 
insert into t2 select 'barbar', 'no' from t1 A, t1 B where A.a < 10;
185
 
insert into t2 select 'bazbazbaz', 'no' from t1 A, t1 B where A.a < 10;
 
190
insert into t2 select 'foo', 'no' from t1 A, t1 B;
 
191
insert into t2 select 'barbar', 'no' from t1 A, t1 B;
 
192
insert into t2 select 'bazbazbaz', 'no' from t1 A, t1 B;
186
193
 
187
194
insert into t2 values ('fon', '1'), ('fop','1'), ('barbaq','1'), 
188
195
  ('barbas','1'), ('bazbazbay', '1'),('zz','1');
196
203
#
197
204
create table t2 (a decimal(10,5), filler char(200), key(a));
198
205
 
199
 
insert into t2 select 345.67890, 'no' from t1 A, t1 B where A.a < 10;
200
 
insert into t2 select 43245.34, 'no' from t1 A, t1 B where A.a < 10;
201
 
insert into t2 select 64224.56344, 'no' from t1 A, t1 B where A.a < 10;
 
206
insert into t2 select 345.67890, 'no' from t1 A, t1 B;
 
207
insert into t2 select 43245.34, 'no' from t1 A, t1 B;
 
208
insert into t2 select 64224.56344, 'no' from t1 A, t1 B;
202
209
 
203
210
insert into t2 values (0, '1'), (22334.123,'1'), (33333,'1'), 
204
211
  (55555,'1'), (77777, '1');
217
224
set @str="update t2 set b=1 where a not in (";
218
225
select count(*) from (
219
226
  select @str:=concat(@str, @cnt:=@cnt+1, ",") 
220
 
  from t1 A, t1 B, t1 C, t1 D  where A.a < 10) Z;
 
227
  from t1 A, t1 B, t1 C, t1 D) Z;
221
228
 
222
229
set @str:=concat(@str, "10000)");
223
230
select substr(@str, 1, 50);
230
237
#   "unsigned_keypart NOT IN(negative_number,...)" 
231
238
#   (introduced in fix BUG#15872) 
232
239
create table t1 (
233
 
  some_id int,
 
240
  some_id int(5) unsigned,
234
241
  key (some_id)
235
242
);
236
243
insert into t1 values (1),(2);
239
246
select some_id from t1 where some_id not in(-4,-1,3423534,2342342);
240
247
 
241
248
#
242
 
# BUG#24261: crash when WHERE contains NOT IN ('<negative value>') for column type
 
249
# BUG#24261: crash when WHERE contains NOT IN ('<negative value>') for unsigned column type
243
250
#
244
251
 
245
252
select some_id from t1 where some_id not in('-1', '0');
262
269
INSERT INTO t4 VALUES (1,1),(2,2),(1000,1000),(1001,1001),(1002,1002),
263
270
       (1003,1003),(1004,1004);
264
271
 
265
 
--sorted_result
266
272
EXPLAIN SELECT STRAIGHT_JOIN * FROM t3 
267
273
  JOIN t1 ON t3.a=t1.a 
268
274
  JOIN t2 ON t3.a=t2.a
273
279
  JOIN t2 ON t3.a=t2.a
274
280
  JOIN t4 WHERE t4.a IN (t1.b, t2.b);
275
281
 
276
 
--sorted_result
277
282
EXPLAIN SELECT STRAIGHT_JOIN 
278
283
   (SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) 
279
284
  FROM t3, t1, t2
287
292
DROP TABLE t1,t2,t3,t4;  
288
293
 
289
294
#
290
 
# BUG#19342: IN works incorrectly for BIGINT values
 
295
# BUG#19342: IN works incorrectly for BIGINT UNSIGNED values
291
296
#
292
 
CREATE TABLE t1(a BIGINT);
293
 
INSERT INTO t1 VALUES (0x0FFFFFFFFFFFFFFF);
 
297
CREATE TABLE t1(a BIGINT UNSIGNED);
 
298
INSERT INTO t1 VALUES (0xFFFFFFFFFFFFFFFF);
294
299
 
295
300
SELECT * FROM t1 WHERE a=-1 OR a=-2 ;
296
301
SELECT * FROM t1 WHERE a IN (-1, -2);
297
302
 
298
303
CREATE TABLE t2 (a BIGINT UNSIGNED);
299
304
insert into t2 values(13491727406643098568),
300
 
       (0x0fffffefffffffff),
301
 
       (0x0ffffffeffffffff),
302
 
       (0x0fffffffefffffff),
303
 
       (0x0ffffffffeffffff),
304
 
       (0x0fffffffffefffff),
305
 
       (0x0ffffffffffeffff),
306
 
       (0x0fffffffffffefff),
307
 
       (0x0ffffffffffffeff),
308
 
       (0x0fffffffffffffef),
309
 
       (0x0ffffffffffffffe),
310
 
       (0x0fffffffffffffff),
311
 
       (0x2000000000000000),
312
 
       (0x2000000000000001),
313
 
       (0x2000000000000002),
314
 
       (0x2000000000000300),
315
 
       (0x2000000000000400),
316
 
       (0x2000000000000401),
317
 
       (0x2000000000004001),
318
 
       (0x2000000000040001),
319
 
       (0x2000000000400001),
320
 
       (0x2000000004000001),
321
 
       (0x2000000040000001),
322
 
       (0x2000000400000001),
323
 
       (0x2000004000000001),
324
 
       (0x2000040000000001);
 
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);
325
330
 
326
 
SELECT HEX(a) FROM t2 WHERE a IN (0xBB3C3E98175D33C8, 42);
 
331
SELECT HEX(a) FROM t2 WHERE a IN 
 
332
  (CAST(0xBB3C3E98175D33C8 AS UNSIGNED),
 
333
   42);
327
334
 
328
335
SELECT HEX(a) FROM t2 WHERE a IN
329
 
  (0xBB3C3E98175D33C8,
330
 
   0x2fffffffffffffff,
331
 
   0x2000000000000000,
332
 
   0x2000000000000400,
333
 
   0x2000000000000401,
 
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),
334
341
   42);
335
342
 
336
343
SELECT HEX(a) FROM t2 WHERE a IN 
337
 
  (0x7fffffffffffffff, 
338
 
   0x2000000000000001);
339
 
SELECT HEX(a) FROM t2 WHERE a IN 
340
 
  (0x2ffffffffffffffe, 
341
 
   0x2fffffffffffffff);
342
 
SELECT HEX(a) FROM t2 WHERE a IN 
343
 
  (0x2ffffffffffffffe, 
344
 
   0x2fffffffffffffff,
 
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,
345
352
   'abc');
346
353
 
347
 
CREATE TABLE t3 (a BIGINT);
 
354
CREATE TABLE t3 (a BIGINT UNSIGNED);
348
355
INSERT INTO t3 VALUES (9223372036854775551);
349
356
 
350
357
SELECT HEX(a) FROM t3 WHERE a IN (9223372036854775807, 42);
362
369
CREATE TABLE t1 (id int not null);
363
370
INSERT INTO t1 VALUES (1),(2);
364
371
 
365
 
--error ER_DIVISION_BY_ZERO
366
372
SELECT id FROM t1 WHERE id IN(4564, (SELECT IF(1=0,1,1/0)) );
367
373
 
368
374
DROP TABLE t1;
373
379
#
374
380
# Bug#18360: Type aggregation for IN and CASE may lead to a wrong result 
375
381
#
376
 
create TEMPORARY table t1(f1 char(1)) ENGINE=MYISAM;
 
382
create table t1(f1 char(1));
377
383
insert into t1 values ('a'),('b'),('1');
378
384
select f1 from t1 where f1 in ('a',1);
379
385
select f1, case f1 when 'a' then '+' when 1 then '-' end from t1;
384
390
explain select f1 from t1 where f1 in ('a','b');
385
391
select f1 from t1 where f1 in (2,1);
386
392
explain select f1 from t1 where f1 in (2,1);
387
 
create TEMPORARY table t2(f2 int, index t2f2(f2)) ENGINE=MYISAM;
 
393
create table t2(f2 int, index t2f2(f2));
388
394
insert into t2 values(0),(1),(2);
389
395
select f2 from t2 where f2 in ('a',2);
390
396
explain select f2 from t2 where f2 in ('a',2);
398
404
# Bug #31075: crash in get_func_mm_tree
399
405
#
400
406
 
401
 
create table t1 (a datetime, key(a));
 
407
create table t1 (a time, key(a));
402
408
insert into t1 values (),(),(),(),(),(),(),(),(),();
403
409
select a from t1 where a not in (a,a,a) group by a;
404
410
drop table t1;