~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysql-test/t/heap_hash.test

Merged in changes. 
Edited a the comment test case so deal with our version bump.

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