~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/heap_btree.test

  • Committer: Monty Taylor
  • Date: 2008-08-16 21:06:22 UTC
  • Revision ID: monty@inaugust.com-20080816210622-zpnn13unyinqzn72
Updated po files.

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