~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/heap.test

  • Committer: Brian Aker
  • Date: 2010-04-05 23:46:43 UTC
  • Revision ID: brian@gaz-20100405234643-0he3xnj902rc70r8
Fixing tests to work with PBXT.

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 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=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
 
#show table status like "t1";
 
12
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
 
13
show table status like "t1";
13
14
show keys from t1;
14
15
select * from t1;
15
16
select * from t1 where a=4;
20
21
alter table t1 add c int not null, add key (c,a);
21
22
drop table t1;
22
23
 
23
 
create table t1 (a int not null,b int not null, primary key (a)) engine=memory comment="testing heaps";
 
24
create temporary table t1 (a int not null,b int not null, primary key (a)) engine=memory comment="testing heaps";
24
25
insert into t1 values(1,1),(2,2),(3,3),(4,4);
25
26
delete from t1 where a > 0;
26
27
select * from t1;
27
28
drop table t1;
28
29
 
29
 
create table t1 (a int not null,b int not null, primary key (a)) engine=heap comment="testing heaps";
 
30
create temporary table t1 (a int not null,b int not null, primary key (a)) engine=MEMORY comment="testing heaps";
30
31
insert into t1 values(1,1),(2,2),(3,3),(4,4);
31
 
alter table t1 modify a int not null auto_increment, engine=myisam, comment="new myisam table";
32
 
#show table status like "t1";
 
32
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";
33
35
select * from t1;
34
36
drop table t1;
35
37
 
36
 
create table t1 (a int not null) engine=heap;
 
38
create temporary table t1 (a int not null) engine=MEMORY;
37
39
insert into t1 values (869751),(736494),(226312),(802616),(728912);
38
40
select * from t1 where a > 736494;
39
41
alter table t1 add unique uniq_id(a);
41
43
select * from t1 where a = 736494;
42
44
select * from t1 where a=869751 or a=736494;
43
45
select * from t1 where a in (869751,736494,226312,802616);
44
 
alter table t1 engine=myisam;
45
 
explain select * from t1 where a in (869751,736494,226312,802616);
46
 
drop table t1;
 
46
create temporary table t2 SELECT * FROM t1;
 
47
explain select * from t2 where a in (869751,736494,226312,802616);
 
48
drop table t1,t2;
47
49
 
48
 
create table t1 (x int not null, y int not null, key x (x), unique y (y))
49
 
engine=heap;
 
50
create temporary table t1 (x int not null, y int not null, key x (x), unique y (y))
 
51
engine=MEMORY;
50
52
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
51
53
select * from t1 where x=1;
 
54
-- error 1137
52
55
select * from t1,t1 as t2 where t1.x=t2.y;
 
56
-- error 1137
53
57
explain select * from t1,t1 as t2 where t1.x=t2.y;
54
58
drop table t1;
55
59
 
56
 
create table t1 (a int) engine=heap;
 
60
create temporary table t1 (a int) engine=MEMORY;
57
61
insert into t1 values(1);
58
62
select max(a) from t1;
59
63
drop table t1;
60
64
 
61
 
CREATE TABLE t1 ( a int not null default 0, b int not null default 0,  key(a),  key(b)  ) ENGINE=HEAP;
 
65
CREATE TEMPORARY TABLE t1 ( a int not null default 0, b int not null default 0,  key(a),  key(b)  ) ENGINE=MEMORY;
62
66
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
63
67
select * from t1 where a=1; 
64
68
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
65
69
select * from t1 where a=1;
66
70
drop table t1;
67
71
 
68
 
create table t1 (id int not null, primary key (id)) engine=HEAP;
 
72
create temporary table t1 (id int not null, primary key (id)) engine=MEMORY;
69
73
insert into t1 values(1);
70
74
select max(id) from t1; 
71
75
insert into t1 values(2);
73
77
replace into t1 values(1);
74
78
drop table t1;
75
79
 
76
 
create table t1 (n int) engine=heap;
 
80
create temporary table t1 (n int) engine=MEMORY;
77
81
drop table t1;
78
82
 
79
 
create table t1 (n int) engine=heap;
 
83
create temporary table t1 (n int) engine=MEMORY;
80
84
drop table if exists t1;
81
85
 
82
86
# Test of non unique index
83
87
 
84
 
CREATE table t1(f1 int not null,f2 char(20) not 
85
 
null,index(f2)) engine=heap;
 
88
CREATE TEMPORARY table t1(f1 int not null,f2 char(20) not 
 
89
null,index(f2)) engine=MEMORY;
86
90
INSERT into t1 set f1=12,f2="bill";
87
91
INSERT into t1 set f1=13,f2="bill";
88
92
INSERT into t1 set f1=14,f2="bill";
100
104
# Test when using part key searches
101
105
#
102
106
 
103
 
create table t1 (btn char(10) not null, key(btn)) engine=heap;
 
107
create temporary table t1 (btn char(10) not null, key(btn)) engine=MEMORY;
104
108
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
105
109
explain select * from t1 where btn like "q%";
106
110
select * from t1 where btn like "q%";
114
118
# Test of NULL keys
115
119
#
116
120
 
117
 
CREATE TABLE t1 (
 
121
CREATE TEMPORARY TABLE t1 (
118
122
  a int default NULL,
119
123
  b int default NULL,
120
124
  KEY a (a),
121
125
  UNIQUE b (b)
122
 
) engine=heap;
 
126
) engine=MEMORY;
123
127
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
124
128
SELECT * FROM t1 WHERE a=NULL;
125
129
explain SELECT * FROM t1 WHERE a IS NULL;
132
136
INSERT INTO t1 VALUES (1,3);
133
137
DROP TABLE t1;
134
138
 
135
 
CREATE TABLE t1 (
 
139
CREATE TEMPORARY TABLE t1 (
136
140
  a int default NULL,
137
141
  key a (a)
138
 
) ENGINE=HEAP;
 
142
) ENGINE=MEMORY;
139
143
INSERT INTO t1 VALUES (10), (10), (10);
140
144
EXPLAIN SELECT * FROM t1 WHERE a=10;
141
145
SELECT * FROM t1 WHERE a=10;
145
149
# Test when deleting all rows
146
150
#
147
151
 
148
 
CREATE TABLE t1 (a int not null, primary key(a)) engine=heap;
 
152
CREATE TEMPORARY TABLE t1 (a int not null, primary key(a)) engine=MEMORY;
149
153
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
150
154
DELETE from t1 where a < 100;
151
155
SELECT * from t1;
152
156
DROP TABLE t1;
153
157
 
154
158
#
155
 
# Bug#4411 Server hangs when trying to SELECT MAX(id) from an empty HEAP table
 
159
# Bug#4411 Server hangs when trying to SELECT MAX(id) from an empty MEMORY table
156
160
#
157
 
CREATE TABLE `job_titles` (
 
161
CREATE TEMPORARY TABLE `job_titles` (
158
162
  `job_title_id` int NOT NULL default '0',
159
163
  `job_title` char(18) NOT NULL default '',
160
164
  PRIMARY KEY  (`job_title_id`),
161
165
  UNIQUE KEY `job_title_id` (`job_title_id`,`job_title`)
162
 
) ENGINE=HEAP;
 
166
) ENGINE=MEMORY;
163
167
 
164
168
SELECT MAX(job_title_id) FROM job_titles;
165
169
 
170
174
# (Bug #6082)
171
175
#
172
176
 
173
 
CREATE TABLE t1 (a INT NOT NULL, B INT, KEY(B)) ENGINE=HEAP;
 
177
CREATE TEMPORARY TABLE t1 (a INT NOT NULL, B INT, KEY(B)) ENGINE=MEMORY;
174
178
INSERT INTO t1 VALUES(1,1), (1,NULL);
175
179
SELECT * FROM t1 WHERE B is not null;
176
180
DROP TABLE t1;
179
183
# Bug #6748
180
184
# heap_rfirst() doesn't work (and never did!)
181
185
#
182
 
CREATE TABLE t1 (pseudo char(35) PRIMARY KEY, date int NOT NULL) ENGINE=HEAP;
 
186
CREATE TEMPORARY TABLE t1 (pseudo char(35) PRIMARY KEY, date int NOT NULL) ENGINE=MEMORY;
183
187
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
188
DELETE FROM t1 WHERE date<1101106546;
185
189
SELECT * FROM t1;
189
193
# Bug #6878: a problem with small length records
190
194
#
191
195
 
192
 
create table t1(a char(2)) engine=memory;
 
196
create temporary table t1(a char(2)) engine=memory;
193
197
insert into t1 values (NULL), (NULL);
194
198
delete from t1 where a is null;
195
199
insert into t1 values ('2'), ('3');
198
202
 
199
203
#
200
204
# Test varchar
201
 
# We can't use varchar.inc becasue heap doesn't support blob's
 
205
# We can't use varchar.inc becasue MEMORY doesn't support blob's
202
206
#
203
207
 
204
208
let $default=`select @@storage_engine`;
205
 
set storage_engine=HEAP;
 
209
set storage_engine=MEMORY;
206
210
 
207
211
#
208
212
# Simple basic test that endspace is saved
209
213
#
210
214
 
211
 
create table t1 (v varchar(10), c char(10), t varchar(50));
 
215
create temporary table t1 (v varchar(10), c char(10), t varchar(50));
212
216
insert into t1 values('+ ', '+ ', '+ ');
213
217
set @a=repeat(' ',20);
214
218
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
216
220
 
217
221
# Check how columns are copied
218
222
show create table t1;
219
 
create table t2 like t1;
 
223
create temporary table t2 like t1;
220
224
show create table t2;
221
 
create table t3 select * from t1;
 
225
create temporary table t3 select * from t1;
222
226
show create table t3;
223
227
alter table t1 modify c varchar(10);
224
228
show create table t1;
232
236
#
233
237
# Testing of keys
234
238
#
235
 
create table t1 (v varchar(10), c char(10), t varchar(50), key(v), key(c), key(t(10)));
 
239
create temporary table t1 (v varchar(10), c char(10), t varchar(50), key(v), key(c), key(t(10)));
236
240
show create table t1;
237
241
disable_query_log;
238
242
begin;
295
299
# Test unique keys
296
300
#
297
301
 
298
 
create table t1 (a char(10), unique (a));
 
302
create temporary table t1 (a char(10), unique (a));
299
303
insert into t1 values ('a');
300
304
--error ER_DUP_ENTRY
301
305
insert into t1 values ('a ');
317
321
# Testing of btree keys
318
322
#
319
323
 
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)));
 
324
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
325
show create table t1;
322
326
disable_query_log;
323
327
let $1=10;
373
377
# Test unique btree keys
374
378
#
375
379
 
376
 
create table t1 (a char(10), unique using btree (a)) engine=heap;
 
380
create temporary table t1 (a char(10), unique using btree (a)) engine=MEMORY;
377
381
insert into t1 values ('a');
378
382
--error ER_DUP_ENTRY
379
383
insert into t1 values ('a ');
395
399
# test show create table
396
400
#
397
401
 
398
 
create table t1 (v varchar(10), c char(10), t varchar(50), key(v(5)), key(c(5)), key(t(5)));
 
402
create temporary table t1 (v varchar(10), c char(10), t varchar(50), key(v(5)), key(c(5)), key(t(5)));
399
403
show create table t1;
400
404
drop table t1;
401
405
 
402
 
create table t1 (v varchar(16383), key(v(10)));
 
406
create temporary table t1 (v varchar(16383), key(v(10)));
403
407
show create table t1;
404
408
insert into t1 values(repeat('a',16383));
405
409
select length(v) from t1 where v=repeat('a',16383);
414
418
# Bug #8489: Strange auto_increment behaviour
415
419
#
416
420
 
417
 
create table t1 (a bigint auto_increment primary key, b int,
418
 
  key (b, a)) engine=heap;
 
421
create temporary table t1 (a bigint auto_increment primary key, b int,
 
422
  key (b, a)) engine=MEMORY;
419
423
insert t1 (b) values (1),(1),(1),(1),(1),(1),(1),(1);
420
424
select * from t1;
421
425
drop table t1;
422
426
 
423
 
create table t1 (a int not null, b int not null auto_increment,
424
 
  primary key(a, b), key(b)) engine=heap;
 
427
create temporary table t1 (a int not null, b int not null auto_increment,
 
428
  primary key(a, b), key(b)) engine=MEMORY;
425
429
insert t1 (a) values (1),(1),(1),(1),(1),(1),(1),(1);
426
430
select * from t1;
427
431
drop table t1;
428
432
 
429
433
--error 1075
430
 
create table t1 (a int not null, b int not null auto_increment,
431
 
  primary key(a, b)) engine=heap;
 
434
create temporary table t1 (a int not null, b int not null auto_increment,
 
435
  primary key(a, b)) engine=MEMORY;
432
436
 
433
437
#
434
 
# Bug #10566: Verify that we can create a prefixed key with length > 255
 
438
# Bug #10566: Verify that we can create temporary a prefixed key with length > 255
435
439
#
436
 
create table t1 (c char(255), primary key(c(90)));
 
440
create temporary table t1 (c char(255), primary key(c(90)));
437
441
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
438
442
--error ER_DUP_ENTRY
439
443
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
442
446
#
443
447
# Bug 12796: Record doesn't show when selecting through index
444
448
#
445
 
CREATE TABLE t1 (a int, key(a)) engine=heap;
 
449
CREATE TEMPORARY TABLE t1 (a int, key(a)) engine=MEMORY;
446
450
insert into t1 values (0);
447
451
delete from t1;
448
452
select * from t1;
455
459
#
456
460
# Bug #3094: Row format of memory tables should always be reported as Fixed
457
461
#
458
 
create table t1 (c char(10)) engine=memory;
459
 
create table t2 (c varchar(10)) engine=memory;
460
 
--replace_column 3 # 8 #
 
462
create temporary table t1 (c char(10)) engine=memory;
 
463
create temporary table t2 (c varchar(10)) engine=memory;
 
464
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
461
465
show table status like 't_';
462
466
drop table t1, t2;
463
467
 
465
469
# BUG#18233 - Memory tables INDEX USING HASH (a,b) returns 1 row on
466
470
#             SELECT WHERE a= AND b=
467
471
#
468
 
CREATE TABLE t1(a VARCHAR(1), b VARCHAR(2), c VARCHAR(256),
 
472
CREATE TEMPORARY TABLE t1(a VARCHAR(1), b VARCHAR(2), c VARCHAR(256),
469
473
                KEY(a), KEY(b), KEY(c)) ENGINE=MEMORY;
470
474
INSERT INTO t1 VALUES('a','aa',REPEAT('a', 256)),('a','aa',REPEAT('a',256));
471
475
SELECT COUNT(*) FROM t1 WHERE a='a';
478
482
#
479
483
# BUG#26080 - Memory Storage engine not working properly
480
484
#
481
 
CREATE TABLE t1(c1 VARCHAR(100), c2 INT) ENGINE=MEMORY;
 
485
CREATE TEMPORARY TABLE t1(c1 VARCHAR(100), c2 INT) ENGINE=MEMORY;
482
486
INSERT INTO t1 VALUES('', 0);
483
487
ALTER TABLE t1 MODIFY c1 VARCHAR(101);
484
488
SELECT c2 FROM t1;