~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/heap_hash.result

  • Committer: Stewart Smith
  • Date: 2008-11-21 16:06:07 UTC
  • mto: This revision was merged to the branch mainline in revision 593.
  • Revision ID: stewart@flamingspork.com-20081121160607-n6gdlt013spuo54r
remove mysql_frm_type
and fix engines to return correct value from delete_table when table doesn't exist.
(it should be ENOENT).

Also fix up some tests that manipulated frm files by hand. These tests are no longer valid and will need to be rewritten in the not too distant future.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
drop table if exists t1,t2;
2
 
create temporary table t1 (a int not null,b int not null, primary key using HASH (a)) engine=MEMORY comment="testing heaps";
 
2
create table t1 (a int not null,b int not null, primary key using HASH (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
 
show table status like "t1";
6
 
Session Schema  Name    Type    Engine  Version Rows    Avg_row_length  Table_size      Auto_increment
7
 
#       test    t1      TEMPORARY       MEMORY  #       #       #       #       #
8
5
show keys from t1;
9
 
Table   Unique  Key_name        Seq_in_index    Column_name
10
 
t1      YES     PRIMARY 1       a
 
6
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
7
t1      0       PRIMARY 1       a       NULL    3       NULL    NULL            HASH            
11
8
select * from t1;
12
9
a       b
13
10
2       2
26
23
4       6
27
24
alter table t1 add c int not null, add key using HASH (c,a);
28
25
drop table t1;
29
 
create temporary table t1 (a int not null,b int not null, primary key using HASH (a)) engine=MEMORY comment="testing heaps";
 
26
create table t1 (a int not null,b int not null, primary key using HASH (a)) engine=heap comment="testing heaps";
30
27
insert into t1 values(1,1),(2,2),(3,3),(4,4);
31
28
delete from t1 where a > 0;
32
29
select * from t1;
33
30
a       b
34
31
drop table t1;
35
 
create temporary table t1 (a int not null,b int not null, primary key using HASH (a)) engine=MEMORY comment="testing heaps";
 
32
create table t1 (a int not null,b int not null, primary key using HASH (a)) engine=heap comment="testing heaps";
36
33
insert into t1 values(1,1),(2,2),(3,3),(4,4);
37
 
alter table t1 modify a int not null auto_increment, engine=innodb, comment="new innodb table";
38
 
show table status like "t1";
39
 
Session Schema  Name    Type    Engine  Version Rows    Avg_row_length  Table_size      Auto_increment
40
 
#       test    t1      TEMPORARY       InnoDB  #       #       #       #       #
 
34
alter table t1 modify a int not null auto_increment, engine=myisam, comment="new myisam table";
41
35
select * from t1;
42
36
a       b
43
37
1       1
45
39
3       3
46
40
4       4
47
41
drop table t1;
48
 
create temporary table t1 (a int not null) engine=MEMORY;
 
42
create table t1 (a int not null) engine=heap;
49
43
insert into t1 values (869751),(736494),(226312),(802616),(728912);
50
44
select * from t1 where a > 736494;
51
45
a
69
63
736494
70
64
802616
71
65
869751
72
 
alter table t1 engine=innodb;
 
66
alter table t1 engine=myisam;
73
67
explain select * from t1 where a in (869751,736494,226312,802616);
74
68
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
75
 
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
76
70
drop table t1;
77
 
create temporary table t1 (x int not null, y int not null, key x  using HASH (x), unique y  using HASH (y))
78
 
engine=MEMORY;
 
71
create table t1 (x int not null, y int not null, key x  using HASH (x), unique y  using HASH (y))
 
72
engine=heap;
79
73
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
80
74
select * from t1 where x=1;
81
75
x       y
82
76
1       3
83
77
1       1
84
78
select * from t1,t1 as t2 where t1.x=t2.y;
85
 
ERROR HY000: Can't reopen table: 't1'
 
79
x       y       x       y
 
80
1       1       1       1
 
81
2       2       2       2
 
82
1       3       1       1
 
83
2       4       2       2
 
84
2       5       2       2
 
85
2       6       2       2
86
86
explain select * from t1,t1 as t2 where t1.x=t2.y;
87
 
ERROR HY000: Can't reopen table: 't1'
 
87
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
88
1       SIMPLE  t1      ALL     x       NULL    NULL    NULL    6       
 
89
1       SIMPLE  t2      eq_ref  y       y       4       test.t1.x       1       
88
90
drop table t1;
89
 
create temporary table t1 (a int) engine=MEMORY;
 
91
create table t1 (a int) engine=heap;
90
92
insert into t1 values(1);
91
93
select max(a) from t1;
92
94
max(a)
93
95
1
94
96
drop table t1;
95
 
CREATE TEMPORARY TABLE t1 ( a int not null default 0, b int not null default 0,  key  using HASH (a),  key  using HASH (b)  ) ENGINE=MEMORY;
 
97
CREATE TABLE t1 ( a int not null default 0, b int not null default 0,  key  using HASH (a),  key  using HASH (b)  ) ENGINE=HEAP;
96
98
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
97
99
select * from t1 where a=1;
98
100
a       b
118
120
1       2
119
121
1       1
120
122
drop table t1;
121
 
create temporary table t1 (id int not null, primary key  using HASH (id)) engine=MEMORY;
 
123
create table t1 (id int not null, primary key  using HASH (id)) engine=HEAP;
122
124
insert into t1 values(1);
123
125
select max(id) from t1;
124
126
max(id)
129
131
2
130
132
replace into t1 values(1);
131
133
drop table t1;
132
 
create temporary table t1 (n int) engine=MEMORY;
 
134
create table t1 (n int) engine=heap;
133
135
drop table t1;
134
 
create temporary table t1 (n int) engine=MEMORY;
 
136
create table t1 (n int) engine=heap;
135
137
drop table if exists t1;
136
 
CREATE TEMPORARY table t1(f1 int not null,f2 char(20) not 
137
 
null,index(f2)) engine=MEMORY;
 
138
CREATE table t1(f1 int not null,f2 char(20) not 
 
139
null,index(f2)) engine=heap;
138
140
INSERT into t1 set f1=12,f2="bill";
139
141
INSERT into t1 set f1=13,f2="bill";
140
142
INSERT into t1 set f1=14,f2="bill";
153
155
12      ted
154
156
12      ted
155
157
drop table t1;
156
 
create temporary table t1 (btn char(10) not null, key using HASH (btn)) engine=MEMORY;
 
158
create table t1 (btn char(10) not null, key using HASH (btn)) engine=heap;
157
159
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
158
160
explain select * from t1 where btn like "q%";
159
161
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
169
171
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
170
172
1       SIMPLE  t1      ref     btn     btn     48      const,const     2       Using where
171
173
drop table t1;
172
 
CREATE TEMPORARY TABLE t1 (
 
174
CREATE TABLE t1 (
173
175
a int default NULL,
174
176
b int default NULL,
175
177
KEY a using HASH (a),
176
178
UNIQUE b using HASH (b)
177
 
) engine=MEMORY;
 
179
) engine=heap;
178
180
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
179
181
SELECT * FROM t1 WHERE a=NULL;
180
182
a       b
195
197
INSERT INTO t1 VALUES (1,3);
196
198
ERROR 23000: Duplicate entry '3' for key 'b'
197
199
DROP TABLE t1;
198
 
CREATE TEMPORARY TABLE t1 (a int not null, primary key using HASH (a)) engine=MEMORY;
 
200
CREATE TABLE t1 (a int not null, primary key using HASH (a)) engine=heap;
199
201
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
200
202
DELETE from t1 where a < 100;
201
203
SELECT * from t1;
202
204
a
203
205
DROP TABLE t1;
204
 
create temporary table t1
 
206
create table t1
205
207
(
206
208
a char(8) not null,
207
209
b char(20) not null,
208
210
c int not null,
209
211
key (a)
210
 
) engine=MEMORY;
 
212
) engine=heap;
211
213
insert into t1 values ('aaaa', 'prefill-hash=5',0);
212
214
insert into t1 values ('aaab', 'prefill-hash=0',0);
213
215
insert into t1 values ('aaac', 'prefill-hash=7',0);
229
231
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
230
232
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
231
233
insert into t1 select * from t1;
232
 
ERROR HY000: Can't reopen table: 't1'
233
 
flush tables;
234
 
explain select * from t1 where a='aaaa';
235
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
236
 
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
237
 
explain select * from t1 where a='aaab';
238
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
239
 
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
240
 
explain select * from t1 where a='aaac';
241
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
242
 
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
243
 
explain select * from t1 where a='aaad';
244
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
245
 
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
246
 
flush tables;
247
 
explain select * from t1 where a='aaaa';
248
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
249
 
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
250
 
explain select * from t1 where a='aaab';
251
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
252
 
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
253
 
explain select * from t1 where a='aaac';
254
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
255
 
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
256
 
explain select * from t1 where a='aaad';
257
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
258
 
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
259
 
create temporary table t2 as select * from t1;
 
234
flush tables;
 
235
explain select * from t1 where a='aaaa';
 
236
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
237
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
 
238
explain select * from t1 where a='aaab';
 
239
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
240
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
 
241
explain select * from t1 where a='aaac';
 
242
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
243
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
 
244
explain select * from t1 where a='aaad';
 
245
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
246
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
 
247
flush tables;
 
248
explain select * from t1 where a='aaaa';
 
249
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
250
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
 
251
explain select * from t1 where a='aaab';
 
252
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
253
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
 
254
explain select * from t1 where a='aaac';
 
255
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
256
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
 
257
explain select * from t1 where a='aaad';
 
258
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
259
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
 
260
create table t2 as select * from t1;
260
261
delete from t1;
261
262
insert into t1 select * from t2;
262
263
explain select * from t1 where a='aaaa';
272
273
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
273
274
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
274
275
drop table t1, t2;
275
 
create temporary table t1 (
 
276
create table t1 (
276
277
id int not null primary key auto_increment, 
277
278
name varchar(20) not null,
278
279
index heap_idx(name),
279
280
index btree_idx using btree(name)
280
 
) engine=MEMORY;
281
 
create temporary table t2 (
 
281
) engine=heap;
 
282
create table t2 (
282
283
id int not null primary key auto_increment, 
283
284
name varchar(20) not null,
284
285
index btree_idx using btree(name),
285
286
index heap_idx(name)
286
 
) engine=MEMORY;
 
287
) engine=heap;
287
288
insert into t1 (name) values ('Matt'), ('Lilu'), ('Corbin'), ('Carly'), 
288
289
('Suzy'), ('Hoppy'), ('Burrito'), ('Mimi'), ('Sherry'), ('Ben'), ('Phil'), 
289
290
('Emily'), ('Mike');
290
291
insert into t2 select * from t1;
291
292
explain select * from t1 where name='matt';
292
293
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
293
 
1       SIMPLE  t1      ref     heap_idx,btree_idx      heap_idx        82      const   2       Using where
 
294
1       SIMPLE  t1      ref     heap_idx,btree_idx      btree_idx       82      const   1       Using where
294
295
explain select * from t2 where name='matt';
295
296
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
296
 
1       SIMPLE  t2      ref     btree_idx,heap_idx      btree_idx       82      const   2       Using where
 
297
1       SIMPLE  t2      ref     btree_idx,heap_idx      btree_idx       82      const   1       Using where
297
298
explain select * from t1 where name='Lilu';
298
299
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
299
 
1       SIMPLE  t1      ref     heap_idx,btree_idx      heap_idx        82      const   2       Using where
 
300
1       SIMPLE  t1      ref     heap_idx,btree_idx      btree_idx       82      const   1       Using where
300
301
explain select * from t2 where name='Lilu';
301
302
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
302
 
1       SIMPLE  t2      ref     btree_idx,heap_idx      btree_idx       82      const   2       Using where
 
303
1       SIMPLE  t2      ref     btree_idx,heap_idx      btree_idx       82      const   1       Using where
303
304
explain select * from t1 where name='Phil';
304
305
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
305
 
1       SIMPLE  t1      ref     heap_idx,btree_idx      heap_idx        82      const   2       Using where
 
306
1       SIMPLE  t1      ref     heap_idx,btree_idx      btree_idx       82      const   1       Using where
306
307
explain select * from t2 where name='Phil';
307
308
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
308
 
1       SIMPLE  t2      ref     btree_idx,heap_idx      btree_idx       82      const   2       Using where
 
309
1       SIMPLE  t2      ref     btree_idx,heap_idx      btree_idx       82      const   1       Using where
309
310
explain select * from t1 where name='Lilu';
310
311
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
311
 
1       SIMPLE  t1      ref     heap_idx,btree_idx      heap_idx        82      const   2       Using where
 
312
1       SIMPLE  t1      ref     heap_idx,btree_idx      btree_idx       82      const   1       Using where
312
313
explain select * from t2 where name='Lilu';
313
314
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
314
 
1       SIMPLE  t2      ref     btree_idx,heap_idx      btree_idx       82      const   2       Using where
 
315
1       SIMPLE  t2      ref     btree_idx,heap_idx      btree_idx       82      const   1       Using where
315
316
insert into t1 (name) select name from t2;
316
317
insert into t1 (name) select name from t2;
317
318
insert into t1 (name) select name from t2;
326
327
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
327
328
1       SIMPLE  t1      ref     heap_idx        heap_idx        82      const   9       Using where
328
329
show index from t1;
329
 
Table   Unique  Key_name        Seq_in_index    Column_name
330
 
t1      YES     PRIMARY 1       id
331
 
t1      NO      heap_idx        1       name
332
 
t1      NO      btree_idx       1       name
 
330
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
331
t1      0       PRIMARY 1       id      NULL    91      NULL    NULL            HASH            
 
332
t1      1       heap_idx        1       name    NULL    10      NULL    NULL            HASH            
 
333
t1      1       btree_idx       1       name    A       NULL    NULL    NULL            BTREE           
333
334
show index from t1;
334
 
Table   Unique  Key_name        Seq_in_index    Column_name
335
 
t1      YES     PRIMARY 1       id
336
 
t1      NO      heap_idx        1       name
337
 
t1      NO      btree_idx       1       name
338
 
create temporary table t3
 
335
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
336
t1      0       PRIMARY 1       id      NULL    91      NULL    NULL            HASH            
 
337
t1      1       heap_idx        1       name    NULL    10      NULL    NULL            HASH            
 
338
t1      1       btree_idx       1       name    A       NULL    NULL    NULL            BTREE           
 
339
create table t3
339
340
(
340
341
a varchar(20) not null,
341
342
b varchar(20) not null,
342
343
key (a,b)
343
 
) engine=MEMORY;
 
344
) engine=heap;
344
345
insert into t3 select name, name from t1;
345
346
show index from t3;
346
 
Table   Unique  Key_name        Seq_in_index    Column_name
347
 
t3      NO      a       1       a
348
 
t3      NO      a       2       b
 
347
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
348
t3      1       a       1       a       NULL    NULL    NULL    NULL            HASH            
 
349
t3      1       a       2       b       NULL    13      NULL    NULL            HASH            
349
350
show index from t3;
350
 
Table   Unique  Key_name        Seq_in_index    Column_name
351
 
t3      NO      a       1       a
352
 
t3      NO      a       2       b
 
351
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
352
t3      1       a       1       a       NULL    NULL    NULL    NULL            HASH            
 
353
t3      1       a       2       b       NULL    13      NULL    NULL            HASH            
353
354
explain select * from t1 ignore key(btree_idx), t3 where t1.name='matt' and t3.a = concat('',t1.name) and t3.b=t1.name;
354
355
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
355
356
1       SIMPLE  t1      ref     heap_idx        heap_idx        82      const   9       Using where
366
367
1       SIMPLE  t1      range   a       a       5       NULL    4       Using where
367
368
drop table t1;
368
369
End of 4.1 tests
369
 
CREATE TEMPORARY TABLE t1(col1 VARCHAR(32) COLLATE utf8_bin NOT NULL, 
 
370
CREATE TABLE t1(col1 VARCHAR(32) COLLATE utf8_bin NOT NULL, 
370
371
col2 VARCHAR(32) COLLATE utf8_bin NOT NULL, 
371
372
UNIQUE KEY key1 USING HASH (col1, col2)) ENGINE=MEMORY;
372
373
INSERT INTO t1 VALUES('A', 'A');
373
374
INSERT INTO t1 VALUES('A ', 'A ');
374
375
ERROR 23000: Duplicate entry 'A -A ' for key 'key1'
375
376
DROP TABLE t1;
376
 
CREATE TEMPORARY TABLE t1(col1 VARCHAR(32) COLLATE utf8_bin NOT NULL, 
 
377
CREATE TABLE t1(col1 VARCHAR(32) COLLATE utf8_bin NOT NULL, 
377
378
col2 VARCHAR(32) COLLATE utf8_bin NOT NULL, 
378
379
UNIQUE KEY key1 USING HASH (col1, col2)) ENGINE=MEMORY;
379
380
INSERT INTO t1 VALUES('A', 'A');