~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/range.result

Reverted 1103

Show diffs side-by-side

added added

removed removed

Lines of Context:
217
217
update t1 set y=x;
218
218
explain select * from t1, t1 t2 where t1.y = 8 and t2.x between 7 and t1.y+0;
219
219
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
220
 
1       SIMPLE  t1      ref     y       y       5       const   1       Using where
 
220
1       SIMPLE  t1      ref     y       y       5       const   1       
221
221
1       SIMPLE  t2      range   x       x       5       NULL    2       Using where; Using join buffer
222
222
explain select * from t1, t1 t2 where t1.y = 8 and t2.x >= 7 and t2.x <= t1.y+0;
223
223
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
224
 
1       SIMPLE  t1      ref     y       y       5       const   1       Using where
 
224
1       SIMPLE  t1      ref     y       y       5       const   1       
225
225
1       SIMPLE  t2      range   x       x       5       NULL    2       Using where; Using join buffer
226
226
explain select * from t1, t1 t2 where t1.y = 2 and t2.x between t1.y-1 and t1.y+1;
227
227
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
228
 
1       SIMPLE  t1      ref     y       y       5       const   1       Using where
 
228
1       SIMPLE  t1      ref     y       y       5       const   1       
229
229
1       SIMPLE  t2      range   x       x       5       NULL    3       Using where; Using join buffer
230
230
explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= t1.y-1 and t2.x <= t1.y+1;
231
231
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
232
 
1       SIMPLE  t1      ref     y       y       5       const   1       Using where
 
232
1       SIMPLE  t1      ref     y       y       5       const   1       
233
233
1       SIMPLE  t2      range   x       x       5       NULL    3       Using where; Using join buffer
234
234
explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 0 and t1.y;
235
235
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
236
 
1       SIMPLE  t1      ref     y       y       5       const   1       Using where
 
236
1       SIMPLE  t1      ref     y       y       5       const   1       
237
237
1       SIMPLE  t2      range   x       x       5       NULL    2       Using where; Using join buffer
238
238
explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 0 and t2.x <= t1.y;
239
239
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
240
 
1       SIMPLE  t1      ref     y       y       5       const   1       Using where
 
240
1       SIMPLE  t1      ref     y       y       5       const   1       
241
241
1       SIMPLE  t2      range   x       x       5       NULL    2       Using where; Using join buffer
242
242
explain select count(*) from t1 where x in (1);
243
243
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
244
 
1       SIMPLE  t1      ref     x       x       5       const   1       Using where; Using index
 
244
1       SIMPLE  t1      ref     x       x       5       const   1       Using index
245
245
explain select count(*) from t1 where x in (1,2);
246
246
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
247
247
1       SIMPLE  t1      index   x       x       5       NULL    9       Using where; Using index
253
253
explain select * from t1, t2 where (t1.key1 <t2.keya + 1) and t2.keya=3;
254
254
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
255
255
1       SIMPLE  t2      ref     j1      j1      4       const   1       Using index
256
 
1       SIMPLE  t1      index   i1      i1      4       NULL    7       Using where; Using index; Using join buffer
 
256
1       SIMPLE  t1      range   i1      i1      4       NULL    3       Using where; Using index; Using join buffer
257
257
explain select * from t1 force index(i1), t2 force index(j1) where 
258
258
(t1.key1 <t2.keya + 1) and t2.keya=3;
259
259
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
260
260
1       SIMPLE  t2      ref     j1      j1      4       const   1       Using index
261
 
1       SIMPLE  t1      index   i1      i1      4       NULL    7       Using where; Using index; Using join buffer
 
261
1       SIMPLE  t1      range   i1      i1      4       NULL    3       Using where; Using index; Using join buffer
262
262
DROP TABLE t1,t2;
263
263
CREATE TEMPORARY TABLE t1 (
264
264
a int default NULL,
418
418
test.t2 analyze status  OK
419
419
explain select * from t1, t2  where t1.uid=t2.uid AND t1.uid > 0;
420
420
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
421
 
1       SIMPLE  #       range   uid_index       uid_index       4       #       #       Using where
422
 
1       SIMPLE  #       ref     uid_index       uid_index       4       #       #       
 
421
1       SIMPLE  t1      range   uid_index       uid_index       4       NULL    #       Using where
 
422
1       SIMPLE  t2      ref     uid_index       uid_index       4       test.t1.uid     #       
423
423
explain select * from t1, t2  where t1.uid=t2.uid AND t2.uid > 0;
424
424
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
425
 
1       SIMPLE  #       range   uid_index       uid_index       4       #       #       Using where
426
 
1       SIMPLE  #       ref     uid_index       uid_index       4       #       #       
 
425
1       SIMPLE  t1      range   uid_index       uid_index       4       NULL    #       Using where
 
426
1       SIMPLE  t2      ref     uid_index       uid_index       4       test.t1.uid     #       
427
427
explain select * from t1, t2  where t1.uid=t2.uid AND t1.uid != 0;
428
428
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
429
 
1       SIMPLE  #       range   uid_index       uid_index       4       #       #       Using where
430
 
1       SIMPLE  #       ref     uid_index       uid_index       4       #       #       
 
429
1       SIMPLE  t1      range   uid_index       uid_index       4       NULL    #       Using where
 
430
1       SIMPLE  t2      ref     uid_index       uid_index       4       test.t1.uid     #       
431
431
explain select * from t1, t2  where t1.uid=t2.uid AND t2.uid != 0;
432
432
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
433
 
1       SIMPLE  #       range   uid_index       uid_index       4       #       #       Using where
434
 
1       SIMPLE  #       ref     uid_index       uid_index       4       #       #       
 
433
1       SIMPLE  t1      range   uid_index       uid_index       4       NULL    #       Using where
 
434
1       SIMPLE  t2      ref     uid_index       uid_index       4       test.t1.uid     #       
435
435
select * from t1, t2  where t1.uid=t2.uid AND t1.uid > 0;
436
436
id      name    uid     id      name    uid
437
437
1001    A       1       1001    A       1
489
489
1025    Y       25      1025    Y       25
490
490
1026    Z       26      1026    Z       26
491
491
drop table t1,t2;
492
 
create table t1 (x bigint unsigned not null);
 
492
create table t1 (x bigint not null);
493
493
insert into t1(x) values (0x0ffffffffffffff0);
494
494
insert into t1(x) values (0x0ffffffffffffff1);
495
495
select * from t1;
507
507
0
508
508
select count(*) from t1 where x < -16;
509
509
count(*)
510
 
1
 
510
0
511
511
select count(*) from t1 where x = -16;
512
512
count(*)
513
 
1
 
513
0
514
514
select count(*) from t1 where x > -16;
515
515
count(*)
516
 
0
 
516
2
517
517
select count(*) from t1 where x = 18446744073709551601;
518
518
count(*)
519
519
0
544
544
1
545
545
select count(*) from t2 where x = 18446744073709551601;
546
546
count(*)
547
 
0
 
547
1
548
548
drop table t1,t2;
549
549
create table t1 (x bigint not null primary key) engine=innodb;
550
550
insert into t1(x) values (0x0ffffffffffffff0);
575
575
count(*)
576
576
0
577
577
drop table t1;
578
 
create table t1 (a bigint unsigned);
579
 
show create table t1;
580
 
Table   Create Table
581
 
t1      CREATE TABLE `t1` (
582
 
  `a` BIGINT UNSIGNED DEFAULT NULL
583
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
578
create table t1 (a bigint);
584
579
create index t1i on t1(a);
585
 
show create table t1;
586
 
Table   Create Table
587
 
t1      CREATE TABLE `t1` (
588
 
  `a` BIGINT UNSIGNED DEFAULT NULL,
589
 
  KEY `t1i` (`a`)
590
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
591
 
insert into t1 values (9223372036854775807);
592
 
truncate t1;
593
580
insert into t1 select 18446744073709551615;
594
581
insert into t1 select 18446744073709551614;
595
582
explain select * from t1 where a <> -1;
597
584
1       SIMPLE  t1      index   t1i     t1i     9       NULL    2       Using where; Using index
598
585
select * from t1 where a <> -1;
599
586
a
600
 
-1
 
587
-2
601
588
explain select * from t1 where a > -1 or a < -1;
602
589
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
603
590
1       SIMPLE  t1      index   t1i     t1i     9       NULL    2       Using where; Using index
657
644
filler char(82),
658
645
PRIMARY KEY (pk1,pk2,pk3,pk4)
659
646
);
660
 
insert into t2 select 1, A.a+10*B.a, 432, 44, 'fillerZ' from t1 A CROSS JOIN t1 B;
 
647
insert into t2 select 1, A.a+10*B.a, 432, 44, 'fillerZ' from t1 A, t1 B;
661
648
INSERT INTO t2 VALUES (2621, 2635, 0, 0,'filler'), (2621, 2635, 1, 0,'filler'),
662
649
(2621, 2635, 10, 0,'filler'), (2621, 2635, 11, 0,'filler'),
663
650
(2621, 2635, 14, 0,'filler'), (2621, 2635, 1000015, 0,'filler');
672
659
insert into t1 values ('x'), ('xx');
673
660
explain select a from t1 where a > 'x';
674
661
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
675
 
1       SIMPLE  t1      range   a       a       7       NULL    2       Using where
 
662
1       SIMPLE  t1      range   a       a       7       NULL    1       Using where
676
663
select a from t1 where a > 'x';
677
664
a
678
665
xx
707
694
v.oxrootid ='d8c4177d09f8b11f5.52725521' AND
708
695
s.oxleft > v.oxleft AND s.oxleft < v.oxright;
709
696
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
710
 
1       SIMPLE  #       ALL     OXLEFT  NULL    NULL    #       #       Range checked for each record (index map: 0x4)
711
 
1       SIMPLE  #       ALL     OXLEFT,OXRIGHT,OXROOTID NULL    NULL    #       #       Using where
 
697
1       SIMPLE  v       ALL     OXLEFT,OXRIGHT,OXROOTID NULL    NULL    NULL    #       Using where
 
698
1       SIMPLE  s       ALL     OXLEFT  NULL    NULL    NULL    #       Range checked for each record (index map: 0x4)
712
699
SELECT s.oxid FROM t1 v, t1 s 
713
700
WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND
714
701
v.oxrootid ='d8c4177d09f8b11f5.52725521' AND
881
868
(55,'C'), (56,'C'), (57,'C'), (58,'C'), (59,'C'), (60,'C');
882
869
EXPLAIN SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B';
883
870
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
884
 
1       SIMPLE  t1      range   status  status  83      NULL    10      Using where; Using index
 
871
1       SIMPLE  t1      range   status  status  83      NULL    28      Using where; Using index
885
872
EXPLAIN SELECT * FROM t1 WHERE status NOT IN ('A','B');
886
873
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
887
 
1       SIMPLE  t1      range   status  status  83      NULL    10      Using where; Using index
 
874
1       SIMPLE  t1      range   status  status  83      NULL    28      Using where; Using index
888
875
SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B';
889
876
id      status
890
877
53      C
907
894
60      C
908
895
EXPLAIN SELECT status FROM t1 WHERE status <> 'A' AND status <> 'B';
909
896
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
910
 
1       SIMPLE  t1      range   status  status  83      NULL    10      Using where; Using index
 
897
1       SIMPLE  t1      range   status  status  83      NULL    28      Using where; Using index
911
898
EXPLAIN SELECT status FROM t1 WHERE status NOT IN ('A','B');
912
899
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
913
 
1       SIMPLE  t1      range   status  status  83      NULL    10      Using where; Using index
 
900
1       SIMPLE  t1      range   status  status  83      NULL    28      Using where; Using index
914
901
EXPLAIN SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B';
915
902
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
916
 
1       SIMPLE  t1      range   status  status  83      NULL    9       Using where; Using index
 
903
1       SIMPLE  t1      range   status  status  83      NULL    18      Using where; Using index
917
904
EXPLAIN SELECT * FROM t1 WHERE status < 'A' OR status > 'B';
918
905
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
919
 
1       SIMPLE  t1      range   status  status  83      NULL    9       Using where; Using index
 
906
1       SIMPLE  t1      range   status  status  83      NULL    18      Using where; Using index
920
907
SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B';
921
908
id      status
922
909
53      C
969
956
insert into t1 values ('a ','');
970
957
insert into t1 values ('a  ', '');
971
958
insert into t1 select concat('a', 1000 + A.a + 10 * (B.a + 10 * C.a)), ''
972
 
  from t3 A CROSS JOIN t3 B CROSS JOIN t3 C;
 
959
  from t3 A, t3 B, t3 C;
973
960
create table t2 (a varchar(10), filler char(200), key(a));
974
961
insert into t2 select * from t1;
975
962
explain select * from t1 where a between 'a' and 'a ';
976
963
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
977
 
1       SIMPLE  #       ref     a       a       43      #       #       Using where
 
964
1       SIMPLE  t1      ref     a       a       43      const   #       Using where
978
965
explain select * from t1 where a = 'a' or a='a ';
979
966
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
980
 
1       SIMPLE  #       ref     a       a       43      #       #       Using where
 
967
1       SIMPLE  t1      ref     a       a       43      const   #       Using where
981
968
explain select * from t2 where a between 'a' and 'a ';
982
969
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
983
 
1       SIMPLE  #       ref     a       a       43      #       #       Using where
 
970
1       SIMPLE  t2      ref     a       a       43      const   #       Using where
984
971
explain select * from t2 where a = 'a' or a='a ';
985
972
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
986
 
1       SIMPLE  #       ref     a       a       43      #       #       Using where
 
973
1       SIMPLE  t2      ref     a       a       43      const   #       Using where
987
974
update t1 set a='b' where a<>'a';
988
975
explain select * from t1 where a not between 'b' and 'b';
989
976
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
990
 
1       SIMPLE  #       #       #       #       #       #       #       Using where
 
977
1       SIMPLE  t1      ALL     a       NULL    NULL    NULL    #       Using where
991
978
select a, hex(filler) from t1 where a not between 'b' and 'b';
992
979
a       hex(filler)
993
980
a       
1043
1030
('A2','2005-12-01 08:00:00',1000);
1044
1031
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 23:59:59';
1045
1032
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1046
 
1       SIMPLE  #       range   PRIMARY PRIMARY 90      #       #       Using where
 
1033
1       SIMPLE  t1      range   PRIMARY PRIMARY 90      NULL    #       Using where
1047
1034
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 23:59:59';
1048
1035
item    started price
1049
1036
A1      2005-11-01 08:00:00     1000.000
1138
1125
insert into t2e select * from t2;
1139
1126
analyze table t2e;
1140
1127
Table   Op      Msg_type        Msg_text
1141
 
test.t2e        analyze note    The storage engine for the table doesn't support analyze
 
1128
test.t2e        analyze status  OK
1142
1129
explain select * from t2e where a=1000 and b<11;
1143
1130
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1144
 
1       SIMPLE  t2e     ref     a       a       5       const   11      Using where
 
1131
1       SIMPLE  t2e     ref     a       a       5       const   502     Using where
1145
1132
drop table t1, t2;
1146
1133
End of 5.1 tests
1147
1134
CREATE TABLE t1 (c1 DECIMAL(10,0),INDEX(c1));