~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/func_in.result

  • Committer: Daniel Nichter
  • Date: 2011-10-23 16:01:37 UTC
  • mto: This revision was merged to the branch mainline in revision 2448.
  • Revision ID: daniel@percona.com-20111023160137-7ac3blgz8z4tf8za
Add Administration Getting Started and Logging.  Capitalize SQL clause keywords.

Show diffs side-by-side

added added

removed removed

Lines of Context:
216
216
44
217
217
46
218
218
DROP TABLE t1;
219
 
create table t1 (a int) ENGINE=MYISAM;
 
219
create table t1 (a int);
220
220
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
221
 
create table t2 (a int, filler char(200), key(a)) ENGINE=MYISAM;
222
 
insert into t2 select C.a*2,   'no'  from t1 A, t1 B, t1 C;
 
221
create temporary table t2 (a int, filler char(200), key(a)) engine=myisam;
 
222
insert into t2 select C.a*2,   'no'  from t1 A, t1 B, t1 C where A.a < 10;
223
223
insert into t2 select C.a*2+1, 'yes' from t1 C;
224
224
explain 
225
225
select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18);
226
226
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
227
 
1       SIMPLE  t2      range   a       a       5       NULL    12      Using where; Using MRR
 
227
1       SIMPLE  t2      range   a       a       5       NULL    12      Using where
228
228
select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18);
229
229
a       filler
230
230
1       yes
239
239
19      yes
240
240
explain select * from t2 force index(a) where a NOT IN (2,2,2,2,2,2);
241
241
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
242
 
1       SIMPLE  t2      range   a       a       5       NULL    912     Using where; Using MRR
 
242
1       SIMPLE  t2      range   a       a       5       NULL    912     Using where
243
243
explain select * from t2 force index(a) where a <> 2;
244
244
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
245
 
1       SIMPLE  t2      range   a       a       5       NULL    912     Using where; Using MRR
 
245
1       SIMPLE  t2      range   a       a       5       NULL    912     Using where
246
246
drop table t2;
247
247
create table t2 (a datetime, filler char(200), key(a));
248
248
insert into t2 select '2006-04-25 10:00:00' + interval C.a minute,
254
254
'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', 
255
255
'2006-04-25 10:06:00', '2006-04-25 10:08:00');
256
256
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
257
 
1       SIMPLE  t2      range   a       a       9       NULL    20      Using where; Using MRR
 
257
1       SIMPLE  t2      range   a       a       9       NULL    11      Using where
258
258
select * from t2 where a NOT IN (
259
259
'2006-04-25 10:00:00','2006-04-25 10:02:00','2006-04-25 10:04:00', 
260
260
'2006-04-25 10:06:00', '2006-04-25 10:08:00');
271
271
2006-04-25 10:19:00     yes
272
272
drop table t2;
273
273
create table t2 (a varchar(10), filler char(200), key(a));
274
 
insert into t2 select 'foo', 'no' from t1 A, t1 B;
275
 
insert into t2 select 'barbar', 'no' from t1 A, t1 B;
276
 
insert into t2 select 'bazbazbaz', 'no' from t1 A, t1 B;
 
274
insert into t2 select 'foo', 'no' from t1 A, t1 B where A.a < 10;
 
275
insert into t2 select 'barbar', 'no' from t1 A, t1 B where A.a < 10;
 
276
insert into t2 select 'bazbazbaz', 'no' from t1 A, t1 B where A.a < 10;
277
277
insert into t2 values ('fon', '1'), ('fop','1'), ('barbaq','1'), 
278
278
('barbas','1'), ('bazbazbay', '1'),('zz','1');
279
279
explain select * from t2 where a not in('foo','barbar', 'bazbazbaz');
280
280
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
281
 
1       SIMPLE  t2      range   a       a       43      NULL    5       Using where; Using MRR
 
281
1       SIMPLE  t2      range   a       a       43      NULL    5       Using where
282
282
drop table t2;
283
283
create table t2 (a decimal(10,5), filler char(200), key(a));
284
 
insert into t2 select 345.67890, 'no' from t1 A, t1 B;
285
 
insert into t2 select 43245.34, 'no' from t1 A, t1 B;
286
 
insert into t2 select 64224.56344, 'no' from t1 A, t1 B;
 
284
insert into t2 select 345.67890, 'no' from t1 A, t1 B where A.a < 10;
 
285
insert into t2 select 43245.34, 'no' from t1 A, t1 B where A.a < 10;
 
286
insert into t2 select 64224.56344, 'no' from t1 A, t1 B where A.a < 10;
287
287
insert into t2 values (0, '1'), (22334.123,'1'), (33333,'1'), 
288
288
(55555,'1'), (77777, '1');
289
289
explain
290
290
select * from t2 where a not in (345.67890, 43245.34, 64224.56344);
291
291
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
292
 
1       SIMPLE  t2      range   a       a       7       NULL    4       Using where; Using MRR
 
292
1       SIMPLE  t2      range   a       a       7       NULL    4       Using where
293
293
select * from t2 where a not in (345.67890, 43245.34, 64224.56344);
294
294
a       filler
295
295
0.00000 1
304
304
set @str="update t2 set b=1 where a not in (";
305
305
select count(*) from (
306
306
select @str:=concat(@str, @cnt:=@cnt+1, ",") 
307
 
from t1 A, t1 B, t1 C, t1 D) Z;
 
307
from t1 A, t1 B, t1 C, t1 D  where A.a < 10) Z;
308
308
count(*)
309
309
10000
310
310
set @str:=concat(@str, "10000)");
349
349
JOIN t2 ON t3.a=t2.a
350
350
JOIN t4 WHERE t4.a IN (t1.b, t2.b);
351
351
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
352
 
1       SIMPLE  t3      index   PRIMARY PRIMARY 4       NULL    4       Using index
353
352
1       SIMPLE  t1      eq_ref  PRIMARY PRIMARY 4       test.t3.a       1       
354
353
1       SIMPLE  t2      ALL     PRIMARY NULL    NULL    NULL    5       Using where; Using join buffer
 
354
1       SIMPLE  t3      index   PRIMARY PRIMARY 4       NULL    4       Using index
355
355
1       SIMPLE  t4      ALL     PRIMARY NULL    NULL    NULL    7       Range checked for each record (index map: 0x1)
356
356
SELECT STRAIGHT_JOIN * FROM t3 
357
357
JOIN t1 ON t3.a=t1.a 
367
367
FROM t3, t1, t2
368
368
WHERE t3.a=t1.a AND t3.a=t2.a;
369
369
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
370
 
1       PRIMARY t3      index   PRIMARY PRIMARY 4       NULL    4       Using index
371
370
1       PRIMARY t1      eq_ref  PRIMARY PRIMARY 4       test.t3.a       1       
372
371
1       PRIMARY t2      ALL     PRIMARY NULL    NULL    NULL    5       Using where; Using join buffer
 
372
1       PRIMARY t3      index   PRIMARY PRIMARY 4       NULL    4       Using index
373
373
2       DEPENDENT SUBQUERY      t4      index   NULL    PRIMARY 4       NULL    7       Using where; Using index
374
374
SELECT STRAIGHT_JOIN 
375
375
(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) 
385
385
a
386
386
SELECT * FROM t1 WHERE a IN (-1, -2);
387
387
a
388
 
CREATE TABLE t2 (a BIGINT);
 
388
CREATE TABLE t2 (a BIGINT UNSIGNED);
389
389
insert into t2 values(13491727406643098568),
390
390
(0x0fffffefffffffff),
391
391
(0x0ffffffeffffffff),
457
457
CREATE TABLE t1 (id int not null);
458
458
INSERT INTO t1 VALUES (1),(2);
459
459
SELECT id FROM t1 WHERE id IN(4564, (SELECT IF(1=0,1,1/0)) );
460
 
id
461
 
Warnings:
462
 
Error   1365    Division by 0
463
 
Error   1365    Division by 0
 
460
ERROR 22012: Division by 0
464
461
DROP TABLE t1;
465
462
End of 5.0 tests
466
 
create table t1(f1 char(1)) ENGINE=MYISAM;
 
463
create TEMPORARY table t1(f1 char(1)) ENGINE=MYISAM;
467
464
insert into t1 values ('a'),('b'),('1');
468
465
select f1 from t1 where f1 in ('a',1);
469
466
f1
495
492
explain select f1 from t1 where f1 in (2,1);
496
493
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
497
494
1       SIMPLE  t1      index   t1f1_idx        t1f1_idx        7       NULL    3       Using where; Using index
498
 
create table t2(f2 int, index t2f2(f2)) ENGINE=MYISAM;
 
495
create TEMPORARY table t2(f2 int, index t2f2(f2)) ENGINE=MYISAM;
499
496
insert into t2 values(0),(1),(2);
500
497
select f2 from t2 where f2 in ('a',2);
501
498
f2
531
528
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
532
529
1       SIMPLE  t2      index   t2f2    t2f2    5       NULL    3       Using where; Using index
533
530
drop table t1, t2;
534
 
create table t1 (a time, key(a));
 
531
create table t1 (a datetime, key(a));
535
532
insert into t1 values (),(),(),(),(),(),(),(),(),();
536
533
select a from t1 where a not in (a,a,a) group by a;
537
534
a