1
by brian
clean slate |
1 |
#
|
2 |
# Test of heap tables. |
|
3 |
#
|
|
4 |
||
5 |
--disable_warnings
|
|
6 |
drop table if exists t1; |
|
7 |
--enable_warnings
|
|
8 |
||
1116.1.2
by Brian Aker
Remove options which are just for internal optimizations. |
9 |
create temporary table t1 (a int not null,b int not null, primary key using BTREE (a)) engine=heap comment="testing heaps"; |
1
by brian
clean slate |
10 |
insert into t1 values(1,1),(2,2),(3,3),(4,4); |
11 |
delete from t1 where a=1 or a=0; |
|
12 |
#show table status like "t1"; |
|
13 |
show keys from t1; |
|
14 |
select * from t1; |
|
15 |
select * from t1 where a=4; |
|
16 |
update t1 set b=5 where a=4; |
|
17 |
update t1 set b=b+1 where a>=3; |
|
18 |
replace t1 values (3,3); |
|
19 |
select * from t1; |
|
20 |
alter table t1 add c int not null, add key using BTREE (c,a); |
|
21 |
drop table t1; |
|
22 |
||
1106.3.1
by Brian Aker
Heap is now tmp only table |
23 |
create temporary table t1 (a int not null,b int not null, primary key using BTREE (a)) engine=heap comment="testing heaps"; |
1
by brian
clean slate |
24 |
insert into t1 values(-2,-2),(-1,-1),(0,0),(1,1),(2,2),(3,3),(4,4); |
25 |
delete from t1 where a > -3; |
|
26 |
select * from t1; |
|
27 |
drop table t1; |
|
28 |
||
1106.3.1
by Brian Aker
Heap is now tmp only table |
29 |
create temporary table t1 (a int not null,b int not null, primary key using BTREE (a)) engine=heap comment="testing heaps"; |
1
by brian
clean slate |
30 |
insert into t1 values(1,1),(2,2),(3,3),(4,4); |
1063.9.3
by Brian Aker
Partial fix for tests for tmp |
31 |
alter table t1 modify a int not null auto_increment, engine=innodb, comment="new innodb table"; |
1
by brian
clean slate |
32 |
#show table status like "t1"; |
33 |
select * from t1; |
|
34 |
drop table t1; |
|
35 |
||
1106.3.1
by Brian Aker
Heap is now tmp only table |
36 |
create temporary table t1 (a int not null) engine=heap; |
1
by brian
clean slate |
37 |
insert into t1 values (869751),(736494),(226312),(802616),(728912); |
38 |
select * from t1 where a > 736494; |
|
39 |
alter table t1 add unique uniq_id using BTREE (a); |
|
40 |
select * from t1 where a > 736494; |
|
41 |
select * from t1 where a = 736494; |
|
42 |
select * from t1 where a=869751 or a=736494; |
|
43 |
select * from t1 where a in (869751,736494,226312,802616); |
|
1063.9.3
by Brian Aker
Partial fix for tests for tmp |
44 |
alter table t1 engine=innodb; |
1
by brian
clean slate |
45 |
explain select * from t1 where a in (869751,736494,226312,802616); |
46 |
drop table t1; |
|
47 |
||
1106.3.1
by Brian Aker
Heap is now tmp only table |
48 |
create temporary table t1 (x int not null, y int not null, key x using BTREE (x,y), unique y using BTREE (y)) |
1
by brian
clean slate |
49 |
engine=heap; |
50 |
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6); |
|
51 |
explain select * from t1 where x=1; |
|
52 |
select * from t1 where x=1; |
|
1106.3.1
by Brian Aker
Heap is now tmp only table |
53 |
-- error 1137
|
1
by brian
clean slate |
54 |
select * from t1,t1 as t2 where t1.x=t2.y; |
1106.3.1
by Brian Aker
Heap is now tmp only table |
55 |
-- error 1137
|
1
by brian
clean slate |
56 |
explain select * from t1,t1 as t2 where t1.x=t2.y; |
57 |
drop table t1; |
|
58 |
||
1106.3.1
by Brian Aker
Heap is now tmp only table |
59 |
create temporary table t1 (a int) engine=heap; |
1
by brian
clean slate |
60 |
insert into t1 values(1); |
61 |
select max(a) from t1; |
|
62 |
drop table t1; |
|
63 |
||
1106.3.1
by Brian Aker
Heap is now tmp only table |
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; |
1
by brian
clean slate |
65 |
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6); |
66 |
select * from t1 where a=1; |
|
67 |
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6); |
|
68 |
select * from t1 where a=1; |
|
69 |
--replace_result 0 x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x 11 x 12 x 13 x 14 x
|
|
70 |
explain select * from t1 where a=1 order by a,b; |
|
71 |
--replace_result 0 x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x 11 x 12 x 13 x 14 x
|
|
72 |
explain select * from t1 where a=1 order by b; |
|
73 |
select * from t1 where b=1; |
|
74 |
--replace_result 0 x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x 11 x 12 x 13 x 14 x
|
|
75 |
explain select * from t1 where b=1; |
|
76 |
drop table t1; |
|
77 |
||
1106.3.1
by Brian Aker
Heap is now tmp only table |
78 |
create temporary table t1 (id int not null, primary key using BTREE (id)) engine=HEAP; |
1
by brian
clean slate |
79 |
insert into t1 values(1); |
80 |
select max(id) from t1; |
|
81 |
insert into t1 values(2); |
|
82 |
select max(id) from t1; |
|
83 |
replace into t1 values(1); |
|
84 |
drop table t1; |
|
85 |
||
1106.3.1
by Brian Aker
Heap is now tmp only table |
86 |
create temporary table t1 (n int) engine=heap; |
1
by brian
clean slate |
87 |
drop table t1; |
88 |
||
1106.3.1
by Brian Aker
Heap is now tmp only table |
89 |
create temporary table t1 (n int) engine=heap; |
1
by brian
clean slate |
90 |
drop table if exists t1; |
91 |
||
92 |
# Test of non unique index |
|
93 |
||
1106.3.1
by Brian Aker
Heap is now tmp only table |
94 |
CREATE TEMPORARY table t1(f1 int not null,f2 char(20) not |
1
by brian
clean slate |
95 |
null,index(f2)) engine=heap; |
96 |
INSERT into t1 set f1=12,f2="bill"; |
|
97 |
INSERT into t1 set f1=13,f2="bill"; |
|
98 |
INSERT into t1 set f1=14,f2="bill"; |
|
99 |
INSERT into t1 set f1=15,f2="bill"; |
|
100 |
INSERT into t1 set f1=16,f2="ted"; |
|
101 |
INSERT into t1 set f1=12,f2="ted"; |
|
102 |
INSERT into t1 set f1=12,f2="ted"; |
|
103 |
INSERT into t1 set f1=12,f2="ted"; |
|
104 |
INSERT into t1 set f1=12,f2="ted"; |
|
105 |
delete from t1 where f2="bill"; |
|
106 |
select * from t1; |
|
107 |
drop table t1; |
|
108 |
||
109 |
#
|
|
110 |
# Test when using part key searches |
|
111 |
#
|
|
112 |
||
1106.3.1
by Brian Aker
Heap is now tmp only table |
113 |
create temporary table t1 (btn char(10) not null, key using BTREE (btn)) engine=heap; |
1
by brian
clean slate |
114 |
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i"); |
115 |
explain select * from t1 where btn like "i%"; |
|
116 |
--replace_column 9 #
|
|
117 |
explain select * from t1 where btn like "h%"; |
|
118 |
explain select * from t1 where btn like "a%"; |
|
119 |
explain select * from t1 where btn like "b%"; |
|
120 |
# For the following the BTREE MAY notice that there is no possible matches |
|
121 |
select * from t1 where btn like "ff%"; |
|
122 |
select * from t1 where btn like " %"; |
|
123 |
select * from t1 where btn like "q%"; |
|
124 |
alter table t1 add column new_col char(1) not null, add key using BTREE (btn,new_col), drop key btn; |
|
125 |
update t1 set new_col=left(btn,1); |
|
126 |
explain select * from t1 where btn="a"; |
|
127 |
explain select * from t1 where btn="a" and new_col="a"; |
|
128 |
drop table t1; |
|
129 |
||
130 |
#
|
|
131 |
# Test of NULL keys |
|
132 |
#
|
|
133 |
||
1106.3.1
by Brian Aker
Heap is now tmp only table |
134 |
CREATE TEMPORARY TABLE t1 ( |
1
by brian
clean slate |
135 |
a int default NULL, |
136 |
b int default NULL, |
|
137 |
KEY a using BTREE (a), |
|
138 |
UNIQUE b using BTREE (b) |
|
139 |
) engine=heap; |
|
140 |
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3); |
|
141 |
SELECT * FROM t1 WHERE a=NULL; |
|
142 |
explain SELECT * FROM t1 WHERE a IS NULL; |
|
143 |
SELECT * FROM t1 WHERE a<=>NULL; |
|
144 |
SELECT * FROM t1 WHERE b=NULL; |
|
145 |
explain SELECT * FROM t1 WHERE b IS NULL; |
|
146 |
SELECT * FROM t1 WHERE b<=>NULL; |
|
147 |
||
148 |
--error ER_DUP_ENTRY
|
|
149 |
INSERT INTO t1 VALUES (1,3); |
|
150 |
DROP TABLE t1; |
|
151 |
||
1106.3.1
by Brian Aker
Heap is now tmp only table |
152 |
CREATE TEMPORARY TABLE t1 (a int, b int, c int, key using BTREE (a, b, c)) engine=heap; |
1
by brian
clean slate |
153 |
INSERT INTO t1 VALUES (1, NULL, NULL), (1, 1, NULL), (1, NULL, 1); |
154 |
SELECT * FROM t1 WHERE a=1 and b IS NULL; |
|
155 |
SELECT * FROM t1 WHERE a=1 and c IS NULL; |
|
156 |
SELECT * FROM t1 WHERE a=1 and b IS NULL and c IS NULL; |
|
157 |
DROP TABLE t1; |
|
158 |
||
159 |
#
|
|
160 |
# Test when deleting all rows |
|
161 |
#
|
|
162 |
||
1106.3.1
by Brian Aker
Heap is now tmp only table |
163 |
CREATE TEMPORARY TABLE t1 (a int not null, primary key using BTREE (a)) engine=heap; |
1
by brian
clean slate |
164 |
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11); |
165 |
DELETE from t1 where a < 100; |
|
166 |
SELECT * from t1; |
|
167 |
DROP TABLE t1; |
|
168 |
||
169 |
#
|
|
170 |
# Bug #9719: problem with delete |
|
171 |
#
|
|
172 |
||
1106.3.1
by Brian Aker
Heap is now tmp only table |
173 |
create temporary table t1(a int not null, key using btree(a)) engine=heap; |
1
by brian
clean slate |
174 |
insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3); |
175 |
select a from t1 where a > 2 order by a; |
|
176 |
delete from t1 where a < 4; |
|
177 |
select a from t1 order by a; |
|
178 |
insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3); |
|
179 |
select a from t1 where a > 4 order by a; |
|
180 |
delete from t1 where a > 4; |
|
181 |
select a from t1 order by a; |
|
182 |
select a from t1 where a > 3 order by a; |
|
183 |
delete from t1 where a >= 2; |
|
184 |
select a from t1 order by a; |
|
185 |
drop table t1; |
|
186 |
||
187 |
#
|
|
188 |
# Bug#26996 - Update of a Field in a Memory Table ends with wrong result |
|
189 |
#
|
|
1106.3.1
by Brian Aker
Heap is now tmp only table |
190 |
CREATE TEMPORARY TABLE t1 ( |
1
by brian
clean slate |
191 |
c1 CHAR(3), |
192 |
c2 INTEGER, |
|
193 |
KEY USING BTREE(c1), |
|
194 |
KEY USING BTREE(c2) |
|
195 |
) ENGINE= MEMORY; |
|
196 |
INSERT INTO t1 VALUES ('ABC',0), ('A',0), ('B',0), ('C',0); |
|
197 |
UPDATE t1 SET c2= c2 + 1 WHERE c1 = 'A'; |
|
198 |
SELECT * FROM t1; |
|
199 |
DROP TABLE t1; |
|
200 |
||
201 |
#
|
|
202 |
# Bug#24985 - UTF8 ENUM primary key on MEMORY using BTREE |
|
203 |
# causes incorrect duplicate entries |
|
204 |
#
|
|
1106.3.1
by Brian Aker
Heap is now tmp only table |
205 |
CREATE TEMPORARY TABLE t1 ( |
1
by brian
clean slate |
206 |
c1 ENUM('1', '2'), |
207 |
UNIQUE USING BTREE(c1) |
|
377.1.4
by Brian Aker
Big, fat, UTF-8 patch. This fixes some of the oddities around only one |
208 |
) ENGINE= MEMORY; |
1
by brian
clean slate |
209 |
INSERT INTO t1 VALUES('1'), ('2'); |
210 |
DROP TABLE t1; |
|
211 |
||
212 |
#
|
|
213 |
# BUG#30590 - delete from memory table with composite btree primary key |
|
214 |
#
|
|
1106.3.1
by Brian Aker
Heap is now tmp only table |
215 |
CREATE TEMPORARY TABLE t1 (a INT, KEY USING BTREE(a)) ENGINE=MEMORY; |
1
by brian
clean slate |
216 |
INSERT INTO t1 VALUES(1),(2),(2); |
217 |
DELETE FROM t1 WHERE a=2; |
|
218 |
SELECT * FROM t1; |
|
219 |
DROP TABLE t1; |
|
220 |
||
221 |
--echo End of 4.1 tests
|
|
222 |
||
223 |
#
|
|
224 |
# BUG#18160 - Memory-/HEAP Table endless growing indexes |
|
225 |
#
|
|
1106.3.1
by Brian Aker
Heap is now tmp only table |
226 |
CREATE TEMPORARY TABLE t1(val INT, KEY USING BTREE(val)) ENGINE=memory; |
1
by brian
clean slate |
227 |
INSERT INTO t1 VALUES(0); |
228 |
--replace_result 37 21
|
|
229 |
SELECT INDEX_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1'; |
|
230 |
UPDATE t1 SET val=1; |
|
231 |
--replace_result 37 21
|
|
232 |
SELECT INDEX_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1'; |
|
233 |
DROP TABLE t1; |
|
234 |
||
235 |
#
|
|
236 |
# BUG#12873 - BTREE index on MEMORY table with multiple NULL values doesn't |
|
237 |
# work properly |
|
238 |
#
|
|
1106.3.1
by Brian Aker
Heap is now tmp only table |
239 |
CREATE TEMPORARY TABLE t1 (a INT, UNIQUE USING BTREE(a)) ENGINE=MEMORY; |
1
by brian
clean slate |
240 |
INSERT INTO t1 VALUES(NULL),(NULL); |
241 |
DROP TABLE t1; |
|
242 |
||
243 |
#
|
|
244 |
# Bug #30885: MEMORY returns incorrect data if BTREE index is used for NULL lookup |
|
245 |
#
|
|
1106.3.1
by Brian Aker
Heap is now tmp only table |
246 |
create temporary table t1(a varchar(255), b varchar(255), |
1
by brian
clean slate |
247 |
key using btree (a,b)) engine=memory; |
248 |
insert into t1 values (1, 1), (3, 3), (2, 2), (NULL, 1), (NULL, NULL), (0, 0); |
|
249 |
select * from t1 where a is null; |
|
250 |
drop table t1; |
|
251 |
||
252 |
--echo End of 5.0 tests
|
|
253 |