1
# include/index_merge2.inc
6
# $engine_type -- storage engine to be tested
7
# has to be set before sourcing this script.
9
# Note: The comments/expectations refer to InnoDB.
10
# They might be not valid for other storage engines.
13
# 2006-08-02 ML test refactored
14
# old name was t/index_merge_innodb.test
15
# main code went into include/index_merge2.inc
18
--echo #---------------- Index merge test 2 -------------------------------------------
20
eval SET SESSION STORAGE_ENGINE = $engine_type;
23
drop table if exists t1,t2;
39
eval insert into t1 values (200-$1, $1);
45
explain select * from t1 where key1 < 5 or key2 > 197;
47
select * from t1 where key1 < 5 or key2 > 197;
49
explain select * from t1 where key1 < 3 or key2 > 195;
50
select * from t1 where key1 < 3 or key2 > 195;
52
# Primary key as case-sensitive string with \0s.
53
# also make primary key be longer then max. index length of MyISAM.
54
alter table t1 add str1 char (255) not null,
55
add zeroval int not null default 0,
56
add str2 char (255) not null,
57
add str3 char (255) not null;
59
update t1 set str1='aaa', str2='bbb', str3=concat(key2, '-', key1 div 2, '_' ,if(key1 mod 2 = 0, 'a', 'A'));
61
alter table t1 add primary key (str1, zeroval, str2, str3);
63
explain select * from t1 where key1 < 5 or key2 > 197;
65
select * from t1 where key1 < 5 or key2 > 197;
67
explain select * from t1 where key1 < 3 or key2 > 195;
68
select * from t1 where key1 < 3 or key2 > 195;
73
pk integer not null auto_increment primary key,
75
key2 integer not null,
85
eval insert into t1 (key1, key2, filler) values ($1/4, $1/8, 'filler-data');
89
explain select pk from t1 where key1 = 1 and key2 = 1;
90
select pk from t1 where key2 = 1 and key1 = 1;
91
select pk from t1 ignore index(key1,key2) where key2 = 1 and key1 = 1;
93
# More tests for BUG#5401.
96
pk int primary key auto_increment,
108
index i1(key1a, key1b),
109
index i2(key2a, key2b),
110
index i3(key3a, key3b)
113
create table t2 (a int);
114
insert into t2 values (0),(1),(2),(3),(4),(NULL);
116
insert into t1 (key1a, key1b, key2a, key2b, key3a, key3b)
117
select A.a, B.a, C.a, D.a, C.a, D.a from t2 A,t2 B,t2 C, t2 D;
118
insert into t1 (key1a, key1b, key2a, key2b, key3a, key3b)
119
select key1a, key1b, key2a, key2b, key3a, key3b from t1;
120
insert into t1 (key1a, key1b, key2a, key2b, key3a, key3b)
121
select key1a, key1b, key2a, key2b, key3a, key3b from t1;
123
select count(*) from t1;
125
explain select count(*) from t1 where
126
key1a = 2 and key1b is null and key2a = 2 and key2b is null;
128
select count(*) from t1 where
129
key1a = 2 and key1b is null and key2a = 2 and key2b is null;
131
explain select count(*) from t1 where
132
key1a = 2 and key1b is null and key3a = 2 and key3b is null;
134
select count(*) from t1 where
135
key1a = 2 and key1b is null and key3a = 2 and key3b is null;
143
index idx2 (id1,id2),
146
insert into t1 values(1,'20040101'), (2,'20040102');
147
select * from t1 where id1 = 1 and id2= '20040101';
150
# BUG#21277: Index Merge/sort_union: wrong query results
154
key2 int not null default 0,
155
key3 int not null default 0
158
insert into t1(key1) values (1),(2),(3),(4),(5),(6),(7),(8);
164
eval insert into t1 (key1) select key1+@d from t1;
169
alter table t1 add index i2(key2);
170
alter table t1 add index i3(key3);
171
update t1 set key2=key1,key3=key1;
173
# to test the bug, the following must use "sort_union":
174
explain select * from t1 where (key3 > 30 and key3<35) or (key2 >32 and key2 < 40);
175
select * from t1 where (key3 > 30 and key3<35) or (key2 >32 and key2 < 40);