Commit 6c9bfe78 authored by marko's avatar marko

branches/zip: innodb-index.test: Add FORCE INDEX directives and remove

those SELECTs whose ORDER BY cannot possibly make use of an index.
parent 2561797b
This diff is collapsed.
...@@ -9,15 +9,15 @@ alter table t1 add index b (b), add index b (b); ...@@ -9,15 +9,15 @@ alter table t1 add index b (b), add index b (b);
alter table t1 add index (b,b); alter table t1 add index (b,b);
alter table t1 add index d2 (d); alter table t1 add index d2 (d);
show create table t1; show create table t1;
explain select * from t1 order by d; explain select * from t1 force index(d2) order by d;
select * from t1 order by d; select * from t1 force index (d2) order by d;
--error ER_DUP_ENTRY --error ER_DUP_ENTRY
alter table t1 add unique index (b); alter table t1 add unique index (b);
show create table t1; show create table t1;
alter table t1 add index (b); alter table t1 add index (b);
show create table t1; show create table t1;
-- Check how existing tables interfere with temporary tables. # Check how existing tables interfere with temporary tables.
CREATE TABLE `t1#1`(a INT PRIMARY KEY) ENGINE=InnoDB; CREATE TABLE `t1#1`(a INT PRIMARY KEY) ENGINE=InnoDB;
--error 156 --error 156
...@@ -29,7 +29,7 @@ drop table `t1#2`; ...@@ -29,7 +29,7 @@ drop table `t1#2`;
alter table t1 add unique index (c), add index (d); alter table t1 add unique index (c), add index (d);
show create table t1; show create table t1;
explain select * from t1 order by c; explain select * from t1 force index(c) order by c;
--error ER_REQUIRES_PRIMARY_KEY --error ER_REQUIRES_PRIMARY_KEY
drop index c on t1; drop index c on t1;
alter table t1 add primary key (a), drop index c; alter table t1 add primary key (a), drop index c;
...@@ -40,18 +40,18 @@ alter table t1 add primary key (c); ...@@ -40,18 +40,18 @@ alter table t1 add primary key (c);
alter table t1 drop primary key, add primary key (b); alter table t1 drop primary key, add primary key (b);
create unique index c on t1 (c); create unique index c on t1 (c);
show create table t1; show create table t1;
explain select * from t1 order by c; explain select * from t1 force index(c) order by c;
select * from t1 order by c; select * from t1 force index(c) order by c;
alter table t1 drop index b, add index (b); alter table t1 drop index b, add index (b);
show create table t1; show create table t1;
insert into t1 values(6,1,'ggg','ggg'); insert into t1 values(6,1,'ggg','ggg');
select * from t1; select * from t1;
select * from t1 order by b; select * from t1 force index(b) order by b;
select * from t1 order by c; select * from t1 force index(c) order by c;
select * from t1 order by d; select * from t1 force index(d) order by d;
explain select * from t1 order by b; explain select * from t1 force index(b) order by b;
explain select * from t1 order by c; explain select * from t1 force index(c) order by c;
explain select * from t1 order by d; explain select * from t1 force index(d) order by d;
show create table t1; show create table t1;
drop table t1; drop table t1;
...@@ -64,21 +64,18 @@ alter table t1 add unique index (d(10)); ...@@ -64,21 +64,18 @@ alter table t1 add unique index (d(10));
show create table t1; show create table t1;
insert into t1 values(5,1,'ggg','ggg'); insert into t1 values(5,1,'ggg','ggg');
select * from t1; select * from t1;
select * from t1 order by b; select * from t1 force index(c) order by c;
select * from t1 order by c; select * from t1 force index(d) order by d;
select * from t1 order by d;
explain select * from t1 order by b; explain select * from t1 order by b;
explain select * from t1 order by c; explain select * from t1 force index(c) order by c;
explain select * from t1 order by d; explain select * from t1 force index(d) order by d;
show create table t1; show create table t1;
alter table t1 drop index d; alter table t1 drop index d;
insert into t1 values(8,9,'fff','fff'); insert into t1 values(8,9,'fff','fff');
select * from t1; select * from t1;
select * from t1 order by b; select * from t1 force index(c) order by c;
select * from t1 order by c;
select * from t1 order by d;
explain select * from t1 order by b; explain select * from t1 order by b;
explain select * from t1 order by c; explain select * from t1 force index(c) order by c;
explain select * from t1 order by d; explain select * from t1 order by d;
show create table t1; show create table t1;
drop table t1; drop table t1;
...@@ -89,32 +86,22 @@ commit; ...@@ -89,32 +86,22 @@ commit;
alter table t1 add unique index (b,c); alter table t1 add unique index (b,c);
insert into t1 values(8,9,'fff','fff'); insert into t1 values(8,9,'fff','fff');
select * from t1; select * from t1;
select * from t1 order by b; select * from t1 force index(b) order by b;
select * from t1 order by c; explain select * from t1 force index(b) order by b;
select * from t1 order by d;
explain select * from t1 order by b;
explain select * from t1 order by c;
explain select * from t1 order by d;
show create table t1; show create table t1;
alter table t1 add index (b,c); alter table t1 add index (b,c);
insert into t1 values(11,11,'kkk','kkk'); insert into t1 values(11,11,'kkk','kkk');
select * from t1; select * from t1;
select * from t1 order by b; select * from t1 force index(b) order by b;
select * from t1 order by c; explain select * from t1 force index(b) order by b;
select * from t1 order by d;
explain select * from t1 order by b;
explain select * from t1 order by c;
explain select * from t1 order by d;
show create table t1; show create table t1;
alter table t1 add unique index (c,d); alter table t1 add unique index (c,d);
insert into t1 values(13,13,'yyy','aaa'); insert into t1 values(13,13,'yyy','aaa');
select * from t1; select * from t1;
select * from t1 order by b; select * from t1 force index(b) order by b;
select * from t1 order by c; select * from t1 force index(c) order by c;
select * from t1 order by d; explain select * from t1 force index(b) order by b;
explain select * from t1 order by b; explain select * from t1 force index(c) order by c;
explain select * from t1 order by c;
explain select * from t1 order by d;
show create table t1; show create table t1;
drop table t1; drop table t1;
...@@ -135,10 +122,10 @@ alter table t4 drop index d; ...@@ -135,10 +122,10 @@ alter table t4 drop index d;
alter table t2 drop index b; alter table t2 drop index b;
--error ER_DROP_INDEX_FK --error ER_DROP_INDEX_FK
alter table t2 drop index b, drop index c, drop index d; alter table t2 drop index b, drop index c, drop index d;
-- Apparently, the following makes mysql_alter_table() drop index d. # Apparently, the following makes mysql_alter_table() drop index d.
create unique index dc on t2 (d,c); create unique index dc on t2 (d,c);
create index dc on t1 (b,c); create index dc on t1 (b,c);
-- This should preserve the foreign key constraints. # This should preserve the foreign key constraints.
alter table t2 add primary key (a); alter table t2 add primary key (a);
insert into t1 values (1,1,1); insert into t1 values (1,1,1);
insert into t3 values (1,1,1); insert into t3 values (1,1,1);
...@@ -148,7 +135,7 @@ commit; ...@@ -148,7 +135,7 @@ commit;
alter table t4 add constraint dc foreign key (a) references t1(a); alter table t4 add constraint dc foreign key (a) references t1(a);
show create table t4; show create table t4;
--replace_regex /'test\.#sql-[0-9a-f_]*'/'#sql-temporary'/ --replace_regex /'test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
# a foreign key 'test/dc' already exists
--error ER_CANT_CREATE_TABLE --error ER_CANT_CREATE_TABLE
alter table t3 add constraint dc foreign key (a) references t1(a); alter table t3 add constraint dc foreign key (a) references t1(a);
show create table t3; show create table t3;
...@@ -158,7 +145,7 @@ show create table t2; ...@@ -158,7 +145,7 @@ show create table t2;
delete from t1; delete from t1;
--error ER_CANT_DROP_FIELD_OR_KEY --error ER_CANT_DROP_FIELD_OR_KEY
drop index dc on t4; drop index dc on t4;
-- there is no foreign key dc on t3 # there is no foreign key dc on t3
--replace_regex /'\.\/test\/#sql2-[0-9a-f-]*'/'#sql2-temporary'/ --replace_regex /'\.\/test\/#sql2-[0-9a-f-]*'/'#sql2-temporary'/
--error ER_ERROR_ON_RENAME --error ER_ERROR_ON_RENAME
alter table t3 drop foreign key dc; alter table t3 drop foreign key dc;
...@@ -177,32 +164,22 @@ commit; ...@@ -177,32 +164,22 @@ commit;
alter table t1 add unique index (b); alter table t1 add unique index (b);
insert into t1 values(8,9,'fff','fff'); insert into t1 values(8,9,'fff','fff');
select * from t1; select * from t1;
select * from t1 order by b;
select * from t1 order by c;
select * from t1 order by d;
explain select * from t1 order by b;
explain select * from t1 order by c;
explain select * from t1 order by d;
show create table t1; show create table t1;
alter table t1 add index (b); alter table t1 add index (b);
insert into t1 values(10,10,'kkk','iii'); insert into t1 values(10,10,'kkk','iii');
select * from t1; select * from t1;
select * from t1 order by b; select * from t1 force index(b) order by b;
select * from t1 order by c; explain select * from t1 force index(b) order by b;
select * from t1 order by d;
explain select * from t1 order by b;
explain select * from t1 order by c;
explain select * from t1 order by d;
show create table t1; show create table t1;
alter table t1 add unique index (c), add index (d); alter table t1 add unique index (c), add index (d);
insert into t1 values(11,11,'aaa','mmm'); insert into t1 values(11,11,'aaa','mmm');
select * from t1; select * from t1;
select * from t1 order by b; select * from t1 force index(b) order by b;
select * from t1 order by c; select * from t1 force index(c) order by c;
select * from t1 order by d; select * from t1 force index(d) order by d;
explain select * from t1 order by b; explain select * from t1 force index(b) order by b;
explain select * from t1 order by c; explain select * from t1 force index(c) order by c;
explain select * from t1 order by d; explain select * from t1 force index(d) order by d;
show create table t1; show create table t1;
check table t1; check table t1;
drop table t1; drop table t1;
...@@ -217,22 +194,18 @@ show create table t1; ...@@ -217,22 +194,18 @@ show create table t1;
alter table t1 add index (b); alter table t1 add index (b);
insert into t1 values(8,9,'fff','fff'); insert into t1 values(8,9,'fff','fff');
select * from t1; select * from t1;
select * from t1 order by b; select * from t1 force index(b) order by b;
select * from t1 order by c; explain select * from t1 force index(b) order by b;
select * from t1 order by d;
explain select * from t1 order by b;
explain select * from t1 order by c;
explain select * from t1 order by d;
show create table t1; show create table t1;
alter table t1 add unique index (c), add index (d); alter table t1 add unique index (c), add index (d);
insert into t1 values(10,10,'aaa','kkk'); insert into t1 values(10,10,'aaa','kkk');
select * from t1; select * from t1;
select * from t1 order by b; select * from t1 force index(b) order by b;
select * from t1 order by c; select * from t1 force index(c) order by c;
select * from t1 order by d; select * from t1 force index(d) order by d;
explain select * from t1 order by b; explain select * from t1 force index(b) order by b;
explain select * from t1 order by c; explain select * from t1 force index(c) order by c;
explain select * from t1 order by d; explain select * from t1 force index(d) order by d;
show create table t1; show create table t1;
check table t1; check table t1;
drop table t1; drop table t1;
...@@ -273,12 +246,12 @@ alter table t1 add unique index (b); ...@@ -273,12 +246,12 @@ alter table t1 add unique index (b);
insert into t1 values (10,20,20),(11,19,19),(12,18,18),(13,17,17); insert into t1 values (10,20,20),(11,19,19),(12,18,18),(13,17,17);
show create table t1; show create table t1;
check table t1; check table t1;
explain select * from t1 order by c; explain select * from t1 force index(c) order by c;
explain select * from t1 order by a; explain select * from t1 order by a;
explain select * from t1 order by b; explain select * from t1 force index(b) order by b;
select * from t1 order by a; select * from t1 order by a;
select * from t1 order by b; select * from t1 force index(b) order by b;
select * from t1 order by c; select * from t1 force index(c) order by c;
drop table t1; drop table t1;
create table t1(a int not null, b int not null) engine=innodb; create table t1(a int not null, b int not null) engine=innodb;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment