~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/range.result

pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
macros.
Add PANDORA_DRIZZLE_BUILD to run the extra checks that drizzle needs that 
plugins would also need to run so we can just use that macro in generated
external plugin builds.
Added support to register_plugins for external plugin building.
Renamed register_plugins.py to pandora-plugin.

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 DEFAULT '0000-00-00' NOT NULL,
4
 
type int(11) DEFAULT '0' NOT NULL,
5
 
event_id int(11) DEFAULT '0' NOT NULL,
 
3
event_date date NULL,
 
4
type int DEFAULT '0' NOT NULL,
 
5
event_id int DEFAULT '0' NOT NULL,
6
6
PRIMARY KEY (event_date,type,event_id)
7
7
);
8
8
INSERT INTO t1 VALUES ('1999-07-10',100100,24), ('1999-07-11',100100,25),
45
45
1999-07-15      100600  16
46
46
drop table t1;
47
47
CREATE TABLE t1 (
48
 
PAPER_ID smallint(6) DEFAULT '0' NOT NULL,
49
 
YEAR smallint(6) DEFAULT '0' NOT NULL,
50
 
ISSUE smallint(6) DEFAULT '0' NOT NULL,
51
 
CLOSED tinyint(4) DEFAULT '0' NOT NULL,
52
 
ISS_DATE date DEFAULT '0000-00-00' NOT NULL,
 
48
PAPER_ID int DEFAULT '0' NOT NULL,
 
49
YEAR int DEFAULT '0' NOT NULL,
 
50
ISSUE int DEFAULT '0' NOT NULL,
 
51
CLOSED int DEFAULT '0' NOT NULL,
 
52
ISS_DATE date,
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  status  OK
85
82
drop table t1;
86
83
CREATE TABLE t1 (
87
 
id int(11) NOT NULL auto_increment,
88
 
parent_id int(11) DEFAULT '0' NOT NULL,
89
 
level tinyint(4) DEFAULT '0' NOT NULL,
 
84
id int NOT NULL auto_increment,
 
85
parent_id int DEFAULT '0' NOT NULL,
 
86
level int DEFAULT '0' NOT NULL,
90
87
PRIMARY KEY (id),
91
88
KEY parent_id (parent_id),
92
89
KEY level (level)
99
96
(19,3,2), (5,1,1), (179,5,2);
100
97
SELECT * FROM t1 WHERE level = 1 AND parent_id = 1;
101
98
id      parent_id       level
 
99
2       1       1
102
100
3       1       1
103
101
4       1       1
104
 
2       1       1
 
102
5       1       1
105
103
6       1       1
106
104
7       1       1
107
 
5       1       1
108
105
SELECT * FROM t1 WHERE level = 1 AND parent_id = 1 order by id;
109
106
id      parent_id       level
110
107
2       1       1
148
145
aString
149
146
believe in myself
150
147
drop table t1;
151
 
CREATE TABLE t1 (
152
 
t1ID int(10) unsigned NOT NULL auto_increment,
153
 
art binary(1) NOT NULL default '',
 
148
CREATE TEMPORARY TABLE t1 (
 
149
t1ID int NOT NULL auto_increment,
 
150
art varbinary(1) NOT NULL default '',
154
151
KNR char(5) NOT NULL default '',
155
152
RECHNR char(6) NOT NULL default '',
156
153
POSNR char(2) NOT NULL default '',
221
218
explain select * from t1, t1 t2 where t1.y = 8 and t2.x between 7 and t1.y+0;
222
219
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
223
220
1       SIMPLE  t1      ref     y       y       5       const   1       
224
 
1       SIMPLE  t2      range   x       x       5       NULL    2       Using index condition; Using MRR; Using join buffer
 
221
1       SIMPLE  t2      range   x       x       5       NULL    2       Using where; Using join buffer
225
222
explain select * from t1, t1 t2 where t1.y = 8 and t2.x >= 7 and t2.x <= t1.y+0;
226
223
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
227
224
1       SIMPLE  t1      ref     y       y       5       const   1       
228
 
1       SIMPLE  t2      range   x       x       5       NULL    2       Using index condition; Using MRR; Using join buffer
 
225
1       SIMPLE  t2      range   x       x       5       NULL    2       Using where; Using join buffer
229
226
explain select * from t1, t1 t2 where t1.y = 2 and t2.x between t1.y-1 and t1.y+1;
230
227
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
231
228
1       SIMPLE  t1      ref     y       y       5       const   1       
232
 
1       SIMPLE  t2      range   x       x       5       NULL    3       Using index condition; Using MRR; Using join buffer
 
229
1       SIMPLE  t2      range   x       x       5       NULL    3       Using where; Using join buffer
233
230
explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= t1.y-1 and t2.x <= t1.y+1;
234
231
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
235
232
1       SIMPLE  t1      ref     y       y       5       const   1       
236
 
1       SIMPLE  t2      range   x       x       5       NULL    3       Using index condition; Using MRR; Using join buffer
 
233
1       SIMPLE  t2      range   x       x       5       NULL    3       Using where; Using join buffer
237
234
explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 0 and t1.y;
238
235
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
239
236
1       SIMPLE  t1      ref     y       y       5       const   1       
240
 
1       SIMPLE  t2      range   x       x       5       NULL    2       Using index condition; Using MRR; Using join buffer
 
237
1       SIMPLE  t2      range   x       x       5       NULL    2       Using where; Using join buffer
241
238
explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 0 and t2.x <= t1.y;
242
239
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
243
240
1       SIMPLE  t1      ref     y       y       5       const   1       
244
 
1       SIMPLE  t2      range   x       x       5       NULL    2       Using index condition; Using MRR; Using join buffer
 
241
1       SIMPLE  t2      range   x       x       5       NULL    2       Using where; Using join buffer
245
242
explain select count(*) from t1 where x in (1);
246
243
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
247
244
1       SIMPLE  t1      ref     x       x       5       const   1       Using index
249
246
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
250
247
1       SIMPLE  t1      index   x       x       5       NULL    9       Using where; Using index
251
248
drop table t1;
252
 
CREATE TABLE t1 (key1 int(11) NOT NULL default '0', KEY i1 (key1));
 
249
CREATE TABLE t1 (key1 int NOT NULL default '0', KEY i1 (key1));
253
250
INSERT INTO t1 VALUES (0),(0),(0),(0),(0),(1),(1);
254
 
CREATE TABLE t2 (keya int(11) NOT NULL default '0', KEY j1 (keya));
 
251
CREATE TABLE t2 (keya int NOT NULL default '0', KEY j1 (keya));
255
252
INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2);
256
253
explain select * from t1, t2 where (t1.key1 <t2.keya + 1) and t2.keya=3;
257
254
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
258
255
1       SIMPLE  t2      ref     j1      j1      4       const   1       Using index
259
 
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
260
257
explain select * from t1 force index(i1), t2 force index(j1) where 
261
258
(t1.key1 <t2.keya + 1) and t2.keya=3;
262
259
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
263
260
1       SIMPLE  t2      ref     j1      j1      4       const   1       Using index
264
 
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
265
262
DROP TABLE t1,t2;
266
 
CREATE TABLE t1 (
267
 
a int(11) default NULL,
268
 
b int(11) default NULL,
 
263
CREATE TEMPORARY TABLE t1 (
 
264
a int default NULL,
 
265
b int default NULL,
269
266
KEY a (a),
270
267
KEY b (b)
271
268
) ENGINE=MyISAM;
276
273
(33,5),(33,5),(33,5),(33,5),(34,5),(35,5);
277
274
EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=5;
278
275
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
279
 
1       SIMPLE  t1      range   a,b     a       5       NULL    2       Using index condition; Using where; Using MRR
 
276
1       SIMPLE  t1      range   a,b     a       5       NULL    2       Using where
280
277
SELECT * FROM t1 WHERE a IN(1,2) AND b=5;
281
278
a       b
282
279
DROP TABLE t1;
304
301
15      1
305
302
47      1
306
303
DROP TABLE t1;
307
 
CREATE TABLE t1 (
308
 
id int( 11 ) unsigned NOT NULL AUTO_INCREMENT ,
309
 
line int( 5 ) unsigned NOT NULL default '0',
310
 
columnid int( 3 ) unsigned NOT NULL default '0',
311
 
owner int( 3 ) unsigned NOT NULL default '0',
312
 
ordinal int( 3 ) unsigned NOT NULL default '0',
313
 
showid smallint( 6 ) unsigned NOT NULL default '1',
314
 
tableid int( 1 ) unsigned NOT NULL default '1',
315
 
content int( 5 ) unsigned NOT NULL default '188',
 
304
CREATE TEMPORARY TABLE t1 (
 
305
id int NOT NULL AUTO_INCREMENT ,
 
306
line int NOT NULL default '0',
 
307
columnid int NOT NULL default '0',
 
308
owner int NOT NULL default '0',
 
309
ordinal int NOT NULL default '0',
 
310
showid int NOT NULL default '1',
 
311
tableid int NOT NULL default '1',
 
312
content int NOT NULL default '188',
316
313
PRIMARY KEY ( owner, id ) ,
317
314
KEY menu( owner, showid, columnid ) ,
318
315
KEY `COLUMN` ( owner, columnid, line ) ,
325
322
13      13      1       188     1       5       0
326
323
15      15      1       188     1       1       0
327
324
drop table t1;
328
 
create  table t1 (id int(10) primary key);
 
325
create  table t1 (id int primary key);
329
326
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
330
327
select id from t1 where id in (2,5,9) ;
331
328
id
418
415
analyze table t1,t2;
419
416
Table   Op      Msg_type        Msg_text
420
417
test.t1 analyze status  OK
421
 
test.t2 analyze status  Table is already up to date
 
418
test.t2 analyze status  OK
422
419
explain select * from t1, t2  where t1.uid=t2.uid AND t1.uid > 0;
423
420
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
424
 
1       SIMPLE  t1      range   uid_index       uid_index       4       NULL    112     Using index condition; Using MRR
425
 
1       SIMPLE  t2      ref     uid_index       uid_index       4       test.t1.uid     38      
 
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     #       
426
423
explain select * from t1, t2  where t1.uid=t2.uid AND t2.uid > 0;
427
424
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
428
 
1       SIMPLE  t1      range   uid_index       uid_index       4       NULL    112     Using index condition; Using MRR
429
 
1       SIMPLE  t2      ref     uid_index       uid_index       4       test.t1.uid     38      
 
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     #       
430
427
explain select * from t1, t2  where t1.uid=t2.uid AND t1.uid != 0;
431
428
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
432
 
1       SIMPLE  t1      range   uid_index       uid_index       4       NULL    113     Using index condition; Using MRR
433
 
1       SIMPLE  t2      ref     uid_index       uid_index       4       test.t1.uid     38      
 
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     #       
434
431
explain select * from t1, t2  where t1.uid=t2.uid AND t2.uid != 0;
435
432
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
436
 
1       SIMPLE  t1      range   uid_index       uid_index       4       NULL    113     Using index condition; Using MRR
437
 
1       SIMPLE  t2      ref     uid_index       uid_index       4       test.t1.uid     38      
 
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     #       
438
435
select * from t1, t2  where t1.uid=t2.uid AND t1.uid > 0;
439
436
id      name    uid     id      name    uid
440
437
1001    A       1       1001    A       1
492
489
1025    Y       25      1025    Y       25
493
490
1026    Z       26      1026    Z       26
494
491
drop table t1,t2;
495
 
create table t1 (x bigint unsigned not null);
496
 
insert into t1(x) values (0xfffffffffffffff0);
497
 
insert into t1(x) values (0xfffffffffffffff1);
 
492
create table t1 (x bigint not null);
 
493
insert into t1(x) values (0x0ffffffffffffff0);
 
494
insert into t1(x) values (0x0ffffffffffffff1);
498
495
select * from t1;
499
496
x
500
 
18446744073709551600
501
 
18446744073709551601
 
497
1152921504606846960
 
498
1152921504606846961
502
499
select count(*) from t1 where x>0;
503
500
count(*)
504
501
2
519
516
2
520
517
select count(*) from t1 where x = 18446744073709551601;
521
518
count(*)
522
 
1
 
519
0
523
520
create table t2 (x bigint not null);
524
521
insert into t2(x) values (-16);
525
522
insert into t2(x) values (-15);
547
544
1
548
545
select count(*) from t2 where x = 18446744073709551601;
549
546
count(*)
550
 
0
 
547
1
551
548
drop table t1,t2;
552
 
create table t1 (x bigint unsigned not null primary key) engine=innodb;
553
 
insert into t1(x) values (0xfffffffffffffff0);
554
 
insert into t1(x) values (0xfffffffffffffff1);
 
549
create table t1 (x bigint not null primary key) engine=innodb;
 
550
insert into t1(x) values (0x0ffffffffffffff0);
 
551
insert into t1(x) values (0x0ffffffffffffff1);
555
552
select * from t1;
556
553
x
557
 
18446744073709551600
558
 
18446744073709551601
 
554
1152921504606846960
 
555
1152921504606846961
559
556
select count(*) from t1 where x>0;
560
557
count(*)
561
558
2
576
573
2
577
574
select count(*) from t1 where x = 18446744073709551601;
578
575
count(*)
579
 
1
 
576
0
580
577
drop table t1;
581
 
create table t1 (a bigint unsigned);
 
578
create table t1 (a bigint);
582
579
create index t1i on t1(a);
583
580
insert into t1 select 18446744073709551615;
584
581
insert into t1 select 18446744073709551614;
587
584
1       SIMPLE  t1      index   t1i     t1i     9       NULL    2       Using where; Using index
588
585
select * from t1 where a <> -1;
589
586
a
590
 
18446744073709551614
591
 
18446744073709551615
 
587
-2
592
588
explain select * from t1 where a > -1 or a < -1;
593
589
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
594
590
1       SIMPLE  t1      index   t1i     t1i     9       NULL    2       Using where; Using index
595
591
select * from t1 where a > -1 or a < -1;
596
592
a
597
 
18446744073709551614
598
 
18446744073709551615
 
593
-2
599
594
explain select * from t1 where a > -1;
600
595
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
601
596
1       SIMPLE  t1      index   t1i     t1i     9       NULL    2       Using where; Using index
602
597
select * from t1 where a > -1;
603
598
a
604
 
18446744073709551614
605
 
18446744073709551615
606
599
explain select * from t1 where a < -1;
607
600
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
608
 
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Impossible WHERE noticed after reading const tables
 
601
1       SIMPLE  t1      index   t1i     t1i     9       NULL    2       Using where; Using index
609
602
select * from t1 where a < -1;
610
603
a
 
604
-2
611
605
drop table t1;
612
 
set names latin1;
613
 
create table t1 (a char(10), b text, key (a)) character set latin1;
 
606
create table t1 (a char(10), b text, key (a));
614
607
INSERT INTO t1 (a) VALUES
615
608
('111'),('222'),('222'),('222'),('222'),('444'),('aaa'),('AAA'),('bbb');
616
609
explain select * from t1 where a='aaa';
617
610
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
618
 
1       SIMPLE  t1      ref     a       a       11      const   2       Using index condition
 
611
1       SIMPLE  t1      ref     a       a       43      const   2       Using where
619
612
explain select * from t1 where a=binary 'aaa';
620
613
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
621
 
1       SIMPLE  t1      range   a       a       11      NULL    2       Using index condition; Using MRR
622
 
explain select * from t1 where a='aaa' collate latin1_bin;
623
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
624
 
1       SIMPLE  t1      range   a       a       11      NULL    2       Using index condition; Using MRR
625
 
explain select * from t1 where a='aaa' collate latin1_german1_ci;
626
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
627
 
1       SIMPLE  t1      ALL     a       NULL    NULL    NULL    9       Using where
 
614
1       SIMPLE  t1      range   a       a       43      NULL    2       Using where
 
615
explain select * from t1 where a='aaa' collate utf8_bin;
 
616
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
617
1       SIMPLE  t1      range   a       a       43      NULL    2       Using where
628
618
drop table t1;
629
619
CREATE TABLE t1 (
630
 
`CLIENT` char(3) character set latin1 collate latin1_bin NOT NULL default '000',
631
 
`ARG1` char(3) character set latin1 collate latin1_bin NOT NULL default '',
632
 
`ARG2` char(3) character set latin1 collate latin1_bin NOT NULL default '',
633
 
`FUNCTION` varchar(10) character set latin1 collate latin1_bin NOT NULL default '',
634
 
`FUNCTINT` int(11) NOT NULL default '0',
 
620
`CLIENT` char(3) collate utf8_bin NOT NULL default '000',
 
621
`ARG1` char(3) collate utf8_bin NOT NULL default '',
 
622
`ARG2` char(3) collate utf8_bin NOT NULL default '',
 
623
`FUNCTION` varchar(10) collate utf8_bin NOT NULL default '',
 
624
`FUNCTINT` int NOT NULL default '0',
635
625
KEY `VERI_CLNT~2` (`ARG1`)
636
 
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
626
) ENGINE=InnoDB;
637
627
INSERT INTO t1 VALUES ('000',' 0',' 0','Text 001',0), ('000',' 0',' 1','Text 002',0),
638
628
('000',' 1',' 2','Text 003',0), ('000',' 2',' 3','Text 004',0),
639
629
('001',' 3',' 0','Text 017',0);
647
637
create table t1 (a int);
648
638
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
649
639
CREATE TABLE t2 (
650
 
pk1 int(11) NOT NULL,
651
 
pk2 int(11) NOT NULL,
652
 
pk3 int(11) NOT NULL,
653
 
pk4 int(11) NOT NULL,
 
640
pk1 int NOT NULL,
 
641
pk2 int NOT NULL,
 
642
pk3 int NOT NULL,
 
643
pk4 int NOT NULL,
654
644
filler char(82),
655
645
PRIMARY KEY (pk1,pk2,pk3,pk4)
656
 
) DEFAULT CHARSET=latin1;
 
646
);
657
647
insert into t2 select 1, A.a+10*B.a, 432, 44, 'fillerZ' from t1 A, t1 B;
658
648
INSERT INTO t2 VALUES (2621, 2635, 0, 0,'filler'), (2621, 2635, 1, 0,'filler'),
659
649
(2621, 2635, 10, 0,'filler'), (2621, 2635, 11, 0,'filler'),
669
659
insert into t1 values ('x'), ('xx');
670
660
explain select a from t1 where a > 'x';
671
661
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
672
 
1       SIMPLE  t1      range   a       a       2       NULL    2       Using where
 
662
1       SIMPLE  t1      range   a       a       7       NULL    1       Using where
673
663
select a from t1 where a > 'x';
674
664
a
675
665
xx
676
666
drop table t1;
677
667
CREATE TABLE t1 (
678
 
OXID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT '',
679
 
OXPARENTID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT 'oxrootid',
 
668
OXID varchar(32) NOT NULL DEFAULT '',
 
669
OXPARENTID varchar(32) NOT NULL DEFAULT 'oxrootid',
680
670
OXLEFT int NOT NULL DEFAULT '0',
681
671
OXRIGHT int NOT NULL DEFAULT '0',
682
 
OXROOTID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT '',
 
672
OXROOTID varchar(32) NOT NULL DEFAULT '',
683
673
PRIMARY KEY  (OXID),
684
674
KEY OXNID (OXID),
685
675
KEY OXLEFT (OXLEFT),
686
676
KEY OXRIGHT (OXRIGHT),
687
677
KEY OXROOTID (OXROOTID)
688
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci;
 
678
);
689
679
INSERT INTO t1 VALUES
690
680
('d8c4177d09f8b11f5.52725521','oxrootid',1,40,'d8c4177d09f8b11f5.52725521'),
691
681
('d8c4177d151affab2.81582770','d8c4177d09f8b11f5.52725521',2,3,
704
694
v.oxrootid ='d8c4177d09f8b11f5.52725521' AND
705
695
s.oxleft > v.oxleft AND s.oxleft < v.oxright;
706
696
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
707
 
1       SIMPLE  v       ref     OXLEFT,OXRIGHT,OXROOTID OXROOTID        34      const   5       Using index condition
708
 
1       SIMPLE  s       ALL     OXLEFT  NULL    NULL    NULL    6       Range checked for each record (index map: 0x4)
 
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)
709
699
SELECT s.oxid FROM t1 v, t1 s 
710
700
WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND
711
701
v.oxrootid ='d8c4177d09f8b11f5.52725521' AND
860
850
drop table t1;
861
851
End of 4.1 tests
862
852
CREATE TABLE t1 (
863
 
id int(11) NOT NULL auto_increment,
 
853
id int NOT NULL auto_increment,
864
854
status varchar(20),
865
855
PRIMARY KEY  (id),
866
856
KEY (status)
878
868
(55,'C'), (56,'C'), (57,'C'), (58,'C'), (59,'C'), (60,'C');
879
869
EXPLAIN SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B';
880
870
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
881
 
1       SIMPLE  t1      range   status  status  23      NULL    11      Using index condition; Using MRR
 
871
1       SIMPLE  t1      range   status  status  83      NULL    28      Using where; Using index
882
872
EXPLAIN SELECT * FROM t1 WHERE status NOT IN ('A','B');
883
873
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
884
 
1       SIMPLE  t1      range   status  status  23      NULL    11      Using index condition; Using MRR
 
874
1       SIMPLE  t1      range   status  status  83      NULL    28      Using where; Using index
885
875
SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B';
886
876
id      status
887
877
53      C
904
894
60      C
905
895
EXPLAIN SELECT status FROM t1 WHERE status <> 'A' AND status <> 'B';
906
896
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
907
 
1       SIMPLE  t1      range   status  status  23      NULL    11      Using where; Using index
 
897
1       SIMPLE  t1      range   status  status  83      NULL    28      Using where; Using index
908
898
EXPLAIN SELECT status FROM t1 WHERE status NOT IN ('A','B');
909
899
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
910
 
1       SIMPLE  t1      range   status  status  23      NULL    11      Using where; Using index
 
900
1       SIMPLE  t1      range   status  status  83      NULL    28      Using where; Using index
911
901
EXPLAIN SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B';
912
902
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
913
 
1       SIMPLE  t1      range   status  status  23      NULL    10      Using index condition; Using MRR
 
903
1       SIMPLE  t1      range   status  status  83      NULL    18      Using where; Using index
914
904
EXPLAIN SELECT * FROM t1 WHERE status < 'A' OR status > 'B';
915
905
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
916
 
1       SIMPLE  t1      range   status  status  23      NULL    10      Using index condition; Using MRR
 
906
1       SIMPLE  t1      range   status  status  83      NULL    18      Using where; Using index
917
907
SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B';
918
908
id      status
919
909
53      C
935
925
59      C
936
926
60      C
937
927
DROP TABLE t1;
938
 
CREATE TABLE  t1 (a int, b int, primary key(a,b));
939
 
INSERT INTO  t1 VALUES
940
 
(1,1),(1,2),(1,3),(2,1),(2,2),(2,3),(3,1),(3,2),(3,3),(4,1),(4,2),(4,3);
941
 
CREATE VIEW v1 as SELECT a,b FROM t1 WHERE b=3;
942
 
EXPLAIN SELECT a,b FROM t1 WHERE a < 2 and b=3;
943
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
944
 
1       SIMPLE  t1      range   PRIMARY PRIMARY 4       NULL    4       Using where; Using index
945
 
EXPLAIN SELECT a,b FROM v1 WHERE a < 2 and b=3;
946
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
947
 
1       SIMPLE  t1      range   PRIMARY PRIMARY 4       NULL    4       Using where; Using index
948
 
EXPLAIN SELECT a,b FROM t1 WHERE a < 2;
949
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
950
 
1       SIMPLE  t1      range   PRIMARY PRIMARY 4       NULL    4       Using where; Using index
951
 
EXPLAIN SELECT a,b FROM v1 WHERE a < 2;
952
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
953
 
1       SIMPLE  t1      range   PRIMARY PRIMARY 4       NULL    4       Using where; Using index
954
 
SELECT a,b FROM t1 WHERE a < 2 and b=3;
955
 
a       b
956
 
1       3
957
 
SELECT a,b FROM v1 WHERE a < 2 and b=3;
958
 
a       b
959
 
1       3
960
 
DROP VIEW v1;
961
 
DROP TABLE t1;
962
928
CREATE TABLE t1 (name varchar(15) NOT NULL, KEY idx(name));
963
929
INSERT INTO t1 VALUES ('Betty'), ('Anna');
964
930
SELECT * FROM t1;
983
949
a
984
950
2
985
951
DROP TABLE t1;
986
 
create table t1 (a int, b int, primary key(a,b));
987
 
create view v1 as select a, b from t1;
988
 
INSERT INTO `t1` VALUES
989
 
(0,0),(1,0),(2,0),(3,0),(4,0),(5,1),(6,1),(7,1),(8,1),(9,1),(10,2),(11,2),(12,2)
990
 
,(13,2),(14,2),(15,3),(16,3),(17,3),(18,3),(19,3);
991
 
explain select * from t1 where a in (3,4)  and b in (1,2,3);
992
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
993
 
1       SIMPLE  t1      range   PRIMARY PRIMARY 8       NULL    #       Using where; Using index
994
 
explain select * from v1 where a in (3,4)  and b in (1,2,3);
995
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
996
 
1       SIMPLE  t1      range   PRIMARY PRIMARY 8       NULL    #       Using where; Using index
997
 
explain select * from t1 where a between 3 and 4 and b between 1 and 2;
998
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
999
 
1       SIMPLE  t1      range   PRIMARY PRIMARY 8       NULL    #       Using where; Using index
1000
 
explain select * from v1 where a between 3 and 4 and b between 1 and 2;
1001
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1002
 
1       SIMPLE  t1      range   PRIMARY PRIMARY 8       NULL    #       Using where; Using index
1003
 
drop view v1;
1004
 
drop table t1;
1005
952
create table t3 (a int);
1006
953
insert into t3 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
1007
 
create table t1 (a varchar(10), filler char(200), key(a)) charset=binary;
 
954
create table t1 (a varchar(10), filler char(200), key(a));
1008
955
insert into t1 values ('a','');
1009
956
insert into t1 values ('a ','');
1010
957
insert into t1 values ('a  ', '');
1014
961
insert into t2 select * from t1;
1015
962
explain select * from t1 where a between 'a' and 'a ';
1016
963
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1017
 
1       SIMPLE  t1      range   a       a       13      NULL    #       Using index condition; Using MRR
 
964
1       SIMPLE  t1      ref     a       a       43      const   #       Using where
1018
965
explain select * from t1 where a = 'a' or a='a ';
1019
966
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1020
 
1       SIMPLE  t1      range   a       a       13      NULL    #       Using index condition; Using MRR
 
967
1       SIMPLE  t1      ref     a       a       43      const   #       Using where
1021
968
explain select * from t2 where a between 'a' and 'a ';
1022
969
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1023
 
1       SIMPLE  t2      ref     a       a       13      const   #       Using index condition
 
970
1       SIMPLE  t2      ref     a       a       43      const   #       Using where
1024
971
explain select * from t2 where a = 'a' or a='a ';
1025
972
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1026
 
1       SIMPLE  t2      ref     a       a       13      const   #       Using index condition
 
973
1       SIMPLE  t2      ref     a       a       43      const   #       Using where
1027
974
update t1 set a='b' where a<>'a';
1028
975
explain select * from t1 where a not between 'b' and 'b';
1029
976
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1030
 
1       SIMPLE  t1      range   a       a       13      NULL    #       Using index condition; Using MRR
 
977
1       SIMPLE  t1      ALL     a       NULL    NULL    NULL    #       Using where
1031
978
select a, hex(filler) from t1 where a not between 'b' and 'b';
1032
979
a       hex(filler)
1033
 
a       0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
 
980
a       
 
981
a       
 
982
a       
1034
983
drop table t1,t2,t3;
1035
 
create table t1 (a int);
1036
 
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
1037
 
create table t2 (a int, key(a));
1038
 
insert into t2 select 2*(A.a + 10*(B.a + 10*C.a)) from t1 A, t1 B, t1 C;
1039
 
set @a="select * from t2 force index (a) where a NOT IN(0";
1040
 
select count(*) from (select @a:=concat(@a, ',', a) from t2 ) Z;
1041
 
count(*)
1042
 
1000
1043
 
set @a=concat(@a, ')');
1044
 
insert into t2 values (11),(13),(15);
1045
 
set @b= concat("explain ", @a);
1046
 
prepare stmt1 from @b;
1047
 
execute stmt1;
1048
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1049
 
1       SIMPLE  t2      index   a       a       5       NULL    1003    Using where; Using index
1050
 
prepare stmt1 from @a;
1051
 
execute stmt1;
1052
 
a
1053
 
11
1054
 
13
1055
 
15
1056
 
drop table t1, t2;
1057
984
CREATE TABLE t1 (
1058
985
id int NOT NULL DEFAULT '0',
1059
986
b int NOT NULL DEFAULT '0',
1071
998
0       3       4
1072
999
EXPLAIN  SELECT * FROM t1 WHERE b<=3 AND 3<=c;
1073
1000
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1074
 
1       SIMPLE  t1      range   idx1,idx2       idx2    4       NULL    3       Using index condition; Using where; Using MRR
 
1001
1       SIMPLE  t1      range   idx1,idx2       idx2    4       NULL    2       Using where
1075
1002
EXPLAIN  SELECT * FROM t1 WHERE 3 BETWEEN b AND c;
1076
1003
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1077
 
1       SIMPLE  t1      range   idx1,idx2       idx2    4       NULL    3       Using where; Using MRR
 
1004
1       SIMPLE  t1      range   idx1,idx2       idx2    4       NULL    2       Using where
1078
1005
SELECT * FROM t1 WHERE 0 < b OR 0 > c;
1079
1006
id      b       c
1080
1007
0       3       4
1090
1017
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1091
1018
1       SIMPLE  t1      ALL     idx1,idx2       NULL    NULL    NULL    10      Using where
1092
1019
DROP TABLE t1;
1093
 
CREATE TABLE t1 (                                      
 
1020
CREATE TEMPORARY TABLE t1 (                                      
1094
1021
item char(20) NOT NULL default '',                          
1095
 
started datetime NOT NULL default '0000-00-00 00:00:00', 
 
1022
started datetime, 
1096
1023
price decimal(16,3) NOT NULL default '0.000',                 
1097
1024
PRIMARY KEY (item,started)                     
1098
1025
) ENGINE=MyISAM;
1101
1028
('A1','2005-11-15 00:00:00',2000),
1102
1029
('A1','2005-12-12 08:00:00',3000),
1103
1030
('A2','2005-12-01 08:00:00',1000);
1104
 
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
1105
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1106
 
1       SIMPLE  t1      ref     PRIMARY PRIMARY 20      const   2       Using index condition
1107
 
Warnings:
1108
 
Warning 1292    Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
1109
 
Warning 1292    Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
1110
 
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
1111
 
item    started price
1112
 
A1      2005-11-01 08:00:00     1000.000
1113
 
A1      2005-11-15 00:00:00     2000.000
1114
 
Warnings:
1115
 
Warning 1292    Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
1116
 
Warning 1292    Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
1117
 
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
1118
 
item    started price
1119
 
A1      2005-11-01 08:00:00     1000.000
1120
 
A1      2005-11-15 00:00:00     2000.000
1121
 
DROP INDEX `PRIMARY` ON t1;
1122
 
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
1123
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1124
 
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    4       Using where
1125
 
Warnings:
1126
 
Warning 1292    Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
1127
 
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
1128
 
item    started price
1129
 
A1      2005-11-01 08:00:00     1000.000
1130
 
A1      2005-11-15 00:00:00     2000.000
1131
 
Warnings:
1132
 
Warning 1292    Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
 
1031
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 23:59:59';
 
1032
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
1033
1       SIMPLE  t1      range   PRIMARY PRIMARY 90      NULL    #       Using where
 
1034
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 23:59:59';
 
1035
item    started price
 
1036
A1      2005-11-01 08:00:00     1000.000
 
1037
A1      2005-11-15 00:00:00     2000.000
1133
1038
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
1134
1039
item    started price
1135
1040
A1      2005-11-01 08:00:00     1000.000
1139
1044
BUG#32198 "Comparison of DATE with DATETIME still not using indexes correctly"
1140
1045
 
1141
1046
CREATE TABLE t1 (
1142
 
id int(11) NOT NULL auto_increment,
 
1047
id int NOT NULL auto_increment,
1143
1048
dateval date default NULL,
1144
1049
PRIMARY KEY  (id),
1145
1050
KEY dateval (dateval)
1151
1056
This must use range access:
1152
1057
explain select * from t1 where dateval >= '2007-01-01 00:00:00' and dateval <= '2007-01-02 23:59:59';
1153
1058
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1154
 
1       SIMPLE  t1      range   dateval dateval 4       NULL    2       Using index condition; Using MRR
 
1059
1       SIMPLE  t1      index   dateval PRIMARY 4       NULL    11      Using where
1155
1060
drop table t1;
1156
1061
CREATE TABLE t1 (
1157
1062
a varchar(32), index (a)
1158
 
) DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
 
1063
) DEFAULT COLLATE=utf8_bin;
1159
1064
INSERT INTO t1 VALUES
1160
1065
('B'), ('A'), ('A'), ('C'), ('B'), ('A'), ('A');
1161
1066
SELECT a FROM t1 WHERE a='b' OR a='B';
1164
1069
B
1165
1070
EXPLAIN SELECT a FROM t1 WHERE a='b' OR a='B';
1166
1071
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1167
 
1       SIMPLE  t1      range   a       a       35      NULL    3       Using where; Using index
 
1072
1       SIMPLE  t1      range   a       a       131     NULL    3       Using where; Using index
1168
1073
DROP TABLE t1;
1169
 
CREATE TABLE t1 (f1 TINYINT(11) UNSIGNED NOT NULL, PRIMARY KEY (f1));
 
1074
CREATE TABLE t1 (f1 int NOT NULL, PRIMARY KEY (f1));
1170
1075
INSERT INTO t1 VALUES (127),(254),(0),(1),(255);
1171
 
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 256;
1172
 
COUNT(*)
1173
 
5
1174
 
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 256.0;
1175
 
COUNT(*)
1176
 
5
1177
 
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 255;
 
1076
SELECT COUNT(*) FROM t1 WHERE f1 < 256;
 
1077
COUNT(*)
 
1078
5
 
1079
SELECT COUNT(*) FROM t1 WHERE f1 < 256.0;
 
1080
COUNT(*)
 
1081
5
 
1082
SELECT COUNT(*) FROM t1 WHERE f1 < 255;
1178
1083
COUNT(*)
1179
1084
4
1180
 
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < -1;
 
1085
SELECT COUNT(*) FROM t1 WHERE f1 < -1;
1181
1086
COUNT(*)
1182
1087
0
1183
 
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -1;
 
1088
SELECT COUNT(*) FROM t1 WHERE f1 > -1;
1184
1089
COUNT(*)
1185
1090
5
1186
1091
DROP TABLE t1;
1187
 
CREATE TABLE t1 ( f1 TINYINT(11) NOT NULL, PRIMARY KEY (f1));
 
1092
CREATE TABLE t1 ( f1 int NOT NULL, PRIMARY KEY (f1));
1188
1093
INSERT INTO t1 VALUES (127),(126),(0),(-128),(-127);
1189
 
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 128;
1190
 
COUNT(*)
1191
 
5
1192
 
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 128.0;
1193
 
COUNT(*)
1194
 
5
1195
 
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 127;
 
1094
SELECT COUNT(*) FROM t1 WHERE f1 < 128;
 
1095
COUNT(*)
 
1096
5
 
1097
SELECT COUNT(*) FROM t1 WHERE f1 < 128.0;
 
1098
COUNT(*)
 
1099
5
 
1100
SELECT COUNT(*) FROM t1 WHERE f1 < 127;
1196
1101
COUNT(*)
1197
1102
4
1198
 
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -129;
1199
 
COUNT(*)
1200
 
5
1201
 
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -129.0;
1202
 
COUNT(*)
1203
 
5
1204
 
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -128;
 
1103
SELECT COUNT(*) FROM t1 WHERE f1 > -129;
 
1104
COUNT(*)
 
1105
5
 
1106
SELECT COUNT(*) FROM t1 WHERE f1 > -129.0;
 
1107
COUNT(*)
 
1108
5
 
1109
SELECT COUNT(*) FROM t1 WHERE f1 > -128;
1205
1110
COUNT(*)
1206
1111
4
1207
1112
DROP TABLE t1;
1215
1120
select 'In following EXPLAIN the access method should be ref, #rows~=500 (and not 2)' Z;
1216
1121
Z
1217
1122
In following EXPLAIN the access method should be ref, #rows~=500 (and not 2)
1218
 
explain select * from t2 where a=1000 and b<11;
 
1123
create temporary table t2e like t2;
 
1124
alter table t2e engine=myisam;
 
1125
insert into t2e select * from t2;
 
1126
analyze table t2e;
 
1127
Table   Op      Msg_type        Msg_text
 
1128
test.t2e        analyze note    The storage engine for the table doesn't support analyze
 
1129
explain select * from t2e where a=1000 and b<11;
1219
1130
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1220
 
1       SIMPLE  t2      ref     a       a       5       const   502     Using index condition
 
1131
1       SIMPLE  t2e     ref     a       a       5       const   11      Using where
1221
1132
drop table t1, t2;
1222
1133
End of 5.1 tests
1223
1134
CREATE TABLE t1 (c1 DECIMAL(10,0),INDEX(c1));