6
6
drop table if exists t1,t2,t3;
9
create table t1 (a int not null,b int not null, primary key (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 (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 (c,a);
23
create table t1 (a int not null,b int not null, primary key (a)) engine=memory comment="testing heaps";
23
create temporary table t1 (a int not null,b int not null, primary key (a)) engine=memory comment="testing heaps";
24
24
insert into t1 values(1,1),(2,2),(3,3),(4,4);
25
25
delete from t1 where a > 0;
29
create table t1 (a int not null,b int not null, primary key (a)) engine=heap comment="testing heaps";
29
create temporary table t1 (a int not null,b int not null, primary key (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(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
create table t2 SELECT * FROM t1;
44
create temporary table t2 SELECT * FROM t1;
45
45
explain select * from t2 where a in (869751,736494,226312,802616);
48
create table t1 (x int not null, y int not null, key x (x), unique y (y))
48
create temporary table t1 (x int not null, y int not null, key x (x), unique y (y))
50
50
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
51
51
select * from t1 where x=1;
52
53
select * from t1,t1 as t2 where t1.x=t2.y;
53
55
explain select * from t1,t1 as t2 where t1.x=t2.y;
56
create table t1 (a int) engine=heap;
58
create temporary table t1 (a int) engine=heap;
57
59
insert into t1 values(1);
58
60
select max(a) from t1;
61
CREATE TABLE t1 ( a int not null default 0, b int not null default 0, key(a), key(b) ) ENGINE=HEAP;
63
CREATE TEMPORARY TABLE t1 ( a int not null default 0, b int not null default 0, key(a), key(b) ) ENGINE=HEAP;
62
64
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
63
65
select * from t1 where a=1;
64
66
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
65
67
select * from t1 where a=1;
68
create table t1 (id int not null, primary key (id)) engine=HEAP;
70
create temporary table t1 (id int not null, primary key (id)) engine=HEAP;
69
71
insert into t1 values(1);
70
72
select max(id) from t1;
71
73
insert into t1 values(2);
73
75
replace into t1 values(1);
76
create table t1 (n int) engine=heap;
78
create temporary table t1 (n int) engine=heap;
79
create table t1 (n int) engine=heap;
81
create temporary table t1 (n int) engine=heap;
80
82
drop table if exists t1;
82
84
# Test of non unique index
84
CREATE table t1(f1 int not null,f2 char(20) not
86
CREATE TEMPORARY table t1(f1 int not null,f2 char(20) not
85
87
null,index(f2)) engine=heap;
86
88
INSERT into t1 set f1=12,f2="bill";
87
89
INSERT into t1 set f1=13,f2="bill";
100
102
# Test when using part key searches
103
create table t1 (btn char(10) not null, key(btn)) engine=heap;
105
create temporary table t1 (btn char(10) not null, key(btn)) engine=heap;
104
106
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
105
107
explain select * from t1 where btn like "q%";
106
108
select * from t1 where btn like "q%";
145
147
# Test when deleting all rows
148
CREATE TABLE t1 (a int not null, primary key(a)) engine=heap;
150
CREATE TEMPORARY TABLE t1 (a int not null, primary key(a)) engine=heap;
149
151
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
150
152
DELETE from t1 where a < 100;
151
153
SELECT * from t1;
155
157
# Bug#4411 Server hangs when trying to SELECT MAX(id) from an empty HEAP table
157
CREATE TABLE `job_titles` (
159
CREATE TEMPORARY TABLE `job_titles` (
158
160
`job_title_id` int NOT NULL default '0',
159
161
`job_title` char(18) NOT NULL default '',
160
162
PRIMARY KEY (`job_title_id`),
173
CREATE TABLE t1 (a INT NOT NULL, B INT, KEY(B)) ENGINE=HEAP;
175
CREATE TEMPORARY TABLE t1 (a INT NOT NULL, B INT, KEY(B)) ENGINE=HEAP;
174
176
INSERT INTO t1 VALUES(1,1), (1,NULL);
175
177
SELECT * FROM t1 WHERE B is not null;
180
182
# heap_rfirst() doesn't work (and never did!)
182
CREATE TABLE t1 (pseudo char(35) PRIMARY KEY, date int NOT NULL) ENGINE=HEAP;
184
CREATE TEMPORARY TABLE t1 (pseudo char(35) PRIMARY KEY, date int NOT NULL) ENGINE=HEAP;
183
185
INSERT INTO t1 VALUES ('massecot',1101106491),('altec',1101106492),('stitch+',1101106304),('Seb Corgan',1101106305),('beerfilou',1101106263),('flaker',1101106529),('joce8',5),('M4vrick',1101106418),('gabay008',1101106525),('Vamp irX',1101106291),('ZoomZip',1101106546),('rip666',1101106502),('CBP ',1101106397),('guezpard',1101106496);
184
186
DELETE FROM t1 WHERE date<1101106546;
185
187
SELECT * FROM t1;
189
191
# Bug #6878: a problem with small length records
192
create table t1(a char(2)) engine=memory;
194
create temporary table t1(a char(2)) engine=memory;
193
195
insert into t1 values (NULL), (NULL);
194
196
delete from t1 where a is null;
195
197
insert into t1 values ('2'), ('3');
208
210
# Simple basic test that endspace is saved
211
create table t1 (v varchar(10), c char(10), t varchar(50));
213
create temporary table t1 (v varchar(10), c char(10), t varchar(50));
212
214
insert into t1 values('+ ', '+ ', '+ ');
213
215
set @a=repeat(' ',20);
214
216
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
317
319
# Testing of btree keys
320
create table t1 (v varchar(10), c char(10), t varchar(50), key using btree (v), key using btree (c), key using btree (t(10)));
322
create temporary table t1 (v varchar(10), c char(10), t varchar(50), key using btree (v), key using btree (c), key using btree (t(10)));
321
323
show create table t1;
322
324
disable_query_log;
395
397
# test show create table
398
create table t1 (v varchar(10), c char(10), t varchar(50), key(v(5)), key(c(5)), key(t(5)));
400
create temporary table t1 (v varchar(10), c char(10), t varchar(50), key(v(5)), key(c(5)), key(t(5)));
399
401
show create table t1;
402
create table t1 (v varchar(16383), key(v(10)));
404
create temporary table t1 (v varchar(16383), key(v(10)));
403
405
show create table t1;
404
406
insert into t1 values(repeat('a',16383));
405
407
select length(v) from t1 where v=repeat('a',16383);
414
416
# Bug #8489: Strange auto_increment behaviour
417
create table t1 (a bigint auto_increment primary key, b int,
419
create temporary table t1 (a bigint auto_increment primary key, b int,
418
420
key (b, a)) engine=heap;
419
421
insert t1 (b) values (1),(1),(1),(1),(1),(1),(1),(1);
420
422
select * from t1;
423
create table t1 (a int not null, b int not null auto_increment,
425
create temporary table t1 (a int not null, b int not null auto_increment,
424
426
primary key(a, b), key(b)) engine=heap;
425
427
insert t1 (a) values (1),(1),(1),(1),(1),(1),(1),(1);
426
428
select * from t1;
430
create table t1 (a int not null, b int not null auto_increment,
432
create temporary table t1 (a int not null, b int not null auto_increment,
431
433
primary key(a, b)) engine=heap;
434
# Bug #10566: Verify that we can create a prefixed key with length > 255
436
# Bug #10566: Verify that we can create temporary a prefixed key with length > 255
436
create table t1 (c char(255), primary key(c(90)));
438
create temporary table t1 (c char(255), primary key(c(90)));
437
439
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
438
440
--error ER_DUP_ENTRY
439
441
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
465
467
# BUG#18233 - Memory tables INDEX USING HASH (a,b) returns 1 row on
466
468
# SELECT WHERE a= AND b=
468
CREATE TABLE t1(a VARCHAR(1), b VARCHAR(2), c VARCHAR(256),
470
CREATE TEMPORARY TABLE t1(a VARCHAR(1), b VARCHAR(2), c VARCHAR(256),
469
471
KEY(a), KEY(b), KEY(c)) ENGINE=MEMORY;
470
472
INSERT INTO t1 VALUES('a','aa',REPEAT('a', 256)),('a','aa',REPEAT('a',256));
471
473
SELECT COUNT(*) FROM t1 WHERE a='a';