~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/heap_hash.test

  • Committer: Brian Aker
  • Date: 2010-04-05 23:46:43 UTC
  • Revision ID: brian@gaz-20100405234643-0he3xnj902rc70r8
Fixing tests to work with PBXT.

Show diffs side-by-side

added added

removed removed

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