~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/heap.result

  • Committer: Patrick Galbraith
  • Date: 2008-07-24 16:57:40 UTC
  • mto: (202.2.4 rename-mysql-to-drizzle)
  • mto: This revision was merged to the branch mainline in revision 212.
  • Revision ID: patg@ishvara-20080724165740-x58yw6zs6d9o17lf
Most everything working with client rename
mysqlslap test still fails... can't connect to the server

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