2
# Test of MEMORY tables.
6
6
drop table if exists t1;
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";
16
15
select * from t1 where a=4;
21
20
alter table t1 add c int not null, add key using BTREE (c,a);
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;
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";
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);
50
create temporary table t1 (x int not null, y int not null, key x using BTREE (x,y), unique y using BTREE (y))
48
create table t1 (x int not null, y int not null, key x using BTREE (x,y), unique y using BTREE (y))
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;
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;
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);
85
81
replace into t1 values(1);
88
create temporary table t1 (n int) engine=MEMORY;
84
create table t1 (n int) engine=heap;
91
create temporary table t1 (n int) engine=MEMORY;
87
create table t1 (n int) engine=heap;
92
88
drop table if exists t1;
94
90
# Test of non unique index
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
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
136
CREATE TEMPORARY 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)
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);
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
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
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;
215
211
# BUG#30590 - delete from memory table with composite btree primary key
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
226
# BUG#18160 - Memory-/MEMORY Table endless growing indexes
222
# BUG#18160 - Memory-/HEAP Table endless growing indexes
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';
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';
229
--replace_result 37 21
230
SELECT INDEX_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1';
238
234
# BUG#12873 - BTREE index on MEMORY table with multiple NULL values doesn't
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);
246
242
# Bug #30885: MEMORY returns incorrect data if BTREE index is used for NULL lookup
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;