~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/heap_btree.test

  • Committer: Stewart Smith
  • Date: 2008-11-21 16:06:07 UTC
  • mto: This revision was merged to the branch mainline in revision 593.
  • Revision ID: stewart@flamingspork.com-20081121160607-n6gdlt013spuo54r
remove mysql_frm_type
and fix engines to return correct value from delete_table when table doesn't exist.
(it should be ENOENT).

Also fix up some tests that manipulated frm files by hand. These tests are no longer valid and will need to be rewritten in the not too distant future.

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;
7
7
--enable_warnings
8
8
 
9
 
create temporary table t1 (a int not null,b int not null, primary key using BTREE (a)) engine=MEMORY comment="testing heaps";
 
9
create table t1 (a int not null,b int not null, primary key using BTREE (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 BTREE (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 BTREE (a)) engine=MEMORY comment="testing heaps";
 
23
create table t1 (a int not null,b int not null, primary key using BTREE (a)) engine=heap comment="testing heaps";
25
24
insert into t1 values(-2,-2),(-1,-1),(0,0),(1,1),(2,2),(3,3),(4,4);
26
25
delete from t1 where a > -3;
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 BTREE (a)) engine=MEMORY comment="testing heaps";
 
29
create table t1 (a int not null,b int not null, primary key using BTREE (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 BTREE (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 BTREE (x,y), unique y  using BTREE (y))
51
 
engine=MEMORY;
 
48
create table t1 (x int not null, y int not null, key x  using BTREE (x,y), unique y  using BTREE (y))
 
49
engine=heap;
52
50
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
53
51
explain select * from t1 where x=1;
54
52
select * from t1 where x=1;
55
53
select * from t1,t1 as t2 where t1.x=t2.y;
56
54
explain select * from t1,t1 as t2 where t1.x=t2.y;
57
55
drop table t1;
58
56
 
59
 
create temporary table t1 (a int) engine=MEMORY;
 
57
create table t1 (a int) engine=heap;
60
58
insert into t1 values(1);
61
59
select max(a) from t1;
62
60
drop table t1;
63
61
 
64
 
CREATE TEMPORARY TABLE t1 ( a int not null default 0, b int not null default 0,  key  using BTREE (a,b),  key  using BTREE (b)  ) ENGINE=MEMORY;
 
62
CREATE TABLE t1 ( a int not null default 0, b int not null default 0,  key  using BTREE (a,b),  key  using BTREE (b)  ) ENGINE=HEAP;
65
63
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
66
64
select * from t1 where a=1; 
67
65
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
77
73
explain select * from t1 where b=1;
78
74
drop table t1;
79
75
 
80
 
create temporary table t1 (id int not null, primary key  using BTREE (id)) engine=MEMORY;
 
76
create table t1 (id int not null, primary key  using BTREE (id)) engine=HEAP;
81
77
insert into t1 values(1);
82
78
select max(id) from t1; 
83
79
insert into t1 values(2);
85
81
replace into t1 values(1);
86
82
drop table t1;
87
83
 
88
 
create temporary table t1 (n int) engine=MEMORY;
 
84
create table t1 (n int) engine=heap;
89
85
drop table t1;
90
86
 
91
 
create temporary table t1 (n int) engine=MEMORY;
 
87
create table t1 (n int) engine=heap;
92
88
drop table if exists t1;
93
89
 
94
90
# Test of non unique index
95
91
 
96
 
CREATE TEMPORARY table t1(f1 int not null,f2 char(20) not 
97
 
null,index(f2)) engine=MEMORY;
 
92
CREATE table t1(f1 int not null,f2 char(20) not 
 
93
null,index(f2)) engine=heap;
98
94
INSERT into t1 set f1=12,f2="bill";
99
95
INSERT into t1 set f1=13,f2="bill";
100
96
INSERT into t1 set f1=14,f2="bill";
112
108
# Test when using part key searches
113
109
#
114
110
 
115
 
create temporary table t1 (btn char(10) not null, key using BTREE (btn)) engine=MEMORY;
 
111
create table t1 (btn char(10) not null, key using BTREE (btn)) engine=heap;
116
112
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
117
113
explain select * from t1 where btn like "i%";
118
114
--replace_column 9 #
133
129
# Test of NULL keys
134
130
#
135
131
 
136
 
CREATE TEMPORARY TABLE t1 (
 
132
CREATE TABLE t1 (
137
133
  a int default NULL,
138
134
  b int default NULL,
139
135
  KEY a using BTREE (a),
140
136
  UNIQUE b using BTREE (b)
141
 
) engine=MEMORY;
 
137
) engine=heap;
142
138
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
143
139
SELECT * FROM t1 WHERE a=NULL;
144
140
explain SELECT * FROM t1 WHERE a IS NULL;
151
147
INSERT INTO t1 VALUES (1,3);
152
148
DROP TABLE t1;
153
149
 
154
 
CREATE TEMPORARY TABLE t1 (a int, b int, c int, key using BTREE (a, b, c)) engine=MEMORY;
 
150
CREATE TABLE t1 (a int, b int, c int, key using BTREE (a, b, c)) engine=heap;
155
151
INSERT INTO t1 VALUES (1, NULL, NULL), (1, 1, NULL), (1, NULL, 1);
156
152
SELECT * FROM t1 WHERE a=1 and b IS NULL;
157
153
SELECT * FROM t1 WHERE a=1 and c IS NULL;
162
158
# Test when deleting all rows
163
159
#
164
160
 
165
 
CREATE TEMPORARY TABLE t1 (a int not null, primary key using BTREE (a)) engine=MEMORY;
 
161
CREATE TABLE t1 (a int not null, primary key using BTREE (a)) engine=heap;
166
162
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
167
163
DELETE from t1 where a < 100;
168
164
SELECT * from t1;
172
168
# Bug #9719: problem with delete
173
169
#
174
170
 
175
 
create temporary table t1(a int not null, key using btree(a)) engine=MEMORY;
 
171
create table t1(a int not null, key using btree(a)) engine=heap;
176
172
insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3);
177
173
select a from t1 where a > 2 order by a;
178
174
delete from t1 where a < 4;
189
185
#
190
186
# Bug#26996 - Update of a Field in a Memory Table ends with wrong result
191
187
#
192
 
CREATE TEMPORARY TABLE t1 (
 
188
CREATE TABLE t1 (
193
189
  c1 CHAR(3),
194
190
  c2 INTEGER,
195
191
  KEY USING BTREE(c1),
204
200
# Bug#24985 - UTF8 ENUM primary key on MEMORY using BTREE
205
201
#             causes incorrect duplicate entries
206
202
#
207
 
CREATE TEMPORARY TABLE t1 (
 
203
CREATE TABLE t1 (
208
204
  c1 ENUM('1', '2'),
209
205
  UNIQUE USING BTREE(c1)
210
206
) ENGINE= MEMORY;
214
210
#
215
211
# BUG#30590 - delete from memory table with composite btree primary key
216
212
#
217
 
CREATE TEMPORARY TABLE t1 (a INT, KEY USING BTREE(a)) ENGINE=MEMORY;
 
213
CREATE TABLE t1 (a INT, KEY USING BTREE(a)) ENGINE=MEMORY;
218
214
INSERT INTO t1 VALUES(1),(2),(2);
219
215
DELETE FROM t1 WHERE a=2;
220
216
SELECT * FROM t1;
223
219
--echo End of 4.1 tests
224
220
 
225
221
#
226
 
# BUG#18160 - Memory-/MEMORY Table endless growing indexes
 
222
# BUG#18160 - Memory-/HEAP Table endless growing indexes
227
223
#
228
 
#CREATE TEMPORARY TABLE t1(val INT, KEY USING BTREE(val)) ENGINE=memory;
229
 
#INSERT INTO t1 VALUES(0);
230
 
#--replace_result 37 21
231
 
#SELECT INDEX_LENGTH FROM data_dictionary.tables WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1';
232
 
#UPDATE t1 SET val=1;
233
 
#--replace_result 37 21
234
 
#SELECT INDEX_LENGTH FROM data_dictionary.tables WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1';
235
 
#DROP TABLE t1;
 
224
CREATE TABLE t1(val INT, KEY USING BTREE(val)) ENGINE=memory;
 
225
INSERT INTO t1 VALUES(0);
 
226
--replace_result 37 21
 
227
SELECT INDEX_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1';
 
228
UPDATE t1 SET val=1;
 
229
--replace_result 37 21
 
230
SELECT INDEX_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1';
 
231
DROP TABLE t1;
236
232
 
237
233
#
238
234
# BUG#12873 - BTREE index on MEMORY table with multiple NULL values doesn't
239
235
# work properly
240
236
#
241
 
CREATE TEMPORARY TABLE t1 (a INT, UNIQUE USING BTREE(a)) ENGINE=MEMORY;
 
237
CREATE TABLE t1 (a INT, UNIQUE USING BTREE(a)) ENGINE=MEMORY;
242
238
INSERT INTO t1 VALUES(NULL),(NULL);
243
239
DROP TABLE t1;
244
240
 
245
241
#
246
242
# Bug #30885: MEMORY returns incorrect data if BTREE index is used for NULL lookup
247
243
#
248
 
create temporary table t1(a varchar(255), b varchar(255), 
 
244
create table t1(a varchar(255), b varchar(255), 
249
245
                key using btree (a,b)) engine=memory; 
250
246
insert into t1 values (1, 1), (3, 3), (2, 2), (NULL, 1), (NULL, NULL), (0, 0);
251
247
select * from t1 where a is null;