~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/include/index_merge2.inc

  • Committer: Brian Aker
  • Date: 2009-05-11 17:50:22 UTC
  • Revision ID: brian@gaz-20090511175022-y35q9ky6uh9ldcjt
Replacing Sun employee copyright headers (aka... anything done by a Sun
employee is copyright by Sun).

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
 
54
54
# Primary key as case-sensitive string with \0s.
55
55
# also make primary key be longer then max. index length of MyISAM.
56
 
ALTER TABLE t1 ADD str1 CHAR (100) DEFAULT "catfood" NOT NULL,
57
 
                ADD zeroval INT NOT NULL DEFAULT 0,
58
 
                ADD str2 CHAR (100) DEFAULT "bird" NOT NULL,
59
 
                ADD str3 CHAR (100) DEFAULT "dog" NOT NULL;
60
 
 
61
 
UPDATE t1 SET str1='aaa', str2='bbb', str3=concat(key2, '-', key1 div 2, '_' ,if(key1 mod 2 = 0, 'a', 'A'));
62
 
 
63
 
ALTER TABLE t1 ADD PRIMARY KEY (str1, zeroval, str2, str3);
64
 
 
65
 
EXPLAIN SELECT * FROM t1 WHERE key1 < 5 OR key2 > 197;
 
56
alter table t1 add str1 char (100) not null,
 
57
                add zeroval int not null default 0,
 
58
                add str2 char (100) not null,
 
59
                add str3 char (100) not null;
 
60
 
 
61
update t1 set str1='aaa', str2='bbb', str3=concat(key2, '-', key1 div 2, '_' ,if(key1 mod 2 = 0, 'a', 'A'));
 
62
 
 
63
alter table t1 add primary key (str1, zeroval, str2, str3);
 
64
 
 
65
explain select * from t1 where key1 < 5 or key2 > 197;
66
66
 
67
67
select * from t1 where key1 < 5 or key2 > 197;
68
68
 
112
112
  index i1(key1a, key1b),
113
113
  index i2(key2a, key2b),
114
114
  index i3(key3a, key3b)
115
 
);
 
115
) ENGINE=myisam;
116
116
 
117
117
create table t2 (a int);
118
118
insert into t2 values (0),(1),(2),(3),(4),(NULL);
126
126
analyze table t1;
127
127
select count(*) from t1;
128
128
 
129
 
--replace_column 9 #
130
129
explain select count(*) from t1 where
131
130
  key1a = 2 and key1b is null and  key2a = 2 and key2b is null;
132
131
 
133
132
select count(*) from t1 where
134
133
  key1a = 2 and key1b is null and key2a = 2 and key2b is null;
135
134
 
136
 
--replace_column 9 #
137
135
explain select count(*) from t1 where
138
136
  key1a = 2 and key1b is null and key3a = 2 and key3b is null;
139
137
 
182
180
explain select * from t1 where (key3 > 30 and key3<35) or (key2 >32 and key2 < 40);
183
181
select * from t1 where (key3 > 30 and key3<35) or (key2 >32 and key2 < 40);
184
182
drop table t1;
185
 
 
186
 
--echo #
187
 
--echo # Bug#56423: Different count with SELECT and CREATE SELECT queries
188
 
--echo #
189
 
 
190
 
CREATE TABLE t1 (
191
 
  a INT,
192
 
  b INT,
193
 
  c INT,
194
 
  d INT,
195
 
  PRIMARY KEY (a),
196
 
  KEY (c),
197
 
  KEY bd (b,d)
198
 
);
199
 
 
200
 
INSERT INTO t1 VALUES
201
 
(1, 0, 1, 0),
202
 
(2, 1, 1, 1),
203
 
(3, 1, 1, 1),
204
 
(4, 0, 1, 1);
205
 
 
206
 
EXPLAIN
207
 
SELECT a
208
 
FROM t1
209
 
WHERE c = 1 AND b = 1 AND d = 1;
210
 
 
211
 
CREATE TABLE t2 ( a INT )
212
 
SELECT a
213
 
FROM t1
214
 
WHERE c = 1 AND b = 1 AND d = 1;
215
 
 
216
 
SELECT * FROM t2;
217
 
 
218
 
DROP TABLE t1, t2;
219
 
 
220
 
CREATE TABLE t1( a INT, b INT, KEY(a), KEY(b) );
221
 
INSERT INTO t1 VALUES (1, 2), (1, 2), (1, 2), (1, 2);
222
 
SELECT * FROM t1 FORCE INDEX(a, b) WHERE a = 1 AND b = 2;
223
 
 
224
 
DROP TABLE t1;
225
 
 
226
 
--echo # Code coverage of fix.
227
 
CREATE TABLE t1 ( a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b INT);
228
 
INSERT INTO t1 (b) VALUES (1);
229
 
UPDATE t1 SET b = 2 WHERE a = 1;
230
 
SELECT * FROM t1;
231
 
 
232
 
CREATE TABLE t2 ( a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, b VARCHAR(1) );
233
 
INSERT INTO t2 (b) VALUES ('a');
234
 
UPDATE t2 SET b = 'b' WHERE a = 1;
235
 
SELECT * FROM t2;
236
 
 
237
 
DROP TABLE t1, t2;