~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/heap_hash.test

  • Committer: Padraig O'Sullivan
  • Date: 2009-09-13 01:03:01 UTC
  • mto: (1126.9.2 captain-20090915-01)
  • mto: This revision was merged to the branch mainline in revision 1133.
  • Revision ID: osullivan.padraig@gmail.com-20090913010301-tcvvezipx1124acy
Added calls to the dtrace delete begin/end probes.

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 temporary table t1 (a int not null,b int not null, primary key using HASH (a)) engine=heap 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
 
--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 temporary 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 temporary 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
31
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";
 
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 temporary 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);
48
46
drop table t1;
49
47
 
50
48
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;
 
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
-- error 1137
57
55
explain select * from t1,t1 as t2 where t1.x=t2.y;
58
56
drop table t1;
59
57
 
60
 
create temporary table t1 (a int) engine=MEMORY;
 
58
create temporary table t1 (a int) engine=heap;
61
59
insert into t1 values(1);
62
60
select max(a) from t1;
63
61
drop table t1;
64
62
 
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;
 
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=HEAP;
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
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
69
67
select * from t1 where a=1;
70
68
drop table t1;
71
69
 
72
 
create temporary table t1 (id int not null, primary key  using HASH (id)) engine=MEMORY;
 
70
create temporary table t1 (id int not null, primary key  using HASH (id)) engine=HEAP;
73
71
insert into t1 values(1);
74
72
select max(id) from t1; 
75
73
insert into t1 values(2);
77
75
replace into t1 values(1);
78
76
drop table t1;
79
77
 
80
 
create temporary table t1 (n int) engine=MEMORY;
 
78
create temporary table t1 (n int) engine=heap;
81
79
drop table t1;
82
80
 
83
 
create temporary table t1 (n int) engine=MEMORY;
 
81
create temporary table t1 (n int) engine=heap;
84
82
drop table if exists t1;
85
83
 
86
84
# Test of non unique index
87
85
 
88
86
CREATE TEMPORARY table t1(f1 int not null,f2 char(20) not 
89
 
null,index(f2)) engine=MEMORY;
 
87
null,index(f2)) engine=heap;
90
88
INSERT into t1 set f1=12,f2="bill";
91
89
INSERT into t1 set f1=13,f2="bill";
92
90
INSERT into t1 set f1=14,f2="bill";
104
102
# Test when using part key searches
105
103
#
106
104
 
107
 
create temporary table t1 (btn char(10) not null, key using HASH (btn)) engine=MEMORY;
 
105
create temporary table t1 (btn char(10) not null, key using HASH (btn)) engine=heap;
108
106
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
109
107
explain select * from t1 where btn like "q%";
110
108
select * from t1 where btn like "q%";
123
121
  b int default NULL,
124
122
  KEY a using HASH (a),
125
123
  UNIQUE b using HASH (b)
126
 
) engine=MEMORY;
 
124
) engine=heap;
127
125
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
128
126
SELECT * FROM t1 WHERE a=NULL;
129
127
explain SELECT * FROM t1 WHERE a IS NULL;
140
138
# Test when deleting all rows
141
139
#
142
140
 
143
 
CREATE TEMPORARY TABLE t1 (a int not null, primary key using HASH (a)) engine=MEMORY;
 
141
CREATE TEMPORARY TABLE t1 (a int not null, primary key using HASH (a)) engine=heap;
144
142
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
145
143
DELETE from t1 where a < 100;
146
144
SELECT * from t1;
156
154
  b char(20) not null,
157
155
  c int not null,
158
156
  key (a)
159
 
) engine=MEMORY;
 
157
) engine=heap;
160
158
 
161
159
insert into t1 values ('aaaa', 'prefill-hash=5',0);
162
160
insert into t1 values ('aaab', 'prefill-hash=0',0);
205
203
  name varchar(20) not null,
206
204
  index heap_idx(name),
207
205
  index btree_idx using btree(name)
208
 
) engine=MEMORY;
 
206
) engine=heap;
209
207
 
210
208
create temporary table t2 (
211
209
  id int not null primary key auto_increment, 
212
210
  name varchar(20) not null,
213
211
  index btree_idx using btree(name),
214
212
  index heap_idx(name)
215
 
) engine=MEMORY;
 
213
) engine=heap;
216
214
 
217
215
insert into t1 (name) values ('Matt'), ('Lilu'), ('Corbin'), ('Carly'), 
218
216
  ('Suzy'), ('Hoppy'), ('Burrito'), ('Mimi'), ('Sherry'), ('Ben'), ('Phil'), 
248
246
  a varchar(20) not null,
249
247
  b varchar(20) not null,
250
248
  key (a,b)
251
 
) engine=MEMORY;
 
249
) engine=heap;
252
250
insert into t3 select name, name from t1;
253
251
show index from t3;
254
252
show index from t3;
259
257
drop table t1, t2, t3;
260
258
 
261
259
# Fix for BUG#8371: wrong rec_per_key value for hash index on temporary table
262
 
create temporary table t1 ( a int, index (a) ) engine=memory;
 
260
create temporary temporary table t1 ( a int, index (a) ) engine=memory;
263
261
insert into t1 values (1),(2),(3),(4),(5);
264
262
select a from t1 where a in (1,3);
265
263
explain select a from t1 where a in (1,3);