~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/heap.result

  • Committer: Monty Taylor
  • Date: 2009-04-14 19:16:51 UTC
  • mto: (997.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 994.
  • Revision ID: mordred@inaugust.com-20090414191651-ltbww6hpqks8k7qk
Clarified instructions in README.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
drop table if exists t1,t2,t3;
2
 
create temporary table t1 (a int not null,b int not null, primary key (a)) engine=MEMORY comment="testing heaps";
 
2
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;
3
3
insert into t1 values(1,1),(2,2),(3,3),(4,4);
4
4
delete from t1 where a=1 or a=0;
5
 
show table status like "t1";
6
 
Session Schema  Name    Type    Engine  Version Rows    Avg_row_length  Table_size      Auto_increment
7
 
#       test    t1      TEMPORARY       MEMORY  #       #       #       #       #
8
5
show keys from t1;
9
 
Table   Unique  Key_name        Seq_in_index    Column_name
10
 
t1      TRUE    PRIMARY 1       a
 
6
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
7
t1      0       PRIMARY 1       a       NULL    3       NULL    NULL            HASH            
11
8
select * from t1;
12
9
a       b
13
10
2       2
26
23
4       6
27
24
alter table t1 add c int not null, add key (c,a);
28
25
drop table t1;
29
 
create temporary table t1 (a int not null,b int not null, primary key (a)) engine=memory comment="testing heaps";
 
26
create table t1 (a int not null,b int not null, primary key (a)) engine=memory comment="testing heaps";
30
27
insert into t1 values(1,1),(2,2),(3,3),(4,4);
31
28
delete from t1 where a > 0;
32
29
select * from t1;
33
30
a       b
34
31
drop table t1;
35
 
create temporary table t1 (a int not null,b int not null, primary key (a)) engine=MEMORY comment="testing heaps";
 
32
create table t1 (a int not null,b int not null, primary key (a)) engine=heap comment="testing heaps";
36
33
insert into t1 values(1,1),(2,2),(3,3),(4,4);
37
 
alter table t1 modify a int not null auto_increment, engine=innodb, comment="new innodb table";
38
 
show table status like "t1";
39
 
Session Schema  Name    Type    Engine  Version Rows    Avg_row_length  Table_size      Auto_increment
40
 
#       test    t1      TEMPORARY       InnoDB  #       #       #       #       #
 
34
alter table t1 modify a int not null auto_increment, engine=myisam, comment="new myisam table";
41
35
select * from t1;
42
36
a       b
43
37
1       1
45
39
3       3
46
40
4       4
47
41
drop table t1;
48
 
create temporary table t1 (a int not null) engine=MEMORY;
 
42
create table t1 (a int not null) engine=heap;
49
43
insert into t1 values (869751),(736494),(226312),(802616),(728912);
50
44
select * from t1 where a > 736494;
51
45
a
69
63
736494
70
64
802616
71
65
869751
72
 
create temporary table t2 SELECT * FROM t1;
73
 
explain select * from t2 where a in (869751,736494,226312,802616);
 
66
alter table t1 engine=myisam;
 
67
explain select * from t1 where a in (869751,736494,226312,802616);
74
68
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
75
 
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    5       Using where
76
 
drop table t1,t2;
77
 
create temporary table t1 (x int not null, y int not null, key x (x), unique y (y))
78
 
engine=MEMORY;
 
69
1       SIMPLE  t1      range   uniq_id uniq_id 4       NULL    4       Using where; Using index
 
70
drop table t1;
 
71
create table t1 (x int not null, y int not null, key x (x), unique y (y))
 
72
engine=heap;
79
73
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
80
74
select * from t1 where x=1;
81
75
x       y
82
76
1       3
83
77
1       1
84
78
select * from t1,t1 as t2 where t1.x=t2.y;
85
 
ERROR HY000: Can't reopen table: 't1'
 
79
x       y       x       y
 
80
1       1       1       1
 
81
2       2       2       2
 
82
1       3       1       1
 
83
2       4       2       2
 
84
2       5       2       2
 
85
2       6       2       2
86
86
explain select * from t1,t1 as t2 where t1.x=t2.y;
87
 
ERROR HY000: Can't reopen table: 't1'
 
87
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
88
1       SIMPLE  t1      ALL     x       NULL    NULL    NULL    6       
 
89
1       SIMPLE  t2      eq_ref  y       y       4       test.t1.x       1       
88
90
drop table t1;
89
 
create temporary table t1 (a int) engine=MEMORY;
 
91
create table t1 (a int) engine=heap;
90
92
insert into t1 values(1);
91
93
select max(a) from t1;
92
94
max(a)
93
95
1
94
96
drop table t1;
95
 
CREATE TEMPORARY TABLE t1 ( a int not null default 0, b int not null default 0,  key(a),  key(b)  ) ENGINE=MEMORY;
 
97
CREATE TABLE t1 ( a int not null default 0, b int not null default 0,  key(a),  key(b)  ) ENGINE=HEAP;
96
98
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
97
99
select * from t1 where a=1;
98
100
a       b
118
120
1       2
119
121
1       1
120
122
drop table t1;
121
 
create temporary table t1 (id int not null, primary key (id)) engine=MEMORY;
 
123
create table t1 (id int not null, primary key (id)) engine=HEAP;
122
124
insert into t1 values(1);
123
125
select max(id) from t1;
124
126
max(id)
129
131
2
130
132
replace into t1 values(1);
131
133
drop table t1;
132
 
create temporary table t1 (n int) engine=MEMORY;
 
134
create table t1 (n int) engine=heap;
133
135
drop table t1;
134
 
create temporary table t1 (n int) engine=MEMORY;
 
136
create table t1 (n int) engine=heap;
135
137
drop table if exists t1;
136
 
CREATE TEMPORARY table t1(f1 int not null,f2 char(20) not 
137
 
null,index(f2)) engine=MEMORY;
 
138
CREATE table t1(f1 int not null,f2 char(20) not 
 
139
null,index(f2)) engine=heap;
138
140
INSERT into t1 set f1=12,f2="bill";
139
141
INSERT into t1 set f1=13,f2="bill";
140
142
INSERT into t1 set f1=14,f2="bill";
153
155
12      ted
154
156
12      ted
155
157
drop table t1;
156
 
create temporary table t1 (btn char(10) not null, key(btn)) engine=MEMORY;
 
158
create table t1 (btn char(10) not null, key(btn)) engine=heap;
157
159
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
158
160
explain select * from t1 where btn like "q%";
159
161
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
169
171
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
170
172
1       SIMPLE  t1      ref     btn     btn     48      const,const     2       Using where
171
173
drop table t1;
172
 
CREATE TEMPORARY TABLE t1 (
 
174
CREATE TABLE t1 (
173
175
a int default NULL,
174
176
b int default NULL,
175
177
KEY a (a),
176
178
UNIQUE b (b)
177
 
) engine=MEMORY;
 
179
) engine=heap;
178
180
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
179
181
SELECT * FROM t1 WHERE a=NULL;
180
182
a       b
195
197
INSERT INTO t1 VALUES (1,3);
196
198
ERROR 23000: Duplicate entry '3' for key 'b'
197
199
DROP TABLE t1;
198
 
CREATE TEMPORARY TABLE t1 (
 
200
CREATE TABLE t1 (
199
201
a int default NULL,
200
202
key a (a)
201
 
) ENGINE=MEMORY;
 
203
) ENGINE=HEAP;
202
204
INSERT INTO t1 VALUES (10), (10), (10);
203
205
EXPLAIN SELECT * FROM t1 WHERE a=10;
204
206
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
209
211
10
210
212
10
211
213
DROP TABLE t1;
212
 
CREATE TEMPORARY TABLE t1 (a int not null, primary key(a)) engine=MEMORY;
 
214
CREATE TABLE t1 (a int not null, primary key(a)) engine=heap;
213
215
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
214
216
DELETE from t1 where a < 100;
215
217
SELECT * from t1;
216
218
a
217
219
DROP TABLE t1;
218
 
CREATE TEMPORARY TABLE `job_titles` (
 
220
CREATE TABLE `job_titles` (
219
221
`job_title_id` int NOT NULL default '0',
220
222
`job_title` char(18) NOT NULL default '',
221
223
PRIMARY KEY  (`job_title_id`),
222
224
UNIQUE KEY `job_title_id` (`job_title_id`,`job_title`)
223
 
) ENGINE=MEMORY;
 
225
) ENGINE=HEAP;
224
226
SELECT MAX(job_title_id) FROM job_titles;
225
227
MAX(job_title_id)
226
228
NULL
227
229
DROP TABLE job_titles;
228
 
CREATE TEMPORARY TABLE t1 (a INT NOT NULL, B INT, KEY(B)) ENGINE=MEMORY;
 
230
CREATE TABLE t1 (a INT NOT NULL, B INT, KEY(B)) ENGINE=HEAP;
229
231
INSERT INTO t1 VALUES(1,1), (1,NULL);
230
232
SELECT * FROM t1 WHERE B is not null;
231
233
a       B
232
234
1       1
233
235
DROP TABLE t1;
234
 
CREATE TEMPORARY TABLE t1 (pseudo char(35) PRIMARY KEY, date int NOT NULL) ENGINE=MEMORY;
 
236
CREATE TABLE t1 (pseudo char(35) PRIMARY KEY, date int NOT NULL) ENGINE=HEAP;
235
237
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);
236
238
DELETE FROM t1 WHERE date<1101106546;
237
239
SELECT * FROM t1;
238
240
pseudo  date
239
241
ZoomZip 1101106546
240
242
DROP TABLE t1;
241
 
create temporary table t1(a char(2)) engine=memory;
 
243
create table t1(a char(2)) engine=memory;
242
244
insert into t1 values (NULL), (NULL);
243
245
delete from t1 where a is null;
244
246
insert into t1 values ('2'), ('3');
247
249
3
248
250
2
249
251
drop table t1;
250
 
set storage_engine=MEMORY;
251
 
create temporary table t1 (v varchar(10), c char(10), t varchar(50));
 
252
set storage_engine=HEAP;
 
253
create table t1 (v varchar(10), c char(10), t varchar(50));
252
254
insert into t1 values('+ ', '+ ', '+ ');
253
255
set @a=repeat(' ',20);
254
256
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
261
263
*+         *+         *+                    *
262
264
show create table t1;
263
265
Table   Create Table
264
 
t1      CREATE TEMPORARY TABLE `t1` (
 
266
t1      CREATE TABLE `t1` (
265
267
  `v` varchar(10) DEFAULT NULL,
266
268
  `c` varchar(10) DEFAULT NULL,
267
269
  `t` varchar(50) DEFAULT NULL
268
270
) ENGINE=MEMORY
269
 
create temporary table t2 like t1;
 
271
create table t2 like t1;
270
272
show create table t2;
271
273
Table   Create Table
272
 
t2      CREATE TEMPORARY TABLE `t2` (
 
274
t2      CREATE TABLE `t2` (
273
275
  `v` varchar(10) DEFAULT NULL,
274
276
  `c` varchar(10) DEFAULT NULL,
275
277
  `t` varchar(50) DEFAULT NULL
276
278
) ENGINE=MEMORY
277
 
create temporary table t3 select * from t1;
 
279
create table t3 select * from t1;
278
280
show create table t3;
279
281
Table   Create Table
280
 
t3      CREATE TEMPORARY TABLE `t3` (
 
282
t3      CREATE TABLE `t3` (
281
283
  `v` varchar(10) DEFAULT NULL,
282
284
  `c` varchar(10) DEFAULT NULL,
283
285
  `t` varchar(50) DEFAULT NULL
285
287
alter table t1 modify c varchar(10);
286
288
show create table t1;
287
289
Table   Create Table
288
 
t1      CREATE TEMPORARY TABLE `t1` (
 
290
t1      CREATE TABLE `t1` (
289
291
  `v` varchar(10) DEFAULT NULL,
290
292
  `c` varchar(10) DEFAULT NULL,
291
293
  `t` varchar(50) DEFAULT NULL
293
295
alter table t1 modify v char(10);
294
296
show create table t1;
295
297
Table   Create Table
296
 
t1      CREATE TEMPORARY TABLE `t1` (
 
298
t1      CREATE TABLE `t1` (
297
299
  `v` varchar(10) DEFAULT NULL,
298
300
  `c` varchar(10) DEFAULT NULL,
299
301
  `t` varchar(50) DEFAULT NULL
301
303
alter table t1 modify t varchar(50);
302
304
show create table t1;
303
305
Table   Create Table
304
 
t1      CREATE TEMPORARY TABLE `t1` (
 
306
t1      CREATE TABLE `t1` (
305
307
  `v` varchar(10) DEFAULT NULL,
306
308
  `c` varchar(10) DEFAULT NULL,
307
309
  `t` varchar(50) DEFAULT NULL
311
313
*+ *+ *+ *
312
314
*+         *+         *+                    *
313
315
drop table t1,t2,t3;
314
 
create temporary table t1 (v varchar(10), c char(10), t varchar(50), key(v), key(c), key(t(10)));
 
316
create table t1 (v varchar(10), c char(10), t varchar(50), key(v), key(c), key(t(10)));
315
317
show create table t1;
316
318
Table   Create Table
317
 
t1      CREATE TEMPORARY TABLE `t1` (
 
319
t1      CREATE TABLE `t1` (
318
320
  `v` varchar(10) DEFAULT NULL,
319
321
  `c` varchar(10) DEFAULT NULL,
320
322
  `t` varchar(50) DEFAULT NULL,
321
323
  KEY `v` (`v`),
322
324
  KEY `c` (`c`),
323
 
  KEY `t` (`t`(10))
 
325
  KEY `t` (`t`())
324
326
) ENGINE=MEMORY
325
327
select count(*) from t1;
326
328
count(*)
518
520
h       10
519
521
i       10
520
522
drop table t1;
521
 
create temporary table t1 (a char(10), unique (a));
 
523
create table t1 (a char(10), unique (a));
522
524
insert into t1 values ('a');
523
525
insert into t1 values ('a ');
524
526
ERROR 23000: Duplicate entry 'a ' for key 'a'
534
536
update t1 set a='a      ' where a like 'a ';
535
537
update t1 set a='a  ' where a like 'a      ';
536
538
drop table t1;
537
 
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)));
 
539
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)));
538
540
show create table t1;
539
541
Table   Create Table
540
 
t1      CREATE TEMPORARY TABLE `t1` (
 
542
t1      CREATE TABLE `t1` (
541
543
  `v` varchar(10) DEFAULT NULL,
542
544
  `c` varchar(10) DEFAULT NULL,
543
545
  `t` varchar(50) DEFAULT NULL,
544
546
  KEY `v` (`v`) USING BTREE,
545
547
  KEY `c` (`c`) USING BTREE,
546
 
  KEY `t` (`t`(10)) USING BTREE
 
548
  KEY `t` (`t`()) USING BTREE
547
549
) ENGINE=MEMORY
548
550
select count(*) from t1;
549
551
count(*)
609
611
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
610
612
1       SIMPLE  t1      ref     v       v       43      const   #       Using where
611
613
drop table t1;
612
 
create temporary table t1 (a char(10), unique using btree (a)) engine=MEMORY;
 
614
create table t1 (a char(10), unique using btree (a)) engine=heap;
613
615
insert into t1 values ('a');
614
616
insert into t1 values ('a ');
615
617
ERROR 23000: Duplicate entry 'a ' for key 'a'
625
627
update t1 set a='a      ' where a like 'a ';
626
628
update t1 set a='a  ' where a like 'a      ';
627
629
drop table t1;
628
 
create temporary table t1 (v varchar(10), c char(10), t varchar(50), key(v(5)), key(c(5)), key(t(5)));
 
630
create table t1 (v varchar(10), c char(10), t varchar(50), key(v(5)), key(c(5)), key(t(5)));
629
631
show create table t1;
630
632
Table   Create Table
631
 
t1      CREATE TEMPORARY TABLE `t1` (
 
633
t1      CREATE TABLE `t1` (
632
634
  `v` varchar(10) DEFAULT NULL,
633
635
  `c` varchar(10) DEFAULT NULL,
634
636
  `t` varchar(50) DEFAULT NULL,
635
 
  KEY `v` (`v`(5)),
636
 
  KEY `c` (`c`(5)),
637
 
  KEY `t` (`t`(5))
 
637
  KEY `v` (`v`()),
 
638
  KEY `c` (`c`()),
 
639
  KEY `t` (`t`())
638
640
) ENGINE=MEMORY
639
641
drop table t1;
640
 
create temporary table t1 (v varchar(16383), key(v(10)));
 
642
create table t1 (v varchar(16383), key(v(10)));
641
643
show create table t1;
642
644
Table   Create Table
643
 
t1      CREATE TEMPORARY TABLE `t1` (
 
645
t1      CREATE TABLE `t1` (
644
646
  `v` varchar(16383) DEFAULT NULL,
645
 
  KEY `v` (`v`(10))
 
647
  KEY `v` (`v`())
646
648
) ENGINE=MEMORY
647
649
insert into t1 values(repeat('a',16383));
648
650
select length(v) from t1 where v=repeat('a',16383);
650
652
16383
651
653
drop table t1;
652
654
set storage_engine=InnoDB;
653
 
create temporary table t1 (a bigint auto_increment primary key, b int,
654
 
key (b, a)) engine=MEMORY;
 
655
create table t1 (a bigint auto_increment primary key, b int,
 
656
key (b, a)) engine=heap;
655
657
insert t1 (b) values (1),(1),(1),(1),(1),(1),(1),(1);
656
658
select * from t1;
657
659
a       b
664
666
7       1
665
667
8       1
666
668
drop table t1;
667
 
create temporary table t1 (a int not null, b int not null auto_increment,
668
 
primary key(a, b), key(b)) engine=MEMORY;
 
669
create table t1 (a int not null, b int not null auto_increment,
 
670
primary key(a, b), key(b)) engine=heap;
669
671
insert t1 (a) values (1),(1),(1),(1),(1),(1),(1),(1);
670
672
select * from t1;
671
673
a       b
678
680
1       7
679
681
1       8
680
682
drop table t1;
681
 
create temporary table t1 (a int not null, b int not null auto_increment,
682
 
primary key(a, b)) engine=MEMORY;
 
683
create table t1 (a int not null, b int not null auto_increment,
 
684
primary key(a, b)) engine=heap;
683
685
ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key
684
 
create temporary table t1 (c char(255), primary key(c(90)));
 
686
create table t1 (c char(255), primary key(c(90)));
685
687
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
686
688
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
687
689
ERROR 23000: Duplicate entry 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl' for key 'PRIMARY'
688
690
drop table t1;
689
 
CREATE TEMPORARY TABLE t1 (a int, key(a)) engine=MEMORY;
 
691
CREATE TABLE t1 (a int, key(a)) engine=heap;
690
692
insert into t1 values (0);
691
693
delete from t1;
692
694
select * from t1;
696
698
a
697
699
0
698
700
drop table t1;
699
 
create temporary table t1 (c char(10)) engine=memory;
700
 
create temporary table t2 (c varchar(10)) engine=memory;
 
701
create table t1 (c char(10)) engine=memory;
 
702
create table t2 (c varchar(10)) engine=memory;
701
703
show table status like 't_';
702
 
Session Schema  Name    Type    Engine  Version Rows    Avg_row_length  Table_size      Auto_increment
703
 
#       test    t1      TEMPORARY       MEMORY  #       #       #       #       #
704
 
#       test    t2      TEMPORARY       MEMORY  #       #       #       #       #
 
704
Name    Engine  Version Row_format      Rows    Avg_row_length  Data_length     Max_data_length Index_length    Data_free       Auto_increment  Create_time     Update_time     Check_time      Collation       Checksum        Create_options  Comment
 
705
t1      MEMORY  #       Fixed   0       42      0       #       0       0       NULL    NULL    NULL    NULL    utf8_general_ci NULL            
 
706
t2      MEMORY  #       Fixed   0       42      0       #       0       0       NULL    NULL    NULL    NULL    utf8_general_ci NULL            
705
707
drop table t1, t2;
706
 
CREATE TEMPORARY TABLE t1(a VARCHAR(1), b VARCHAR(2), c VARCHAR(256),
 
708
CREATE TABLE t1(a VARCHAR(1), b VARCHAR(2), c VARCHAR(256),
707
709
KEY(a), KEY(b), KEY(c)) ENGINE=MEMORY;
708
710
INSERT INTO t1 VALUES('a','aa',REPEAT('a', 256)),('a','aa',REPEAT('a',256));
709
711
SELECT COUNT(*) FROM t1 WHERE a='a';
716
718
COUNT(*)
717
719
2
718
720
DROP TABLE t1;
719
 
CREATE TEMPORARY TABLE t1(c1 VARCHAR(100), c2 INT) ENGINE=MEMORY;
 
721
CREATE TABLE t1(c1 VARCHAR(100), c2 INT) ENGINE=MEMORY;
720
722
INSERT INTO t1 VALUES('', 0);
721
723
ALTER TABLE t1 MODIFY c1 VARCHAR(101);
722
724
SELECT c2 FROM t1;