~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/range.result

  • Committer: Monty Taylor
  • Date: 2009-08-12 06:25:19 UTC
  • mto: (1114.1.1 innodb-plugin-merge)
  • mto: This revision was merged to the branch mainline in revision 1183.
  • Revision ID: mordred@inaugust.com-20090812062519-cij02mrrunvnxblt
Tags: innodb-plugin-1.0.4
InnoDB Plugin 1.0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
drop table if exists t1, t2, t3;
2
2
CREATE TABLE t1 (
3
 
event_date date NULL,
 
3
event_date date DEFAULT '0000-00-00' NOT NULL,
4
4
type int DEFAULT '0' NOT NULL,
5
5
event_id int DEFAULT '0' NOT NULL,
6
6
PRIMARY KEY (event_date,type,event_id)
49
49
YEAR int DEFAULT '0' NOT NULL,
50
50
ISSUE int DEFAULT '0' NOT NULL,
51
51
CLOSED int DEFAULT '0' NOT NULL,
52
 
ISS_DATE date,
 
52
ISS_DATE date DEFAULT '0000-00-00' NOT NULL,
53
53
PRIMARY KEY (PAPER_ID,YEAR,ISSUE)
54
54
);
55
55
INSERT INTO t1 VALUES (3,1999,34,0,'1999-07-12'), (1,1999,111,0,'1999-03-23'),
79
79
check table t1;
80
80
Table   Op      Msg_type        Msg_text
81
81
test.t1 check   status  OK
 
82
repair table t1;
 
83
Table   Op      Msg_type        Msg_text
 
84
test.t1 repair  note    The storage engine for the table doesn't support repair
82
85
drop table t1;
83
86
CREATE TABLE t1 (
84
87
id int NOT NULL auto_increment,
145
148
aString
146
149
believe in myself
147
150
drop table t1;
148
 
CREATE TEMPORARY TABLE t1 (
 
151
CREATE TABLE t1 (
149
152
t1ID int NOT NULL auto_increment,
150
153
art varbinary(1) NOT NULL default '',
151
154
KNR char(5) NOT NULL default '',
217
220
update t1 set y=x;
218
221
explain select * from t1, t1 t2 where t1.y = 8 and t2.x between 7 and t1.y+0;
219
222
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
221
 
1       SIMPLE  t2      range   x       x       5       NULL    2       Using where; Using join buffer
 
223
1       SIMPLE  t1      ref     y       y       5       const   1       
 
224
1       SIMPLE  t2      range   x       x       5       NULL    2       Using where; Using MRR; Using join buffer
222
225
explain select * from t1, t1 t2 where t1.y = 8 and t2.x >= 7 and t2.x <= t1.y+0;
223
226
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
225
 
1       SIMPLE  t2      range   x       x       5       NULL    2       Using where; Using join buffer
 
227
1       SIMPLE  t1      ref     y       y       5       const   1       
 
228
1       SIMPLE  t2      range   x       x       5       NULL    2       Using where; Using MRR; Using join buffer
226
229
explain select * from t1, t1 t2 where t1.y = 2 and t2.x between t1.y-1 and t1.y+1;
227
230
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
229
 
1       SIMPLE  t2      range   x       x       5       NULL    3       Using where; Using join buffer
 
231
1       SIMPLE  t1      ref     y       y       5       const   1       
 
232
1       SIMPLE  t2      range   x       x       5       NULL    3       Using where; Using MRR; Using join buffer
230
233
explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= t1.y-1 and t2.x <= t1.y+1;
231
234
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
233
 
1       SIMPLE  t2      range   x       x       5       NULL    3       Using where; Using join buffer
 
235
1       SIMPLE  t1      ref     y       y       5       const   1       
 
236
1       SIMPLE  t2      range   x       x       5       NULL    3       Using where; Using MRR; Using join buffer
234
237
explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 0 and t1.y;
235
238
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
237
 
1       SIMPLE  t2      range   x       x       5       NULL    2       Using where; Using join buffer
 
239
1       SIMPLE  t1      ref     y       y       5       const   1       
 
240
1       SIMPLE  t2      range   x       x       5       NULL    2       Using where; Using MRR; Using join buffer
238
241
explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 0 and t2.x <= t1.y;
239
242
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
241
 
1       SIMPLE  t2      range   x       x       5       NULL    2       Using where; Using join buffer
 
243
1       SIMPLE  t1      ref     y       y       5       const   1       
 
244
1       SIMPLE  t2      range   x       x       5       NULL    2       Using where; Using MRR; Using join buffer
242
245
explain select count(*) from t1 where x in (1);
243
246
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
 
247
1       SIMPLE  t1      ref     x       x       5       const   1       Using index
245
248
explain select count(*) from t1 where x in (1,2);
246
249
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
247
250
1       SIMPLE  t1      index   x       x       5       NULL    9       Using where; Using index
253
256
explain select * from t1, t2 where (t1.key1 <t2.keya + 1) and t2.keya=3;
254
257
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
255
258
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
 
259
1       SIMPLE  t1      range   i1      i1      4       NULL    3       Using where; Using index; Using join buffer
257
260
explain select * from t1 force index(i1), t2 force index(j1) where 
258
261
(t1.key1 <t2.keya + 1) and t2.keya=3;
259
262
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
260
263
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
 
264
1       SIMPLE  t1      range   i1      i1      4       NULL    3       Using where; Using index; Using join buffer
262
265
DROP TABLE t1,t2;
263
 
CREATE TEMPORARY TABLE t1 (
 
266
CREATE TABLE t1 (
264
267
a int default NULL,
265
268
b int default NULL,
266
269
KEY a (a),
273
276
(33,5),(33,5),(33,5),(33,5),(34,5),(35,5);
274
277
EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=5;
275
278
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
276
 
1       SIMPLE  t1      range   a,b     a       5       NULL    2       Using where
 
279
1       SIMPLE  t1      range   a,b     a       5       NULL    2       Using where; Using MRR
277
280
SELECT * FROM t1 WHERE a IN(1,2) AND b=5;
278
281
a       b
279
282
DROP TABLE t1;
301
304
15      1
302
305
47      1
303
306
DROP TABLE t1;
304
 
CREATE TEMPORARY TABLE t1 (
 
307
CREATE TABLE t1 (
305
308
id int NOT NULL AUTO_INCREMENT ,
306
309
line int NOT NULL default '0',
307
310
columnid int NOT NULL default '0',
351
354
name char(1) not null,
352
355
uid int not null,
353
356
primary key (id),
354
 
index uid_index (uid));
 
357
index uid_index (uid)) ENGINE=Myisam;
355
358
create table t2 (
356
359
id int not null auto_increment,
357
360
name char(1) not null,
358
361
uid int not null,
359
362
primary key (id),
360
 
index uid_index (uid));
 
363
index uid_index (uid)) engine=myisam;
361
364
insert into t1(id, uid, name) values(1, 0, ' ');
362
365
insert into t1(uid, name) values(0, ' ');
363
366
insert into t2(uid, name) select uid, name from t1;
415
418
analyze table t1,t2;
416
419
Table   Op      Msg_type        Msg_text
417
420
test.t1 analyze status  OK
418
 
test.t2 analyze status  OK
 
421
test.t2 analyze status  Table is already up to date
419
422
explain select * from t1, t2  where t1.uid=t2.uid AND t1.uid > 0;
420
423
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       #       #       
 
424
1       SIMPLE  t1      range   uid_index       uid_index       4       NULL    112     Using where; Using MRR
 
425
1       SIMPLE  t2      ref     uid_index       uid_index       4       test.t1.uid     38      
423
426
explain select * from t1, t2  where t1.uid=t2.uid AND t2.uid > 0;
424
427
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       #       #       
 
428
1       SIMPLE  t1      range   uid_index       uid_index       4       NULL    112     Using where; Using MRR
 
429
1       SIMPLE  t2      ref     uid_index       uid_index       4       test.t1.uid     38      
427
430
explain select * from t1, t2  where t1.uid=t2.uid AND t1.uid != 0;
428
431
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       #       #       
 
432
1       SIMPLE  t1      range   uid_index       uid_index       4       NULL    113     Using where; Using MRR
 
433
1       SIMPLE  t2      ref     uid_index       uid_index       4       test.t1.uid     38      
431
434
explain select * from t1, t2  where t1.uid=t2.uid AND t2.uid != 0;
432
435
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       #       #       
 
436
1       SIMPLE  t1      range   uid_index       uid_index       4       NULL    113     Using where; Using MRR
 
437
1       SIMPLE  t2      ref     uid_index       uid_index       4       test.t1.uid     38      
435
438
select * from t1, t2  where t1.uid=t2.uid AND t1.uid > 0;
436
439
id      name    uid     id      name    uid
437
440
1001    A       1       1001    A       1
489
492
1025    Y       25      1025    Y       25
490
493
1026    Z       26      1026    Z       26
491
494
drop table t1,t2;
492
 
create table t1 (x bigint unsigned not null);
 
495
create table t1 (x bigint not null);
493
496
insert into t1(x) values (0x0ffffffffffffff0);
494
497
insert into t1(x) values (0x0ffffffffffffff1);
495
498
select * from t1;
507
510
0
508
511
select count(*) from t1 where x < -16;
509
512
count(*)
510
 
1
 
513
0
511
514
select count(*) from t1 where x = -16;
512
515
count(*)
513
 
1
 
516
0
514
517
select count(*) from t1 where x > -16;
515
518
count(*)
516
 
0
 
519
2
517
520
select count(*) from t1 where x = 18446744073709551601;
518
521
count(*)
519
522
0
544
547
1
545
548
select count(*) from t2 where x = 18446744073709551601;
546
549
count(*)
547
 
0
 
550
1
548
551
drop table t1,t2;
549
552
create table t1 (x bigint not null primary key) engine=innodb;
550
553
insert into t1(x) values (0x0ffffffffffffff0);
575
578
count(*)
576
579
0
577
580
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
 
581
create table t1 (a bigint);
584
582
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
583
insert into t1 select 18446744073709551615;
594
584
insert into t1 select 18446744073709551614;
595
585
explain select * from t1 where a <> -1;
597
587
1       SIMPLE  t1      index   t1i     t1i     9       NULL    2       Using where; Using index
598
588
select * from t1 where a <> -1;
599
589
a
600
 
-1
 
590
-2
601
591
explain select * from t1 where a > -1 or a < -1;
602
592
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
603
593
1       SIMPLE  t1      index   t1i     t1i     9       NULL    2       Using where; Using index
624
614
1       SIMPLE  t1      ref     a       a       43      const   2       Using where
625
615
explain select * from t1 where a=binary 'aaa';
626
616
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
627
 
1       SIMPLE  t1      range   a       a       43      NULL    2       Using where
 
617
1       SIMPLE  t1      range   a       a       43      NULL    2       Using where; Using MRR
628
618
explain select * from t1 where a='aaa' collate utf8_bin;
629
619
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
630
 
1       SIMPLE  t1      range   a       a       43      NULL    2       Using where
 
620
1       SIMPLE  t1      range   a       a       43      NULL    2       Using where; Using MRR
631
621
drop table t1;
632
622
CREATE TABLE t1 (
633
623
`CLIENT` char(3) collate utf8_bin NOT NULL default '000',
657
647
filler char(82),
658
648
PRIMARY KEY (pk1,pk2,pk3,pk4)
659
649
);
660
 
insert into t2 select 1, A.a+10*B.a, 432, 44, 'fillerZ' from t1 A CROSS JOIN t1 B;
 
650
insert into t2 select 1, A.a+10*B.a, 432, 44, 'fillerZ' from t1 A, t1 B;
661
651
INSERT INTO t2 VALUES (2621, 2635, 0, 0,'filler'), (2621, 2635, 1, 0,'filler'),
662
652
(2621, 2635, 10, 0,'filler'), (2621, 2635, 11, 0,'filler'),
663
653
(2621, 2635, 14, 0,'filler'), (2621, 2635, 1000015, 0,'filler');
672
662
insert into t1 values ('x'), ('xx');
673
663
explain select a from t1 where a > 'x';
674
664
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
 
665
1       SIMPLE  t1      range   a       a       7       NULL    1       Using where
676
666
select a from t1 where a > 'x';
677
667
a
678
668
xx
688
678
KEY OXLEFT (OXLEFT),
689
679
KEY OXRIGHT (OXRIGHT),
690
680
KEY OXROOTID (OXROOTID)
691
 
);
 
681
) ENGINE=MyISAM;
692
682
INSERT INTO t1 VALUES
693
683
('d8c4177d09f8b11f5.52725521','oxrootid',1,40,'d8c4177d09f8b11f5.52725521'),
694
684
('d8c4177d151affab2.81582770','d8c4177d09f8b11f5.52725521',2,3,
707
697
v.oxrootid ='d8c4177d09f8b11f5.52725521' AND
708
698
s.oxleft > v.oxleft AND s.oxleft < v.oxright;
709
699
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
 
700
1       SIMPLE  v       ref     OXLEFT,OXRIGHT,OXROOTID OXROOTID        130     const   5       Using where
 
701
1       SIMPLE  s       ALL     OXLEFT  NULL    NULL    NULL    6       Range checked for each record (index map: 0x4)
712
702
SELECT s.oxid FROM t1 v, t1 s 
713
703
WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND
714
704
v.oxrootid ='d8c4177d09f8b11f5.52725521' AND
881
871
(55,'C'), (56,'C'), (57,'C'), (58,'C'), (59,'C'), (60,'C');
882
872
EXPLAIN SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B';
883
873
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
 
874
1       SIMPLE  t1      range   status  status  83      NULL    28      Using where; Using index
885
875
EXPLAIN SELECT * FROM t1 WHERE status NOT IN ('A','B');
886
876
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
 
877
1       SIMPLE  t1      range   status  status  83      NULL    28      Using where; Using index
888
878
SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B';
889
879
id      status
890
880
53      C
907
897
60      C
908
898
EXPLAIN SELECT status FROM t1 WHERE status <> 'A' AND status <> 'B';
909
899
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
 
900
1       SIMPLE  t1      range   status  status  83      NULL    28      Using where; Using index
911
901
EXPLAIN SELECT status FROM t1 WHERE status NOT IN ('A','B');
912
902
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
 
903
1       SIMPLE  t1      range   status  status  83      NULL    28      Using where; Using index
914
904
EXPLAIN SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B';
915
905
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
 
906
1       SIMPLE  t1      range   status  status  83      NULL    18      Using where; Using index
917
907
EXPLAIN SELECT * FROM t1 WHERE status < 'A' OR status > 'B';
918
908
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
 
909
1       SIMPLE  t1      range   status  status  83      NULL    18      Using where; Using index
920
910
SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B';
921
911
id      status
922
912
53      C
969
959
insert into t1 values ('a ','');
970
960
insert into t1 values ('a  ', '');
971
961
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;
 
962
  from t3 A, t3 B, t3 C;
973
963
create table t2 (a varchar(10), filler char(200), key(a));
974
964
insert into t2 select * from t1;
975
965
explain select * from t1 where a between 'a' and 'a ';
976
966
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
977
 
1       SIMPLE  #       ref     a       a       43      #       #       Using where
 
967
1       SIMPLE  t1      ref     a       a       43      const   #       Using where
978
968
explain select * from t1 where a = 'a' or a='a ';
979
969
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
980
 
1       SIMPLE  #       ref     a       a       43      #       #       Using where
 
970
1       SIMPLE  t1      ref     a       a       43      const   #       Using where
981
971
explain select * from t2 where a between 'a' and 'a ';
982
972
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
983
 
1       SIMPLE  #       ref     a       a       43      #       #       Using where
 
973
1       SIMPLE  t2      ref     a       a       43      const   #       Using where
984
974
explain select * from t2 where a = 'a' or a='a ';
985
975
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
986
 
1       SIMPLE  #       ref     a       a       43      #       #       Using where
 
976
1       SIMPLE  t2      ref     a       a       43      const   #       Using where
987
977
update t1 set a='b' where a<>'a';
988
978
explain select * from t1 where a not between 'b' and 'b';
989
979
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
990
 
1       SIMPLE  #       #       #       #       #       #       #       Using where
 
980
1       SIMPLE  t1      ALL     a       NULL    NULL    NULL    #       Using where
991
981
select a, hex(filler) from t1 where a not between 'b' and 'b';
992
982
a       hex(filler)
993
983
a       
1011
1001
0       3       4
1012
1002
EXPLAIN  SELECT * FROM t1 WHERE b<=3 AND 3<=c;
1013
1003
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1014
 
1       SIMPLE  t1      range   idx1,idx2       idx2    4       NULL    2       Using where
 
1004
1       SIMPLE  t1      range   idx1,idx2       idx2    4       NULL    2       Using where; Using MRR
1015
1005
EXPLAIN  SELECT * FROM t1 WHERE 3 BETWEEN b AND c;
1016
1006
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1017
 
1       SIMPLE  t1      range   idx1,idx2       idx2    4       NULL    2       Using where
 
1007
1       SIMPLE  t1      range   idx1,idx2       idx2    4       NULL    2       Using where; Using MRR
1018
1008
SELECT * FROM t1 WHERE 0 < b OR 0 > c;
1019
1009
id      b       c
1020
1010
0       3       4
1030
1020
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1031
1021
1       SIMPLE  t1      ALL     idx1,idx2       NULL    NULL    NULL    10      Using where
1032
1022
DROP TABLE t1;
1033
 
CREATE TEMPORARY TABLE t1 (                                      
 
1023
CREATE TABLE t1 (                                      
1034
1024
item char(20) NOT NULL default '',                          
1035
 
started datetime, 
 
1025
started datetime NOT NULL default '0000-00-00 00:00:00', 
1036
1026
price decimal(16,3) NOT NULL default '0.000',                 
1037
1027
PRIMARY KEY (item,started)                     
1038
1028
) ENGINE=MyISAM;
1041
1031
('A1','2005-11-15 00:00:00',2000),
1042
1032
('A1','2005-12-12 08:00:00',3000),
1043
1033
('A2','2005-12-01 08:00:00',1000);
1044
 
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 23:59:59';
1045
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1046
 
1       SIMPLE  #       range   PRIMARY PRIMARY 90      #       #       Using where
1047
 
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 23:59:59';
1048
 
item    started price
1049
 
A1      2005-11-01 08:00:00     1000.000
1050
 
A1      2005-11-15 00:00:00     2000.000
 
1034
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
 
1035
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1036
1       SIMPLE  t1      ref     PRIMARY PRIMARY 82      const   2       Using where
 
1037
Warnings:
 
1038
Warning 1292    Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
 
1039
Warning 1292    Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
 
1040
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
 
1041
item    started price
 
1042
A1      2005-11-01 08:00:00     1000.000
 
1043
A1      2005-11-15 00:00:00     2000.000
 
1044
Warnings:
 
1045
Warning 1292    Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
 
1046
Warning 1292    Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
 
1047
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
 
1048
item    started price
 
1049
A1      2005-11-01 08:00:00     1000.000
 
1050
A1      2005-11-15 00:00:00     2000.000
 
1051
DROP INDEX `PRIMARY` ON t1;
 
1052
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
 
1053
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1054
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    4       Using where
 
1055
Warnings:
 
1056
Warning 1292    Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
 
1057
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
 
1058
item    started price
 
1059
A1      2005-11-01 08:00:00     1000.000
 
1060
A1      2005-11-15 00:00:00     2000.000
 
1061
Warnings:
 
1062
Warning 1292    Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
1051
1063
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
1052
1064
item    started price
1053
1065
A1      2005-11-01 08:00:00     1000.000
1125
1137
DROP TABLE t1;
1126
1138
create table t1 (a int);
1127
1139
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
1128
 
create table t2 (a int, b int, filler char(100));
 
1140
create table t2 (a int, b int, filler char(100)) ENGINE=myisam;
1129
1141
insert into t2 select A.a + 10 * (B.a + 10 * C.a), 10, 'filler' from t1 A,
1130
1142
t1 B, t1 C where A.a < 5;
1131
1143
insert into t2 select 1000, b, 'filler' from t2;
1133
1145
select 'In following EXPLAIN the access method should be ref, #rows~=500 (and not 2)' Z;
1134
1146
Z
1135
1147
In following EXPLAIN the access method should be ref, #rows~=500 (and not 2)
1136
 
create temporary table t2e like t2;
1137
 
alter table t2e engine=myisam;
1138
 
insert into t2e select * from t2;
1139
 
analyze table t2e;
1140
 
Table   Op      Msg_type        Msg_text
1141
 
test.t2e        analyze note    The storage engine for the table doesn't support analyze
1142
 
explain select * from t2e where a=1000 and b<11;
 
1148
explain select * from t2 where a=1000 and b<11;
1143
1149
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
 
1150
1       SIMPLE  t2      ref     a       a       5       const   502     Using where
1145
1151
drop table t1, t2;
1146
1152
End of 5.1 tests
1147
1153
CREATE TABLE t1 (c1 DECIMAL(10,0),INDEX(c1));