~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysql-test/r/heap_btree.result

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
drop table if exists t1;
2
 
create temporary table t1 (a int not null,b int not null, primary key using BTREE (a)) engine=MEMORY comment="testing heaps";
 
2
create table t1 (a int not null,b int not null, primary key using BTREE (a)) engine=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100;
3
3
insert into t1 values(1,1),(2,2),(3,3),(4,4);
4
4
delete from t1 where a=1 or a=0;
5
5
show keys from t1;
23
23
4       6
24
24
alter table t1 add c int not null, add key using BTREE (c,a);
25
25
drop table t1;
26
 
create temporary table t1 (a int not null,b int not null, primary key using BTREE (a)) engine=MEMORY comment="testing heaps";
 
26
create table t1 (a int not null,b int not null, primary key using BTREE (a)) engine=heap comment="testing heaps";
27
27
insert into t1 values(-2,-2),(-1,-1),(0,0),(1,1),(2,2),(3,3),(4,4);
28
28
delete from t1 where a > -3;
29
29
select * from t1;
30
30
a       b
31
31
drop table t1;
32
 
create temporary table t1 (a int not null,b int not null, primary key using BTREE (a)) engine=MEMORY comment="testing heaps";
 
32
create table t1 (a int not null,b int not null, primary key using BTREE (a)) engine=heap comment="testing heaps";
33
33
insert into t1 values(1,1),(2,2),(3,3),(4,4);
34
 
alter table t1 modify a int not null auto_increment, engine=innodb, comment="new innodb table";
 
34
alter table t1 modify a int not null auto_increment, engine=myisam, comment="new myisam table";
35
35
select * from t1;
36
36
a       b
37
37
1       1
39
39
3       3
40
40
4       4
41
41
drop table t1;
42
 
create temporary table t1 (a int not null) engine=MEMORY;
 
42
create table t1 (a int not null) engine=heap;
43
43
insert into t1 values (869751),(736494),(226312),(802616),(728912);
44
44
select * from t1 where a > 736494;
45
45
a
63
63
736494
64
64
802616
65
65
869751
66
 
alter table t1 engine=innodb;
 
66
alter table t1 engine=myisam;
67
67
explain select * from t1 where a in (869751,736494,226312,802616);
68
68
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
69
 
1       SIMPLE  t1      index   uniq_id uniq_id 4       NULL    5       Using where; Using index
 
69
1       SIMPLE  t1      range   uniq_id uniq_id 4       NULL    4       Using where; Using index
70
70
drop table t1;
71
 
create temporary table t1 (x int not null, y int not null, key x  using BTREE (x,y), unique y  using BTREE (y))
72
 
engine=MEMORY;
 
71
create table t1 (x int not null, y int not null, key x  using BTREE (x,y), unique y  using BTREE (y))
 
72
engine=heap;
73
73
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
74
74
explain select * from t1 where x=1;
75
75
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
79
79
1       1
80
80
1       3
81
81
select * from t1,t1 as t2 where t1.x=t2.y;
82
 
ERROR HY000: Can't reopen table: 't1'
 
82
x       y       x       y
 
83
1       1       1       1
 
84
2       2       2       2
 
85
1       3       1       1
 
86
2       4       2       2
 
87
2       5       2       2
 
88
2       6       2       2
83
89
explain select * from t1,t1 as t2 where t1.x=t2.y;
84
 
ERROR HY000: Can't reopen table: 't1'
 
90
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
91
1       SIMPLE  t1      ALL     x       NULL    NULL    NULL    6       
 
92
1       SIMPLE  t2      eq_ref  y       y       4       test.t1.x       1       
85
93
drop table t1;
86
 
create temporary table t1 (a int) engine=MEMORY;
 
94
create table t1 (a int) engine=heap;
87
95
insert into t1 values(1);
88
96
select max(a) from t1;
89
97
max(a)
90
98
1
91
99
drop table t1;
92
 
CREATE TEMPORARY TABLE t1 ( a int not null default 0, b int not null default 0,  key  using BTREE (a,b),  key  using BTREE (b)  ) ENGINE=MEMORY;
 
100
CREATE TABLE t1 ( a int not null default 0, b int not null default 0,  key  using BTREE (a,b),  key  using BTREE (b)  ) ENGINE=HEAP;
93
101
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
94
102
select * from t1 where a=1;
95
103
a       b
128
136
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
129
137
x       SIMPLE  tx      ref     b       b       x       const   x       
130
138
drop table t1;
131
 
create temporary table t1 (id int not null, primary key  using BTREE (id)) engine=MEMORY;
 
139
create table t1 (id int unsigned not null, primary key  using BTREE (id)) engine=HEAP;
132
140
insert into t1 values(1);
133
141
select max(id) from t1;
134
142
max(id)
139
147
2
140
148
replace into t1 values(1);
141
149
drop table t1;
142
 
create temporary table t1 (n int) engine=MEMORY;
 
150
create table t1 (n int) engine=heap;
143
151
drop table t1;
144
 
create temporary table t1 (n int) engine=MEMORY;
 
152
create table t1 (n int) engine=heap;
145
153
drop table if exists t1;
146
 
CREATE TEMPORARY table t1(f1 int not null,f2 char(20) not 
147
 
null,index(f2)) engine=MEMORY;
 
154
CREATE table t1(f1 int not null,f2 char(20) not 
 
155
null,index(f2)) engine=heap;
148
156
INSERT into t1 set f1=12,f2="bill";
149
157
INSERT into t1 set f1=13,f2="bill";
150
158
INSERT into t1 set f1=14,f2="bill";
163
171
12      ted
164
172
12      ted
165
173
drop table t1;
166
 
create temporary table t1 (btn char(10) not null, key using BTREE (btn)) engine=MEMORY;
 
174
create table t1 (btn char(10) not null, key using BTREE (btn)) engine=heap;
167
175
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
168
176
explain select * from t1 where btn like "i%";
169
177
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
170
 
1       SIMPLE  t1      range   btn     btn     42      NULL    1       Using where
 
178
1       SIMPLE  t1      range   btn     btn     10      NULL    1       Using where
171
179
explain select * from t1 where btn like "h%";
172
180
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
173
 
1       SIMPLE  t1      range   btn     btn     42      NULL    #       Using where
 
181
1       SIMPLE  t1      range   btn     btn     10      NULL    #       Using where
174
182
explain select * from t1 where btn like "a%";
175
183
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
176
 
1       SIMPLE  t1      range   btn     btn     42      NULL    1       Using where
 
184
1       SIMPLE  t1      range   btn     btn     10      NULL    1       Using where
177
185
explain select * from t1 where btn like "b%";
178
186
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
179
 
1       SIMPLE  t1      range   btn     btn     42      NULL    1       Using where
 
187
1       SIMPLE  t1      range   btn     btn     10      NULL    1       Using where
180
188
select * from t1 where btn like "ff%";
181
189
btn
182
190
select * from t1 where btn like " %";
187
195
update t1 set new_col=left(btn,1);
188
196
explain select * from t1 where btn="a";
189
197
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
190
 
1       SIMPLE  t1      ref     btn     btn     42      const   1       Using where
 
198
1       SIMPLE  t1      ref     btn     btn     10      const   1       Using where
191
199
explain select * from t1 where btn="a" and new_col="a";
192
200
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
193
 
1       SIMPLE  t1      ref     btn     btn     48      const,const     1       Using where
 
201
1       SIMPLE  t1      ref     btn     btn     11      const,const     1       Using where
194
202
drop table t1;
195
 
CREATE TEMPORARY TABLE t1 (
 
203
CREATE TABLE t1 (
196
204
a int default NULL,
197
205
b int default NULL,
198
206
KEY a using BTREE (a),
199
207
UNIQUE b using BTREE (b)
200
 
) engine=MEMORY;
 
208
) engine=heap;
201
209
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
202
210
SELECT * FROM t1 WHERE a=NULL;
203
211
a       b
218
226
INSERT INTO t1 VALUES (1,3);
219
227
ERROR 23000: Duplicate entry '3' for key 'b'
220
228
DROP TABLE t1;
221
 
CREATE TEMPORARY TABLE t1 (a int, b int, c int, key using BTREE (a, b, c)) engine=MEMORY;
 
229
CREATE TABLE t1 (a int, b int, c int, key using BTREE (a, b, c)) engine=heap;
222
230
INSERT INTO t1 VALUES (1, NULL, NULL), (1, 1, NULL), (1, NULL, 1);
223
231
SELECT * FROM t1 WHERE a=1 and b IS NULL;
224
232
a       b       c
232
240
a       b       c
233
241
1       NULL    NULL
234
242
DROP TABLE t1;
235
 
CREATE TEMPORARY TABLE t1 (a int not null, primary key using BTREE (a)) engine=MEMORY;
 
243
CREATE TABLE t1 (a int not null, primary key using BTREE (a)) engine=heap;
236
244
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
237
245
DELETE from t1 where a < 100;
238
246
SELECT * from t1;
239
247
a
240
248
DROP TABLE t1;
241
 
create temporary table t1(a int not null, key using btree(a)) engine=MEMORY;
 
249
create table t1(a int not null, key using btree(a)) engine=heap;
242
250
insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3);
243
251
select a from t1 where a > 2 order by a;
244
252
a
272
280
1
273
281
1
274
282
drop table t1;
275
 
CREATE TEMPORARY TABLE t1 (
 
283
CREATE TABLE t1 (
276
284
c1 CHAR(3),
277
285
c2 INTEGER,
278
286
KEY USING BTREE(c1),
287
295
B       0
288
296
C       0
289
297
DROP TABLE t1;
290
 
CREATE TEMPORARY TABLE t1 (
 
298
CREATE TABLE t1 (
291
299
c1 ENUM('1', '2'),
292
300
UNIQUE USING BTREE(c1)
293
 
) ENGINE= MEMORY;
294
 
INSERT INTO t1 VALUES('1'), ('2');
295
 
DROP TABLE t1;
296
 
CREATE TEMPORARY TABLE t1 (a INT, KEY USING BTREE(a)) ENGINE=MEMORY;
 
301
) ENGINE= MEMORY DEFAULT CHARSET= utf8;
 
302
INSERT INTO t1 VALUES('1'), ('2');
 
303
DROP TABLE t1;
 
304
CREATE TABLE t1 (
 
305
c1 SET('1', '2'),
 
306
UNIQUE USING BTREE(c1)
 
307
) ENGINE= MEMORY DEFAULT CHARSET= utf8;
 
308
INSERT INTO t1 VALUES('1'), ('2');
 
309
DROP TABLE t1;
 
310
CREATE TABLE t1 (a INT, KEY USING BTREE(a)) ENGINE=MEMORY;
297
311
INSERT INTO t1 VALUES(1),(2),(2);
298
312
DELETE FROM t1 WHERE a=2;
299
313
SELECT * FROM t1;
301
315
1
302
316
DROP TABLE t1;
303
317
End of 4.1 tests
304
 
CREATE TEMPORARY TABLE t1(val INT, KEY USING BTREE(val)) ENGINE=memory;
 
318
CREATE TABLE t1(val INT, KEY USING BTREE(val)) ENGINE=memory;
305
319
INSERT INTO t1 VALUES(0);
306
320
SELECT INDEX_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1';
307
321
INDEX_LENGTH
 
322
21
308
323
UPDATE t1 SET val=1;
309
324
SELECT INDEX_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1';
310
325
INDEX_LENGTH
 
326
21
311
327
DROP TABLE t1;
312
 
CREATE TEMPORARY TABLE t1 (a INT, UNIQUE USING BTREE(a)) ENGINE=MEMORY;
 
328
CREATE TABLE t1 (a INT, UNIQUE USING BTREE(a)) ENGINE=MEMORY;
313
329
INSERT INTO t1 VALUES(NULL),(NULL);
314
330
DROP TABLE t1;
315
 
create temporary table t1(a varchar(255), b varchar(255), 
 
331
create table t1(a varchar(255), b varchar(255), 
316
332
key using btree (a,b)) engine=memory;
317
333
insert into t1 values (1, 1), (3, 3), (2, 2), (NULL, 1), (NULL, NULL), (0, 0);
318
334
select * from t1 where a is null;