10
event_date date DEFAULT '0000-00-00' NOT NULL,
11
type int(11) DEFAULT '0' NOT NULL,
12
event_id int(11) DEFAULT '0' NOT NULL,
11
type int DEFAULT '0' NOT NULL,
12
event_id int DEFAULT '0' NOT NULL,
13
13
PRIMARY KEY (event_date,type,event_id)
41
PAPER_ID smallint(6) DEFAULT '0' NOT NULL,
42
YEAR smallint(6) DEFAULT '0' NOT NULL,
43
ISSUE smallint(6) DEFAULT '0' NOT NULL,
44
CLOSED tinyint(4) DEFAULT '0' NOT NULL,
45
ISS_DATE date DEFAULT '0000-00-00' NOT NULL,
41
PAPER_ID int DEFAULT '0' NOT NULL,
42
YEAR int DEFAULT '0' NOT NULL,
43
ISSUE int DEFAULT '0' NOT NULL,
44
CLOSED int DEFAULT '0' NOT NULL,
46
46
PRIMARY KEY (PAPER_ID,YEAR,ISSUE)
48
48
INSERT INTO t1 VALUES (3,1999,34,0,'1999-07-12'), (1,1999,111,0,'1999-03-23'),
62
62
(3,1999,35,0,'1999-07-12');
63
63
select YEAR,ISSUE from t1 where PAPER_ID=3 and (YEAR>1999 or (YEAR=1999 and ISSUE>28)) order by YEAR,ISSUE;
69
id int(11) NOT NULL auto_increment,
70
parent_id int(11) DEFAULT '0' NOT NULL,
71
level tinyint(4) DEFAULT '0' NOT NULL,
68
id int NOT NULL auto_increment,
69
parent_id int DEFAULT '0' NOT NULL,
70
level int DEFAULT '0' NOT NULL,
73
72
KEY parent_id (parent_id),
119
118
CREATE TABLE t1 (
120
t1ID int(10) unsigned NOT NULL auto_increment,
121
art binary(1) NOT NULL default '',
119
t1ID int NOT NULL auto_increment,
120
art varbinary(1) NOT NULL default '',
122
121
KNR char(5) NOT NULL default '',
123
122
RECHNR char(6) NOT NULL default '',
124
123
POSNR char(2) NOT NULL default '',
198
197
# bug #1172: "Force index" option caused server crash
200
CREATE TABLE t1 (key1 int(11) NOT NULL default '0', KEY i1 (key1));
199
CREATE TABLE t1 (key1 int NOT NULL default '0', KEY i1 (key1));
201
200
INSERT INTO t1 VALUES (0),(0),(0),(0),(0),(1),(1);
202
CREATE TABLE t2 (keya int(11) NOT NULL default '0', KEY j1 (keya));
201
CREATE TABLE t2 (keya int NOT NULL default '0', KEY j1 (keya));
203
202
INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2);
204
203
explain select * from t1, t2 where (t1.key1 <t2.keya + 1) and t2.keya=3;
205
204
explain select * from t1 force index(i1), t2 force index(j1) where
264
263
CREATE TABLE t1 (
265
id int( 11 ) unsigned NOT NULL AUTO_INCREMENT ,
266
line int( 5 ) unsigned NOT NULL default '0',
267
columnid int( 3 ) unsigned NOT NULL default '0',
268
owner int( 3 ) unsigned NOT NULL default '0',
269
ordinal int( 3 ) unsigned NOT NULL default '0',
270
showid smallint( 6 ) unsigned NOT NULL default '1',
271
tableid int( 1 ) unsigned NOT NULL default '1',
272
content int( 5 ) unsigned NOT NULL default '188',
264
id int NOT NULL AUTO_INCREMENT ,
265
line int NOT NULL default '0',
266
columnid int NOT NULL default '0',
267
owner int NOT NULL default '0',
268
ordinal int NOT NULL default '0',
269
showid int NOT NULL default '1',
270
tableid int NOT NULL default '1',
271
content int NOT NULL default '188',
273
272
PRIMARY KEY ( owner, id ) ,
274
273
KEY menu( owner, showid, columnid ) ,
275
274
KEY `COLUMN` ( owner, columnid, line ) ,
286
285
# test for a bug with in() and unique key
289
create table t1 (id int(10) primary key);
288
create table t1 (id int primary key);
290
289
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
292
291
select id from t1 where id in (2,5,9) ;
313
312
name char(1) not null,
314
313
uid int not null,
315
314
primary key (id),
316
index uid_index (uid));
315
index uid_index (uid)) ENGINE=Myisam;
318
317
create table t2 (
319
318
id int not null auto_increment,
320
319
name char(1) not null,
321
320
uid int not null,
322
321
primary key (id),
323
index uid_index (uid));
322
index uid_index (uid)) engine=myisam;
325
324
insert into t1(id, uid, name) values(1, 0, ' ');
326
325
insert into t1(uid, name) values(0, ' ');
393
392
# Fix for bug#4488
395
create table t1 (x bigint unsigned not null);
396
insert into t1(x) values (0xfffffffffffffff0);
397
insert into t1(x) values (0xfffffffffffffff1);
394
create table t1 (x bigint not null);
395
insert into t1(x) values (0x0ffffffffffffff0);
396
insert into t1(x) values (0x0ffffffffffffff1);
398
397
select * from t1;
399
398
select count(*) from t1 where x>0;
400
399
select count(*) from t1 where x=0;
419
418
drop table t1,t2;
421
420
--disable_warnings
422
create table t1 (x bigint unsigned not null primary key) engine=innodb;
421
create table t1 (x bigint not null primary key) engine=innodb;
423
422
--enable_warnings
424
insert into t1(x) values (0xfffffffffffffff0);
425
insert into t1(x) values (0xfffffffffffffff1);
423
insert into t1(x) values (0x0ffffffffffffff0);
424
insert into t1(x) values (0x0ffffffffffffff1);
426
425
select * from t1;
427
426
select count(*) from t1 where x>0;
428
427
select count(*) from t1 where x=0;
438
# Bug #11185 incorrect comparison of unsigned int to signed constant
437
# Bug #11185 incorrect comparison of int to signed constant
440
create table t1 (a bigint unsigned);
439
create table t1 (a bigint);
441
440
create index t1i on t1(a);
442
441
insert into t1 select 18446744073709551615;
443
442
insert into t1 select 18446744073709551614;
457
456
# Bug #6045: Binary Comparison regression in MySQL 4.1
458
457
# Binary searches didn't use a case insensitive index.
461
create table t1 (a char(10), b text, key (a)) character set latin1;
459
create table t1 (a char(10), b text, key (a));
462
460
INSERT INTO t1 (a) VALUES
463
461
('111'),('222'),('222'),('222'),('222'),('444'),('aaa'),('AAA'),('bbb');
464
462
# all these three can be optimized
465
463
explain select * from t1 where a='aaa';
466
464
explain select * from t1 where a=binary 'aaa';
467
explain select * from t1 where a='aaa' collate latin1_bin;
469
explain select * from t1 where a='aaa' collate latin1_german1_ci;
465
explain select * from t1 where a='aaa' collate utf8_bin;
472
468
# Test for BUG#9348 "result for WHERE A AND (B OR C) differs from WHERE a AND (C OR B)"
473
469
--disable_warnings
474
470
CREATE TABLE t1 (
475
`CLIENT` char(3) character set latin1 collate latin1_bin NOT NULL default '000',
476
`ARG1` char(3) character set latin1 collate latin1_bin NOT NULL default '',
477
`ARG2` char(3) character set latin1 collate latin1_bin NOT NULL default '',
478
`FUNCTION` varchar(10) character set latin1 collate latin1_bin NOT NULL default '',
479
`FUNCTINT` int(11) NOT NULL default '0',
471
`CLIENT` char(3) collate utf8_bin NOT NULL default '000',
472
`ARG1` char(3) collate utf8_bin NOT NULL default '',
473
`ARG2` char(3) collate utf8_bin NOT NULL default '',
474
`FUNCTION` varchar(10) collate utf8_bin NOT NULL default '',
475
`FUNCTINT` int NOT NULL default '0',
480
476
KEY `VERI_CLNT~2` (`ARG1`)
481
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
482
478
--enable_warnings
484
480
INSERT INTO t1 VALUES ('000',' 0',' 0','Text 001',0), ('000',' 0',' 1','Text 002',0),
496
492
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
498
494
CREATE TABLE t2 (
499
pk1 int(11) NOT NULL,
500
pk2 int(11) NOT NULL,
501
pk3 int(11) NOT NULL,
502
pk4 int(11) NOT NULL,
504
500
PRIMARY KEY (pk1,pk2,pk3,pk4)
505
) DEFAULT CHARSET=latin1;
507
503
insert into t2 select 1, A.a+10*B.a, 432, 44, 'fillerZ' from t1 A, t1 B;
508
504
INSERT INTO t2 VALUES (2621, 2635, 0, 0,'filler'), (2621, 2635, 1, 0,'filler'),
532
528
CREATE TABLE t1 (
533
OXID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT '',
534
OXPARENTID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT 'oxrootid',
529
OXID varchar(32) NOT NULL DEFAULT '',
530
OXPARENTID varchar(32) NOT NULL DEFAULT 'oxrootid',
535
531
OXLEFT int NOT NULL DEFAULT '0',
536
532
OXRIGHT int NOT NULL DEFAULT '0',
537
OXROOTID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT '',
533
OXROOTID varchar(32) NOT NULL DEFAULT '',
538
534
PRIMARY KEY (OXID),
539
535
KEY OXNID (OXID),
540
536
KEY OXLEFT (OXLEFT),
541
537
KEY OXRIGHT (OXRIGHT),
542
538
KEY OXROOTID (OXROOTID)
543
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci;
545
541
INSERT INTO t1 VALUES
546
542
('d8c4177d09f8b11f5.52725521','oxrootid',1,40,'d8c4177d09f8b11f5.52725521'),
758
# Test for bug #10031: range to be used over a view
761
CREATE TABLE t1 (a int, b int, primary key(a,b));
763
INSERT INTO t1 VALUES
764
(1,1),(1,2),(1,3),(2,1),(2,2),(2,3),(3,1),(3,2),(3,3),(4,1),(4,2),(4,3);
766
CREATE VIEW v1 as SELECT a,b FROM t1 WHERE b=3;
768
EXPLAIN SELECT a,b FROM t1 WHERE a < 2 and b=3;
769
EXPLAIN SELECT a,b FROM v1 WHERE a < 2 and b=3;
771
EXPLAIN SELECT a,b FROM t1 WHERE a < 2;
772
EXPLAIN SELECT a,b FROM v1 WHERE a < 2;
774
SELECT a,b FROM t1 WHERE a < 2 and b=3;
775
SELECT a,b FROM v1 WHERE a < 2 and b=3;
781
754
# Bug #11853: DELETE statement with a NOT (LIKE/<=>) where condition
782
755
# for an indexed attribute
804
# BUG#13317: range optimization doesn't work for IN over VIEW.
806
create table t1 (a int, b int, primary key(a,b));
807
create view v1 as select a, b from t1;
809
INSERT INTO `t1` VALUES
810
(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)
811
,(13,2),(14,2),(15,3),(16,3),(17,3),(18,3),(19,3);
814
explain select * from t1 where a in (3,4) and b in (1,2,3);
816
explain select * from v1 where a in (3,4) and b in (1,2,3);
818
explain select * from t1 where a between 3 and 4 and b between 1 and 2;
820
explain select * from v1 where a between 3 and 4 and b between 1 and 2;
826
777
create table t3 (a int);
827
778
insert into t3 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
829
create table t1 (a varchar(10), filler char(200), key(a)) charset=binary;
780
create table t1 (a varchar(10), filler char(200), key(a));
830
781
insert into t1 values ('a','');
831
782
insert into t1 values ('a ','');
832
783
insert into t1 values ('a ', '');
854
805
drop table t1,t2,t3;
859
create table t1 (a int);
860
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
861
create table t2 (a int, key(a));
862
insert into t2 select 2*(A.a + 10*(B.a + 10*C.a)) from t1 A, t1 B, t1 C;
864
set @a="select * from t2 force index (a) where a NOT IN(0";
865
select count(*) from (select @a:=concat(@a, ',', a) from t2 ) Z;
866
set @a=concat(@a, ')');
868
insert into t2 values (11),(13),(15);
870
set @b= concat("explain ", @a);
872
prepare stmt1 from @b;
875
prepare stmt1 from @a;
881
808
# Bug #18165: range access for BETWEEN with a constant for the first argument
913
840
CREATE TABLE t1 (
914
841
item char(20) NOT NULL default '',
915
started datetime NOT NULL default '0000-00-00 00:00:00',
916
843
price decimal(16,3) NOT NULL default '0.000',
917
844
PRIMARY KEY (item,started)
923
850
('A1','2005-12-12 08:00:00',3000),
924
851
('A2','2005-12-01 08:00:00',1000);
926
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
927
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
928
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
930
DROP INDEX `PRIMARY` ON t1;
932
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
933
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
934
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
853
EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 23:59:59';
854
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 23:59:59';
855
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
857
# Disabling for now, since it fails. Likely due to only currently
858
# checking for bad datetimes on string conversions...
860
#DROP INDEX `PRIMARY` ON t1;
862
#EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 23:59:59';
863
#SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 23:59:59';
864
#SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
939
869
--echo BUG#32198 "Comparison of DATE with DATETIME still not using indexes correctly"
941
871
CREATE TABLE t1 (
942
id int(11) NOT NULL auto_increment,
872
id int NOT NULL auto_increment,
943
873
dateval date default NULL,
944
874
PRIMARY KEY (id),
945
875
KEY dateval (dateval)
963
893
CREATE TABLE t1 (
964
894
a varchar(32), index (a)
965
) DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
895
) DEFAULT COLLATE=utf8_bin;
967
897
INSERT INTO t1 VALUES
968
898
('B'), ('A'), ('A'), ('C'), ('B'), ('A'), ('A');
979
909
# test UNSIGNED. only occurs when indexed.
980
CREATE TABLE t1 (f1 TINYINT(11) UNSIGNED NOT NULL, PRIMARY KEY (f1));
910
CREATE TABLE t1 (f1 int NOT NULL, PRIMARY KEY (f1));
982
912
INSERT INTO t1 VALUES (127),(254),(0),(1),(255);
984
914
# test upper bound
986
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 256;
987
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 256.0;
916
SELECT COUNT(*) FROM t1 WHERE f1 < 256;
917
SELECT COUNT(*) FROM t1 WHERE f1 < 256.0;
989
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 255;
919
SELECT COUNT(*) FROM t1 WHERE f1 < 255;
991
921
# show we don't fiddle with lower bound on UNSIGNED
993
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < -1;
923
SELECT COUNT(*) FROM t1 WHERE f1 < -1;
995
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -1;
925
SELECT COUNT(*) FROM t1 WHERE f1 > -1;
1000
930
# test signed. only occurs when index.
1001
CREATE TABLE t1 ( f1 TINYINT(11) NOT NULL, PRIMARY KEY (f1));
931
CREATE TABLE t1 ( f1 int NOT NULL, PRIMARY KEY (f1));
1003
933
INSERT INTO t1 VALUES (127),(126),(0),(-128),(-127);
1005
935
# test upper bound
1007
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 128;
1008
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 128.0;
937
SELECT COUNT(*) FROM t1 WHERE f1 < 128;
938
SELECT COUNT(*) FROM t1 WHERE f1 < 128.0;
1010
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 127;
940
SELECT COUNT(*) FROM t1 WHERE f1 < 127;
1012
942
# test lower bound
1014
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -129;
1015
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -129.0;
944
SELECT COUNT(*) FROM t1 WHERE f1 > -129;
945
SELECT COUNT(*) FROM t1 WHERE f1 > -129.0;
1017
SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -128;
947
SELECT COUNT(*) FROM t1 WHERE f1 > -128;
1025
955
create table t1 (a int);
1026
956
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
1028
create table t2 (a int, b int, filler char(100));
958
create table t2 (a int, b int, filler char(100)) ENGINE=myisam;
1029
959
insert into t2 select A.a + 10 * (B.a + 10 * C.a), 10, 'filler' from t1 A,
1030
960
t1 B, t1 C where A.a < 5;