~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/pbxt/heap.result

Merge Nathan

Show diffs side-by-side

added added

removed removed

Lines of Context:
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";
3
 
insert into t1 values(1,1),(2,2),(3,3),(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
 
show keys from t1;
9
 
Table   Unique  Key_name        Seq_in_index    Column_name
10
 
t1      YES     PRIMARY 1       a
11
 
select * from t1;
12
 
a       b
13
 
2       2
14
 
3       3
15
 
4       4
16
 
select * from t1 where a=4;
17
 
a       b
18
 
4       4
19
 
update t1 set b=5 where a=4;
20
 
update t1 set b=b+1 where a>=3;
21
 
replace t1 values (3,3);
22
 
select * from t1;
23
 
a       b
24
 
2       2
25
 
3       3
26
 
4       6
27
 
alter table t1 add c int not null, add key (c,a);
28
 
drop table t1;
29
 
create temporary table t1 (a int not null,b int not null, primary key (a)) engine=memory comment="testing heaps";
30
 
insert into t1 values(1,1),(2,2),(3,3),(4,4);
31
 
delete from t1 where a > 0;
32
 
select * from t1;
33
 
a       b
34
 
drop table t1;
35
 
create temporary table t1 (a int not null,b int not null, primary key (a)) engine=MEMORY comment="testing heaps";
36
 
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  #       #       #       #       #
41
 
select * from t1;
42
 
a       b
43
 
1       1
44
 
2       2
45
 
3       3
46
 
4       4
47
 
drop table t1;
48
 
create temporary table t1 (a int not null) engine=MEMORY;
49
 
insert into t1 values (869751),(736494),(226312),(802616),(728912);
50
 
select * from t1 where a > 736494;
51
 
a
52
 
869751
53
 
802616
54
 
alter table t1 add unique uniq_id(a);
55
 
select * from t1 where a > 736494;
56
 
a
57
 
869751
58
 
802616
59
 
select * from t1 where a = 736494;
60
 
a
61
 
736494
62
 
select * from t1 where a=869751 or a=736494;
63
 
a
64
 
736494
65
 
869751
66
 
select * from t1 where a in (869751,736494,226312,802616);
67
 
a
68
 
226312
69
 
736494
70
 
802616
71
 
869751
72
 
create temporary table t2 SELECT * FROM t1;
73
 
explain select * from t2 where a in (869751,736494,226312,802616);
74
 
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;
79
 
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
80
 
select * from t1 where x=1;
81
 
x       y
82
 
1       3
83
 
1       1
84
 
select * from t1,t1 as t2 where t1.x=t2.y;
85
 
ERROR HY000: Can't reopen table: 't1'
86
 
explain select * from t1,t1 as t2 where t1.x=t2.y;
87
 
ERROR HY000: Can't reopen table: 't1'
88
 
drop table t1;
89
 
create temporary table t1 (a int) engine=MEMORY;
90
 
insert into t1 values(1);
91
 
select max(a) from t1;
92
 
max(a)
93
 
1
94
 
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;
96
 
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
97
 
select * from t1 where a=1;
98
 
a       b
99
 
1       6
100
 
1       5
101
 
1       4
102
 
1       3
103
 
1       2
104
 
1       1
105
 
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
106
 
select * from t1 where a=1;
107
 
a       b
108
 
1       6
109
 
1       5
110
 
1       4
111
 
1       3
112
 
1       2
113
 
1       1
114
 
1       6
115
 
1       5
116
 
1       4
117
 
1       3
118
 
1       2
119
 
1       1
120
 
drop table t1;
121
 
create temporary table t1 (id int not null, primary key (id)) engine=MEMORY;
122
 
insert into t1 values(1);
123
 
select max(id) from t1;
124
 
max(id)
125
 
1
126
 
insert into t1 values(2);
127
 
select max(id) from t1;
128
 
max(id)
129
 
2
130
 
replace into t1 values(1);
131
 
drop table t1;
132
 
create temporary table t1 (n int) engine=MEMORY;
133
 
drop table t1;
134
 
create temporary table t1 (n int) engine=MEMORY;
135
 
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
 
INSERT into t1 set f1=12,f2="bill";
139
 
INSERT into t1 set f1=13,f2="bill";
140
 
INSERT into t1 set f1=14,f2="bill";
141
 
INSERT into t1 set f1=15,f2="bill";
142
 
INSERT into t1 set f1=16,f2="ted";
143
 
INSERT into t1 set f1=12,f2="ted";
144
 
INSERT into t1 set f1=12,f2="ted";
145
 
INSERT into t1 set f1=12,f2="ted";
146
 
INSERT into t1 set f1=12,f2="ted";
147
 
delete from t1 where f2="bill";
148
 
select * from t1;
149
 
f1      f2
150
 
16      ted
151
 
12      ted
152
 
12      ted
153
 
12      ted
154
 
12      ted
155
 
drop table t1;
156
 
create temporary table t1 (btn char(10) not null, key(btn)) engine=MEMORY;
157
 
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
158
 
explain select * from t1 where btn like "q%";
159
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
160
 
1       SIMPLE  t1      ALL     btn     NULL    NULL    NULL    14      Using where
161
 
select * from t1 where btn like "q%";
162
 
btn
163
 
alter table t1 add column new_col char(1) not null, add key (btn,new_col), drop key btn;
164
 
update t1 set new_col=left(btn,1);
165
 
explain select * from t1 where btn="a";
166
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
167
 
1       SIMPLE  t1      ALL     btn     NULL    NULL    NULL    14      Using where
168
 
explain select * from t1 where btn="a" and new_col="a";
169
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
170
 
1       SIMPLE  t1      ref     btn     btn     48      const,const     2       Using where
171
 
drop table t1;
172
 
CREATE TEMPORARY TABLE t1 (
173
 
a int default NULL,
174
 
b int default NULL,
175
 
KEY a (a),
176
 
UNIQUE b (b)
177
 
) engine=MEMORY;
178
 
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
179
 
SELECT * FROM t1 WHERE a=NULL;
180
 
a       b
181
 
explain SELECT * FROM t1 WHERE a IS NULL;
182
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
183
 
1       SIMPLE  t1      ref     a       a       5       const   2       Using where
184
 
SELECT * FROM t1 WHERE a<=>NULL;
185
 
a       b
186
 
NULL    99
187
 
SELECT * FROM t1 WHERE b=NULL;
188
 
a       b
189
 
explain SELECT * FROM t1 WHERE b IS NULL;
190
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
191
 
1       SIMPLE  t1      ref     b       b       5       const   1       Using where
192
 
SELECT * FROM t1 WHERE b<=>NULL;
193
 
a       b
194
 
99      NULL
195
 
INSERT INTO t1 VALUES (1,3);
196
 
ERROR 23000: Duplicate entry '3' for key 'b'
197
 
DROP TABLE t1;
198
 
CREATE TEMPORARY TABLE t1 (
199
 
a int default NULL,
200
 
key a (a)
201
 
) ENGINE=MEMORY;
202
 
INSERT INTO t1 VALUES (10), (10), (10);
203
 
EXPLAIN SELECT * FROM t1 WHERE a=10;
204
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
205
 
1       SIMPLE  t1      ref     a       a       5       const   3       Using where
206
 
SELECT * FROM t1 WHERE a=10;
207
 
a
208
 
10
209
 
10
210
 
10
211
 
DROP TABLE t1;
212
 
CREATE TEMPORARY TABLE t1 (a int not null, primary key(a)) engine=MEMORY;
213
 
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
214
 
DELETE from t1 where a < 100;
215
 
SELECT * from t1;
216
 
a
217
 
DROP TABLE t1;
218
 
CREATE TEMPORARY TABLE `job_titles` (
219
 
`job_title_id` int NOT NULL default '0',
220
 
`job_title` char(18) NOT NULL default '',
221
 
PRIMARY KEY  (`job_title_id`),
222
 
UNIQUE KEY `job_title_id` (`job_title_id`,`job_title`)
223
 
) ENGINE=MEMORY;
224
 
SELECT MAX(job_title_id) FROM job_titles;
225
 
MAX(job_title_id)
226
 
NULL
227
 
DROP TABLE job_titles;
228
 
CREATE TEMPORARY TABLE t1 (a INT NOT NULL, B INT, KEY(B)) ENGINE=MEMORY;
229
 
INSERT INTO t1 VALUES(1,1), (1,NULL);
230
 
SELECT * FROM t1 WHERE B is not null;
231
 
a       B
232
 
1       1
233
 
DROP TABLE t1;
234
 
CREATE TEMPORARY TABLE t1 (pseudo char(35) PRIMARY KEY, date int NOT NULL) ENGINE=MEMORY;
235
 
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
 
DELETE FROM t1 WHERE date<1101106546;
237
 
SELECT * FROM t1;
238
 
pseudo  date
239
 
ZoomZip 1101106546
240
 
DROP TABLE t1;
241
 
create temporary table t1(a char(2)) engine=memory;
242
 
insert into t1 values (NULL), (NULL);
243
 
delete from t1 where a is null;
244
 
insert into t1 values ('2'), ('3');
245
 
select * from t1;
246
 
a
247
 
3
248
 
2
249
 
drop table t1;
250
 
set storage_engine=MEMORY;
251
 
create temporary table t1 (v varchar(10), c char(10), t varchar(50));
252
 
insert into t1 values('+ ', '+ ', '+ ');
253
 
set @a=repeat(' ',20);
254
 
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
255
 
ERROR 22001: Data too long for column 'v' at row 1
256
 
set @a=repeat(' ',10);
257
 
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
258
 
ERROR 22001: Data too long for column 'v' at row 1
259
 
set @a=repeat(' ',9);
260
 
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
261
 
select concat('*',v,'*',c,'*',t,'*') from t1;
262
 
concat('*',v,'*',c,'*',t,'*')
263
 
*+ *+ *+ *
264
 
*+         *+         *+         *
265
 
show create table t1;
266
 
Table   Create Table
267
 
t1      CREATE TEMPORARY TABLE `t1` (
268
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
269
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
270
 
  `t` VARCHAR(50) COLLATE utf8_general_ci DEFAULT NULL
271
 
) ENGINE=MEMORY COLLATE = utf8_general_ci
272
 
create temporary table t2 like t1;
273
 
show create table t2;
274
 
Table   Create Table
275
 
t2      CREATE TEMPORARY TABLE `t2` (
276
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
277
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
278
 
  `t` VARCHAR(50) COLLATE utf8_general_ci DEFAULT NULL
279
 
) ENGINE=MEMORY COLLATE = utf8_general_ci
280
 
create temporary table t3 select * from t1;
281
 
show create table t3;
282
 
Table   Create Table
283
 
t3      CREATE TEMPORARY TABLE `t3` (
284
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
285
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
286
 
  `t` VARCHAR(50) COLLATE utf8_general_ci DEFAULT NULL
287
 
) ENGINE=MEMORY COLLATE = utf8_general_ci
288
 
alter table t1 modify c varchar(10);
289
 
show create table t1;
290
 
Table   Create Table
291
 
t1      CREATE TEMPORARY TABLE `t1` (
292
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
293
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
294
 
  `t` VARCHAR(50) COLLATE utf8_general_ci DEFAULT NULL
295
 
) ENGINE=MEMORY COLLATE = utf8_general_ci
296
 
alter table t1 modify v char(10);
297
 
show create table t1;
298
 
Table   Create Table
299
 
t1      CREATE TEMPORARY TABLE `t1` (
300
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
301
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
302
 
  `t` VARCHAR(50) COLLATE utf8_general_ci DEFAULT NULL
303
 
) ENGINE=MEMORY COLLATE = utf8_general_ci
304
 
alter table t1 modify t varchar(50);
305
 
show create table t1;
306
 
Table   Create Table
307
 
t1      CREATE TEMPORARY TABLE `t1` (
308
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
309
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
310
 
  `t` VARCHAR(50) COLLATE utf8_general_ci DEFAULT NULL
311
 
) ENGINE=MEMORY COLLATE = utf8_general_ci
312
 
select concat('*',v,'*',c,'*',t,'*') from t1;
313
 
concat('*',v,'*',c,'*',t,'*')
314
 
*+ *+ *+ *
315
 
*+         *+         *+         *
316
 
drop table t1,t2,t3;
317
 
create temporary table t1 (v varchar(10), c char(10), t varchar(50), key(v), key(c), key(t(10)));
318
 
show create table t1;
319
 
Table   Create Table
320
 
t1      CREATE TEMPORARY TABLE `t1` (
321
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
322
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
323
 
  `t` VARCHAR(50) COLLATE utf8_general_ci DEFAULT NULL,
324
 
  KEY `v` (`v`),
325
 
  KEY `c` (`c`),
326
 
  KEY `t` (`t`(10))
327
 
) ENGINE=MEMORY COLLATE = utf8_general_ci
328
 
select count(*) from t1;
329
 
count(*)
330
 
270
331
 
insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1)));
332
 
select count(*) from t1 where v='a';
333
 
count(*)
334
 
10
335
 
select count(*) from t1 where c='a';
336
 
count(*)
337
 
10
338
 
select count(*) from t1 where t='a';
339
 
count(*)
340
 
10
341
 
select count(*) from t1 where v='a  ';
342
 
count(*)
343
 
10
344
 
select count(*) from t1 where c='a  ';
345
 
count(*)
346
 
10
347
 
select count(*) from t1 where t='a  ';
348
 
count(*)
349
 
10
350
 
select count(*) from t1 where v between 'a' and 'a ';
351
 
count(*)
352
 
10
353
 
select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
354
 
count(*)
355
 
10
356
 
select count(*) from t1 where v like 'a%';
357
 
count(*)
358
 
11
359
 
select count(*) from t1 where c like 'a%';
360
 
count(*)
361
 
11
362
 
select count(*) from t1 where t like 'a%';
363
 
count(*)
364
 
11
365
 
select count(*) from t1 where v like 'a %';
366
 
count(*)
367
 
9
368
 
explain select count(*) from t1 where v='a  ';
369
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
370
 
1       SIMPLE  t1      ref     v       v       43      const   10      Using where
371
 
explain select count(*) from t1 where c='a  ';
372
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
373
 
1       SIMPLE  t1      ref     c       c       43      const   10      Using where
374
 
explain select count(*) from t1 where t='a  ';
375
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
376
 
1       SIMPLE  t1      ref     t       t       43      const   10      Using where
377
 
explain select count(*) from t1 where v like 'a%';
378
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
379
 
1       SIMPLE  t1      ALL     v       NULL    NULL    NULL    271     Using where
380
 
explain select count(*) from t1 where v between 'a' and 'a ';
381
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
382
 
1       SIMPLE  t1      ref     v       v       43      const   10      Using where
383
 
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
384
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
385
 
1       SIMPLE  t1      ref     v       v       43      const   10      Using where
386
 
alter table t1 add unique(v);
387
 
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
388
 
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*'));
389
 
qq
390
 
*a*a*a*
391
 
*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
 
explain select * from t1 where v='a';
401
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
402
 
1       SIMPLE  t1      ref     v       v       43      const   10      Using where
403
 
select v,count(*) from t1 group by v limit 10;
404
 
v       count(*)
405
 
a      1
406
 
a       10
407
 
b       10
408
 
c       10
409
 
d       10
410
 
e       10
411
 
f       10
412
 
g       10
413
 
h       10
414
 
i       10
415
 
select v,count(t) from t1 group by v limit 10;
416
 
v       count(t)
417
 
a      1
418
 
a       10
419
 
b       10
420
 
c       10
421
 
d       10
422
 
e       10
423
 
f       10
424
 
g       10
425
 
h       10
426
 
i       10
427
 
select v,count(c) from t1 group by v limit 10;
428
 
v       count(c)
429
 
a      1
430
 
a       10
431
 
b       10
432
 
c       10
433
 
d       10
434
 
e       10
435
 
f       10
436
 
g       10
437
 
h       10
438
 
i       10
439
 
select sql_big_result trim(v),count(t) from t1 group by v limit 10;
440
 
trim(v) count(t)
441
 
a      1
442
 
a       10
443
 
b       10
444
 
c       10
445
 
d       10
446
 
e       10
447
 
f       10
448
 
g       10
449
 
h       10
450
 
i       10
451
 
select sql_big_result trim(v),count(c) from t1 group by v limit 10;
452
 
trim(v) count(c)
453
 
a      1
454
 
a       10
455
 
b       10
456
 
c       10
457
 
d       10
458
 
e       10
459
 
f       10
460
 
g       10
461
 
h       10
462
 
i       10
463
 
select c,count(*) from t1 group by c limit 10;
464
 
c       count(*)
465
 
a      1
466
 
a       10
467
 
b       10
468
 
c       10
469
 
d       10
470
 
e       10
471
 
f       10
472
 
g       10
473
 
h       10
474
 
i       10
475
 
select c,count(t) from t1 group by c limit 10;
476
 
c       count(t)
477
 
a      1
478
 
a       10
479
 
b       10
480
 
c       10
481
 
d       10
482
 
e       10
483
 
f       10
484
 
g       10
485
 
h       10
486
 
i       10
487
 
select t,count(*) from t1 group by t limit 10;
488
 
t       count(*)
489
 
a      1
490
 
a       10
491
 
b       10
492
 
c       10
493
 
d       10
494
 
e       10
495
 
f       10
496
 
g       10
497
 
h       10
498
 
i       10
499
 
select t,count(t) from t1 group by t limit 10;
500
 
t       count(t)
501
 
a      1
502
 
a       10
503
 
b       10
504
 
c       10
505
 
d       10
506
 
e       10
507
 
f       10
508
 
g       10
509
 
h       10
510
 
i       10
511
 
select sql_big_result trim(t),count(t) from t1 group by t limit 10;
512
 
trim(t) count(t)
513
 
a      1
514
 
a       10
515
 
b       10
516
 
c       10
517
 
d       10
518
 
e       10
519
 
f       10
520
 
g       10
521
 
h       10
522
 
i       10
523
 
drop table t1;
524
 
create temporary table t1 (a char(10), unique (a));
525
 
insert into t1 values ('a');
526
 
insert into t1 values ('a ');
527
 
ERROR 23000: Duplicate entry 'a ' for key 'a'
528
 
alter table t1 modify a varchar(10);
529
 
insert into t1 values ('a '),('a  '),('a   '),('a         ');
530
 
ERROR 23000: Duplicate entry 'a ' for key 'a'
531
 
insert into t1 values ('a     ');
532
 
ERROR 23000: Duplicate entry 'a     ' for key 'a'
533
 
insert into t1 values ('a          ');
534
 
ERROR 22001: Data too long for column 'a' at row 1
535
 
insert into t1 values ('a ');
536
 
ERROR 23000: Duplicate entry 'a ' for key 'a'
537
 
update t1 set a='a      ' where a like 'a ';
538
 
update t1 set a='a  ' where a like 'a      ';
539
 
drop table t1;
540
 
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)));
541
 
show create table t1;
542
 
Table   Create Table
543
 
t1      CREATE TEMPORARY TABLE `t1` (
544
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
545
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
546
 
  `t` VARCHAR(50) COLLATE utf8_general_ci DEFAULT NULL,
547
 
  KEY `v` (`v`) USING BTREE,
548
 
  KEY `c` (`c`) USING BTREE,
549
 
  KEY `t` (`t`(10)) USING BTREE
550
 
) ENGINE=MEMORY COLLATE = utf8_general_ci
551
 
select count(*) from t1;
552
 
count(*)
553
 
270
554
 
insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1)));
555
 
select count(*) from t1 where v='a';
556
 
count(*)
557
 
10
558
 
select count(*) from t1 where c='a';
559
 
count(*)
560
 
10
561
 
select count(*) from t1 where t='a';
562
 
count(*)
563
 
10
564
 
select count(*) from t1 where v='a  ';
565
 
count(*)
566
 
10
567
 
select count(*) from t1 where c='a  ';
568
 
count(*)
569
 
10
570
 
select count(*) from t1 where t='a  ';
571
 
count(*)
572
 
10
573
 
select count(*) from t1 where v between 'a' and 'a ';
574
 
count(*)
575
 
10
576
 
select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
577
 
count(*)
578
 
10
579
 
explain select count(*) from t1 where v='a  ';
580
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
581
 
1       SIMPLE  t1      ref     v       v       43      const   #       Using where
582
 
explain select count(*) from t1 where c='a  ';
583
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
584
 
1       SIMPLE  t1      ref     c       c       43      const   #       Using where
585
 
explain select count(*) from t1 where t='a  ';
586
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
587
 
1       SIMPLE  t1      ref     t       t       43      const   #       Using where
588
 
explain select count(*) from t1 where v like 'a%';
589
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
590
 
1       SIMPLE  t1      ALL     v       NULL    NULL    NULL    #       Using where
591
 
explain select count(*) from t1 where v between 'a' and 'a ';
592
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
593
 
1       SIMPLE  t1      ref     v       v       43      const   #       Using where
594
 
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
595
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
596
 
1       SIMPLE  t1      ref     v       v       43      const   #       Using where
597
 
alter table t1 add unique(v);
598
 
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
599
 
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*'));
600
 
qq
601
 
*a*a*a*
602
 
*a *a *a *
603
 
*a  *a  *a  *
604
 
*a   *a   *a   *
605
 
*a    *a    *a    *
606
 
*a     *a     *a     *
607
 
*a      *a      *a      *
608
 
*a       *a       *a       *
609
 
*a        *a        *a        *
610
 
*a         *a         *a         *
611
 
explain select * from t1 where v='a';
612
 
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
613
 
1       SIMPLE  t1      ref     v       v       43      const   #       Using where
614
 
drop table t1;
615
 
create temporary table t1 (a char(10), unique using btree (a)) engine=MEMORY;
616
 
insert into t1 values ('a');
617
 
insert into t1 values ('a ');
618
 
ERROR 23000: Duplicate entry 'a ' for key 'a'
619
 
alter table t1 modify a varchar(10);
620
 
insert into t1 values ('a '),('a  '),('a   '),('a         ');
621
 
ERROR 23000: Duplicate entry 'a ' for key 'a'
622
 
insert into t1 values ('a     ');
623
 
ERROR 23000: Duplicate entry 'a     ' for key 'a'
624
 
insert into t1 values ('a          ');
625
 
ERROR 22001: Data too long for column 'a' at row 1
626
 
insert into t1 values ('a ');
627
 
ERROR 23000: Duplicate entry 'a ' for key 'a'
628
 
update t1 set a='a      ' where a like 'a ';
629
 
update t1 set a='a  ' where a like 'a      ';
630
 
drop table t1;
631
 
create temporary table t1 (v varchar(10), c char(10), t varchar(50), key(v(5)), key(c(5)), key(t(5)));
632
 
show create table t1;
633
 
Table   Create Table
634
 
t1      CREATE TEMPORARY TABLE `t1` (
635
 
  `v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
636
 
  `c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
637
 
  `t` VARCHAR(50) COLLATE utf8_general_ci DEFAULT NULL,
638
 
  KEY `v` (`v`(5)),
639
 
  KEY `c` (`c`(5)),
640
 
  KEY `t` (`t`(5))
641
 
) ENGINE=MEMORY COLLATE = utf8_general_ci
642
 
drop table t1;
643
 
create temporary table t1 (v varchar(16383), key(v(10)));
644
 
show create table t1;
645
 
Table   Create Table
646
 
t1      CREATE TEMPORARY TABLE `t1` (
647
 
  `v` VARCHAR(16383) COLLATE utf8_general_ci DEFAULT NULL,
648
 
  KEY `v` (`v`(10))
649
 
) ENGINE=MEMORY COLLATE = utf8_general_ci
650
 
insert into t1 values(repeat('a',16383));
651
 
select length(v) from t1 where v=repeat('a',16383);
652
 
length(v)
653
 
16383
654
 
drop table t1;
655
 
set storage_engine=PBXT;
656
 
create temporary table t1 (a bigint auto_increment primary key, b int,
657
 
key (b, a)) engine=MEMORY;
658
 
insert t1 (b) values (1),(1),(1),(1),(1),(1),(1),(1);
659
 
select * from t1;
660
 
a       b
661
 
1       1
662
 
2       1
663
 
3       1
664
 
4       1
665
 
5       1
666
 
6       1
667
 
7       1
668
 
8       1
669
 
drop table t1;
670
 
create temporary table t1 (a int not null, b int not null auto_increment,
671
 
primary key(a, b), key(b)) engine=MEMORY;
672
 
insert t1 (a) values (1),(1),(1),(1),(1),(1),(1),(1);
673
 
select * from t1;
674
 
a       b
675
 
1       1
676
 
1       2
677
 
1       3
678
 
1       4
679
 
1       5
680
 
1       6
681
 
1       7
682
 
1       8
683
 
drop table t1;
684
 
create temporary table t1 (a int not null, b int not null auto_increment,
685
 
primary key(a, b)) engine=MEMORY;
686
 
ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key
687
 
create temporary table t1 (c char(255), primary key(c(90)));
688
 
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
689
 
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
690
 
ERROR 23000: Duplicate entry 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl' for key 'PRIMARY'
691
 
drop table t1;
692
 
CREATE TEMPORARY TABLE t1 (a int, key(a)) engine=MEMORY;
693
 
insert into t1 values (0);
694
 
delete from t1;
695
 
select * from t1;
696
 
a
697
 
insert into t1 values (0), (1);
698
 
select * from t1 where a = 0;
699
 
a
700
 
0
701
 
drop table t1;
702
 
create temporary table t1 (c char(10)) engine=memory;
703
 
create temporary table t2 (c varchar(10)) engine=memory;
704
 
show table status like 't_';
705
 
Session Schema  Name    Type    Engine  Version Rows    Avg_row_length  Table_size      Auto_increment
706
 
#       test    t1      TEMPORARY       MEMORY  #       #       #       #       #
707
 
#       test    t2      TEMPORARY       MEMORY  #       #       #       #       #
708
 
drop table t1, t2;
709
 
CREATE TEMPORARY TABLE t1(a VARCHAR(1), b VARCHAR(2), c VARCHAR(256),
710
 
KEY(a), KEY(b), KEY(c)) ENGINE=MEMORY;
711
 
INSERT INTO t1 VALUES('a','aa',REPEAT('a', 256)),('a','aa',REPEAT('a',256));
712
 
SELECT COUNT(*) FROM t1 WHERE a='a';
713
 
COUNT(*)
714
 
2
715
 
SELECT COUNT(*) FROM t1 WHERE b='aa';
716
 
COUNT(*)
717
 
2
718
 
SELECT COUNT(*) FROM t1 WHERE c=REPEAT('a',256);
719
 
COUNT(*)
720
 
2
721
 
DROP TABLE t1;
722
 
CREATE TEMPORARY TABLE t1(c1 VARCHAR(100), c2 INT) ENGINE=MEMORY;
723
 
INSERT INTO t1 VALUES('', 0);
724
 
ALTER TABLE t1 MODIFY c1 VARCHAR(101);
725
 
SELECT c2 FROM t1;
726
 
c2
727
 
0
728
 
DROP TABLE t1;