~linuxjedi/drizzle/trunk-bug-667053

« back to all changes in this revision

Viewing changes to mysql-test/r/heap_hash.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
drop table if exists t1,t2;
 
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
insert into t1 values(1,1),(2,2),(3,3),(4,4);
 
4
delete from t1 where a=1 or a=0;
 
5
show keys from t1;
 
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            
 
8
select * from t1;
 
9
a       b
 
10
2       2
 
11
3       3
 
12
4       4
 
13
select * from t1 where a=4;
 
14
a       b
 
15
4       4
 
16
update t1 set b=5 where a=4;
 
17
update t1 set b=b+1 where a>=3;
 
18
replace t1 values (3,3);
 
19
select * from t1;
 
20
a       b
 
21
2       2
 
22
3       3
 
23
4       6
 
24
alter table t1 add c int not null, add key using HASH (c,a);
 
25
drop table t1;
 
26
create table t1 (a int not null,b int not null, primary key using HASH (a)) engine=heap comment="testing heaps";
 
27
insert into t1 values(1,1),(2,2),(3,3),(4,4);
 
28
delete from t1 where a > 0;
 
29
select * from t1;
 
30
a       b
 
31
drop table t1;
 
32
create table t1 (a int not null,b int not null, primary key using HASH (a)) engine=heap comment="testing heaps";
 
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=myisam, comment="new myisam table";
 
35
select * from t1;
 
36
a       b
 
37
1       1
 
38
2       2
 
39
3       3
 
40
4       4
 
41
drop table t1;
 
42
create table t1 (a int not null) engine=heap;
 
43
insert into t1 values (869751),(736494),(226312),(802616),(728912);
 
44
select * from t1 where a > 736494;
 
45
a
 
46
869751
 
47
802616
 
48
alter table t1 add unique uniq_id using HASH (a);
 
49
select * from t1 where a > 736494;
 
50
a
 
51
869751
 
52
802616
 
53
select * from t1 where a = 736494;
 
54
a
 
55
736494
 
56
select * from t1 where a=869751 or a=736494;
 
57
a
 
58
736494
 
59
869751
 
60
select * from t1 where a in (869751,736494,226312,802616);
 
61
a
 
62
226312
 
63
736494
 
64
802616
 
65
869751
 
66
alter table t1 engine=myisam;
 
67
explain select * from t1 where a in (869751,736494,226312,802616);
 
68
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
69
1       SIMPLE  t1      range   uniq_id uniq_id 4       NULL    4       Using where; Using index
 
70
drop table t1;
 
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;
 
73
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
 
74
select * from t1 where x=1;
 
75
x       y
 
76
1       3
 
77
1       1
 
78
select * from t1,t1 as t2 where t1.x=t2.y;
 
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
explain select * from t1,t1 as t2 where t1.x=t2.y;
 
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       
 
90
drop table t1;
 
91
create table t1 (a int) engine=heap;
 
92
insert into t1 values(1);
 
93
select max(a) from t1;
 
94
max(a)
 
95
1
 
96
drop table t1;
 
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;
 
98
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
 
99
select * from t1 where a=1;
 
100
a       b
 
101
1       6
 
102
1       5
 
103
1       4
 
104
1       3
 
105
1       2
 
106
1       1
 
107
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
 
108
select * from t1 where a=1;
 
109
a       b
 
110
1       6
 
111
1       5
 
112
1       4
 
113
1       3
 
114
1       2
 
115
1       1
 
116
1       6
 
117
1       5
 
118
1       4
 
119
1       3
 
120
1       2
 
121
1       1
 
122
drop table t1;
 
123
create table t1 (id int unsigned not null, primary key  using HASH (id)) engine=HEAP;
 
124
insert into t1 values(1);
 
125
select max(id) from t1;
 
126
max(id)
 
127
1
 
128
insert into t1 values(2);
 
129
select max(id) from t1;
 
130
max(id)
 
131
2
 
132
replace into t1 values(1);
 
133
drop table t1;
 
134
create table t1 (n int) engine=heap;
 
135
drop table t1;
 
136
create table t1 (n int) engine=heap;
 
137
drop table if exists t1;
 
138
CREATE table t1(f1 int not null,f2 char(20) not 
 
139
null,index(f2)) engine=heap;
 
140
INSERT into t1 set f1=12,f2="bill";
 
141
INSERT into t1 set f1=13,f2="bill";
 
142
INSERT into t1 set f1=14,f2="bill";
 
143
INSERT into t1 set f1=15,f2="bill";
 
144
INSERT into t1 set f1=16,f2="ted";
 
145
INSERT into t1 set f1=12,f2="ted";
 
146
INSERT into t1 set f1=12,f2="ted";
 
147
INSERT into t1 set f1=12,f2="ted";
 
148
INSERT into t1 set f1=12,f2="ted";
 
149
delete from t1 where f2="bill";
 
150
select * from t1;
 
151
f1      f2
 
152
16      ted
 
153
12      ted
 
154
12      ted
 
155
12      ted
 
156
12      ted
 
157
drop table t1;
 
158
create table t1 (btn char(10) not null, key using HASH (btn)) engine=heap;
 
159
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
 
160
explain select * from t1 where btn like "q%";
 
161
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
162
1       SIMPLE  t1      ALL     btn     NULL    NULL    NULL    14      Using where
 
163
select * from t1 where btn like "q%";
 
164
btn
 
165
alter table t1 add column new_col char(1) not null, add key using HASH (btn,new_col), drop key btn;
 
166
update t1 set new_col=left(btn,1);
 
167
explain select * from t1 where btn="a";
 
168
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
169
1       SIMPLE  t1      ALL     btn     NULL    NULL    NULL    14      Using where
 
170
explain select * from t1 where btn="a" and new_col="a";
 
171
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
172
1       SIMPLE  t1      ref     btn     btn     11      const,const     2       Using where
 
173
drop table t1;
 
174
CREATE TABLE t1 (
 
175
a int default NULL,
 
176
b int default NULL,
 
177
KEY a using HASH (a),
 
178
UNIQUE b using HASH (b)
 
179
) engine=heap;
 
180
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
 
181
SELECT * FROM t1 WHERE a=NULL;
 
182
a       b
 
183
explain SELECT * FROM t1 WHERE a IS NULL;
 
184
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
185
1       SIMPLE  t1      ref     a       a       5       const   2       Using where
 
186
SELECT * FROM t1 WHERE a<=>NULL;
 
187
a       b
 
188
NULL    99
 
189
SELECT * FROM t1 WHERE b=NULL;
 
190
a       b
 
191
explain SELECT * FROM t1 WHERE b IS NULL;
 
192
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
193
1       SIMPLE  t1      ref     b       b       5       const   1       Using where
 
194
SELECT * FROM t1 WHERE b<=>NULL;
 
195
a       b
 
196
99      NULL
 
197
INSERT INTO t1 VALUES (1,3);
 
198
ERROR 23000: Duplicate entry '3' for key 'b'
 
199
DROP TABLE t1;
 
200
CREATE TABLE t1 (a int not null, primary key using HASH (a)) engine=heap;
 
201
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
 
202
DELETE from t1 where a < 100;
 
203
SELECT * from t1;
 
204
a
 
205
DROP TABLE t1;
 
206
create table t1
 
207
(
 
208
a char(8) not null,
 
209
b char(20) not null,
 
210
c int not null,
 
211
key (a)
 
212
) engine=heap;
 
213
insert into t1 values ('aaaa', 'prefill-hash=5',0);
 
214
insert into t1 values ('aaab', 'prefill-hash=0',0);
 
215
insert into t1 values ('aaac', 'prefill-hash=7',0);
 
216
insert into t1 values ('aaad', 'prefill-hash=2',0);
 
217
insert into t1 values ('aaae', 'prefill-hash=1',0);
 
218
insert into t1 values ('aaaf', 'prefill-hash=4',0);
 
219
insert into t1 values ('aaag', 'prefill-hash=3',0);
 
220
insert into t1 values ('aaah', 'prefill-hash=6',0);
 
221
explain select * from t1 where a='aaaa';
 
222
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
223
1       SIMPLE  t1      ref     a       a       8       const   2       Using where
 
224
explain select * from t1 where a='aaab';
 
225
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
226
1       SIMPLE  t1      ref     a       a       8       const   2       Using where
 
227
explain select * from t1 where a='aaac';
 
228
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
229
1       SIMPLE  t1      ref     a       a       8       const   2       Using where
 
230
explain select * from t1 where a='aaad';
 
231
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
232
1       SIMPLE  t1      ref     a       a       8       const   2       Using where
 
233
insert into t1 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       8       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       8       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       8       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       8       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       8       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       8       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       8       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       8       const   2       Using where
 
260
create table t2 as select * from t1;
 
261
delete from t1;
 
262
insert into t1 select * from t2;
 
263
explain select * from t1 where a='aaaa';
 
264
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
265
1       SIMPLE  t1      ref     a       a       8       const   2       Using where
 
266
explain select * from t1 where a='aaab';
 
267
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
268
1       SIMPLE  t1      ref     a       a       8       const   2       Using where
 
269
explain select * from t1 where a='aaac';
 
270
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
271
1       SIMPLE  t1      ref     a       a       8       const   2       Using where
 
272
explain select * from t1 where a='aaad';
 
273
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
274
1       SIMPLE  t1      ref     a       a       8       const   2       Using where
 
275
drop table t1, t2;
 
276
create table t1 (
 
277
id int unsigned not null primary key auto_increment, 
 
278
name varchar(20) not null,
 
279
index heap_idx(name),
 
280
index btree_idx using btree(name)
 
281
) engine=heap;
 
282
create table t2 (
 
283
id int unsigned not null primary key auto_increment, 
 
284
name varchar(20) not null,
 
285
index btree_idx using btree(name),
 
286
index heap_idx(name)
 
287
) engine=heap;
 
288
insert into t1 (name) values ('Matt'), ('Lilu'), ('Corbin'), ('Carly'), 
 
289
('Suzy'), ('Hoppy'), ('Burrito'), ('Mimi'), ('Sherry'), ('Ben'), ('Phil'), 
 
290
('Emily'), ('Mike');
 
291
insert into t2 select * from t1;
 
292
explain select * from t1 where name='matt';
 
293
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
294
1       SIMPLE  t1      ref     heap_idx,btree_idx      btree_idx       22      const   1       Using where
 
295
explain select * from t2 where name='matt';
 
296
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
297
1       SIMPLE  t2      ref     btree_idx,heap_idx      btree_idx       22      const   1       Using where
 
298
explain select * from t1 where name='Lilu';
 
299
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
300
1       SIMPLE  t1      ref     heap_idx,btree_idx      btree_idx       22      const   1       Using where
 
301
explain select * from t2 where name='Lilu';
 
302
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
303
1       SIMPLE  t2      ref     btree_idx,heap_idx      btree_idx       22      const   1       Using where
 
304
explain select * from t1 where name='Phil';
 
305
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
306
1       SIMPLE  t1      ref     heap_idx,btree_idx      btree_idx       22      const   1       Using where
 
307
explain select * from t2 where name='Phil';
 
308
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
309
1       SIMPLE  t2      ref     btree_idx,heap_idx      btree_idx       22      const   1       Using where
 
310
explain select * from t1 where name='Lilu';
 
311
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
312
1       SIMPLE  t1      ref     heap_idx,btree_idx      btree_idx       22      const   1       Using where
 
313
explain select * from t2 where name='Lilu';
 
314
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
315
1       SIMPLE  t2      ref     btree_idx,heap_idx      btree_idx       22      const   1       Using where
 
316
insert into t1 (name) select name from t2;
 
317
insert into t1 (name) select name from t2;
 
318
insert into t1 (name) select name from t2;
 
319
insert into t1 (name) select name from t2;
 
320
insert into t1 (name) select name from t2;
 
321
insert into t1 (name) select name from t2;
 
322
flush tables;
 
323
select count(*) from t1 where name='Matt';
 
324
count(*)
 
325
7
 
326
explain select * from t1 ignore index (btree_idx) where name='matt';
 
327
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
328
1       SIMPLE  t1      ref     heap_idx        heap_idx        22      const   7       Using where
 
329
show index from t1;
 
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    13      NULL    NULL            HASH            
 
333
t1      1       btree_idx       1       name    A       NULL    NULL    NULL            BTREE           
 
334
show index from t1;
 
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    13      NULL    NULL            HASH            
 
338
t1      1       btree_idx       1       name    A       NULL    NULL    NULL            BTREE           
 
339
create table t3
 
340
(
 
341
a varchar(20) not null,
 
342
b varchar(20) not null,
 
343
key (a,b)
 
344
) engine=heap;
 
345
insert into t3 select name, name from t1;
 
346
show index from t3;
 
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            
 
350
show index from t3;
 
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            
 
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;
 
355
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
356
1       SIMPLE  t1      ref     heap_idx        heap_idx        22      const   7       Using where
 
357
1       SIMPLE  t3      ref     a       a       44      func,const      7       Using where
 
358
drop table t1, t2, t3;
 
359
create temporary table t1 ( a int, index (a) ) engine=memory;
 
360
insert into t1 values (1),(2),(3),(4),(5);
 
361
select a from t1 where a in (1,3);
 
362
a
 
363
1
 
364
3
 
365
explain select a from t1 where a in (1,3);
 
366
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
367
1       SIMPLE  t1      range   a       a       5       NULL    4       Using where
 
368
drop table t1;
 
369
End of 4.1 tests
 
370
CREATE TABLE t1(col1 VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, 
 
371
col2 VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, 
 
372
UNIQUE KEY key1 USING HASH (col1, col2)) ENGINE=MEMORY;
 
373
INSERT INTO t1 VALUES('A', 'A');
 
374
INSERT INTO t1 VALUES('A ', 'A ');
 
375
ERROR 23000: Duplicate entry 'A -A ' for key 'key1'
 
376
DROP TABLE t1;
 
377
CREATE TABLE t1(col1 VARCHAR(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, 
 
378
col2 VARCHAR(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, 
 
379
UNIQUE KEY key1 USING HASH (col1, col2)) ENGINE=MEMORY;
 
380
INSERT INTO t1 VALUES('A', 'A');
 
381
INSERT INTO t1 VALUES('A ', 'A ');
 
382
ERROR 23000: Duplicate entry 'A -A ' for key 'key1'
 
383
DROP TABLE t1;
 
384
End of 5.0 tests