~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: mordred
  • Date: 2010-04-20 00:00:46 UTC
  • mfrom: (1471.5.3 more-valgrind)
  • mto: This revision was merged to the branch mainline in revision 1498.
  • Revision ID: mordred@orisndriz09-20100420000046-263x5hazl0huw8u3
MergedĀ inĀ more-valgrind.

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      TRUE    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       
 
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
Warnings:
 
256
Note    1265    Data truncated for column 'v' at row 1
 
257
Note    1265    Data truncated for column 'c' at row 1
 
258
select concat('*',v,'*',c,'*',t,'*') from t1;
 
259
concat('*',v,'*',c,'*',t,'*')
 
260
*+ *+ *+ *
 
261
*+         *+         *+                    *
 
262
show create table t1;
 
263
Table   Create Table
 
264
t1      CREATE TEMPORARY TABLE `t1` (
 
265
  `v` varchar(10) DEFAULT NULL,
 
266
  `c` varchar(10) DEFAULT NULL,
 
267
  `t` varchar(50) DEFAULT NULL
 
268
) ENGINE=MEMORY
 
269
create temporary table t2 like t1;
 
270
show create table t2;
 
271
Table   Create Table
 
272
t2      CREATE TEMPORARY TABLE `t2` (
 
273
  `v` varchar(10) DEFAULT NULL,
 
274
  `c` varchar(10) DEFAULT NULL,
 
275
  `t` varchar(50) DEFAULT NULL
 
276
) ENGINE=MEMORY
 
277
create temporary table t3 select * from t1;
 
278
show create table t3;
 
279
Table   Create Table
 
280
t3      CREATE TEMPORARY TABLE `t3` (
 
281
  `v` varchar(10) DEFAULT NULL,
 
282
  `c` varchar(10) DEFAULT NULL,
 
283
  `t` varchar(50) DEFAULT NULL
 
284
) ENGINE=MEMORY
 
285
alter table t1 modify c varchar(10);
 
286
show create table t1;
 
287
Table   Create Table
 
288
t1      CREATE TEMPORARY TABLE `t1` (
 
289
  `v` varchar(10) DEFAULT NULL,
 
290
  `c` varchar(10) DEFAULT NULL,
 
291
  `t` varchar(50) DEFAULT NULL
 
292
) ENGINE=MEMORY
 
293
alter table t1 modify v char(10);
 
294
show create table t1;
 
295
Table   Create Table
 
296
t1      CREATE TEMPORARY TABLE `t1` (
 
297
  `v` varchar(10) DEFAULT NULL,
 
298
  `c` varchar(10) DEFAULT NULL,
 
299
  `t` varchar(50) DEFAULT NULL
 
300
) ENGINE=MEMORY
 
301
alter table t1 modify t varchar(50);
 
302
show create table t1;
 
303
Table   Create Table
 
304
t1      CREATE TEMPORARY TABLE `t1` (
 
305
  `v` varchar(10) DEFAULT NULL,
 
306
  `c` varchar(10) DEFAULT NULL,
 
307
  `t` varchar(50) DEFAULT NULL
 
308
) ENGINE=MEMORY
 
309
select concat('*',v,'*',c,'*',t,'*') from t1;
 
310
concat('*',v,'*',c,'*',t,'*')
 
311
*+ *+ *+ *
 
312
*+         *+         *+                    *
 
313
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)));
 
315
show create table t1;
 
316
Table   Create Table
 
317
t1      CREATE TEMPORARY TABLE `t1` (
 
318
  `v` varchar(10) DEFAULT NULL,
 
319
  `c` varchar(10) DEFAULT NULL,
 
320
  `t` varchar(50) DEFAULT NULL,
 
321
  KEY `v` (`v`),
 
322
  KEY `c` (`c`),
 
323
  KEY `t` (`t`(10))
 
324
) ENGINE=MEMORY
 
325
select count(*) from t1;
 
326
count(*)
 
327
270
 
328
insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1)));
 
329
select count(*) from t1 where v='a';
 
330
count(*)
 
331
10
 
332
select count(*) from t1 where c='a';
 
333
count(*)
 
334
10
 
335
select count(*) from t1 where t='a';
 
336
count(*)
 
337
10
 
338
select count(*) from t1 where v='a  ';
 
339
count(*)
 
340
10
 
341
select count(*) from t1 where c='a  ';
 
342
count(*)
 
343
10
 
344
select count(*) from t1 where t='a  ';
 
345
count(*)
 
346
10
 
347
select count(*) from t1 where v between 'a' and 'a ';
 
348
count(*)
 
349
10
 
350
select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
 
351
count(*)
 
352
10
 
353
select count(*) from t1 where v like 'a%';
 
354
count(*)
 
355
11
 
356
select count(*) from t1 where c like 'a%';
 
357
count(*)
 
358
11
 
359
select count(*) from t1 where t like 'a%';
 
360
count(*)
 
361
11
 
362
select count(*) from t1 where v like 'a %';
 
363
count(*)
 
364
9
 
365
explain select count(*) from t1 where v='a  ';
 
366
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
367
1       SIMPLE  t1      ref     v       v       43      const   10      Using where
 
368
explain select count(*) from t1 where c='a  ';
 
369
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
370
1       SIMPLE  t1      ref     c       c       43      const   10      Using where
 
371
explain select count(*) from t1 where t='a  ';
 
372
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
373
1       SIMPLE  t1      ref     t       t       43      const   10      Using where
 
374
explain select count(*) from t1 where v like 'a%';
 
375
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
376
1       SIMPLE  t1      ALL     v       NULL    NULL    NULL    271     Using where
 
377
explain select count(*) from t1 where v between 'a' and 'a ';
 
378
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
379
1       SIMPLE  t1      ref     v       v       43      const   10      Using where
 
380
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
 
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
alter table t1 add unique(v);
 
384
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
 
385
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*'));
 
386
qq
 
387
*a*a*a*
 
388
*a *a *a *
 
389
*a  *a  *a  *
 
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
explain select * from t1 where v='a';
 
398
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
399
1       SIMPLE  t1      ref     v       v       43      const   10      Using where
 
400
select v,count(*) from t1 group by v limit 10;
 
401
v       count(*)
 
402
a      1
 
403
a       10
 
404
b       10
 
405
c       10
 
406
d       10
 
407
e       10
 
408
f       10
 
409
g       10
 
410
h       10
 
411
i       10
 
412
select v,count(t) from t1 group by v limit 10;
 
413
v       count(t)
 
414
a      1
 
415
a       10
 
416
b       10
 
417
c       10
 
418
d       10
 
419
e       10
 
420
f       10
 
421
g       10
 
422
h       10
 
423
i       10
 
424
select v,count(c) from t1 group by v limit 10;
 
425
v       count(c)
 
426
a      1
 
427
a       10
 
428
b       10
 
429
c       10
 
430
d       10
 
431
e       10
 
432
f       10
 
433
g       10
 
434
h       10
 
435
i       10
 
436
select sql_big_result trim(v),count(t) from t1 group by v limit 10;
 
437
trim(v) count(t)
 
438
a      1
 
439
a       10
 
440
b       10
 
441
c       10
 
442
d       10
 
443
e       10
 
444
f       10
 
445
g       10
 
446
h       10
 
447
i       10
 
448
select sql_big_result trim(v),count(c) from t1 group by v limit 10;
 
449
trim(v) count(c)
 
450
a      1
 
451
a       10
 
452
b       10
 
453
c       10
 
454
d       10
 
455
e       10
 
456
f       10
 
457
g       10
 
458
h       10
 
459
i       10
 
460
select c,count(*) from t1 group by c limit 10;
 
461
c       count(*)
 
462
a      1
 
463
a       10
 
464
b       10
 
465
c       10
 
466
d       10
 
467
e       10
 
468
f       10
 
469
g       10
 
470
h       10
 
471
i       10
 
472
select c,count(t) from t1 group by c limit 10;
 
473
c       count(t)
 
474
a      1
 
475
a       10
 
476
b       10
 
477
c       10
 
478
d       10
 
479
e       10
 
480
f       10
 
481
g       10
 
482
h       10
 
483
i       10
 
484
select t,count(*) from t1 group by t limit 10;
 
485
t       count(*)
 
486
a      1
 
487
a       10
 
488
b       10
 
489
c       10
 
490
d       10
 
491
e       10
 
492
f       10
 
493
g       10
 
494
h       10
 
495
i       10
 
496
select t,count(t) from t1 group by t limit 10;
 
497
t       count(t)
 
498
a      1
 
499
a       10
 
500
b       10
 
501
c       10
 
502
d       10
 
503
e       10
 
504
f       10
 
505
g       10
 
506
h       10
 
507
i       10
 
508
select sql_big_result trim(t),count(t) from t1 group by t limit 10;
 
509
trim(t) count(t)
 
510
a      1
 
511
a       10
 
512
b       10
 
513
c       10
 
514
d       10
 
515
e       10
 
516
f       10
 
517
g       10
 
518
h       10
 
519
i       10
 
520
drop table t1;
 
521
create temporary table t1 (a char(10), unique (a));
 
522
insert into t1 values ('a');
 
523
insert into t1 values ('a ');
 
524
ERROR 23000: Duplicate entry 'a ' for key 'a'
 
525
alter table t1 modify a varchar(10);
 
526
insert into t1 values ('a '),('a  '),('a   '),('a         ');
 
527
ERROR 23000: Duplicate entry 'a ' for key 'a'
 
528
insert into t1 values ('a     ');
 
529
ERROR 23000: Duplicate entry 'a     ' for key 'a'
 
530
insert into t1 values ('a          ');
 
531
ERROR 23000: Duplicate entry 'a         ' for key 'a'
 
532
insert into t1 values ('a ');
 
533
ERROR 23000: Duplicate entry 'a ' for key 'a'
 
534
update t1 set a='a      ' where a like 'a ';
 
535
update t1 set a='a  ' where a like 'a      ';
 
536
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)));
 
538
show create table t1;
 
539
Table   Create Table
 
540
t1      CREATE TEMPORARY TABLE `t1` (
 
541
  `v` varchar(10) DEFAULT NULL,
 
542
  `c` varchar(10) DEFAULT NULL,
 
543
  `t` varchar(50) DEFAULT NULL,
 
544
  KEY `v` (`v`) USING BTREE,
 
545
  KEY `c` (`c`) USING BTREE,
 
546
  KEY `t` (`t`(10)) USING BTREE
 
547
) ENGINE=MEMORY
 
548
select count(*) from t1;
 
549
count(*)
 
550
270
 
551
insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1)));
 
552
select count(*) from t1 where v='a';
 
553
count(*)
 
554
10
 
555
select count(*) from t1 where c='a';
 
556
count(*)
 
557
10
 
558
select count(*) from t1 where t='a';
 
559
count(*)
 
560
10
 
561
select count(*) from t1 where v='a  ';
 
562
count(*)
 
563
10
 
564
select count(*) from t1 where c='a  ';
 
565
count(*)
 
566
10
 
567
select count(*) from t1 where t='a  ';
 
568
count(*)
 
569
10
 
570
select count(*) from t1 where v between 'a' and 'a ';
 
571
count(*)
 
572
10
 
573
select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
 
574
count(*)
 
575
10
 
576
explain select count(*) from t1 where v='a  ';
 
577
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
578
1       SIMPLE  t1      ref     v       v       43      const   #       Using where
 
579
explain select count(*) from t1 where c='a  ';
 
580
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
581
1       SIMPLE  t1      ref     c       c       43      const   #       Using where
 
582
explain select count(*) from t1 where t='a  ';
 
583
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
584
1       SIMPLE  t1      ref     t       t       43      const   #       Using where
 
585
explain select count(*) from t1 where v like 'a%';
 
586
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
587
1       SIMPLE  t1      range   v       v       43      NULL    #       Using where
 
588
explain select count(*) from t1 where v between 'a' and 'a ';
 
589
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
590
1       SIMPLE  t1      ref     v       v       43      const   #       Using where
 
591
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
 
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
alter table t1 add unique(v);
 
595
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
 
596
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*'));
 
597
qq
 
598
*a*a*a*
 
599
*a *a *a *
 
600
*a  *a  *a  *
 
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
explain select * from t1 where v='a';
 
609
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
610
1       SIMPLE  t1      ref     v       v       43      const   #       Using where
 
611
drop table t1;
 
612
create temporary table t1 (a char(10), unique using btree (a)) engine=MEMORY;
 
613
insert into t1 values ('a');
 
614
insert into t1 values ('a ');
 
615
ERROR 23000: Duplicate entry 'a ' for key 'a'
 
616
alter table t1 modify a varchar(10);
 
617
insert into t1 values ('a '),('a  '),('a   '),('a         ');
 
618
ERROR 23000: Duplicate entry 'a ' for key 'a'
 
619
insert into t1 values ('a     ');
 
620
ERROR 23000: Duplicate entry 'a     ' for key 'a'
 
621
insert into t1 values ('a          ');
 
622
ERROR 23000: Duplicate entry 'a         ' for key 'a'
 
623
insert into t1 values ('a ');
 
624
ERROR 23000: Duplicate entry 'a ' for key 'a'
 
625
update t1 set a='a      ' where a like 'a ';
 
626
update t1 set a='a  ' where a like 'a      ';
 
627
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)));
 
629
show create table t1;
 
630
Table   Create Table
 
631
t1      CREATE TEMPORARY TABLE `t1` (
 
632
  `v` varchar(10) DEFAULT NULL,
 
633
  `c` varchar(10) DEFAULT NULL,
 
634
  `t` varchar(50) DEFAULT NULL,
 
635
  KEY `v` (`v`(5)),
 
636
  KEY `c` (`c`(5)),
 
637
  KEY `t` (`t`(5))
 
638
) ENGINE=MEMORY
 
639
drop table t1;
 
640
create temporary table t1 (v varchar(16383), key(v(10)));
 
641
show create table t1;
 
642
Table   Create Table
 
643
t1      CREATE TEMPORARY TABLE `t1` (
 
644
  `v` varchar(16383) DEFAULT NULL,
 
645
  KEY `v` (`v`(10))
 
646
) ENGINE=MEMORY
 
647
insert into t1 values(repeat('a',16383));
 
648
select length(v) from t1 where v=repeat('a',16383);
 
649
length(v)
 
650
16383
 
651
drop table t1;
 
652
set storage_engine=PBXT;
 
653
create temporary table t1 (a bigint auto_increment primary key, b int,
 
654
key (b, a)) engine=MEMORY;
 
655
insert t1 (b) values (1),(1),(1),(1),(1),(1),(1),(1);
 
656
select * from t1;
 
657
a       b
 
658
1       1
 
659
2       1
 
660
3       1
 
661
4       1
 
662
5       1
 
663
6       1
 
664
7       1
 
665
8       1
 
666
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
insert t1 (a) values (1),(1),(1),(1),(1),(1),(1),(1);
 
670
select * from t1;
 
671
a       b
 
672
1       1
 
673
1       2
 
674
1       3
 
675
1       4
 
676
1       5
 
677
1       6
 
678
1       7
 
679
1       8
 
680
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
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)));
 
685
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
 
686
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
 
687
ERROR 23000: Duplicate entry 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl' for key 'PRIMARY'
 
688
drop table t1;
 
689
CREATE TEMPORARY TABLE t1 (a int, key(a)) engine=MEMORY;
 
690
insert into t1 values (0);
 
691
delete from t1;
 
692
select * from t1;
 
693
a
 
694
insert into t1 values (0), (1);
 
695
select * from t1 where a = 0;
 
696
a
 
697
0
 
698
drop table t1;
 
699
create temporary table t1 (c char(10)) engine=memory;
 
700
create temporary table t2 (c varchar(10)) engine=memory;
 
701
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  #       #       #       #       #
 
705
drop table t1, t2;
 
706
CREATE TEMPORARY TABLE t1(a VARCHAR(1), b VARCHAR(2), c VARCHAR(256),
 
707
KEY(a), KEY(b), KEY(c)) ENGINE=MEMORY;
 
708
INSERT INTO t1 VALUES('a','aa',REPEAT('a', 256)),('a','aa',REPEAT('a',256));
 
709
SELECT COUNT(*) FROM t1 WHERE a='a';
 
710
COUNT(*)
 
711
2
 
712
SELECT COUNT(*) FROM t1 WHERE b='aa';
 
713
COUNT(*)
 
714
2
 
715
SELECT COUNT(*) FROM t1 WHERE c=REPEAT('a',256);
 
716
COUNT(*)
 
717
2
 
718
DROP TABLE t1;
 
719
CREATE TEMPORARY TABLE t1(c1 VARCHAR(100), c2 INT) ENGINE=MEMORY;
 
720
INSERT INTO t1 VALUES('', 0);
 
721
ALTER TABLE t1 MODIFY c1 VARCHAR(101);
 
722
SELECT c2 FROM t1;
 
723
c2
 
724
0
 
725
DROP TABLE t1;