~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/heap.test

  • Committer: Monty Taylor
  • Date: 2009-09-22 23:50:12 UTC
  • mto: This revision was merged to the branch mainline in revision 1184.
  • Revision ID: mordred@inaugust.com-20090922235012-i0a3bs91f6krqduc
Fixed multi_malloc.h include guard.
Added include guard checking script.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#
2
 
# Test of MEMORY tables.
 
2
# Test of heap 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=MEMORY comment="testing heaps";
 
9
create temporary table t1 (a int not null,b int not null, primary key (a)) engine=heap 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
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
13
 
show table status like "t1";
 
12
#show table status like "t1";
14
13
show keys from t1;
15
14
select * from t1;
16
15
select * from t1 where a=4;
18
17
update t1 set b=b+1 where a>=3;
19
18
replace t1 values (3,3);
20
19
select * from t1;
21
 
alter table t1 add c int DEFAULT 42 not null, add key (c,a);
 
20
alter table t1 add c int not null, add key (c,a);
22
21
drop table t1;
23
22
 
24
23
create temporary table t1 (a int not null,b int not null, primary key (a)) engine=memory comment="testing heaps";
27
26
select * from t1;
28
27
drop table t1;
29
28
 
30
 
create temporary table t1 (a int not null,b int not null, primary key (a)) engine=MEMORY comment="testing heaps";
 
29
create temporary table t1 (a int not null,b int not null, primary key (a)) engine=heap comment="testing heaps";
31
30
insert into t1 values(1,1),(2,2),(3,3),(4,4);
32
31
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";
 
32
#show table status like "t1";
35
33
select * from t1;
36
34
drop table t1;
37
35
 
38
 
create temporary table t1 (a int not null) engine=MEMORY;
 
36
create temporary 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(a);
48
46
drop table t1,t2;
49
47
 
50
48
create temporary table t1 (x int not null, y int not null, key x (x), unique y (y))
51
 
engine=MEMORY;
 
49
engine=heap;
52
50
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
53
51
select * from t1 where x=1;
54
52
-- error 1137
57
55
explain select * from t1,t1 as t2 where t1.x=t2.y;
58
56
drop table t1;
59
57
 
60
 
create temporary table t1 (a int) engine=MEMORY;
 
58
create temporary table t1 (a int) engine=heap;
61
59
insert into t1 values(1);
62
60
select max(a) from t1;
63
61
drop table t1;
64
62
 
65
 
CREATE TEMPORARY TABLE t1 ( a int not null default 0, b int not null default 0,  key(a),  key(b)  ) ENGINE=MEMORY;
 
63
CREATE TEMPORARY TABLE t1 ( a int not null default 0, b int not null default 0,  key(a),  key(b)  ) ENGINE=HEAP;
66
64
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
67
65
select * from t1 where a=1; 
68
66
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
69
67
select * from t1 where a=1;
70
68
drop table t1;
71
69
 
72
 
create temporary table t1 (id int not null, primary key (id)) engine=MEMORY;
 
70
create temporary table t1 (id int not null, primary key (id)) engine=HEAP;
73
71
insert into t1 values(1);
74
72
select max(id) from t1; 
75
73
insert into t1 values(2);
77
75
replace into t1 values(1);
78
76
drop table t1;
79
77
 
80
 
create temporary table t1 (n int) engine=MEMORY;
 
78
create temporary table t1 (n int) engine=heap;
81
79
drop table t1;
82
80
 
83
 
create temporary table t1 (n int) engine=MEMORY;
 
81
create temporary table t1 (n int) engine=heap;
84
82
drop table if exists t1;
85
83
 
86
84
# Test of non unique index
87
85
 
88
86
CREATE TEMPORARY table t1(f1 int not null,f2 char(20) not 
89
 
null,index(f2)) engine=MEMORY;
 
87
null,index(f2)) engine=heap;
90
88
INSERT into t1 set f1=12,f2="bill";
91
89
INSERT into t1 set f1=13,f2="bill";
92
90
INSERT into t1 set f1=14,f2="bill";
104
102
# Test when using part key searches
105
103
#
106
104
 
107
 
create temporary table t1 (btn char(10) not null, key(btn)) engine=MEMORY;
 
105
create temporary table t1 (btn char(10) not null, key(btn)) engine=heap;
108
106
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
109
107
explain select * from t1 where btn like "q%";
110
108
select * from t1 where btn like "q%";
111
 
alter table t1 add column new_col char(1) DEFAULT "Y" not null, add key (btn,new_col), drop key btn;
 
109
alter table t1 add column new_col char(1) not null, add key (btn,new_col), drop key btn;
112
110
update t1 set new_col=left(btn,1);
113
111
explain select * from t1 where btn="a";
114
112
explain select * from t1 where btn="a" and new_col="a";
123
121
  b int default NULL,
124
122
  KEY a (a),
125
123
  UNIQUE b (b)
126
 
) engine=MEMORY;
 
124
) engine=heap;
127
125
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
128
126
SELECT * FROM t1 WHERE a=NULL;
129
127
explain SELECT * FROM t1 WHERE a IS NULL;
139
137
CREATE TEMPORARY TABLE t1 (
140
138
  a int default NULL,
141
139
  key a (a)
142
 
) ENGINE=MEMORY;
 
140
) ENGINE=HEAP;
143
141
INSERT INTO t1 VALUES (10), (10), (10);
144
142
EXPLAIN SELECT * FROM t1 WHERE a=10;
145
143
SELECT * FROM t1 WHERE a=10;
149
147
# Test when deleting all rows
150
148
#
151
149
 
152
 
CREATE TEMPORARY TABLE t1 (a int not null, primary key(a)) engine=MEMORY;
 
150
CREATE TEMPORARY TABLE t1 (a int not null, primary key(a)) engine=heap;
153
151
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
154
152
DELETE from t1 where a < 100;
155
153
SELECT * from t1;
156
154
DROP TABLE t1;
157
155
 
158
156
#
159
 
# Bug#4411 Server hangs when trying to SELECT MAX(id) from an empty MEMORY table
 
157
# Bug#4411 Server hangs when trying to SELECT MAX(id) from an empty HEAP table
160
158
#
161
159
CREATE TEMPORARY TABLE `job_titles` (
162
160
  `job_title_id` int NOT NULL default '0',
163
161
  `job_title` char(18) NOT NULL default '',
164
162
  PRIMARY KEY  (`job_title_id`),
165
163
  UNIQUE KEY `job_title_id` (`job_title_id`,`job_title`)
166
 
) ENGINE=MEMORY;
 
164
) ENGINE=HEAP;
167
165
 
168
166
SELECT MAX(job_title_id) FROM job_titles;
169
167
 
174
172
# (Bug #6082)
175
173
#
176
174
 
177
 
CREATE TEMPORARY TABLE t1 (a INT NOT NULL, B INT, KEY(B)) ENGINE=MEMORY;
 
175
CREATE TEMPORARY TABLE t1 (a INT NOT NULL, B INT, KEY(B)) ENGINE=HEAP;
178
176
INSERT INTO t1 VALUES(1,1), (1,NULL);
179
177
SELECT * FROM t1 WHERE B is not null;
180
178
DROP TABLE t1;
183
181
# Bug #6748
184
182
# heap_rfirst() doesn't work (and never did!)
185
183
#
186
 
CREATE TEMPORARY TABLE t1 (pseudo char(35) PRIMARY KEY, date int NOT NULL) ENGINE=MEMORY;
 
184
CREATE TEMPORARY TABLE t1 (pseudo char(35) PRIMARY KEY, date int NOT NULL) ENGINE=HEAP;
187
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);
188
186
DELETE FROM t1 WHERE date<1101106546;
189
187
SELECT * FROM t1;
202
200
 
203
201
#
204
202
# Test varchar
205
 
# We can't use varchar.inc becasue MEMORY doesn't support blob's
 
203
# We can't use varchar.inc becasue heap doesn't support blob's
206
204
#
207
205
 
208
206
let $default=`select @@storage_engine`;
209
 
set storage_engine=MEMORY;
 
207
set storage_engine=HEAP;
210
208
 
211
209
#
212
210
# Simple basic test that endspace is saved
215
213
create temporary table t1 (v varchar(10), c char(10), t varchar(50));
216
214
insert into t1 values('+ ', '+ ', '+ ');
217
215
set @a=repeat(' ',20);
218
 
--error ER_DATA_TOO_LONG
219
 
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
220
 
set @a=repeat(' ',10);
221
 
--error ER_DATA_TOO_LONG
222
 
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
223
 
set @a=repeat(' ',9);
224
216
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
225
217
select concat('*',v,'*',c,'*',t,'*') from t1;
226
218
 
315
307
insert into t1 values ('a '),('a  '),('a   '),('a         ');
316
308
--error ER_DUP_ENTRY
317
309
insert into t1 values ('a     ');
318
 
--error ER_DATA_TOO_LONG
 
310
--error ER_DUP_ENTRY
319
311
insert into t1 values ('a          ');
320
312
--error ER_DUP_ENTRY
321
313
insert into t1 values ('a ');
383
375
# Test unique btree keys
384
376
#
385
377
 
386
 
create temporary table t1 (a char(10), unique using btree (a)) engine=MEMORY;
 
378
create temporary table t1 (a char(10), unique using btree (a)) engine=heap;
387
379
insert into t1 values ('a');
388
380
--error ER_DUP_ENTRY
389
381
insert into t1 values ('a ');
393
385
insert into t1 values ('a '),('a  '),('a   '),('a         ');
394
386
--error ER_DUP_ENTRY
395
387
insert into t1 values ('a     ');
396
 
--error ER_DATA_TOO_LONG
 
388
--error ER_DUP_ENTRY
397
389
insert into t1 values ('a          ');
398
390
--error ER_DUP_ENTRY
399
391
insert into t1 values ('a ');
425
417
#
426
418
 
427
419
create temporary table t1 (a bigint auto_increment primary key, b int,
428
 
  key (b, a)) engine=MEMORY;
 
420
  key (b, a)) engine=heap;
429
421
insert t1 (b) values (1),(1),(1),(1),(1),(1),(1),(1);
430
422
select * from t1;
431
423
drop table t1;
432
424
 
433
425
create temporary table t1 (a int not null, b int not null auto_increment,
434
 
  primary key(a, b), key(b)) engine=MEMORY;
 
426
  primary key(a, b), key(b)) engine=heap;
435
427
insert t1 (a) values (1),(1),(1),(1),(1),(1),(1),(1);
436
428
select * from t1;
437
429
drop table t1;
438
430
 
439
 
--error ER_WRONG_AUTO_KEY
 
431
--error 1075
440
432
create temporary table t1 (a int not null, b int not null auto_increment,
441
 
  primary key(a, b)) engine=MEMORY;
 
433
  primary key(a, b)) engine=heap;
442
434
 
443
435
#
444
436
# Bug #10566: Verify that we can create temporary a prefixed key with length > 255
452
444
#
453
445
# Bug 12796: Record doesn't show when selecting through index
454
446
#
455
 
CREATE TEMPORARY TABLE t1 (a int, key(a)) engine=MEMORY;
 
447
CREATE TEMPORARY TABLE t1 (a int, key(a)) engine=heap;
456
448
insert into t1 values (0);
457
449
delete from t1;
458
450
select * from t1;
467
459
#
468
460
create temporary table t1 (c char(10)) engine=memory;
469
461
create temporary table t2 (c varchar(10)) engine=memory;
470
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
 
462
--replace_column 3 # 8 #
471
463
show table status like 't_';
472
464
drop table t1, t2;
473
465