~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/heap_hash.result

  • Committer: Brian Aker
  • Date: 2008-08-16 15:41:14 UTC
  • mto: This revision was merged to the branch mainline in revision 346.
  • Revision ID: brian@tangent.org-20080816154114-eufmwf31p6ie1nd6
Cleaned up depend in Proto utils. Modified int to bool. Put TmpTable class
into play.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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=heap comment="testing heaps";
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 temporary 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 temporary 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=innodb, comment="new innodb 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 temporary 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=innodb;
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      index   uniq_id uniq_id 4       NULL    5       Using where; Using index
70
 
drop table t1;
71
 
create temporary 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
 
ERROR HY000: Can't reopen table: 't1'
80
 
explain select * from t1,t1 as t2 where t1.x=t2.y;
81
 
ERROR HY000: Can't reopen table: 't1'
82
 
drop table t1;
83
 
create temporary table t1 (a int) engine=heap;
84
 
insert into t1 values(1);
85
 
select max(a) from t1;
86
 
max(a)
87
 
1
88
 
drop table t1;
89
 
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=HEAP;
90
 
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
91
 
select * from t1 where a=1;
92
 
a       b
93
 
1       6
94
 
1       5
95
 
1       4
96
 
1       3
97
 
1       2
98
 
1       1
99
 
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
100
 
select * from t1 where a=1;
101
 
a       b
102
 
1       6
103
 
1       5
104
 
1       4
105
 
1       3
106
 
1       2
107
 
1       1
108
 
1       6
109
 
1       5
110
 
1       4
111
 
1       3
112
 
1       2
113
 
1       1
114
 
drop table t1;
115
 
create temporary table t1 (id int not null, primary key  using HASH (id)) engine=HEAP;
116
 
insert into t1 values(1);
117
 
select max(id) from t1;
118
 
max(id)
119
 
1
120
 
insert into t1 values(2);
121
 
select max(id) from t1;
122
 
max(id)
123
 
2
124
 
replace into t1 values(1);
125
 
drop table t1;
126
 
create temporary table t1 (n int) engine=heap;
127
 
drop table t1;
128
 
create temporary table t1 (n int) engine=heap;
129
 
drop table if exists t1;
130
 
CREATE TEMPORARY table t1(f1 int not null,f2 char(20) not 
131
 
null,index(f2)) engine=heap;
132
 
INSERT into t1 set f1=12,f2="bill";
133
 
INSERT into t1 set f1=13,f2="bill";
134
 
INSERT into t1 set f1=14,f2="bill";
135
 
INSERT into t1 set f1=15,f2="bill";
136
 
INSERT into t1 set f1=16,f2="ted";
137
 
INSERT into t1 set f1=12,f2="ted";
138
 
INSERT into t1 set f1=12,f2="ted";
139
 
INSERT into t1 set f1=12,f2="ted";
140
 
INSERT into t1 set f1=12,f2="ted";
141
 
delete from t1 where f2="bill";
142
 
select * from t1;
143
 
f1      f2
144
 
16      ted
145
 
12      ted
146
 
12      ted
147
 
12      ted
148
 
12      ted
149
 
drop table t1;
150
 
create temporary table t1 (btn char(10) not null, key using HASH (btn)) engine=heap;
151
 
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
152
 
explain select * from t1 where btn like "q%";
153
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
154
 
1       SIMPLE  t1      ALL     btn     NULL    NULL    NULL    14      Using where
155
 
select * from t1 where btn like "q%";
156
 
btn
157
 
alter table t1 add column new_col char(1) not null, add key using HASH (btn,new_col), drop key btn;
158
 
update t1 set new_col=left(btn,1);
159
 
explain select * from t1 where btn="a";
160
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
161
 
1       SIMPLE  t1      ALL     btn     NULL    NULL    NULL    14      Using where
162
 
explain select * from t1 where btn="a" and new_col="a";
163
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
164
 
1       SIMPLE  t1      ref     btn     btn     48      const,const     2       Using where
165
 
drop table t1;
166
 
CREATE TEMPORARY TABLE t1 (
167
 
a int default NULL,
168
 
b int default NULL,
169
 
KEY a using HASH (a),
170
 
UNIQUE b using HASH (b)
171
 
) engine=heap;
172
 
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
173
 
SELECT * FROM t1 WHERE a=NULL;
174
 
a       b
175
 
explain SELECT * FROM t1 WHERE a IS NULL;
176
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
177
 
1       SIMPLE  t1      ref     a       a       5       const   2       Using where
178
 
SELECT * FROM t1 WHERE a<=>NULL;
179
 
a       b
180
 
NULL    99
181
 
SELECT * FROM t1 WHERE b=NULL;
182
 
a       b
183
 
explain SELECT * FROM t1 WHERE b IS NULL;
184
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
185
 
1       SIMPLE  t1      ref     b       b       5       const   1       Using where
186
 
SELECT * FROM t1 WHERE b<=>NULL;
187
 
a       b
188
 
99      NULL
189
 
INSERT INTO t1 VALUES (1,3);
190
 
ERROR 23000: Duplicate entry '3' for key 'b'
191
 
DROP TABLE t1;
192
 
CREATE TEMPORARY TABLE t1 (a int not null, primary key using HASH (a)) engine=heap;
193
 
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
194
 
DELETE from t1 where a < 100;
195
 
SELECT * from t1;
196
 
a
197
 
DROP TABLE t1;
198
 
create temporary table t1
199
 
(
200
 
a char(8) not null,
201
 
b char(20) not null,
202
 
c int not null,
203
 
key (a)
204
 
) engine=heap;
205
 
insert into t1 values ('aaaa', 'prefill-hash=5',0);
206
 
insert into t1 values ('aaab', 'prefill-hash=0',0);
207
 
insert into t1 values ('aaac', 'prefill-hash=7',0);
208
 
insert into t1 values ('aaad', 'prefill-hash=2',0);
209
 
insert into t1 values ('aaae', 'prefill-hash=1',0);
210
 
insert into t1 values ('aaaf', 'prefill-hash=4',0);
211
 
insert into t1 values ('aaag', 'prefill-hash=3',0);
212
 
insert into t1 values ('aaah', 'prefill-hash=6',0);
213
 
explain select * from t1 where a='aaaa';
214
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
215
 
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
216
 
explain select * from t1 where a='aaab';
217
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
218
 
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
219
 
explain select * from t1 where a='aaac';
220
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
221
 
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
222
 
explain select * from t1 where a='aaad';
223
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
224
 
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
225
 
insert into t1 select * from t1;
226
 
ERROR HY000: Can't reopen table: 't1'
227
 
flush tables;
228
 
explain select * from t1 where a='aaaa';
229
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
230
 
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
231
 
explain select * from t1 where a='aaab';
232
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
233
 
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
234
 
explain select * from t1 where a='aaac';
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='aaad';
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
 
flush tables;
241
 
explain select * from t1 where a='aaaa';
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='aaab';
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
 
explain select * from t1 where a='aaac';
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='aaad';
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
 
create temporary table t2 as select * from t1;
254
 
delete from t1;
255
 
insert into t1 select * from t2;
256
 
explain select * from t1 where a='aaaa';
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
 
explain select * from t1 where a='aaab';
260
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
261
 
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
262
 
explain select * from t1 where a='aaac';
263
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
264
 
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
265
 
explain select * from t1 where a='aaad';
266
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
267
 
1       SIMPLE  t1      ref     a       a       34      const   2       Using where
268
 
drop table t1, t2;
269
 
create temporary table t1 (
270
 
id int not null primary key auto_increment, 
271
 
name varchar(20) not null,
272
 
index heap_idx(name),
273
 
index btree_idx using btree(name)
274
 
) engine=heap;
275
 
create temporary table t2 (
276
 
id int not null primary key auto_increment, 
277
 
name varchar(20) not null,
278
 
index btree_idx using btree(name),
279
 
index heap_idx(name)
280
 
) engine=heap;
281
 
insert into t1 (name) values ('Matt'), ('Lilu'), ('Corbin'), ('Carly'), 
282
 
('Suzy'), ('Hoppy'), ('Burrito'), ('Mimi'), ('Sherry'), ('Ben'), ('Phil'), 
283
 
('Emily'), ('Mike');
284
 
insert into t2 select * from t1;
285
 
explain select * from t1 where name='matt';
286
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
287
 
1       SIMPLE  t1      ref     heap_idx,btree_idx      btree_idx       82      const   1       Using where
288
 
explain select * from t2 where name='matt';
289
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
290
 
1       SIMPLE  t2      ref     btree_idx,heap_idx      btree_idx       82      const   1       Using where
291
 
explain select * from t1 where name='Lilu';
292
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
293
 
1       SIMPLE  t1      ref     heap_idx,btree_idx      btree_idx       82      const   1       Using where
294
 
explain select * from t2 where name='Lilu';
295
 
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   1       Using where
297
 
explain select * from t1 where name='Phil';
298
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
299
 
1       SIMPLE  t1      ref     heap_idx,btree_idx      btree_idx       82      const   1       Using where
300
 
explain select * from t2 where name='Phil';
301
 
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   1       Using where
303
 
explain select * from t1 where name='Lilu';
304
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
305
 
1       SIMPLE  t1      ref     heap_idx,btree_idx      btree_idx       82      const   1       Using where
306
 
explain select * from t2 where name='Lilu';
307
 
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   1       Using where
309
 
insert into t1 (name) select name from t2;
310
 
insert into t1 (name) select name from t2;
311
 
insert into t1 (name) select name from t2;
312
 
insert into t1 (name) select name from t2;
313
 
insert into t1 (name) select name from t2;
314
 
insert into t1 (name) select name from t2;
315
 
flush tables;
316
 
select count(*) from t1 where name='Matt';
317
 
count(*)
318
 
7
319
 
explain select * from t1 ignore index (btree_idx) where name='matt';
320
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
321
 
1       SIMPLE  t1      ref     heap_idx        heap_idx        82      const   9       Using where
322
 
show index from t1;
323
 
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
324
 
t1      0       PRIMARY 1       id      NULL    91      NULL    NULL            HASH            
325
 
t1      1       heap_idx        1       name    NULL    10      NULL    NULL            HASH            
326
 
t1      1       btree_idx       1       name    A       NULL    NULL    NULL            BTREE           
327
 
show index from t1;
328
 
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
329
 
t1      0       PRIMARY 1       id      NULL    91      NULL    NULL            HASH            
330
 
t1      1       heap_idx        1       name    NULL    10      NULL    NULL            HASH            
331
 
t1      1       btree_idx       1       name    A       NULL    NULL    NULL            BTREE           
332
 
create temporary table t3
333
 
(
334
 
a varchar(20) not null,
335
 
b varchar(20) not null,
336
 
key (a,b)
337
 
) engine=heap;
338
 
insert into t3 select name, name from t1;
339
 
show index from t3;
340
 
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
341
 
t3      1       a       1       a       NULL    NULL    NULL    NULL            HASH            
342
 
t3      1       a       2       b       NULL    13      NULL    NULL            HASH            
343
 
show index from t3;
344
 
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
345
 
t3      1       a       1       a       NULL    NULL    NULL    NULL            HASH            
346
 
t3      1       a       2       b       NULL    13      NULL    NULL            HASH            
347
 
explain select * from t1 ignore key(btree_idx), t3 where t1.name='matt' and t3.a = concat('',t1.name) and t3.b=t1.name;
348
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
349
 
1       SIMPLE  t1      ref     heap_idx        heap_idx        82      const   9       Using where
350
 
1       SIMPLE  t3      ref     a       a       164     func,const      7       Using where
351
 
drop table t1, t2, t3;
352
 
create temporary table t1 ( a int, index (a) ) engine=memory;
353
 
insert into t1 values (1),(2),(3),(4),(5);
354
 
select a from t1 where a in (1,3);
355
 
a
356
 
1
357
 
3
358
 
explain select a from t1 where a in (1,3);
359
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
360
 
1       SIMPLE  t1      range   a       a       5       NULL    4       Using where
361
 
drop table t1;
362
 
End of 4.1 tests
363
 
CREATE TEMPORARY TABLE t1(col1 VARCHAR(32) COLLATE utf8_bin NOT NULL, 
364
 
col2 VARCHAR(32) COLLATE utf8_bin NOT NULL, 
365
 
UNIQUE KEY key1 USING HASH (col1, col2)) ENGINE=MEMORY;
366
 
INSERT INTO t1 VALUES('A', 'A');
367
 
INSERT INTO t1 VALUES('A ', 'A ');
368
 
ERROR 23000: Duplicate entry 'A -A ' for key 'key1'
369
 
DROP TABLE t1;
370
 
CREATE TEMPORARY TABLE t1(col1 VARCHAR(32) COLLATE utf8_bin NOT NULL, 
371
 
col2 VARCHAR(32) 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
 
End of 5.0 tests