~vkolesnikov/pbxt/pbxt-07-diskfull

« back to all changes in this revision

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

  • Committer: paul-mccullagh
  • Date: 2006-10-23 09:14:04 UTC
  • Revision ID: paul-mccullagh-918861e03d351978a9541168a96e58cc826734ee
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
drop table if exists t1,t2,t3;
 
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
insert into t1 values(1,1),(2,2),(3,3),(4,4);
 
4
delete from t1 where a=1 or a=0;
 
5
show keys from t1;
 
6
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment
 
7
t1      0       PRIMARY 1       a       NULL    3       NULL    NULL            HASH    
 
8
select * from t1;
 
9
a       b
 
10
2       2
 
11
3       3
 
12
4       4
 
13
select * from t1 where a=4;
 
14
a       b
 
15
4       4
 
16
update t1 set b=5 where a=4;
 
17
update t1 set b=b+1 where a>=3;
 
18
replace t1 values (3,3);
 
19
select * from t1;
 
20
a       b
 
21
2       2
 
22
3       3
 
23
4       6
 
24
alter table t1 add c int not null, add key (c,a);
 
25
drop table t1;
 
26
create table t1 (a int not null,b int not null, primary key (a)) engine=memory comment="testing heaps";
 
27
insert into t1 values(1,1),(2,2),(3,3),(4,4);
 
28
delete from t1 where a > 0;
 
29
select * from t1;
 
30
a       b
 
31
drop table t1;
 
32
create table t1 (a int not null,b int not null, primary key (a)) engine=heap comment="testing heaps";
 
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=myisam, comment="new myisam table";
 
35
select * from t1;
 
36
a       b
 
37
1       1
 
38
2       2
 
39
3       3
 
40
4       4
 
41
drop table t1;
 
42
create table t1 (a int not null) engine=heap;
 
43
insert into t1 values (869751),(736494),(226312),(802616),(728912);
 
44
select * from t1 where a > 736494;
 
45
a
 
46
869751
 
47
802616
 
48
alter table t1 add unique uniq_id(a);
 
49
select * from t1 where a > 736494;
 
50
a
 
51
869751
 
52
802616
 
53
select * from t1 where a = 736494;
 
54
a
 
55
736494
 
56
select * from t1 where a=869751 or a=736494;
 
57
a
 
58
736494
 
59
869751
 
60
select * from t1 where a in (869751,736494,226312,802616);
 
61
a
 
62
226312
 
63
736494
 
64
802616
 
65
869751
 
66
alter table t1 engine=myisam;
 
67
explain select * from t1 where a in (869751,736494,226312,802616);
 
68
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
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
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
 
74
select * from t1 where x=1;
 
75
x       y
 
76
1       3
 
77
1       1
 
78
select * from t1,t1 as t2 where t1.x=t2.y;
 
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
explain select * from t1,t1 as t2 where t1.x=t2.y;
 
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       
 
90
drop table t1;
 
91
create table t1 (a int) engine=heap;
 
92
insert into t1 values(1);
 
93
select max(a) from t1;
 
94
max(a)
 
95
1
 
96
drop table t1;
 
97
CREATE TABLE t1 ( a int not null default 0, b int not null default 0,  key(a),  key(b)  ) ENGINE=HEAP;
 
98
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
 
99
select * from t1 where a=1;
 
100
a       b
 
101
1       6
 
102
1       5
 
103
1       4
 
104
1       3
 
105
1       2
 
106
1       1
 
107
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
 
108
select * from t1 where a=1;
 
109
a       b
 
110
1       6
 
111
1       5
 
112
1       4
 
113
1       3
 
114
1       2
 
115
1       1
 
116
1       6
 
117
1       5
 
118
1       4
 
119
1       3
 
120
1       2
 
121
1       1
 
122
drop table t1;
 
123
create table t1 (id int unsigned not null, primary key (id)) engine=HEAP;
 
124
insert into t1 values(1);
 
125
select max(id) from t1;
 
126
max(id)
 
127
1
 
128
insert into t1 values(2);
 
129
select max(id) from t1;
 
130
max(id)
 
131
2
 
132
replace into t1 values(1);
 
133
drop table t1;
 
134
create table t1 (n int) engine=heap;
 
135
drop table t1;
 
136
create table t1 (n int) engine=heap;
 
137
drop table if exists t1;
 
138
CREATE table t1(f1 int not null,f2 char(20) not 
 
139
null,index(f2)) engine=heap;
 
140
INSERT into t1 set f1=12,f2="bill";
 
141
INSERT into t1 set f1=13,f2="bill";
 
142
INSERT into t1 set f1=14,f2="bill";
 
143
INSERT into t1 set f1=15,f2="bill";
 
144
INSERT into t1 set f1=16,f2="ted";
 
145
INSERT into t1 set f1=12,f2="ted";
 
146
INSERT into t1 set f1=12,f2="ted";
 
147
INSERT into t1 set f1=12,f2="ted";
 
148
INSERT into t1 set f1=12,f2="ted";
 
149
delete from t1 where f2="bill";
 
150
select * from t1;
 
151
f1      f2
 
152
16      ted
 
153
12      ted
 
154
12      ted
 
155
12      ted
 
156
12      ted
 
157
drop table t1;
 
158
create table t1 (btn char(10) not null, key(btn)) engine=heap;
 
159
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
 
160
explain select * from t1 where btn like "q%";
 
161
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
162
1       SIMPLE  t1      ALL     btn     NULL    NULL    NULL    14      Using where
 
163
select * from t1 where btn like "q%";
 
164
btn
 
165
alter table t1 add column new_col char(1) not null, add key (btn,new_col), drop key btn;
 
166
update t1 set new_col=left(btn,1);
 
167
explain select * from t1 where btn="a";
 
168
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
169
1       SIMPLE  t1      ALL     btn     NULL    NULL    NULL    14      Using where
 
170
explain select * from t1 where btn="a" and new_col="a";
 
171
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
172
1       SIMPLE  t1      ref     btn     btn     11      const,const     2       Using where
 
173
drop table t1;
 
174
CREATE TABLE t1 (
 
175
a int default NULL,
 
176
b int default NULL,
 
177
KEY a (a),
 
178
UNIQUE b (b)
 
179
) engine=heap;
 
180
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
 
181
SELECT * FROM t1 WHERE a=NULL;
 
182
a       b
 
183
explain SELECT * FROM t1 WHERE a IS NULL;
 
184
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
185
1       SIMPLE  t1      ref     a       a       5       const   2       Using where
 
186
SELECT * FROM t1 WHERE a<=>NULL;
 
187
a       b
 
188
NULL    99
 
189
SELECT * FROM t1 WHERE b=NULL;
 
190
a       b
 
191
explain SELECT * FROM t1 WHERE b IS NULL;
 
192
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
193
1       SIMPLE  t1      ref     b       b       5       const   1       Using where
 
194
SELECT * FROM t1 WHERE b<=>NULL;
 
195
a       b
 
196
99      NULL
 
197
INSERT INTO t1 VALUES (1,3);
 
198
ERROR 23000: Duplicate entry '3' for key 'b'
 
199
DROP TABLE t1;
 
200
CREATE TABLE t1 (
 
201
a int default NULL,
 
202
key a (a)
 
203
) ENGINE=HEAP;
 
204
INSERT INTO t1 VALUES (10), (10), (10);
 
205
EXPLAIN SELECT * FROM t1 WHERE a=10;
 
206
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
207
1       SIMPLE  t1      ref     a       a       5       const   3       Using where
 
208
SELECT * FROM t1 WHERE a=10;
 
209
a
 
210
10
 
211
10
 
212
10
 
213
DROP TABLE t1;
 
214
CREATE TABLE t1 (a int not null, primary key(a)) engine=heap;
 
215
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
 
216
DELETE from t1 where a < 100;
 
217
SELECT * from t1;
 
218
a
 
219
DROP TABLE t1;
 
220
CREATE TABLE `job_titles` (
 
221
`job_title_id` int(6) unsigned NOT NULL default '0',
 
222
`job_title` char(18) NOT NULL default '',
 
223
PRIMARY KEY  (`job_title_id`),
 
224
UNIQUE KEY `job_title_id` (`job_title_id`,`job_title`)
 
225
) ENGINE=HEAP;
 
226
SELECT MAX(job_title_id) FROM job_titles;
 
227
MAX(job_title_id)
 
228
NULL
 
229
DROP TABLE job_titles;
 
230
CREATE TABLE t1 (a INT NOT NULL, B INT, KEY(B)) ENGINE=HEAP;
 
231
INSERT INTO t1 VALUES(1,1), (1,NULL);
 
232
SELECT * FROM t1 WHERE B is not null;
 
233
a       B
 
234
1       1
 
235
DROP TABLE t1;
 
236
CREATE TABLE t1 (pseudo char(35) PRIMARY KEY, date int(10) unsigned NOT NULL) ENGINE=HEAP;
 
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);
 
238
DELETE FROM t1 WHERE date<1101106546;
 
239
SELECT * FROM t1;
 
240
pseudo  date
 
241
ZoomZip 1101106546
 
242
DROP TABLE t1;
 
243
create table t1(a char(2)) engine=memory;
 
244
insert into t1 values (NULL), (NULL);
 
245
delete from t1 where a is null;
 
246
insert into t1 values ('2'), ('3');
 
247
select * from t1;
 
248
a
 
249
3
 
250
2
 
251
drop table t1;
 
252
set storage_engine=HEAP;
 
253
create table t1 (v varchar(10), c char(10), t varchar(50));
 
254
insert into t1 values('+ ', '+ ', '+ ');
 
255
set @a=repeat(' ',20);
 
256
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
 
257
Warnings:
 
258
Note    1265    Data truncated for column 'v' at row 1
 
259
select concat('*',v,'*',c,'*',t,'*') from t1;
 
260
concat('*',v,'*',c,'*',t,'*')
 
261
*+ *+*+ *
 
262
*+         *+*+                    *
 
263
show create table t1;
 
264
Table   Create Table
 
265
t1      CREATE TABLE `t1` (
 
266
  `v` varchar(10) DEFAULT NULL,
 
267
  `c` char(10) DEFAULT NULL,
 
268
  `t` varchar(50) DEFAULT NULL
 
269
) ENGINE=MEMORY DEFAULT CHARSET=latin1
 
270
create table t2 like t1;
 
271
show create table t2;
 
272
Table   Create Table
 
273
t2      CREATE TABLE `t2` (
 
274
  `v` varchar(10) DEFAULT NULL,
 
275
  `c` char(10) DEFAULT NULL,
 
276
  `t` varchar(50) DEFAULT NULL
 
277
) ENGINE=MEMORY DEFAULT CHARSET=latin1
 
278
create table t3 select * from t1;
 
279
show create table t3;
 
280
Table   Create Table
 
281
t3      CREATE TABLE `t3` (
 
282
  `v` varchar(10) DEFAULT NULL,
 
283
  `c` char(10) DEFAULT NULL,
 
284
  `t` varchar(50) DEFAULT NULL
 
285
) ENGINE=MEMORY DEFAULT CHARSET=latin1
 
286
alter table t1 modify c varchar(10);
 
287
show create table t1;
 
288
Table   Create Table
 
289
t1      CREATE TABLE `t1` (
 
290
  `v` varchar(10) DEFAULT NULL,
 
291
  `c` varchar(10) DEFAULT NULL,
 
292
  `t` varchar(50) DEFAULT NULL
 
293
) ENGINE=MEMORY DEFAULT CHARSET=latin1
 
294
alter table t1 modify v char(10);
 
295
show create table t1;
 
296
Table   Create Table
 
297
t1      CREATE TABLE `t1` (
 
298
  `v` char(10) DEFAULT NULL,
 
299
  `c` varchar(10) DEFAULT NULL,
 
300
  `t` varchar(50) DEFAULT NULL
 
301
) ENGINE=MEMORY DEFAULT CHARSET=latin1
 
302
alter table t1 modify t varchar(10);
 
303
Warnings:
 
304
Warning 1265    Data truncated for column 't' at row 2
 
305
show create table t1;
 
306
Table   Create Table
 
307
t1      CREATE TABLE `t1` (
 
308
  `v` char(10) DEFAULT NULL,
 
309
  `c` varchar(10) DEFAULT NULL,
 
310
  `t` varchar(10) DEFAULT NULL
 
311
) ENGINE=MEMORY DEFAULT CHARSET=latin1
 
312
select concat('*',v,'*',c,'*',t,'*') from t1;
 
313
concat('*',v,'*',c,'*',t,'*')
 
314
*+*+*+ *
 
315
*+*+*+         *
 
316
drop table t1,t2,t3;
 
317
create 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 TABLE `t1` (
 
321
  `v` varchar(10) DEFAULT NULL,
 
322
  `c` char(10) DEFAULT NULL,
 
323
  `t` varchar(50) DEFAULT NULL,
 
324
  KEY `v` (`v`),
 
325
  KEY `c` (`c`),
 
326
  KEY `t` (`t`(10))
 
327
) ENGINE=MEMORY DEFAULT CHARSET=latin1
 
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       13      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       11      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       13      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       13      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       13      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       13      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 sql_big_result c,count(t) from t1 group by c limit 10;
 
488
c       count(t)
 
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(*) from t1 group by t limit 10;
 
500
t       count(*)
 
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 t,count(t) from t1 group by t limit 10;
 
512
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
select sql_big_result trim(t),count(t) from t1 group by t limit 10;
 
524
trim(t) count(t)
 
525
a      1
 
526
a       10
 
527
b       10
 
528
c       10
 
529
d       10
 
530
e       10
 
531
f       10
 
532
g       10
 
533
h       10
 
534
i       10
 
535
drop table t1;
 
536
create table t1 (a char(10), unique (a));
 
537
insert into t1 values ('a');
 
538
insert into t1 values ('a ');
 
539
ERROR 23000: Duplicate entry 'a' for key 'a'
 
540
alter table t1 modify a varchar(10);
 
541
insert into t1 values ('a '),('a  '),('a   '),('a         ');
 
542
ERROR 23000: Duplicate entry 'a ' for key 'a'
 
543
insert into t1 values ('a     ');
 
544
ERROR 23000: Duplicate entry 'a     ' for key 'a'
 
545
insert into t1 values ('a          ');
 
546
ERROR 23000: Duplicate entry 'a         ' for key 'a'
 
547
insert into t1 values ('a ');
 
548
ERROR 23000: Duplicate entry 'a ' for key 'a'
 
549
update t1 set a='a      ' where a like 'a ';
 
550
update t1 set a='a  ' where a like 'a      ';
 
551
drop table t1;
 
552
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)));
 
553
show create table t1;
 
554
Table   Create Table
 
555
t1      CREATE TABLE `t1` (
 
556
  `v` varchar(10) DEFAULT NULL,
 
557
  `c` char(10) DEFAULT NULL,
 
558
  `t` varchar(50) DEFAULT NULL,
 
559
  KEY `v` (`v`) USING BTREE,
 
560
  KEY `c` (`c`) USING BTREE,
 
561
  KEY `t` (`t`(10)) USING BTREE
 
562
) ENGINE=MEMORY DEFAULT CHARSET=latin1
 
563
select count(*) from t1;
 
564
count(*)
 
565
270
 
566
insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1)));
 
567
select count(*) from t1 where v='a';
 
568
count(*)
 
569
10
 
570
select count(*) from t1 where c='a';
 
571
count(*)
 
572
10
 
573
select count(*) from t1 where t='a';
 
574
count(*)
 
575
10
 
576
select count(*) from t1 where v='a  ';
 
577
count(*)
 
578
10
 
579
select count(*) from t1 where c='a  ';
 
580
count(*)
 
581
10
 
582
select count(*) from t1 where t='a  ';
 
583
count(*)
 
584
10
 
585
select count(*) from t1 where v between 'a' and 'a ';
 
586
count(*)
 
587
10
 
588
select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
 
589
count(*)
 
590
10
 
591
explain select count(*) from t1 where v='a  ';
 
592
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
593
1       SIMPLE  t1      ref     v       v       13      const   #       Using where
 
594
explain select count(*) from t1 where c='a  ';
 
595
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
596
1       SIMPLE  t1      ref     c       c       11      const   #       Using where
 
597
explain select count(*) from t1 where t='a  ';
 
598
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
599
1       SIMPLE  t1      ref     t       t       13      const   #       Using where
 
600
explain select count(*) from t1 where v like 'a%';
 
601
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
602
1       SIMPLE  t1      range   v       v       13      NULL    #       Using where
 
603
explain select count(*) from t1 where v between 'a' and 'a ';
 
604
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
605
1       SIMPLE  t1      ref     v       v       13      const   #       Using where
 
606
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
 
607
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
608
1       SIMPLE  t1      ref     v       v       13      const   #       Using where
 
609
alter table t1 add unique(v);
 
610
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
 
611
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*'));
 
612
qq
 
613
*a*a*a*
 
614
*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
explain select * from t1 where v='a';
 
624
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
625
1       SIMPLE  t1      ref     v       v       13      const   #       Using where
 
626
drop table t1;
 
627
create table t1 (a char(10), unique using btree (a)) engine=heap;
 
628
insert into t1 values ('a');
 
629
insert into t1 values ('a ');
 
630
ERROR 23000: Duplicate entry 'a' for key 'a'
 
631
alter table t1 modify a varchar(10);
 
632
insert into t1 values ('a '),('a  '),('a   '),('a         ');
 
633
ERROR 23000: Duplicate entry 'a ' for key 'a'
 
634
insert into t1 values ('a     ');
 
635
ERROR 23000: Duplicate entry 'a     ' for key 'a'
 
636
insert into t1 values ('a          ');
 
637
ERROR 23000: Duplicate entry 'a         ' for key 'a'
 
638
insert into t1 values ('a ');
 
639
ERROR 23000: Duplicate entry 'a ' for key 'a'
 
640
update t1 set a='a      ' where a like 'a ';
 
641
update t1 set a='a  ' where a like 'a      ';
 
642
drop table t1;
 
643
create table t1 (v varchar(10), c char(10), t varchar(50), key(v(5)), key(c(5)), key(t(5)));
 
644
show create table t1;
 
645
Table   Create Table
 
646
t1      CREATE TABLE `t1` (
 
647
  `v` varchar(10) DEFAULT NULL,
 
648
  `c` char(10) DEFAULT NULL,
 
649
  `t` varchar(50) DEFAULT NULL,
 
650
  KEY `v` (`v`(5)),
 
651
  KEY `c` (`c`(5)),
 
652
  KEY `t` (`t`(5))
 
653
) ENGINE=MEMORY DEFAULT CHARSET=latin1
 
654
drop table t1;
 
655
create table t1 (v varchar(65530), key(v(10)));
 
656
show create table t1;
 
657
Table   Create Table
 
658
t1      CREATE TABLE `t1` (
 
659
  `v` varchar(65530) DEFAULT NULL,
 
660
  KEY `v` (`v`(10))
 
661
) ENGINE=MEMORY DEFAULT CHARSET=latin1
 
662
insert into t1 values(repeat('a',65530));
 
663
select length(v) from t1 where v=repeat('a',65530);
 
664
length(v)
 
665
65530
 
666
drop table t1;
 
667
set storage_engine=PBXT;
 
668
create table t1 (a bigint unsigned auto_increment primary key, b int,
 
669
key (b, a)) engine=heap;
 
670
insert t1 (b) values (1),(1),(1),(1),(1),(1),(1),(1);
 
671
select * from t1;
 
672
a       b
 
673
1       1
 
674
2       1
 
675
3       1
 
676
4       1
 
677
5       1
 
678
6       1
 
679
7       1
 
680
8       1
 
681
drop table t1;
 
682
create table t1 (a int not null, b int not null auto_increment,
 
683
primary key(a, b), key(b)) engine=heap;
 
684
insert t1 (a) values (1),(1),(1),(1),(1),(1),(1),(1);
 
685
select * from t1;
 
686
a       b
 
687
1       1
 
688
1       2
 
689
1       3
 
690
1       4
 
691
1       5
 
692
1       6
 
693
1       7
 
694
1       8
 
695
drop table t1;
 
696
create table t1 (a int not null, b int not null auto_increment,
 
697
primary key(a, b)) engine=heap;
 
698
ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key
 
699
create table t1 (c char(255), primary key(c(90)));
 
700
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
 
701
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
 
702
ERROR 23000: Duplicate entry 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl' for key 'PRIMARY'
 
703
drop table t1;
 
704
CREATE TABLE t1 (a int, key(a)) engine=heap;
 
705
insert into t1 values (0);
 
706
delete from t1;
 
707
select * from t1;
 
708
a
 
709
insert into t1 values (0), (1);
 
710
select * from t1 where a = 0;
 
711
a
 
712
0
 
713
drop table t1;
 
714
create table t1 (c char(10)) engine=memory;
 
715
create table t2 (c varchar(10)) engine=memory;
 
716
show table status like 't_';
 
717
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
 
718
t1      MEMORY  10      Fixed   0       11      0       #       0       0       NULL    NULL    NULL    NULL    latin1_swedish_ci       NULL            
 
719
t2      MEMORY  10      Fixed   0       12      0       #       0       0       NULL    NULL    NULL    NULL    latin1_swedish_ci       NULL            
 
720
drop table t1, t2;
 
721
CREATE TABLE t1(a VARCHAR(1), b VARCHAR(2), c VARCHAR(256),
 
722
KEY(a), KEY(b), KEY(c)) ENGINE=MEMORY;
 
723
INSERT INTO t1 VALUES('a','aa',REPEAT('a', 256)),('a','aa',REPEAT('a',256));
 
724
SELECT COUNT(*) FROM t1 WHERE a='a';
 
725
COUNT(*)
 
726
2
 
727
SELECT COUNT(*) FROM t1 WHERE b='aa';
 
728
COUNT(*)
 
729
2
 
730
SELECT COUNT(*) FROM t1 WHERE c=REPEAT('a',256);
 
731
COUNT(*)
 
732
2
 
733
DROP TABLE t1;