~drizzle-trunk/drizzle/development

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