~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysql-test/r/heap.result

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

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
5
show keys from t1;
23
23
4       6
24
24
alter table t1 add c int not null, add key (c,a);
25
25
drop table t1;
26
 
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";
27
27
insert into t1 values(1,1),(2,2),(3,3),(4,4);
28
28
delete from t1 where a > 0;
29
29
select * from t1;
30
30
a       b
31
31
drop table t1;
32
 
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";
33
33
insert into t1 values(1,1),(2,2),(3,3),(4,4);
34
 
alter table t1 modify a int not null auto_increment, engine=innodb, comment="new innodb table";
 
34
alter table t1 modify a int not null auto_increment, engine=myisam, comment="new myisam table";
35
35
select * from t1;
36
36
a       b
37
37
1       1
39
39
3       3
40
40
4       4
41
41
drop table t1;
42
 
create temporary table t1 (a int not null) engine=MEMORY;
 
42
create table t1 (a int not null) engine=heap;
43
43
insert into t1 values (869751),(736494),(226312),(802616),(728912);
44
44
select * from t1 where a > 736494;
45
45
a
63
63
736494
64
64
802616
65
65
869751
66
 
create temporary table t2 SELECT * FROM t1;
67
 
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);
68
68
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
69
 
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    5       Using where
70
 
drop table t1,t2;
71
 
create temporary table t1 (x int not null, y int not null, key x (x), unique y (y))
72
 
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;
73
73
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
74
74
select * from t1 where x=1;
75
75
x       y
76
76
1       3
77
77
1       1
78
78
select * from t1,t1 as t2 where t1.x=t2.y;
79
 
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
80
86
explain select * from t1,t1 as t2 where t1.x=t2.y;
81
 
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       
82
90
drop table t1;
83
 
create temporary table t1 (a int) engine=MEMORY;
 
91
create table t1 (a int) engine=heap;
84
92
insert into t1 values(1);
85
93
select max(a) from t1;
86
94
max(a)
87
95
1
88
96
drop table t1;
89
 
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;
90
98
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
91
99
select * from t1 where a=1;
92
100
a       b
112
120
1       2
113
121
1       1
114
122
drop table t1;
115
 
create temporary table t1 (id int not null, primary key (id)) engine=MEMORY;
 
123
create table t1 (id int unsigned not null, primary key (id)) engine=HEAP;
116
124
insert into t1 values(1);
117
125
select max(id) from t1;
118
126
max(id)
123
131
2
124
132
replace into t1 values(1);
125
133
drop table t1;
126
 
create temporary table t1 (n int) engine=MEMORY;
 
134
create table t1 (n int) engine=heap;
127
135
drop table t1;
128
 
create temporary table t1 (n int) engine=MEMORY;
 
136
create table t1 (n int) engine=heap;
129
137
drop table if exists t1;
130
 
CREATE TEMPORARY table t1(f1 int not null,f2 char(20) not 
131
 
null,index(f2)) engine=MEMORY;
 
138
CREATE table t1(f1 int not null,f2 char(20) not 
 
139
null,index(f2)) engine=heap;
132
140
INSERT into t1 set f1=12,f2="bill";
133
141
INSERT into t1 set f1=13,f2="bill";
134
142
INSERT into t1 set f1=14,f2="bill";
147
155
12      ted
148
156
12      ted
149
157
drop table t1;
150
 
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;
151
159
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
152
160
explain select * from t1 where btn like "q%";
153
161
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
161
169
1       SIMPLE  t1      ALL     btn     NULL    NULL    NULL    14      Using where
162
170
explain select * from t1 where btn="a" and new_col="a";
163
171
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
164
 
1       SIMPLE  t1      ref     btn     btn     48      const,const     2       Using where
 
172
1       SIMPLE  t1      ref     btn     btn     11      const,const     2       Using where
165
173
drop table t1;
166
 
CREATE TEMPORARY TABLE t1 (
 
174
CREATE TABLE t1 (
167
175
a int default NULL,
168
176
b int default NULL,
169
177
KEY a (a),
170
178
UNIQUE b (b)
171
 
) engine=MEMORY;
 
179
) engine=heap;
172
180
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
173
181
SELECT * FROM t1 WHERE a=NULL;
174
182
a       b
189
197
INSERT INTO t1 VALUES (1,3);
190
198
ERROR 23000: Duplicate entry '3' for key 'b'
191
199
DROP TABLE t1;
192
 
CREATE TEMPORARY TABLE t1 (
 
200
CREATE TABLE t1 (
193
201
a int default NULL,
194
202
key a (a)
195
 
) ENGINE=MEMORY;
 
203
) ENGINE=HEAP;
196
204
INSERT INTO t1 VALUES (10), (10), (10);
197
205
EXPLAIN SELECT * FROM t1 WHERE a=10;
198
206
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
203
211
10
204
212
10
205
213
DROP TABLE t1;
206
 
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;
207
215
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
208
216
DELETE from t1 where a < 100;
209
217
SELECT * from t1;
210
218
a
211
219
DROP TABLE t1;
212
 
CREATE TEMPORARY TABLE `job_titles` (
213
 
`job_title_id` int NOT NULL default '0',
 
220
CREATE TABLE `job_titles` (
 
221
`job_title_id` int(6) unsigned NOT NULL default '0',
214
222
`job_title` char(18) NOT NULL default '',
215
223
PRIMARY KEY  (`job_title_id`),
216
224
UNIQUE KEY `job_title_id` (`job_title_id`,`job_title`)
217
 
) ENGINE=MEMORY;
 
225
) ENGINE=HEAP;
218
226
SELECT MAX(job_title_id) FROM job_titles;
219
227
MAX(job_title_id)
220
228
NULL
221
229
DROP TABLE job_titles;
222
 
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;
223
231
INSERT INTO t1 VALUES(1,1), (1,NULL);
224
232
SELECT * FROM t1 WHERE B is not null;
225
233
a       B
226
234
1       1
227
235
DROP TABLE t1;
228
 
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(10) unsigned NOT NULL) ENGINE=HEAP;
229
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);
230
238
DELETE FROM t1 WHERE date<1101106546;
231
239
SELECT * FROM t1;
232
240
pseudo  date
233
241
ZoomZip 1101106546
234
242
DROP TABLE t1;
235
 
create temporary table t1(a char(2)) engine=memory;
 
243
create table t1(a char(2)) engine=memory;
236
244
insert into t1 values (NULL), (NULL);
237
245
delete from t1 where a is null;
238
246
insert into t1 values ('2'), ('3');
241
249
3
242
250
2
243
251
drop table t1;
244
 
set storage_engine=MEMORY;
245
 
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));
246
254
insert into t1 values('+ ', '+ ', '+ ');
247
255
set @a=repeat(' ',20);
248
256
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
251
259
Note    1265    Data truncated for column 'c' at row 1
252
260
select concat('*',v,'*',c,'*',t,'*') from t1;
253
261
concat('*',v,'*',c,'*',t,'*')
254
 
*+ *+ *+ *
255
 
*+         *+         *+                    *
 
262
*+ *+*+ *
 
263
*+         *+*+                    *
256
264
show create table t1;
257
265
Table   Create Table
258
 
t1      CREATE TEMPORARY TABLE `t1` (
 
266
t1      CREATE TABLE `t1` (
259
267
  `v` varchar(10) DEFAULT NULL,
260
 
  `c` varchar(10) DEFAULT NULL,
 
268
  `c` char(10) DEFAULT NULL,
261
269
  `t` varchar(50) DEFAULT NULL
262
 
) ENGINE=MEMORY
263
 
create temporary table t2 like t1;
 
270
) ENGINE=MEMORY DEFAULT CHARSET=latin1
 
271
create table t2 like t1;
264
272
show create table t2;
265
273
Table   Create Table
266
 
t2      CREATE TEMPORARY TABLE `t2` (
 
274
t2      CREATE TABLE `t2` (
267
275
  `v` varchar(10) DEFAULT NULL,
268
 
  `c` varchar(10) DEFAULT NULL,
 
276
  `c` char(10) DEFAULT NULL,
269
277
  `t` varchar(50) DEFAULT NULL
270
 
) ENGINE=MEMORY
271
 
create temporary table t3 select * from t1;
 
278
) ENGINE=MEMORY DEFAULT CHARSET=latin1
 
279
create table t3 select * from t1;
272
280
show create table t3;
273
281
Table   Create Table
274
 
t3      CREATE TEMPORARY TABLE `t3` (
 
282
t3      CREATE TABLE `t3` (
275
283
  `v` varchar(10) DEFAULT NULL,
276
 
  `c` varchar(10) DEFAULT NULL,
 
284
  `c` char(10) DEFAULT NULL,
277
285
  `t` varchar(50) DEFAULT NULL
278
 
) ENGINE=MEMORY
 
286
) ENGINE=MEMORY DEFAULT CHARSET=latin1
279
287
alter table t1 modify c varchar(10);
280
288
show create table t1;
281
289
Table   Create Table
282
 
t1      CREATE TEMPORARY TABLE `t1` (
 
290
t1      CREATE TABLE `t1` (
283
291
  `v` varchar(10) DEFAULT NULL,
284
292
  `c` varchar(10) DEFAULT NULL,
285
293
  `t` varchar(50) DEFAULT NULL
286
 
) ENGINE=MEMORY
 
294
) ENGINE=MEMORY DEFAULT CHARSET=latin1
287
295
alter table t1 modify v char(10);
288
296
show create table t1;
289
297
Table   Create Table
290
 
t1      CREATE TEMPORARY TABLE `t1` (
291
 
  `v` varchar(10) DEFAULT NULL,
 
298
t1      CREATE TABLE `t1` (
 
299
  `v` char(10) DEFAULT NULL,
292
300
  `c` varchar(10) DEFAULT NULL,
293
301
  `t` varchar(50) DEFAULT NULL
294
 
) ENGINE=MEMORY
295
 
alter table t1 modify t varchar(50);
 
302
) ENGINE=MEMORY DEFAULT CHARSET=latin1
 
303
alter table t1 modify t varchar(10);
 
304
Warnings:
 
305
Warning 1265    Data truncated for column 't' at row 2
296
306
show create table t1;
297
307
Table   Create Table
298
 
t1      CREATE TEMPORARY TABLE `t1` (
299
 
  `v` varchar(10) DEFAULT NULL,
 
308
t1      CREATE TABLE `t1` (
 
309
  `v` char(10) DEFAULT NULL,
300
310
  `c` varchar(10) DEFAULT NULL,
301
 
  `t` varchar(50) DEFAULT NULL
302
 
) ENGINE=MEMORY
 
311
  `t` varchar(10) DEFAULT NULL
 
312
) ENGINE=MEMORY DEFAULT CHARSET=latin1
303
313
select concat('*',v,'*',c,'*',t,'*') from t1;
304
314
concat('*',v,'*',c,'*',t,'*')
305
 
*+ *+ *+ *
306
 
*+         *+         *+                    *
 
315
*+*+*+ *
 
316
*+*+*+         *
307
317
drop table t1,t2,t3;
308
 
create temporary table t1 (v varchar(10), c char(10), t varchar(50), key(v), key(c), key(t(10)));
 
318
create table t1 (v varchar(10), c char(10), t varchar(50), key(v), key(c), key(t(10)));
309
319
show create table t1;
310
320
Table   Create Table
311
 
t1      CREATE TEMPORARY TABLE `t1` (
 
321
t1      CREATE TABLE `t1` (
312
322
  `v` varchar(10) DEFAULT NULL,
313
 
  `c` varchar(10) DEFAULT NULL,
 
323
  `c` char(10) DEFAULT NULL,
314
324
  `t` varchar(50) DEFAULT NULL,
315
325
  KEY `v` (`v`),
316
326
  KEY `c` (`c`),
317
327
  KEY `t` (`t`(10))
318
 
) ENGINE=MEMORY
 
328
) ENGINE=MEMORY DEFAULT CHARSET=latin1
319
329
select count(*) from t1;
320
330
count(*)
321
331
270
358
368
9
359
369
explain select count(*) from t1 where v='a  ';
360
370
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
361
 
1       SIMPLE  t1      ref     v       v       43      const   10      Using where
 
371
1       SIMPLE  t1      ref     v       v       13      const   10      Using where
362
372
explain select count(*) from t1 where c='a  ';
363
373
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
364
 
1       SIMPLE  t1      ref     c       c       43      const   10      Using where
 
374
1       SIMPLE  t1      ref     c       c       11      const   10      Using where
365
375
explain select count(*) from t1 where t='a  ';
366
376
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
367
 
1       SIMPLE  t1      ref     t       t       43      const   10      Using where
 
377
1       SIMPLE  t1      ref     t       t       13      const   10      Using where
368
378
explain select count(*) from t1 where v like 'a%';
369
379
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
370
380
1       SIMPLE  t1      ALL     v       NULL    NULL    NULL    271     Using where
371
381
explain select count(*) from t1 where v between 'a' and 'a ';
372
382
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
373
 
1       SIMPLE  t1      ref     v       v       43      const   10      Using where
 
383
1       SIMPLE  t1      ref     v       v       13      const   10      Using where
374
384
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
375
385
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
376
 
1       SIMPLE  t1      ref     v       v       43      const   10      Using where
 
386
1       SIMPLE  t1      ref     v       v       13      const   10      Using where
377
387
alter table t1 add unique(v);
378
388
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
379
389
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*'));
380
390
qq
381
391
*a*a*a*
382
 
*a *a *a *
383
 
*a  *a  *a  *
384
 
*a   *a   *a   *
385
 
*a    *a    *a    *
386
 
*a     *a     *a     *
387
 
*a      *a      *a      *
388
 
*a       *a       *a       *
389
 
*a        *a        *a        *
390
 
*a         *a         *a         *
 
392
*a *a*a *
 
393
*a  *a*a  *
 
394
*a   *a*a   *
 
395
*a    *a*a    *
 
396
*a     *a*a     *
 
397
*a      *a*a      *
 
398
*a       *a*a       *
 
399
*a        *a*a        *
 
400
*a         *a*a         *
391
401
explain select * from t1 where v='a';
392
402
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
393
 
1       SIMPLE  t1      ref     v       v       43      const   10      Using where
 
403
1       SIMPLE  t1      ref     v       v       13      const   10      Using where
394
404
select v,count(*) from t1 group by v limit 10;
395
405
v       count(*)
396
406
a      1
475
485
g       10
476
486
h       10
477
487
i       10
 
488
select sql_big_result c,count(t) from t1 group by c limit 10;
 
489
c       count(t)
 
490
a      1
 
491
a       10
 
492
b       10
 
493
c       10
 
494
d       10
 
495
e       10
 
496
f       10
 
497
g       10
 
498
h       10
 
499
i       10
478
500
select t,count(*) from t1 group by t limit 10;
479
501
t       count(*)
480
502
a      1
512
534
h       10
513
535
i       10
514
536
drop table t1;
515
 
create temporary table t1 (a char(10), unique (a));
 
537
create table t1 (a char(10), unique (a));
516
538
insert into t1 values ('a');
517
539
insert into t1 values ('a ');
518
 
ERROR 23000: Duplicate entry 'a ' for key 'a'
 
540
ERROR 23000: Duplicate entry 'a' for key 'a'
519
541
alter table t1 modify a varchar(10);
520
542
insert into t1 values ('a '),('a  '),('a   '),('a         ');
521
543
ERROR 23000: Duplicate entry 'a ' for key 'a'
528
550
update t1 set a='a      ' where a like 'a ';
529
551
update t1 set a='a  ' where a like 'a      ';
530
552
drop table t1;
531
 
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)));
 
553
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)));
532
554
show create table t1;
533
555
Table   Create Table
534
 
t1      CREATE TEMPORARY TABLE `t1` (
 
556
t1      CREATE TABLE `t1` (
535
557
  `v` varchar(10) DEFAULT NULL,
536
 
  `c` varchar(10) DEFAULT NULL,
 
558
  `c` char(10) DEFAULT NULL,
537
559
  `t` varchar(50) DEFAULT NULL,
538
560
  KEY `v` (`v`) USING BTREE,
539
561
  KEY `c` (`c`) USING BTREE,
540
562
  KEY `t` (`t`(10)) USING BTREE
541
 
) ENGINE=MEMORY
 
563
) ENGINE=MEMORY DEFAULT CHARSET=latin1
542
564
select count(*) from t1;
543
565
count(*)
544
566
270
569
591
10
570
592
explain select count(*) from t1 where v='a  ';
571
593
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
572
 
1       SIMPLE  t1      ref     v       v       43      const   #       Using where
 
594
1       SIMPLE  t1      ref     v       v       13      const   #       Using where
573
595
explain select count(*) from t1 where c='a  ';
574
596
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
575
 
1       SIMPLE  t1      ref     c       c       43      const   #       Using where
 
597
1       SIMPLE  t1      ref     c       c       11      const   #       Using where
576
598
explain select count(*) from t1 where t='a  ';
577
599
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
578
 
1       SIMPLE  t1      ref     t       t       43      const   #       Using where
 
600
1       SIMPLE  t1      ref     t       t       13      const   #       Using where
579
601
explain select count(*) from t1 where v like 'a%';
580
602
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
581
 
1       SIMPLE  t1      range   v       v       43      NULL    #       Using where
 
603
1       SIMPLE  t1      range   v       v       13      NULL    #       Using where
582
604
explain select count(*) from t1 where v between 'a' and 'a ';
583
605
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
584
 
1       SIMPLE  t1      ref     v       v       43      const   #       Using where
 
606
1       SIMPLE  t1      ref     v       v       13      const   #       Using where
585
607
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
586
608
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
587
 
1       SIMPLE  t1      ref     v       v       43      const   #       Using where
 
609
1       SIMPLE  t1      ref     v       v       13      const   #       Using where
588
610
alter table t1 add unique(v);
589
611
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
590
612
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*'));
591
613
qq
592
614
*a*a*a*
593
 
*a *a *a *
594
 
*a  *a  *a  *
595
 
*a   *a   *a   *
596
 
*a    *a    *a    *
597
 
*a     *a     *a     *
598
 
*a      *a      *a      *
599
 
*a       *a       *a       *
600
 
*a        *a        *a        *
601
 
*a         *a         *a         *
 
615
*a *a*a *
 
616
*a  *a*a  *
 
617
*a   *a*a   *
 
618
*a    *a*a    *
 
619
*a     *a*a     *
 
620
*a      *a*a      *
 
621
*a       *a*a       *
 
622
*a        *a*a        *
 
623
*a         *a*a         *
602
624
explain select * from t1 where v='a';
603
625
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
604
 
1       SIMPLE  t1      ref     v       v       43      const   #       Using where
 
626
1       SIMPLE  t1      ref     v       v       13      const   #       Using where
605
627
drop table t1;
606
 
create temporary table t1 (a char(10), unique using btree (a)) engine=MEMORY;
 
628
create table t1 (a char(10), unique using btree (a)) engine=heap;
607
629
insert into t1 values ('a');
608
630
insert into t1 values ('a ');
609
 
ERROR 23000: Duplicate entry 'a ' for key 'a'
 
631
ERROR 23000: Duplicate entry 'a' for key 'a'
610
632
alter table t1 modify a varchar(10);
611
633
insert into t1 values ('a '),('a  '),('a   '),('a         ');
612
634
ERROR 23000: Duplicate entry 'a ' for key 'a'
619
641
update t1 set a='a      ' where a like 'a ';
620
642
update t1 set a='a  ' where a like 'a      ';
621
643
drop table t1;
622
 
create temporary table t1 (v varchar(10), c char(10), t varchar(50), key(v(5)), key(c(5)), key(t(5)));
 
644
create table t1 (v varchar(10), c char(10), t varchar(50), key(v(5)), key(c(5)), key(t(5)));
623
645
show create table t1;
624
646
Table   Create Table
625
 
t1      CREATE TEMPORARY TABLE `t1` (
 
647
t1      CREATE TABLE `t1` (
626
648
  `v` varchar(10) DEFAULT NULL,
627
 
  `c` varchar(10) DEFAULT NULL,
 
649
  `c` char(10) DEFAULT NULL,
628
650
  `t` varchar(50) DEFAULT NULL,
629
651
  KEY `v` (`v`(5)),
630
652
  KEY `c` (`c`(5)),
631
653
  KEY `t` (`t`(5))
632
 
) ENGINE=MEMORY
 
654
) ENGINE=MEMORY DEFAULT CHARSET=latin1
633
655
drop table t1;
634
 
create temporary table t1 (v varchar(16383), key(v(10)));
 
656
create table t1 (v varchar(65530), key(v(10)));
635
657
show create table t1;
636
658
Table   Create Table
637
 
t1      CREATE TEMPORARY TABLE `t1` (
638
 
  `v` varchar(16383) DEFAULT NULL,
 
659
t1      CREATE TABLE `t1` (
 
660
  `v` varchar(65530) DEFAULT NULL,
639
661
  KEY `v` (`v`(10))
640
 
) ENGINE=MEMORY
641
 
insert into t1 values(repeat('a',16383));
642
 
select length(v) from t1 where v=repeat('a',16383);
 
662
) ENGINE=MEMORY DEFAULT CHARSET=latin1
 
663
insert into t1 values(repeat('a',65530));
 
664
select length(v) from t1 where v=repeat('a',65530);
643
665
length(v)
644
 
16383
 
666
65530
645
667
drop table t1;
646
 
set storage_engine=InnoDB;
647
 
create temporary table t1 (a bigint auto_increment primary key, b int,
648
 
key (b, a)) engine=MEMORY;
 
668
set storage_engine=MyISAM;
 
669
create table t1 (a bigint unsigned auto_increment primary key, b int,
 
670
key (b, a)) engine=heap;
649
671
insert t1 (b) values (1),(1),(1),(1),(1),(1),(1),(1);
650
672
select * from t1;
651
673
a       b
658
680
7       1
659
681
8       1
660
682
drop table t1;
661
 
create temporary table t1 (a int not null, b int not null auto_increment,
662
 
primary key(a, b), key(b)) engine=MEMORY;
 
683
create table t1 (a int not null, b int not null auto_increment,
 
684
primary key(a, b), key(b)) engine=heap;
663
685
insert t1 (a) values (1),(1),(1),(1),(1),(1),(1),(1);
664
686
select * from t1;
665
687
a       b
672
694
1       7
673
695
1       8
674
696
drop table t1;
675
 
create temporary table t1 (a int not null, b int not null auto_increment,
676
 
primary key(a, b)) engine=MEMORY;
 
697
create table t1 (a int not null, b int not null auto_increment,
 
698
primary key(a, b)) engine=heap;
677
699
ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key
678
 
create temporary table t1 (c char(255), primary key(c(90)));
 
700
create table t1 (c char(255), primary key(c(90)));
679
701
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
680
702
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
681
703
ERROR 23000: Duplicate entry 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl' for key 'PRIMARY'
682
704
drop table t1;
683
 
CREATE TEMPORARY TABLE t1 (a int, key(a)) engine=MEMORY;
 
705
CREATE TABLE t1 (a int, key(a)) engine=heap;
684
706
insert into t1 values (0);
685
707
delete from t1;
686
708
select * from t1;
690
712
a
691
713
0
692
714
drop table t1;
693
 
create temporary table t1 (c char(10)) engine=memory;
694
 
create temporary table t2 (c varchar(10)) engine=memory;
 
715
create table t1 (c char(10)) engine=memory;
 
716
create table t2 (c varchar(10)) engine=memory;
695
717
show table status like 't_';
696
718
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
 
719
t1      MEMORY  10      Fixed   0       11      0       #       0       0       NULL    NULL    NULL    NULL    latin1_swedish_ci       NULL            
 
720
t2      MEMORY  10      Fixed   0       12      0       #       0       0       NULL    NULL    NULL    NULL    latin1_swedish_ci       NULL            
697
721
drop table t1, t2;
698
 
CREATE TEMPORARY TABLE t1(a VARCHAR(1), b VARCHAR(2), c VARCHAR(256),
 
722
CREATE TABLE t1(a VARCHAR(1), b VARCHAR(2), c VARCHAR(256),
699
723
KEY(a), KEY(b), KEY(c)) ENGINE=MEMORY;
700
724
INSERT INTO t1 VALUES('a','aa',REPEAT('a', 256)),('a','aa',REPEAT('a',256));
701
725
SELECT COUNT(*) FROM t1 WHERE a='a';
708
732
COUNT(*)
709
733
2
710
734
DROP TABLE t1;
711
 
CREATE TEMPORARY TABLE t1(c1 VARCHAR(100), c2 INT) ENGINE=MEMORY;
 
735
CREATE TABLE t1(c1 VARCHAR(100), c2 INT) ENGINE=MEMORY;
712
736
INSERT INTO t1 VALUES('', 0);
713
737
ALTER TABLE t1 MODIFY c1 VARCHAR(101);
714
738
SELECT c2 FROM t1;