6
6
drop table if exists t1;
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;
9
create temporary 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);
23
create table t1 (a int not null,b int not null, primary key using BTREE (a)) engine=heap comment="testing heaps";
23
create temporary 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;
29
create table t1 (a int not null,b int not null, primary key using BTREE (a)) engine=heap comment="testing heaps";
29
create temporary 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
31
alter table t1 modify a int not null auto_increment, engine=innodb, comment="new innodb table";
32
32
#show table status like "t1";
36
create table t1 (a int not null) engine=heap;
36
create temporary 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);
45
45
explain select * from t1 where a in (869751,736494,226312,802616);
48
create table t1 (x int not null, y int not null, key x using BTREE (x,y), unique y using BTREE (y))
48
create temporary table t1 (x int not null, y int not null, key x using BTREE (x,y), unique y using BTREE (y))
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
54
select * from t1,t1 as t2 where t1.x=t2.y;
54
56
explain select * from t1,t1 as t2 where t1.x=t2.y;
57
create table t1 (a int) engine=heap;
59
create temporary table t1 (a int) engine=heap;
58
60
insert into t1 values(1);
59
61
select max(a) from t1;
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;
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=HEAP;
63
65
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
64
66
select * from t1 where a=1;
65
67
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
73
75
explain select * from t1 where b=1;
76
create table t1 (id int not null, primary key using BTREE (id)) engine=HEAP;
78
create temporary table t1 (id int not null, primary key using BTREE (id)) engine=HEAP;
77
79
insert into t1 values(1);
78
80
select max(id) from t1;
79
81
insert into t1 values(2);
81
83
replace into t1 values(1);
84
create table t1 (n int) engine=heap;
86
create temporary table t1 (n int) engine=heap;
87
create table t1 (n int) engine=heap;
89
create temporary table t1 (n int) engine=heap;
88
90
drop table if exists t1;
90
92
# Test of non unique index
92
CREATE table t1(f1 int not null,f2 char(20) not
94
CREATE TEMPORARY table t1(f1 int not null,f2 char(20) not
93
95
null,index(f2)) engine=heap;
94
96
INSERT into t1 set f1=12,f2="bill";
95
97
INSERT into t1 set f1=13,f2="bill";
108
110
# Test when using part key searches
111
create table t1 (btn char(10) not null, key using BTREE (btn)) engine=heap;
113
create temporary table t1 (btn char(10) not null, key using BTREE (btn)) engine=heap;
112
114
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
113
115
explain select * from t1 where btn like "i%";
114
116
--replace_column 9 #
147
149
INSERT INTO t1 VALUES (1,3);
150
CREATE TABLE t1 (a int, b int, c int, key using BTREE (a, b, c)) engine=heap;
152
CREATE TEMPORARY TABLE t1 (a int, b int, c int, key using BTREE (a, b, c)) engine=heap;
151
153
INSERT INTO t1 VALUES (1, NULL, NULL), (1, 1, NULL), (1, NULL, 1);
152
154
SELECT * FROM t1 WHERE a=1 and b IS NULL;
153
155
SELECT * FROM t1 WHERE a=1 and c IS NULL;
158
160
# Test when deleting all rows
161
CREATE TABLE t1 (a int not null, primary key using BTREE (a)) engine=heap;
163
CREATE TEMPORARY TABLE t1 (a int not null, primary key using BTREE (a)) engine=heap;
162
164
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
163
165
DELETE from t1 where a < 100;
164
166
SELECT * from t1;
168
170
# Bug #9719: problem with delete
171
create table t1(a int not null, key using btree(a)) engine=heap;
173
create temporary table t1(a int not null, key using btree(a)) engine=heap;
172
174
insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3);
173
175
select a from t1 where a > 2 order by a;
174
176
delete from t1 where a < 4;
211
213
# BUG#30590 - delete from memory table with composite btree primary key
213
CREATE TABLE t1 (a INT, KEY USING BTREE(a)) ENGINE=MEMORY;
215
CREATE TEMPORARY TABLE t1 (a INT, KEY USING BTREE(a)) ENGINE=MEMORY;
214
216
INSERT INTO t1 VALUES(1),(2),(2);
215
217
DELETE FROM t1 WHERE a=2;
216
218
SELECT * FROM t1;
222
224
# BUG#18160 - Memory-/HEAP Table endless growing indexes
224
CREATE TABLE t1(val INT, KEY USING BTREE(val)) ENGINE=memory;
226
CREATE TEMPORARY TABLE t1(val INT, KEY USING BTREE(val)) ENGINE=memory;
225
227
INSERT INTO t1 VALUES(0);
226
228
--replace_result 37 21
227
229
SELECT INDEX_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1';
234
236
# BUG#12873 - BTREE index on MEMORY table with multiple NULL values doesn't
237
CREATE TABLE t1 (a INT, UNIQUE USING BTREE(a)) ENGINE=MEMORY;
239
CREATE TEMPORARY TABLE t1 (a INT, UNIQUE USING BTREE(a)) ENGINE=MEMORY;
238
240
INSERT INTO t1 VALUES(NULL),(NULL);
242
244
# Bug #30885: MEMORY returns incorrect data if BTREE index is used for NULL lookup
244
create table t1(a varchar(255), b varchar(255),
246
create temporary table t1(a varchar(255), b varchar(255),
245
247
key using btree (a,b)) engine=memory;
246
248
insert into t1 values (1, 1), (3, 3), (2, 2), (NULL, 1), (NULL, NULL), (0, 0);
247
249
select * from t1 where a is null;