~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/heap.test

  • Committer: Brian Aker
  • Date: 2009-12-01 23:52:10 UTC
  • mfrom: (1235.1.4 push)
  • Revision ID: brian@gaz-20091201235210-rb720ykhz8e06fda
Merge Brian + Monty. This has the HEAP -> MEMORY change in it, so some
breakage for wrong table name is expected.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#
2
 
# Test of heap tables.
 
2
# Test of MEMORY tables.
3
3
#
4
4
 
5
5
--disable_warnings
6
6
drop table if exists t1,t2,t3;
7
7
--enable_warnings
8
8
 
9
 
create temporary table t1 (a int not null,b int not null, primary key (a)) engine=heap comment="testing heaps";
 
9
create temporary table t1 (a int not null,b int not null, primary key (a)) engine=MEMORY comment="testing heaps";
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";
26
26
select * from t1;
27
27
drop table t1;
28
28
 
29
 
create temporary 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=MEMORY 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";
33
33
select * from t1;
34
34
drop table t1;
35
35
 
36
 
create temporary table t1 (a int not null) engine=heap;
 
36
create temporary table t1 (a int not null) engine=MEMORY;
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);
46
46
drop table t1,t2;
47
47
 
48
48
create temporary table t1 (x int not null, y int not null, key x (x), unique y (y))
49
 
engine=heap;
 
49
engine=MEMORY;
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
52
-- error 1137
55
55
explain select * from t1,t1 as t2 where t1.x=t2.y;
56
56
drop table t1;
57
57
 
58
 
create temporary table t1 (a int) engine=heap;
 
58
create temporary table t1 (a int) engine=MEMORY;
59
59
insert into t1 values(1);
60
60
select max(a) from t1;
61
61
drop table t1;
62
62
 
63
 
CREATE TEMPORARY 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=MEMORY;
64
64
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
65
65
select * from t1 where a=1; 
66
66
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
67
67
select * from t1 where a=1;
68
68
drop table t1;
69
69
 
70
 
create temporary table t1 (id int not null, primary key (id)) engine=HEAP;
 
70
create temporary table t1 (id int not null, primary key (id)) engine=MEMORY;
71
71
insert into t1 values(1);
72
72
select max(id) from t1; 
73
73
insert into t1 values(2);
75
75
replace into t1 values(1);
76
76
drop table t1;
77
77
 
78
 
create temporary table t1 (n int) engine=heap;
 
78
create temporary table t1 (n int) engine=MEMORY;
79
79
drop table t1;
80
80
 
81
 
create temporary table t1 (n int) engine=heap;
 
81
create temporary table t1 (n int) engine=MEMORY;
82
82
drop table if exists t1;
83
83
 
84
84
# Test of non unique index
85
85
 
86
86
CREATE TEMPORARY table t1(f1 int not null,f2 char(20) not 
87
 
null,index(f2)) engine=heap;
 
87
null,index(f2)) engine=MEMORY;
88
88
INSERT into t1 set f1=12,f2="bill";
89
89
INSERT into t1 set f1=13,f2="bill";
90
90
INSERT into t1 set f1=14,f2="bill";
102
102
# Test when using part key searches
103
103
#
104
104
 
105
 
create temporary table t1 (btn char(10) not null, key(btn)) engine=heap;
 
105
create temporary table t1 (btn char(10) not null, key(btn)) engine=MEMORY;
106
106
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
107
107
explain select * from t1 where btn like "q%";
108
108
select * from t1 where btn like "q%";
121
121
  b int default NULL,
122
122
  KEY a (a),
123
123
  UNIQUE b (b)
124
 
) engine=heap;
 
124
) engine=MEMORY;
125
125
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
126
126
SELECT * FROM t1 WHERE a=NULL;
127
127
explain SELECT * FROM t1 WHERE a IS NULL;
137
137
CREATE TEMPORARY TABLE t1 (
138
138
  a int default NULL,
139
139
  key a (a)
140
 
) ENGINE=HEAP;
 
140
) ENGINE=MEMORY;
141
141
INSERT INTO t1 VALUES (10), (10), (10);
142
142
EXPLAIN SELECT * FROM t1 WHERE a=10;
143
143
SELECT * FROM t1 WHERE a=10;
147
147
# Test when deleting all rows
148
148
#
149
149
 
150
 
CREATE TEMPORARY TABLE t1 (a int not null, primary key(a)) engine=heap;
 
150
CREATE TEMPORARY TABLE t1 (a int not null, primary key(a)) engine=MEMORY;
151
151
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
152
152
DELETE from t1 where a < 100;
153
153
SELECT * from t1;
154
154
DROP TABLE t1;
155
155
 
156
156
#
157
 
# Bug#4411 Server hangs when trying to SELECT MAX(id) from an empty HEAP table
 
157
# Bug#4411 Server hangs when trying to SELECT MAX(id) from an empty MEMORY table
158
158
#
159
159
CREATE TEMPORARY TABLE `job_titles` (
160
160
  `job_title_id` int NOT NULL default '0',
161
161
  `job_title` char(18) NOT NULL default '',
162
162
  PRIMARY KEY  (`job_title_id`),
163
163
  UNIQUE KEY `job_title_id` (`job_title_id`,`job_title`)
164
 
) ENGINE=HEAP;
 
164
) ENGINE=MEMORY;
165
165
 
166
166
SELECT MAX(job_title_id) FROM job_titles;
167
167
 
172
172
# (Bug #6082)
173
173
#
174
174
 
175
 
CREATE TEMPORARY 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=MEMORY;
176
176
INSERT INTO t1 VALUES(1,1), (1,NULL);
177
177
SELECT * FROM t1 WHERE B is not null;
178
178
DROP TABLE t1;
181
181
# Bug #6748
182
182
# heap_rfirst() doesn't work (and never did!)
183
183
#
184
 
CREATE TEMPORARY 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=MEMORY;
185
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);
186
186
DELETE FROM t1 WHERE date<1101106546;
187
187
SELECT * FROM t1;
200
200
 
201
201
#
202
202
# Test varchar
203
 
# We can't use varchar.inc becasue heap doesn't support blob's
 
203
# We can't use varchar.inc becasue MEMORY doesn't support blob's
204
204
#
205
205
 
206
206
let $default=`select @@storage_engine`;
207
 
set storage_engine=HEAP;
 
207
set storage_engine=MEMORY;
208
208
 
209
209
#
210
210
# Simple basic test that endspace is saved
375
375
# Test unique btree keys
376
376
#
377
377
 
378
 
create temporary table t1 (a char(10), unique using btree (a)) engine=heap;
 
378
create temporary table t1 (a char(10), unique using btree (a)) engine=MEMORY;
379
379
insert into t1 values ('a');
380
380
--error ER_DUP_ENTRY
381
381
insert into t1 values ('a ');
417
417
#
418
418
 
419
419
create temporary table t1 (a bigint auto_increment primary key, b int,
420
 
  key (b, a)) engine=heap;
 
420
  key (b, a)) engine=MEMORY;
421
421
insert t1 (b) values (1),(1),(1),(1),(1),(1),(1),(1);
422
422
select * from t1;
423
423
drop table t1;
424
424
 
425
425
create temporary table t1 (a int not null, b int not null auto_increment,
426
 
  primary key(a, b), key(b)) engine=heap;
 
426
  primary key(a, b), key(b)) engine=MEMORY;
427
427
insert t1 (a) values (1),(1),(1),(1),(1),(1),(1),(1);
428
428
select * from t1;
429
429
drop table t1;
430
430
 
431
431
--error 1075
432
432
create temporary table t1 (a int not null, b int not null auto_increment,
433
 
  primary key(a, b)) engine=heap;
 
433
  primary key(a, b)) engine=MEMORY;
434
434
 
435
435
#
436
436
# Bug #10566: Verify that we can create temporary a prefixed key with length > 255
444
444
#
445
445
# Bug 12796: Record doesn't show when selecting through index
446
446
#
447
 
CREATE TEMPORARY TABLE t1 (a int, key(a)) engine=heap;
 
447
CREATE TEMPORARY TABLE t1 (a int, key(a)) engine=MEMORY;
448
448
insert into t1 values (0);
449
449
delete from t1;
450
450
select * from t1;