~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/heap_hash.test

  • Committer: Brian Aker
  • Date: 2009-01-17 02:46:52 UTC
  • Revision ID: brian@gir-3.local-20090117024652-4ducefje08ajbs1q
Refactor append_identifier and remove dead OPTION_QUOTE_SHOW_CREATE option
(we always quote).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#
2
 
# Test of MEMORY tables.
 
2
# Test of heap tables.
3
3
#
4
4
 
5
5
--disable_warnings
6
6
drop table if exists t1,t2;
7
7
--enable_warnings
8
8
 
9
 
create temporary table t1 (a int not null,b int not null, primary key using HASH (a)) engine=MEMORY comment="testing heaps";
 
9
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;
10
10
insert into t1 values(1,1),(2,2),(3,3),(4,4);
11
11
delete from t1 where a=1 or a=0;
12
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
13
 
show table status like "t1";
 
12
#show table status like "t1";
14
13
show keys from t1;
15
14
select * from t1;
16
15
select * from t1 where a=4;
21
20
alter table t1 add c int not null, add key using HASH (c,a);
22
21
drop table t1;
23
22
 
24
 
create temporary table t1 (a int not null,b int not null, primary key using HASH (a)) engine=MEMORY comment="testing heaps";
 
23
create table t1 (a int not null,b int not null, primary key using HASH (a)) engine=heap comment="testing heaps";
25
24
insert into t1 values(1,1),(2,2),(3,3),(4,4);
26
25
delete from t1 where a > 0;
27
26
select * from t1;
28
27
drop table t1;
29
28
 
30
 
create temporary table t1 (a int not null,b int not null, primary key using HASH (a)) engine=MEMORY comment="testing heaps";
 
29
create table t1 (a int not null,b int not null, primary key using HASH (a)) engine=heap comment="testing heaps";
31
30
insert into t1 values(1,1),(2,2),(3,3),(4,4);
32
 
alter table t1 modify a int not null auto_increment, engine=innodb, comment="new innodb table";
33
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
34
 
show table status like "t1";
 
31
alter table t1 modify a int not null auto_increment, engine=myisam, comment="new myisam table";
 
32
#show table status like "t1";
35
33
select * from t1;
36
34
drop table t1;
37
35
 
38
 
create temporary table t1 (a int not null) engine=MEMORY;
 
36
create table t1 (a int not null) engine=heap;
39
37
insert into t1 values (869751),(736494),(226312),(802616),(728912);
40
38
select * from t1 where a > 736494;
41
39
alter table t1 add unique uniq_id using HASH (a);
43
41
select * from t1 where a = 736494;
44
42
select * from t1 where a=869751 or a=736494;
45
43
select * from t1 where a in (869751,736494,226312,802616);
46
 
alter table t1 engine=innodb;
 
44
alter table t1 engine=myisam;
47
45
explain select * from t1 where a in (869751,736494,226312,802616);
48
46
drop table t1;
49
47
 
50
 
create temporary table t1 (x int not null, y int not null, key x  using HASH (x), unique y  using HASH (y))
51
 
engine=MEMORY;
 
48
create table t1 (x int not null, y int not null, key x  using HASH (x), unique y  using HASH (y))
 
49
engine=heap;
52
50
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
53
51
select * from t1 where x=1;
54
52
select * from t1,t1 as t2 where t1.x=t2.y;
55
53
explain select * from t1,t1 as t2 where t1.x=t2.y;
56
54
drop table t1;
57
55
 
58
 
create temporary table t1 (a int) engine=MEMORY;
 
56
create table t1 (a int) engine=heap;
59
57
insert into t1 values(1);
60
58
select max(a) from t1;
61
59
drop table t1;
62
60
 
63
 
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;
 
61
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;
64
62
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
65
63
select * from t1 where a=1; 
66
64
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
67
65
select * from t1 where a=1;
68
66
drop table t1;
69
67
 
70
 
create temporary table t1 (id int not null, primary key  using HASH (id)) engine=MEMORY;
 
68
create table t1 (id int not null, primary key  using HASH (id)) engine=HEAP;
71
69
insert into t1 values(1);
72
70
select max(id) from t1; 
73
71
insert into t1 values(2);
77
73
replace into t1 values(1);
78
74
drop table t1;
79
75
 
80
 
create temporary table t1 (n int) engine=MEMORY;
 
76
create table t1 (n int) engine=heap;
81
77
drop table t1;
82
78
 
83
 
create temporary table t1 (n int) engine=MEMORY;
 
79
create table t1 (n int) engine=heap;
84
80
drop table if exists t1;
85
81
 
86
82
# Test of non unique index
87
83
 
88
 
CREATE TEMPORARY table t1(f1 int not null,f2 char(20) not 
89
 
null,index(f2)) engine=MEMORY;
 
84
CREATE table t1(f1 int not null,f2 char(20) not 
 
85
null,index(f2)) engine=heap;
90
86
INSERT into t1 set f1=12,f2="bill";
91
87
INSERT into t1 set f1=13,f2="bill";
92
88
INSERT into t1 set f1=14,f2="bill";
104
100
# Test when using part key searches
105
101
#
106
102
 
107
 
create temporary table t1 (btn char(10) not null, key using HASH (btn)) engine=MEMORY;
 
103
create table t1 (btn char(10) not null, key using HASH (btn)) engine=heap;
108
104
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
109
105
explain select * from t1 where btn like "q%";
110
106
select * from t1 where btn like "q%";
118
114
# Test of NULL keys
119
115
#
120
116
 
121
 
CREATE TEMPORARY TABLE t1 (
 
117
CREATE TABLE t1 (
122
118
  a int default NULL,
123
119
  b int default NULL,
124
120
  KEY a using HASH (a),
125
121
  UNIQUE b using HASH (b)
126
 
) engine=MEMORY;
 
122
) engine=heap;
127
123
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
128
124
SELECT * FROM t1 WHERE a=NULL;
129
125
explain SELECT * FROM t1 WHERE a IS NULL;
140
136
# Test when deleting all rows
141
137
#
142
138
 
143
 
CREATE TEMPORARY TABLE t1 (a int not null, primary key using HASH (a)) engine=MEMORY;
 
139
CREATE TABLE t1 (a int not null, primary key using HASH (a)) engine=heap;
144
140
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
145
141
DELETE from t1 where a < 100;
146
142
SELECT * from t1;
150
146
#
151
147
# Hash index # records estimate test
152
148
#
153
 
create temporary table t1
 
149
create table t1
154
150
(
155
151
  a char(8) not null,
156
152
  b char(20) not null,
157
153
  c int not null,
158
154
  key (a)
159
 
) engine=MEMORY;
 
155
) engine=heap;
160
156
 
161
157
insert into t1 values ('aaaa', 'prefill-hash=5',0);
162
158
insert into t1 values ('aaab', 'prefill-hash=0',0);
171
167
explain select * from t1 where a='aaab';
172
168
explain select * from t1 where a='aaac';
173
169
explain select * from t1 where a='aaad';
174
170
insert into t1 select * from t1;
175
171
 
176
172
# avoid statistics differences between normal and ps-protocol tests
189
184
explain select * from t1 where a='aaad';
190
185
 
191
186
# Check if delete_all_rows() updates #hash_buckets
192
 
create temporary table t2 as select * from t1;
 
187
create table t2 as select * from t1;
193
188
delete from t1;
194
189
insert into t1 select * from t2;
195
190
explain select * from t1 where a='aaaa';
200
195
 
201
196
 
202
197
# Btree and hash index use costs. 
203
 
create temporary table t1 (
 
198
create table t1 (
204
199
  id int not null primary key auto_increment, 
205
200
  name varchar(20) not null,
206
201
  index heap_idx(name),
207
202
  index btree_idx using btree(name)
208
 
) engine=MEMORY;
 
203
) engine=heap;
209
204
 
210
 
create temporary table t2 (
 
205
create table t2 (
211
206
  id int not null primary key auto_increment, 
212
207
  name varchar(20) not null,
213
208
  index btree_idx using btree(name),
214
209
  index heap_idx(name)
215
 
) engine=MEMORY;
 
210
) engine=heap;
216
211
 
217
212
insert into t1 (name) values ('Matt'), ('Lilu'), ('Corbin'), ('Carly'), 
218
213
  ('Suzy'), ('Hoppy'), ('Burrito'), ('Mimi'), ('Sherry'), ('Ben'), ('Phil'), 
243
238
 
244
239
show index from t1;
245
240
 
246
 
create temporary table t3
 
241
create table t3
247
242
(
248
243
  a varchar(20) not null,
249
244
  b varchar(20) not null,
250
245
  key (a,b)
251
 
) engine=MEMORY;
 
246
) engine=heap;
252
247
insert into t3 select name, name from t1;
253
248
show index from t3;
254
249
show index from t3;
273
268
# Check that HASH indexes disregard trailing spaces when comparing 
274
269
# strings with binary collations
275
270
 
276
 
CREATE TEMPORARY TABLE t1(col1 VARCHAR(32) COLLATE utf8_bin NOT NULL, 
 
271
CREATE TABLE t1(col1 VARCHAR(32) COLLATE utf8_bin NOT NULL, 
277
272
                col2 VARCHAR(32) COLLATE utf8_bin NOT NULL, 
278
273
                UNIQUE KEY key1 USING HASH (col1, col2)) ENGINE=MEMORY;
279
274
INSERT INTO t1 VALUES('A', 'A');
280
275
--error ER_DUP_ENTRY
281
276
INSERT INTO t1 VALUES('A ', 'A ');
282
277
DROP TABLE t1;
283
 
CREATE TEMPORARY TABLE t1(col1 VARCHAR(32) COLLATE utf8_bin NOT NULL, 
 
278
CREATE TABLE t1(col1 VARCHAR(32) COLLATE utf8_bin NOT NULL, 
284
279
                col2 VARCHAR(32) COLLATE utf8_bin NOT NULL, 
285
280
                UNIQUE KEY key1 USING HASH (col1, col2)) ENGINE=MEMORY;
286
281
INSERT INTO t1 VALUES('A', 'A');