~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/myisam.result

pandora-build v0.100 - Fixes several bugs found by cb1kenobi. Add several thoughts from folks at LCA.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
drop table if exists t1,t2;
2
2
SET SQL_WARNINGS=1;
3
 
CREATE TABLE t1 (
 
3
CREATE TEMPORARY TABLE t1 (
4
4
STRING_DATA char(255) default NULL,
5
5
KEY string_data (STRING_DATA)
6
6
) ENGINE=MyISAM;
14
14
Table   Op      Msg_type        Msg_text
15
15
test.t1 check   status  OK
16
16
drop table t1;
17
 
create table t1 (a tinyint not null auto_increment, b blob not null, primary key (a));
18
 
check table t1;
19
 
Table   Op      Msg_type        Msg_text
20
 
test.t1 check   status  OK
21
 
repair table t1;
22
 
Table   Op      Msg_type        Msg_text
23
 
test.t1 repair  status  OK
24
 
delete from t1 where (a & 1);
25
 
check table t1;
26
 
Table   Op      Msg_type        Msg_text
27
 
test.t1 check   status  OK
28
 
repair table t1;
29
 
Table   Op      Msg_type        Msg_text
30
 
test.t1 repair  status  OK
 
17
create table t1 (a int not null auto_increment, b blob not null, primary key (a));
 
18
check table t1;
 
19
Table   Op      Msg_type        Msg_text
 
20
test.t1 check   status  OK
 
21
delete from t1 where (a mod 2) = 1;
31
22
check table t1;
32
23
Table   Op      Msg_type        Msg_text
33
24
test.t1 check   status  OK
34
25
drop table t1;
35
 
create table t1 (a int not null auto_increment, b int not null, primary key (a), index(b));
 
26
create TEMPORARY table t1 (a int not null auto_increment, b int not null, primary key (a), index(b)) ENGINE=MYISAM;
36
27
insert into t1 (b) values (1),(2),(2),(2),(2);
37
 
optimize table t1;
38
 
Table   Op      Msg_type        Msg_text
39
 
test.t1 optimize        status  OK
40
 
show index from t1;
41
 
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
42
 
t1      0       PRIMARY 1       a       A       5       NULL    NULL            BTREE           
43
 
t1      1       b       1       b       A       1       NULL    NULL            BTREE           
44
 
optimize table t1;
45
 
Table   Op      Msg_type        Msg_text
46
 
test.t1 optimize        status  Table is already up to date
47
 
show index from t1;
48
 
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
49
 
t1      0       PRIMARY 1       a       A       5       NULL    NULL            BTREE           
50
 
t1      1       b       1       b       A       1       NULL    NULL            BTREE           
 
28
alter table t1 engine=MYISAM;
 
29
show index from t1;
 
30
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
31
t1      0       PRIMARY 1       a       A       5       NULL    NULL            BTREE           
 
32
t1      1       b       1       b       A       NULL    NULL    NULL            BTREE           
 
33
alter table t1 engine=MyISAM;
 
34
show index from t1;
 
35
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
36
t1      0       PRIMARY 1       a       A       5       NULL    NULL            BTREE           
 
37
t1      1       b       1       b       A       NULL    NULL    NULL            BTREE           
51
38
drop table t1;
52
 
create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=myisam;
 
39
create temporary table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=myisam;
53
40
insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
54
41
explain select * from t1 order by a;
55
42
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
76
63
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
77
64
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    4       
78
65
drop table t1;
79
 
CREATE TABLE t1 (a INT);
80
 
INSERT INTO  t1 VALUES (1), (2), (3);
81
 
LOCK TABLES t1 WRITE;
82
 
INSERT INTO  t1 VALUES (1), (2), (3);
83
 
OPTIMIZE TABLE t1;
84
 
Table   Op      Msg_type        Msg_text
85
 
test.t1 optimize        status  OK
86
 
DROP TABLE t1;
87
 
create table t1 ( t1 char(255), key(t1(250)));
 
66
create temporary table t1 ( t1 char(255), key(t1(250))) ENGINE=MYISAM;
88
67
insert t1 values ('137513751375137513751375137513751375137569516951695169516951695169516951695169');
89
68
insert t1 values ('178417841784178417841784178417841784178403420342034203420342034203420342034203');
90
69
insert t1 values ('213872387238723872387238723872387238723867376737673767376737673767376737673767');
114
93
insert t1 values ('70'), ('84'), ('60'), ('20'), ('76'), ('89'), ('49'), ('50'),
115
94
('88'), ('61'), ('42'), ('98'), ('39'), ('30'), ('25'), ('66'), ('61'), ('48'),
116
95
('80'), ('84'), ('98'), ('19'), ('91'), ('42'), ('47');
117
 
optimize table t1;
118
 
Table   Op      Msg_type        Msg_text
119
 
test.t1 optimize        status  OK
 
96
alter table t1 ENGINE=myisam;
120
97
check table t1;
121
98
Table   Op      Msg_type        Msg_text
122
99
test.t1 check   status  OK
123
100
drop table t1;
124
 
create table t1 (i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8
 
101
create temporary table t1 (i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8
125
102
int, i9 int, i10 int, i11 int, i12 int, i13 int, i14 int, i15 int, i16 int, i17
126
103
int, i18 int, i19 int, i20 int, i21 int, i22 int, i23 int, i24 int, i25 int,
127
104
i26 int, i27 int, i28 int, i29 int, i30 int, i31 int, i32 int, i33 int, i34
245
222
int, i975 int, i976 int, i977 int, i978 int, i979 int, i980 int, i981 int, i982
246
223
int, i983 int, i984 int, i985 int, i986 int, i987 int, i988 int, i989 int, i990
247
224
int, i991 int, i992 int, i993 int, i994 int, i995 int, i996 int, i997 int, i998
248
 
int, i999 int, i1000 int, b blob) row_format=dynamic;
 
225
int, i999 int, i1000 int, b blob) engine=myisam row_format=dynamic;
249
226
insert into t1 values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
250
227
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
251
228
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
297
274
Table   Op      Msg_type        Msg_text
298
275
test.t1 check   status  OK
299
276
drop table t1;
300
 
CREATE TABLE `t1` (
301
 
`post_id` mediumint(8) unsigned NOT NULL auto_increment,
302
 
`topic_id` mediumint(8) unsigned NOT NULL default '0',
303
 
`post_time` datetime NOT NULL default '0000-00-00 00:00:00',
 
277
CREATE TEMPORARY TABLE `t1` (
 
278
`post_id` int NOT NULL auto_increment,
 
279
`topic_id` int NOT NULL default '0',
 
280
`post_time` datetime,
304
281
`post_text` text NOT NULL,
305
282
`icon_url` varchar(10) NOT NULL default '',
306
 
`sign` tinyint(1) unsigned NOT NULL default '0',
 
283
`sign` int NOT NULL default '0',
307
284
`post_edit` varchar(150) NOT NULL default '',
308
285
`poster_login` varchar(35) NOT NULL default '',
309
286
`ip` varchar(15) NOT NULL default '',
311
288
KEY `post_time` (`post_time`),
312
289
KEY `ip` (`ip`),
313
290
KEY `poster_login` (`poster_login`),
314
 
KEY `topic_id` (`topic_id`),
315
 
FULLTEXT KEY `post_text` (`post_text`)
 
291
KEY `topic_id` (`topic_id`)
 
292
#  FULLTEXT KEY `post_text` (`post_text`)
316
293
) ENGINE=MyISAM;
317
294
INSERT INTO t1 (post_text) VALUES ('ceci est un test'),('ceci est un test'),('ceci est un test'),('ceci est un test'),('ceci est un test');
318
 
REPAIR TABLE t1;
319
 
Table   Op      Msg_type        Msg_text
320
 
test.t1 repair  status  OK
321
295
CHECK TABLE t1;
322
296
Table   Op      Msg_type        Msg_text
323
297
test.t1 check   status  OK
324
298
drop table t1;
325
 
CREATE TABLE t1 (a varchar(300), b varchar(300), c varchar(300), d varchar(300), e varchar(300), KEY t1 (a, b, c, d, e));
 
299
CREATE TEMPORARY TABLE t1 (a varchar(300), b varchar(300), c varchar(300), d varchar(300), e varchar(300), KEY t1 (a, b, c, d, e)) ENGINE=MyISAM;
326
300
ERROR 42000: Specified key was too long; max key length is 1332 bytes
327
 
CREATE TABLE t1 (a varchar(300), b varchar(300), c varchar(300), d varchar(300), e varchar(300));
 
301
CREATE TEMPORARY TABLE t1 (a varchar(300), b varchar(300), c varchar(300), d varchar(300), e varchar(300)) ENGINE=MyISAM;
328
302
ALTER TABLE t1 ADD INDEX t1 (a, b, c, d, e);
329
303
ERROR 42000: Specified key was too long; max key length is 1332 bytes
330
304
DROP TABLE t1;
331
 
CREATE TABLE t1 (a int not null, b int, c int, key(b), key(c), key(a,b), key(c,a));
 
305
CREATE TEMPORARY TABLE t1 (a int not null, b int, c int, key(b), key(c), key(a,b), key(c,a)) ENGINE=MyISAM;
332
306
INSERT into t1 values (0, null, 0), (0, null, 1), (0, null, 2), (0, null,3), (1,1,4);
333
307
create table t2 (a int not null, b int, c int, key(b), key(c), key(a));
334
308
INSERT into t2 values (1,1,1), (2,2,2);
335
 
optimize table t1;
336
 
Table   Op      Msg_type        Msg_text
337
 
test.t1 optimize        status  OK
 
309
alter table t1 ENGINE=MYISAM;
338
310
show index from t1;
339
311
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
340
 
t1      1       b       1       b       A       5       NULL    NULL    YES     BTREE           
341
 
t1      1       c       1       c       A       5       NULL    NULL    YES     BTREE           
342
 
t1      1       a       1       a       A       1       NULL    NULL            BTREE           
343
 
t1      1       a       2       b       A       5       NULL    NULL    YES     BTREE           
344
 
t1      1       c_2     1       c       A       5       NULL    NULL    YES     BTREE           
345
 
t1      1       c_2     2       a       A       5       NULL    NULL            BTREE           
 
312
t1      1       b       1       b       A       NULL    NULL    NULL    YES     BTREE           
 
313
t1      1       c       1       c       A       NULL    NULL    NULL    YES     BTREE           
 
314
t1      1       a       1       a       A       NULL    NULL    NULL            BTREE           
 
315
t1      1       a       2       b       A       NULL    NULL    NULL    YES     BTREE           
 
316
t1      1       c_2     1       c       A       NULL    NULL    NULL    YES     BTREE           
 
317
t1      1       c_2     2       a       A       NULL    NULL    NULL            BTREE           
346
318
explain select * from t1,t2 where t1.a=t2.a;
347
319
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
348
320
1       SIMPLE  t2      ALL     a       NULL    NULL    NULL    2       
349
 
1       SIMPLE  t1      ALL     a       NULL    NULL    NULL    5       Using where; Using join buffer
 
321
1       SIMPLE  t1      ref     a       a       4       test.t2.a       1       
350
322
explain select * from t1,t2 force index(a) where t1.a=t2.a;
351
323
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
352
324
1       SIMPLE  t2      ALL     a       NULL    NULL    NULL    2       
353
 
1       SIMPLE  t1      ALL     a       NULL    NULL    NULL    5       Using where; Using join buffer
 
325
1       SIMPLE  t1      ref     a       a       4       test.t2.a       1       
354
326
explain select * from t1 force index(a),t2 force index(a) where t1.a=t2.a;
355
327
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
356
328
1       SIMPLE  t2      ALL     a       NULL    NULL    NULL    2       
357
 
1       SIMPLE  t1      ref     a       a       4       test.t2.a       3       
 
329
1       SIMPLE  t1      ref     a       a       4       test.t2.a       1       
358
330
explain select * from t1,t2 where t1.b=t2.b;
359
331
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
360
332
1       SIMPLE  t2      ALL     b       NULL    NULL    NULL    2       
361
 
1       SIMPLE  t1      ref     b       b       5       test.t2.b       1       
 
333
1       SIMPLE  t1      ALL     b       NULL    NULL    NULL    5       Using where; Using join buffer
362
334
explain select * from t1,t2 force index(c) where t1.a=t2.a;
363
335
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
364
336
1       SIMPLE  t2      ALL     NULL    NULL    NULL    NULL    2       
365
 
1       SIMPLE  t1      ALL     a       NULL    NULL    NULL    5       Using where; Using join buffer
 
337
1       SIMPLE  t1      ref     a       a       4       test.t2.a       1       
366
338
explain select * from t1 where a=0 or a=2;
367
339
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
368
340
1       SIMPLE  t1      ALL     a       NULL    NULL    NULL    5       Using where
369
341
explain select * from t1 force index (a) where a=0 or a=2;
370
342
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
371
 
1       SIMPLE  t1      range   a       a       4       NULL    4       Using index condition; Using MRR
 
343
1       SIMPLE  t1      range   a       a       4       NULL    4       Using where
372
344
explain select * from t1 where c=1;
373
345
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
374
346
1       SIMPLE  t1      ref     c,c_2   c       5       const   1       
379
351
create table t1 (a int not null auto_increment primary key, b varchar(255));
380
352
insert into t1 (b) values (repeat('a',100)),(repeat('b',100)),(repeat('c',100));
381
353
update t1 set b=repeat(left(b,1),200) where a=1;
382
 
delete from t1 where (a & 1)= 0;
 
354
delete from t1 where (a mod 2) = 0;
383
355
update t1 set b=repeat('e',200) where a=1;
384
356
flush tables;
385
357
check table t1;
398
370
Table   Op      Msg_type        Msg_text
399
371
test.t1 check   status  OK
400
372
drop table t1;
401
 
create table t1 ( a text not null, key a (a(20)));
 
373
create temporary table t1 ( a text not null, key a (a(20))) engine=myisam;
402
374
insert into t1 values ('aaa   '),('aaa'),('aa');
403
375
check table t1;
404
376
Table   Op      Msg_type        Msg_text
405
377
test.t1 check   status  OK
406
 
repair table t1;
407
 
Table   Op      Msg_type        Msg_text
408
 
test.t1 repair  status  OK
409
378
select concat(a,'.') from t1 where a='aaa';
410
379
concat(a,'.')
411
380
aaa   .
420
389
bbb.
421
390
aa.
422
391
drop table t1;
423
 
create table t1(a text not null, b text not null, c text not null, index (a(10),b(10),c(10)));
 
392
create temporary table t1(a text not null, b text not null, c text not null, index (a(10),b(10),c(10))) engine=myisam;
424
393
insert into t1 values('807780', '477', '165');
425
394
insert into t1 values('807780', '477', '162');
426
395
insert into t1 values('807780', '472', '162');
431
400
DROP TABLE IF EXISTS t1;
432
401
Warnings:
433
402
Note    1051    Unknown table 't1'
434
 
CREATE TABLE t1 (a varchar(150) NOT NULL, KEY (a));
 
403
CREATE TEMPORARY TABLE t1 (a varchar(150) NOT NULL, KEY (a)) ENGINE=MyISAM;
435
404
INSERT t1 VALUES ("can \tcan");
436
405
INSERT t1 VALUES ("can   can");
437
406
INSERT t1 VALUES ("can");
475
444
select * from t1;
476
445
a       b
477
446
1       a
478
 
2       b  
 
447
2       b 
479
448
3       c
480
449
delete from t1 where b='b';
481
450
select a,concat(b,'.') from t1;
498
467
1
499
468
explain select sql_big_result distinct t1.a from t1,t2 order by t2.a;
500
469
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
501
 
1       SIMPLE  t1      system  NULL    NULL    NULL    NULL    1       Using temporary
502
 
1       SIMPLE  t2      index   NULL    PRIMARY 4       NULL    2       Using index; Distinct
 
470
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    1       Using temporary; Using filesort
 
471
1       SIMPLE  t2      index   NULL    PRIMARY 4       NULL    2       Using index; Distinct; Using join buffer
503
472
explain select distinct t1.a from t1,t2 order by t2.a;
504
473
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
505
 
1       SIMPLE  t1      system  NULL    NULL    NULL    NULL    1       Using temporary
506
 
1       SIMPLE  t2      index   NULL    PRIMARY 4       NULL    2       Using index; Distinct
 
474
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    1       Using temporary; Using filesort
 
475
1       SIMPLE  t2      index   NULL    PRIMARY 4       NULL    2       Using index; Distinct; Using join buffer
507
476
drop table t1,t2;
508
 
create table t1 (
 
477
create temporary table t1 (
509
478
c1 varchar(32),
510
479
key (c1)
511
480
) engine=myisam;
515
484
c1
516
485
a
517
486
drop table t1;
518
 
create table t1 (a int not null, primary key(a));
519
 
create table t2 (a int not null, b int not null, primary key(a,b));
520
 
insert into t1 values (1),(2),(3),(4),(5),(6);
521
 
insert into t2 values (1,1),(2,1);
522
 
lock tables t1 read local, t2 read local;
523
 
select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
524
 
a       a       b
525
 
1       1       1
526
 
2       2       1
527
 
insert into t2 values(2,0);
528
 
select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
529
 
a       a       b
530
 
1       1       1
531
 
2       2       1
532
 
unlock tables;
533
 
drop table t1,t2;
534
 
CREATE TABLE t1 (c1 varchar(250) NOT NULL);
535
 
CREATE TABLE t2 (c1 varchar(250) NOT NULL, PRIMARY KEY (c1));
536
 
INSERT INTO t1 VALUES ('test000001'), ('test000002'), ('test000003');
537
 
INSERT INTO t2 VALUES ('test000002'), ('test000003'), ('test000004');
538
 
LOCK TABLES t1 READ LOCAL, t2 READ LOCAL;
539
 
SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
540
 
WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
541
 
t1c1    t2c1
542
 
INSERT INTO t2 VALUES ('test000001'), ('test000005');
543
 
SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
544
 
WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
545
 
t1c1    t2c1
546
 
UNLOCK TABLES;
547
 
DROP TABLE t1,t2;
548
 
CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) ENGINE=MyISAM;
549
 
Got one of the listed errors
550
 
create table t1 (a int, b varchar(200), c text not null) checksum=1;
551
 
create table t2 (a int, b varchar(200), c text not null) checksum=0;
 
487
create table t1 (a int, b varchar(200), c text not null);
 
488
create table t2 (a int, b varchar(200), c text not null);
552
489
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
553
490
insert t2 select * from t1;
554
 
checksum table t1, t2, t3 quick;
555
 
Table   Checksum
556
 
test.t1 2948697075
557
 
test.t2 NULL
558
 
test.t3 NULL
559
 
Warnings:
560
 
Error   1146    Table 'test.t3' doesn't exist
561
 
checksum table t1, t2, t3;
562
 
Table   Checksum
563
 
test.t1 2948697075
564
 
test.t2 2948697075
565
 
test.t3 NULL
566
 
Warnings:
567
 
Error   1146    Table 'test.t3' doesn't exist
568
 
checksum table t1, t2, t3 extended;
569
 
Table   Checksum
570
 
test.t1 2948697075
571
 
test.t2 2948697075
572
 
test.t3 NULL
573
 
Warnings:
574
 
Error   1146    Table 'test.t3' doesn't exist
575
 
drop table t1,t2;
576
 
create table t1 (a int, key (a));
577
 
show keys from t1;
578
 
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
579
 
t1      1       a       1       a       A       NULL    NULL    NULL    YES     BTREE           
580
 
alter table t1 disable keys;
581
 
show keys from t1;
582
 
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
583
 
t1      1       a       1       a       A       NULL    NULL    NULL    YES     BTREE   disabled        
584
 
create table t2 (a int);
585
 
set @@rand_seed1=31415926,@@rand_seed2=2718281828;
586
 
insert t1 select * from t2;
587
 
show keys from t1;
588
 
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
589
 
t1      1       a       1       a       A       NULL    NULL    NULL    YES     BTREE   disabled        
590
 
alter table t1 enable keys;
591
 
show keys from t1;
592
 
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
593
 
t1      1       a       1       a       A       1000    NULL    NULL    YES     BTREE           
594
 
alter table t1 engine=heap;
595
 
alter table t1 disable keys;
596
 
Warnings:
597
 
Note    1031    Table storage engine for 't1' doesn't have this option
598
 
show keys from t1;
599
 
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
600
 
t1      1       a       1       a       NULL    500     NULL    NULL    YES     HASH            
 
491
checksum table t1, t2, t3;
 
492
Table   Checksum
 
493
test.t1 2948697075
 
494
test.t2 2948697075
 
495
test.t3 NULL
 
496
Warnings:
 
497
Error   1146    Table 'test.t3' doesn't exist
 
498
checksum table t1, t2, t3;
 
499
Table   Checksum
 
500
test.t1 2948697075
 
501
test.t2 2948697075
 
502
test.t3 NULL
 
503
Warnings:
 
504
Error   1146    Table 'test.t3' doesn't exist
 
505
checksum table t1, t2, t3;
 
506
Table   Checksum
 
507
test.t1 2948697075
 
508
test.t2 2948697075
 
509
test.t3 NULL
 
510
Warnings:
 
511
Error   1146    Table 'test.t3' doesn't exist
601
512
drop table t1,t2;
602
513
create table t1 ( a tinytext, b char(1), index idx (a(1),b) );
603
514
insert into t1 values (null,''), (null,'');
604
515
explain select count(*) from t1 where a is null;
605
516
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
606
 
1       SIMPLE  t1      ref     idx     idx     4       const   1       Using where
 
517
1       SIMPLE  t1      ref     idx     idx     7       const   1       Using where
607
518
select count(*) from t1 where a is null;
608
519
count(*)
609
520
2
610
521
drop table t1;
611
522
create table t1 (c1 int, c2 varchar(4) not null default '',
612
 
key(c2(3))) default charset=utf8;
 
523
key(c2(3)));
613
524
insert into t1 values (1,'A'), (2, 'B'), (3, 'A');
614
525
update t1 set c2='A  B' where c1=2;
615
526
check table t1;
630
541
Table   Checksum
631
542
test.t2 984116287
632
543
drop table t1, t2;
633
 
show variables like 'myisam_stats_method';
634
 
Variable_name   Value
635
 
myisam_stats_method     nulls_unequal
636
 
create table t1 (a int, key(a));
637
 
insert into t1 values (0),(1),(2),(3),(4);
638
 
insert into t1 select NULL from t1;
639
 
analyze table t1;
640
 
Table   Op      Msg_type        Msg_text
641
 
test.t1 analyze status  OK
642
 
show index from t1;
643
 
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
644
 
t1      1       a       1       a       A       10      NULL    NULL    YES     BTREE           
645
 
insert into t1 values (11);
646
 
delete from t1 where a=11;
647
 
check table t1;
648
 
Table   Op      Msg_type        Msg_text
649
 
test.t1 check   status  OK
650
 
show index from t1;
651
 
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
652
 
t1      1       a       1       a       A       10      NULL    NULL    YES     BTREE           
653
 
set myisam_stats_method=nulls_equal;
654
 
show variables like 'myisam_stats_method';
655
 
Variable_name   Value
656
 
myisam_stats_method     nulls_equal
657
 
insert into t1 values (11);
658
 
delete from t1 where a=11;
659
 
analyze table t1;
660
 
Table   Op      Msg_type        Msg_text
661
 
test.t1 analyze status  OK
662
 
show index from t1;
663
 
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
664
 
t1      1       a       1       a       A       5       NULL    NULL    YES     BTREE           
665
 
insert into t1 values (11);
666
 
delete from t1 where a=11;
667
 
check table t1;
668
 
Table   Op      Msg_type        Msg_text
669
 
test.t1 check   status  OK
670
 
show index from t1;
671
 
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
672
 
t1      1       a       1       a       A       5       NULL    NULL    YES     BTREE           
673
 
set myisam_stats_method=DEFAULT;
674
 
show variables like 'myisam_stats_method';
675
 
Variable_name   Value
676
 
myisam_stats_method     nulls_unequal
677
 
insert into t1 values (11);
678
 
delete from t1 where a=11;
679
 
analyze table t1;
680
 
Table   Op      Msg_type        Msg_text
681
 
test.t1 analyze status  OK
682
 
show index from t1;
683
 
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
684
 
t1      1       a       1       a       A       10      NULL    NULL    YES     BTREE           
685
 
insert into t1 values (11);
686
 
delete from t1 where a=11;
687
 
check table t1;
688
 
Table   Op      Msg_type        Msg_text
689
 
test.t1 check   status  OK
690
 
show index from t1;
691
 
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
692
 
t1      1       a       1       a       A       10      NULL    NULL    YES     BTREE           
693
 
drop table t1;
694
 
set myisam_stats_method=nulls_ignored;
695
 
show variables like 'myisam_stats_method';
696
 
Variable_name   Value
697
 
myisam_stats_method     nulls_ignored
698
 
create table t1 (
699
 
a char(3), b char(4), c char(5), d char(6),
700
 
key(a,b,c,d)
701
 
);
702
 
insert into t1 values ('bcd','def1', NULL, 'zz');
703
 
insert into t1 values ('bcd','def2', NULL, 'zz');
704
 
insert into t1 values ('bce','def1', 'yuu', NULL);
705
 
insert into t1 values ('bce','def2', NULL, 'quux');
706
 
analyze table t1;
707
 
Table   Op      Msg_type        Msg_text
708
 
test.t1 analyze status  OK
709
 
show index from t1;
710
 
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
711
 
t1      1       a       1       a       A       2       NULL    NULL    YES     BTREE           
712
 
t1      1       a       2       b       A       4       NULL    NULL    YES     BTREE           
713
 
t1      1       a       3       c       A       4       NULL    NULL    YES     BTREE           
714
 
t1      1       a       4       d       A       4       NULL    NULL    YES     BTREE           
715
 
delete from t1;
716
 
analyze table t1;
717
 
Table   Op      Msg_type        Msg_text
718
 
test.t1 analyze status  OK
719
 
show index from t1;
720
 
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
721
 
t1      1       a       1       a       A       0       NULL    NULL    YES     BTREE           
722
 
t1      1       a       2       b       A       0       NULL    NULL    YES     BTREE           
723
 
t1      1       a       3       c       A       0       NULL    NULL    YES     BTREE           
724
 
t1      1       a       4       d       A       0       NULL    NULL    YES     BTREE           
725
 
set myisam_stats_method=DEFAULT;
726
 
drop table t1;
727
544
create table t1(
728
545
cip INT NOT NULL,
729
 
time TIME NOT NULL,
730
546
score INT NOT NULL DEFAULT 0,
731
547
bob TINYBLOB
732
548
);
733
 
insert into t1 (cip, time) VALUES (1, '00:01'), (2, '00:02'), (3,'00:03');
734
 
insert into t1 (cip, bob, time) VALUES (4, 'a', '00:04'), (5, 'b', '00:05'), 
735
 
(6, 'c', '00:06');
736
 
select * from t1 where bob is null and cip=1;
737
 
cip     time    score   bob
738
 
1       00:01:00        0       NULL
739
 
create index bug on t1 (bob(22), cip, time);
740
 
select * from t1 where bob is null and cip=1;
741
 
cip     time    score   bob
742
 
1       00:01:00        0       NULL
 
549
insert into t1 (cip) VALUES (1), (2), (3);
 
550
insert into t1 (cip, bob) VALUES (4, 'a' ), (5, 'b'), 
 
551
(6, 'c');
 
552
select * from t1 where bob is null and cip=1;
 
553
cip     score   bob
 
554
1       0       NULL
 
555
create index bug on t1 (bob(22), cip);
 
556
select * from t1 where bob is null and cip=1;
 
557
cip     score   bob
 
558
1       0       NULL
743
559
drop table t1;
744
 
create table t1 (
 
560
create temporary table t1 (
745
561
id1 int not null auto_increment,
746
562
id2 int not null default '0',
747
563
t text not null,
759
575
count(id1)
760
576
5
761
577
drop table t1;
762
 
CREATE TABLE t1(a TINYINT, KEY(a)) ENGINE=MyISAM;
 
578
CREATE TEMPORARY TABLE t1(a int, KEY(a)) ENGINE=MyISAM;
763
579
INSERT INTO t1 VALUES(1);
764
580
SELECT MAX(a) FROM t1 IGNORE INDEX(a);
765
581
MAX(a)
772
588
MAX(a)
773
589
1
774
590
DROP TABLE t1;
775
 
CREATE TABLE t1(a CHAR(9), b VARCHAR(7)) ENGINE=MyISAM;
776
 
INSERT INTO t1(a) VALUES('xxxxxxxxx'),('xxxxxxxxx');
777
 
UPDATE t1 AS ta1,t1 AS ta2 SET ta1.b='aaaaaa',ta2.b='bbbbbb';
778
 
SELECT * FROM t1;
779
 
a       b
780
 
xxxxxxxxx       bbbbbb
781
 
xxxxxxxxx       bbbbbb
782
 
DROP TABLE t1;
783
 
SET @@myisam_repair_threads=2;
 
591
SET GLOBAL myisam_repair_threads=2;
784
592
SHOW VARIABLES LIKE 'myisam_repair%';
785
593
Variable_name   Value
786
594
myisam_repair_threads   2
787
 
CREATE TABLE t1 (
788
 
`_id` int(11) NOT NULL default '0',
789
 
`url` text,
790
 
`email` text,
791
 
`description` text,
792
 
`loverlap` int(11) default NULL,
793
 
`roverlap` int(11) default NULL,
794
 
`lneighbor_id` int(11) default NULL,
795
 
`rneighbor_id` int(11) default NULL,
796
 
`length_` int(11) default NULL,
797
 
`sequence` mediumtext,
798
 
`name` text,
799
 
`_obj_class` text NOT NULL,
800
 
PRIMARY KEY  (`_id`),
801
 
UNIQUE KEY `sequence_name_index` (`name`(50)),
802
 
KEY (`length_`)
803
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
804
 
INSERT INTO t1 VALUES
805
 
(1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample1',''),
806
 
(2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample2',''),
807
 
(3,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample3',''),
808
 
(4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample4',''),
809
 
(5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample5',''),
810
 
(6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample6',''),
811
 
(7,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample7',''),
812
 
(8,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample8',''),
813
 
(9,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample9','');
814
 
SELECT _id FROM t1;
815
 
_id
816
 
1
817
 
2
818
 
3
819
 
4
820
 
5
821
 
6
822
 
7
823
 
8
824
 
9
825
 
DELETE FROM t1 WHERE _id < 8;
826
 
SHOW TABLE STATUS LIKE 't1';
827
 
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
828
 
t1      MyISAM  10      Dynamic 2       #       #       #       #       140     #       #       #       #       #       #               
829
 
CHECK TABLE t1 EXTENDED;
830
 
Table   Op      Msg_type        Msg_text
831
 
test.t1 check   status  OK
832
 
OPTIMIZE TABLE t1;
833
 
Table   Op      Msg_type        Msg_text
834
 
test.t1 optimize        status  OK
835
 
CHECK TABLE t1 EXTENDED;
836
 
Table   Op      Msg_type        Msg_text
837
 
test.t1 check   status  OK
838
 
SHOW TABLE STATUS LIKE 't1';
839
 
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
840
 
t1      MyISAM  10      Dynamic 2       #       #       #       #       0       #       #       #       #       #       #               
841
 
SELECT _id FROM t1;
842
 
_id
843
 
8
844
 
9
845
 
DROP TABLE t1;
846
 
CREATE TABLE t1 (
847
 
`_id` int(11) NOT NULL default '0',
848
 
`url` text,
849
 
`email` text,
850
 
`description` text,
851
 
`loverlap` int(11) default NULL,
852
 
`roverlap` int(11) default NULL,
853
 
`lneighbor_id` int(11) default NULL,
854
 
`rneighbor_id` int(11) default NULL,
855
 
`length_` int(11) default NULL,
856
 
`sequence` mediumtext,
857
 
`name` text,
858
 
`_obj_class` text NOT NULL,
859
 
PRIMARY KEY  (`_id`),
860
 
UNIQUE KEY `sequence_name_index` (`name`(50)),
861
 
KEY (`length_`)
862
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
863
 
INSERT INTO t1 VALUES
864
 
(1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample1',''),
865
 
(2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample2',''),
866
 
(3,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample3',''),
867
 
(4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample4',''),
868
 
(5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample5',''),
869
 
(6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample6',''),
870
 
(7,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample7',''),
871
 
(8,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample8',''),
872
 
(9,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample9','');
873
 
SELECT _id FROM t1;
874
 
_id
875
 
1
876
 
2
877
 
3
878
 
4
879
 
5
880
 
6
881
 
7
882
 
8
883
 
9
884
 
DELETE FROM t1 WHERE _id < 8;
885
 
SHOW TABLE STATUS LIKE 't1';
886
 
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
887
 
t1      MyISAM  10      Dynamic 2       #       #       #       #       140     #       #       #       #       #       #               
888
 
CHECK TABLE t1 EXTENDED;
889
 
Table   Op      Msg_type        Msg_text
890
 
test.t1 check   status  OK
891
 
REPAIR TABLE t1 QUICK;
892
 
Table   Op      Msg_type        Msg_text
893
 
test.t1 repair  status  OK
894
 
CHECK TABLE t1 EXTENDED;
895
 
Table   Op      Msg_type        Msg_text
896
 
test.t1 check   status  OK
897
 
SHOW TABLE STATUS LIKE 't1';
898
 
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
899
 
t1      MyISAM  10      Dynamic 2       #       #       #       #       140     #       #       #       #       #       #               
900
 
SELECT _id FROM t1;
901
 
_id
902
 
8
903
 
9
904
 
DROP TABLE t1;
905
 
SET @@myisam_repair_threads=1;
 
595
CREATE TEMPORARY TABLE t1 (
 
596
`_id` int NOT NULL default '0',
 
597
`url` text,
 
598
`email` text,
 
599
`description` text,
 
600
`loverlap` int default NULL,
 
601
`roverlap` int default NULL,
 
602
`lneighbor_id` int default NULL,
 
603
`rneighbor_id` int default NULL,
 
604
`length_` int default NULL,
 
605
`sequence` text,
 
606
`name` text,
 
607
`_obj_class` text NOT NULL,
 
608
PRIMARY KEY  (`_id`),
 
609
UNIQUE KEY `sequence_name_index` (`name`(50)),
 
610
KEY (`length_`)
 
611
) ENGINE=MyISAM;
 
612
INSERT INTO t1 VALUES
 
613
(1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample1',''),
 
614
(2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample2',''),
 
615
(3,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample3',''),
 
616
(4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample4',''),
 
617
(5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample5',''),
 
618
(6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample6',''),
 
619
(7,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample7',''),
 
620
(8,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample8',''),
 
621
(9,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample9','');
 
622
SELECT _id FROM t1;
 
623
_id
 
624
1
 
625
2
 
626
3
 
627
4
 
628
5
 
629
6
 
630
7
 
631
8
 
632
9
 
633
DELETE FROM t1 WHERE _id < 8;
 
634
SHOW TABLE STATUS LIKE 't1';
 
635
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 Plugin_name
 
636
CHECK TABLE t1;
 
637
Table   Op      Msg_type        Msg_text
 
638
test.t1 check   status  OK
 
639
ALTER TABLE t1 ENGINE=MYISAM;
 
640
CHECK TABLE t1;
 
641
Table   Op      Msg_type        Msg_text
 
642
test.t1 check   status  OK
 
643
SHOW TABLE STATUS LIKE 't1';
 
644
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 Plugin_name
 
645
SELECT _id FROM t1;
 
646
_id
 
647
8
 
648
9
 
649
DROP TABLE t1;
 
650
SET GLOBAL myisam_repair_threads=1;
906
651
SHOW VARIABLES LIKE 'myisam_repair%';
907
652
Variable_name   Value
908
653
myisam_repair_threads   1
909
 
CREATE TABLE t1(a VARCHAR(16));
910
 
INSERT INTO t1 VALUES('aaaaaaaa'),(NULL);
911
 
UPDATE t1 AS ta1, t1 AS ta2 SET ta1.a='aaaaaaaaaaaaaaaa';
912
 
SELECT * FROM t1;
913
 
a
914
 
aaaaaaaaaaaaaaaa
915
 
aaaaaaaaaaaaaaaa
916
 
DROP TABLE t1;
917
 
CREATE TABLE t1(a INT);
918
 
INSERT INTO t1 VALUES(1),(2);
919
 
UPDATE t1,t1 AS t2 SET t1.a=t1.a+2 WHERE t1.a=t2.a-1;
920
 
SELECT * FROM t1 ORDER BY a;
921
 
a
922
 
2
923
 
3
924
 
DROP TABLE t1;
925
 
CREATE TABLE t1 (c1 TEXT) AVG_ROW_LENGTH=70100 MAX_ROWS=4100100100;
 
654
CREATE TEMPORARY TABLE t1 (c1 TEXT) ENGINE=MyISAM;
926
655
SHOW TABLE STATUS LIKE 't1';
927
 
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
928
 
t1      MyISAM  10      Dynamic X       X       X       72057594037927935       X       X       X       X       X       X       latin1_swedish_ci       X       max_rows=4100100100 avg_row_length=70100        
 
656
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 Plugin_name
929
657
DROP TABLE t1;
930
 
CREATE TABLE t1 (c1 TEXT NOT NULL, KEY c1 (c1(10))) ENGINE=MyISAM;
 
658
CREATE TEMPORARY TABLE t1 (c1 TEXT NOT NULL, KEY c1 (c1(10))) ENGINE=MyISAM;
931
659
INSERT INTO t1 VALUES
932
660
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
933
661
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
1082
810
drop table if exists t1,t2,t3;
1083
811
--- Testing varchar ---
1084
812
--- Testing varchar ---
1085
 
create table t1 (v varchar(10), c char(10), t text);
 
813
create TEMPORARY table t1 (v varchar(10), c char(10), t text);
1086
814
insert into t1 values('+ ', '+ ', '+ ');
1087
815
set @a=repeat(' ',20);
1088
816
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
1091
819
Note    1265    Data truncated for column 'c' at row 1
1092
820
select concat('*',v,'*',c,'*',t,'*') from t1;
1093
821
concat('*',v,'*',c,'*',t,'*')
1094
 
*+ *+*+ *
1095
 
*+         *+*+                    *
 
822
*+ *+ *+ *
 
823
*+         *+         *+                    *
1096
824
show create table t1;
1097
825
Table   Create Table
1098
 
t1      CREATE TABLE `t1` (
 
826
t1      CREATE TEMPORARY TABLE `t1` (
1099
827
  `v` varchar(10) DEFAULT NULL,
1100
 
  `c` char(10) DEFAULT NULL,
 
828
  `c` varchar(10) DEFAULT NULL,
1101
829
  `t` text
1102
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1103
 
create table t2 like t1;
 
830
) ENGINE=MyISAM
 
831
create TEMPORARY table t2 like t1;
1104
832
show create table t2;
1105
833
Table   Create Table
1106
 
t2      CREATE TABLE `t2` (
 
834
t2      CREATE TEMPORARY TABLE `t2` (
1107
835
  `v` varchar(10) DEFAULT NULL,
1108
 
  `c` char(10) DEFAULT NULL,
 
836
  `c` varchar(10) DEFAULT NULL,
1109
837
  `t` text
1110
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1111
 
create table t3 select * from t1;
 
838
) ENGINE=MyISAM
 
839
create TEMPORARY table t3 select * from t1;
1112
840
show create table t3;
1113
841
Table   Create Table
1114
 
t3      CREATE TABLE `t3` (
 
842
t3      CREATE TEMPORARY TABLE `t3` (
1115
843
  `v` varchar(10) DEFAULT NULL,
1116
 
  `c` char(10) DEFAULT NULL,
 
844
  `c` varchar(10) DEFAULT NULL,
1117
845
  `t` text
1118
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
846
) ENGINE=MyISAM
1119
847
alter table t1 modify c varchar(10);
1120
848
show create table t1;
1121
849
Table   Create Table
1122
 
t1      CREATE TABLE `t1` (
 
850
t1      CREATE TEMPORARY TABLE `t1` (
1123
851
  `v` varchar(10) DEFAULT NULL,
1124
852
  `c` varchar(10) DEFAULT NULL,
1125
853
  `t` text
1126
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
854
) ENGINE=MyISAM
1127
855
alter table t1 modify v char(10);
1128
856
show create table t1;
1129
857
Table   Create Table
1130
 
t1      CREATE TABLE `t1` (
1131
 
  `v` char(10) DEFAULT NULL,
 
858
t1      CREATE TEMPORARY TABLE `t1` (
 
859
  `v` varchar(10) DEFAULT NULL,
1132
860
  `c` varchar(10) DEFAULT NULL,
1133
861
  `t` text
1134
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
862
) ENGINE=MyISAM
1135
863
alter table t1 modify t varchar(10);
1136
864
Warnings:
1137
865
Note    1265    Data truncated for column 't' at row 2
1138
866
show create table t1;
1139
867
Table   Create Table
1140
 
t1      CREATE TABLE `t1` (
1141
 
  `v` char(10) DEFAULT NULL,
 
868
t1      CREATE TEMPORARY TABLE `t1` (
 
869
  `v` varchar(10) DEFAULT NULL,
1142
870
  `c` varchar(10) DEFAULT NULL,
1143
871
  `t` varchar(10) DEFAULT NULL
1144
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
872
) ENGINE=MyISAM
1145
873
select concat('*',v,'*',c,'*',t,'*') from t1;
1146
874
concat('*',v,'*',c,'*',t,'*')
1147
 
*+*+*+ *
1148
 
*+*+*+         *
 
875
*+ *+ *+ *
 
876
*+         *+         *+         *
1149
877
drop table t1,t2,t3;
1150
 
create table t1 (v varchar(10), c char(10), t text, key(v), key(c), key(t(10)));
 
878
create TEMPORARY table t1 (v varchar(10), c char(10), t text, key(v), key(c), key(t(10)));
1151
879
show create table t1;
1152
880
Table   Create Table
1153
 
t1      CREATE TABLE `t1` (
 
881
t1      CREATE TEMPORARY TABLE `t1` (
1154
882
  `v` varchar(10) DEFAULT NULL,
1155
 
  `c` char(10) DEFAULT NULL,
 
883
  `c` varchar(10) DEFAULT NULL,
1156
884
  `t` text,
1157
885
  KEY `v` (`v`),
1158
886
  KEY `c` (`c`),
1159
887
  KEY `t` (`t`(10))
1160
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
888
) ENGINE=MyISAM
1161
889
select count(*) from t1;
1162
890
count(*)
1163
891
270
1200
928
9
1201
929
explain select count(*) from t1 where v='a  ';
1202
930
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1203
 
1       SIMPLE  t1      ref     v       v       13      const   #       Using where; Using index
 
931
1       SIMPLE  t1      ref     v       v       43      const   #       Using where; Using index
1204
932
explain select count(*) from t1 where c='a  ';
1205
933
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1206
 
1       SIMPLE  t1      ref     c       c       11      const   #       Using where; Using index
 
934
1       SIMPLE  t1      ref     c       c       43      const   #       Using where; Using index
1207
935
explain select count(*) from t1 where t='a  ';
1208
936
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1209
 
1       SIMPLE  t1      ref     t       t       13      const   #       Using where
 
937
1       SIMPLE  t1      ref     t       t       43      const   #       Using where
1210
938
explain select count(*) from t1 where v like 'a%';
1211
939
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1212
 
1       SIMPLE  t1      range   v       v       13      NULL    #       Using where; Using index
 
940
1       SIMPLE  t1      range   v       v       43      NULL    #       Using where; Using index
1213
941
explain select count(*) from t1 where v between 'a' and 'a ';
1214
942
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1215
 
1       SIMPLE  t1      ref     v       v       13      const   #       Using where; Using index
 
943
1       SIMPLE  t1      ref     v       v       43      const   #       Using where; Using index
1216
944
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
1217
945
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1218
 
1       SIMPLE  t1      ref     v       v       13      const   #       Using where; Using index
 
946
1       SIMPLE  t1      ref     v       v       43      const   #       Using where; Using index
1219
947
alter table t1 add unique(v);
1220
948
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
1221
949
alter table t1 add key(v);
1222
950
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a';
1223
951
qq
1224
952
*a*a*a*
1225
 
*a *a*a *
1226
 
*a  *a*a  *
1227
 
*a   *a*a   *
1228
 
*a    *a*a    *
1229
 
*a     *a*a     *
1230
 
*a      *a*a      *
1231
 
*a       *a*a       *
1232
 
*a        *a*a        *
1233
 
*a         *a*a         *
 
953
*a *a *a *
 
954
*a  *a  *a  *
 
955
*a   *a   *a   *
 
956
*a    *a    *a    *
 
957
*a     *a     *a     *
 
958
*a      *a      *a      *
 
959
*a       *a       *a       *
 
960
*a        *a        *a        *
 
961
*a         *a         *a         *
1234
962
explain select * from t1 where v='a';
1235
963
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1236
 
1       SIMPLE  t1      ref     v,v_2   #       13      const   #       Using index condition
 
964
1       SIMPLE  t1      ref     v,v_2   #       43      const   #       Using where
1237
965
select v,count(*) from t1 group by v limit 10;
1238
966
v       count(*)
1239
967
a      1
1369
1097
alter table t1 modify v varchar(300), drop key v, drop key v_2, add key v (v);
1370
1098
show create table t1;
1371
1099
Table   Create Table
1372
 
t1      CREATE TABLE `t1` (
 
1100
t1      CREATE TEMPORARY TABLE `t1` (
1373
1101
  `v` varchar(300) DEFAULT NULL,
1374
 
  `c` char(10) DEFAULT NULL,
 
1102
  `c` varchar(10) DEFAULT NULL,
1375
1103
  `t` text,
1376
1104
  KEY `c` (`c`),
1377
1105
  KEY `t` (`t`(10)),
1378
1106
  KEY `v` (`v`)
1379
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1107
) ENGINE=MyISAM
1380
1108
select count(*) from t1 where v='a';
1381
1109
count(*)
1382
1110
10
1397
1125
9
1398
1126
explain select count(*) from t1 where v='a  ';
1399
1127
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1400
 
1       SIMPLE  t1      ref     v       v       303     const   #       Using where; Using index
 
1128
1       SIMPLE  t1      ref     v       v       1203    const   #       Using where; Using index
1401
1129
explain select count(*) from t1 where v like 'a%';
1402
1130
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1403
 
1       SIMPLE  t1      range   v       v       303     NULL    #       Using where; Using index
 
1131
1       SIMPLE  t1      range   v       v       1203    NULL    #       Using where; Using index
1404
1132
explain select count(*) from t1 where v between 'a' and 'a ';
1405
1133
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1406
 
1       SIMPLE  t1      ref     v       v       303     const   #       Using where; Using index
 
1134
1       SIMPLE  t1      ref     v       v       1203    const   #       Using where; Using index
1407
1135
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
1408
1136
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1409
 
1       SIMPLE  t1      ref     v       v       303     const   #       Using where; Using index
 
1137
1       SIMPLE  t1      ref     v       v       1203    const   #       Using where; Using index
1410
1138
explain select * from t1 where v='a';
1411
1139
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1412
 
1       SIMPLE  t1      ref     v       v       303     const   #       Using index condition
 
1140
1       SIMPLE  t1      ref     v       v       1203    const   #       Using where
1413
1141
select v,count(*) from t1 group by v limit 10;
1414
1142
v       count(*)
1415
1143
a      1
1449
1177
alter table t1 drop key v, add key v (v(30));
1450
1178
show create table t1;
1451
1179
Table   Create Table
1452
 
t1      CREATE TABLE `t1` (
 
1180
t1      CREATE TEMPORARY TABLE `t1` (
1453
1181
  `v` varchar(300) DEFAULT NULL,
1454
 
  `c` char(10) DEFAULT NULL,
 
1182
  `c` varchar(10) DEFAULT NULL,
1455
1183
  `t` text,
1456
1184
  KEY `c` (`c`),
1457
1185
  KEY `t` (`t`(10)),
1458
1186
  KEY `v` (`v`(30))
1459
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1187
) ENGINE=MyISAM
1460
1188
select count(*) from t1 where v='a';
1461
1189
count(*)
1462
1190
10
1477
1205
9
1478
1206
explain select count(*) from t1 where v='a  ';
1479
1207
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1480
 
1       SIMPLE  t1      ref     v       v       33      const   #       Using where
 
1208
1       SIMPLE  t1      ref     v       v       123     const   #       Using where
1481
1209
explain select count(*) from t1 where v like 'a%';
1482
1210
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1483
 
1       SIMPLE  t1      range   v       v       33      NULL    #       Using where
 
1211
1       SIMPLE  t1      range   v       v       123     NULL    #       Using where
1484
1212
explain select count(*) from t1 where v between 'a' and 'a ';
1485
1213
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1486
 
1       SIMPLE  t1      ref     v       v       33      const   #       Using where
 
1214
1       SIMPLE  t1      ref     v       v       123     const   #       Using where
1487
1215
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
1488
1216
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1489
 
1       SIMPLE  t1      ref     v       v       33      const   #       Using where
 
1217
1       SIMPLE  t1      ref     v       v       123     const   #       Using where
1490
1218
explain select * from t1 where v='a';
1491
1219
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1492
 
1       SIMPLE  t1      ref     v       v       33      const   #       Using where
 
1220
1       SIMPLE  t1      ref     v       v       123     const   #       Using where
1493
1221
select v,count(*) from t1 group by v limit 10;
1494
1222
v       count(*)
1495
1223
a      1
1527
1255
h       10
1528
1256
i       10
1529
1257
alter table t1 modify v varchar(600), drop key v, add key v (v);
 
1258
Warnings:
 
1259
Warning 1071    Specified key was too long; max key length is 1332 bytes
1530
1260
show create table t1;
1531
1261
Table   Create Table
1532
 
t1      CREATE TABLE `t1` (
 
1262
t1      CREATE TEMPORARY TABLE `t1` (
1533
1263
  `v` varchar(600) DEFAULT NULL,
1534
 
  `c` char(10) DEFAULT NULL,
 
1264
  `c` varchar(10) DEFAULT NULL,
1535
1265
  `t` text,
1536
1266
  KEY `c` (`c`),
1537
1267
  KEY `t` (`t`(10)),
1538
 
  KEY `v` (`v`)
1539
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1268
  KEY `v` (`v`(333))
 
1269
) ENGINE=MyISAM
1540
1270
select v,count(*) from t1 group by v limit 10;
1541
1271
v       count(*)
1542
1272
a      1
1574
1304
h       10
1575
1305
i       10
1576
1306
drop table t1;
1577
 
create table t1 (a char(10), unique (a));
 
1307
create TEMPORARY table t1 (a char(10), unique (a));
1578
1308
insert into t1 values ('a   ');
1579
1309
insert into t1 values ('a ');
1580
 
ERROR 23000: Duplicate entry 'a' for key 'a'
 
1310
ERROR 23000: Duplicate entry 'a ' for key 'a'
1581
1311
alter table t1 modify a varchar(10);
1582
1312
insert into t1 values ('a '),('a  '),('a   '),('a         ');
1583
1313
ERROR 23000: Duplicate entry 'a ' for key 'a'
1604
1334
concat(a,'.')
1605
1335
a  .
1606
1336
drop table t1;
1607
 
create table t1 (v varchar(10), c char(10), t text, key(v(5)), key(c(5)), key(t(5)));
 
1337
create TEMPORARY table t1 (v varchar(10), c char(10), t text, key(v(5)), key(c(5)), key(t(5)));
1608
1338
show create table t1;
1609
1339
Table   Create Table
1610
 
t1      CREATE TABLE `t1` (
 
1340
t1      CREATE TEMPORARY TABLE `t1` (
1611
1341
  `v` varchar(10) DEFAULT NULL,
1612
 
  `c` char(10) DEFAULT NULL,
 
1342
  `c` varchar(10) DEFAULT NULL,
1613
1343
  `t` text,
1614
1344
  KEY `v` (`v`(5)),
1615
1345
  KEY `c` (`c`(5)),
1616
1346
  KEY `t` (`t`(5))
1617
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1618
 
drop table t1;
1619
 
create table t1 (v char(10) character set utf8);
1620
 
show create table t1;
1621
 
Table   Create Table
1622
 
t1      CREATE TABLE `t1` (
1623
 
  `v` char(10) CHARACTER SET utf8 DEFAULT NULL
1624
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1625
 
drop table t1;
1626
 
create table t1 (v varchar(10), c char(10)) row_format=fixed;
1627
 
show create table t1;
1628
 
Table   Create Table
1629
 
t1      CREATE TABLE `t1` (
 
1347
) ENGINE=MyISAM
 
1348
drop table t1;
 
1349
create TEMPORARY table t1 (v char(10));
 
1350
show create table t1;
 
1351
Table   Create Table
 
1352
t1      CREATE TEMPORARY TABLE `t1` (
 
1353
  `v` varchar(10) DEFAULT NULL
 
1354
) ENGINE=MyISAM
 
1355
drop table t1;
 
1356
create TEMPORARY table t1 (v varchar(10), c char(10));
 
1357
show create table t1;
 
1358
Table   Create Table
 
1359
t1      CREATE TEMPORARY TABLE `t1` (
1630
1360
  `v` varchar(10) DEFAULT NULL,
1631
 
  `c` char(10) DEFAULT NULL
1632
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED
 
1361
  `c` varchar(10) DEFAULT NULL
 
1362
) ENGINE=MyISAM
1633
1363
insert into t1 values('a','a'),('a ','a ');
1634
1364
select concat('*',v,'*',c,'*') from t1;
1635
1365
concat('*',v,'*',c,'*')
1636
1366
*a*a*
1637
 
*a *a*
1638
 
drop table t1;
1639
 
create table t1 (v varchar(65530), key(v(10)));
1640
 
insert into t1 values(repeat('a',65530));
1641
 
select length(v) from t1 where v=repeat('a',65530);
1642
 
length(v)
1643
 
65530
1644
 
drop table t1;
1645
 
create table t1(a int, b varchar(12), key ba(b, a));
 
1367
*a *a *
 
1368
drop table t1;
 
1369
create TEMPORARY table t1(a int, b varchar(12), key ba(b, a));
1646
1370
insert into t1 values (1, 'A'), (20, NULL);
1647
1371
explain select * from t1 where a=20 and b is null;
1648
1372
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1649
 
1       SIMPLE  t1      ref     ba      ba      20      const,const     1       Using where; Using index
 
1373
1       SIMPLE  t1      ref     ba      ba      56      const,const     1       Using where; Using index
1650
1374
select * from t1 where a=20 and b is null;
1651
1375
a       b
1652
1376
20      NULL
1653
1377
drop table t1;
1654
 
create table t1 (v varchar(65530), key(v));
1655
 
Warnings:
1656
 
Warning 1071    Specified key was too long; max key length is 1332 bytes
1657
 
drop table if exists t1;
1658
 
create table t1 (v varchar(65536));
1659
 
Warnings:
1660
 
Note    1246    Converting column 'v' from VARCHAR to TEXT
1661
 
show create table t1;
1662
 
Table   Create Table
1663
 
t1      CREATE TABLE `t1` (
1664
 
  `v` mediumtext
1665
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1666
 
drop table t1;
1667
 
create table t1 (v varchar(65530) character set utf8);
1668
 
Warnings:
1669
 
Note    1246    Converting column 'v' from VARCHAR to TEXT
1670
 
show create table t1;
1671
 
Table   Create Table
1672
 
t1      CREATE TABLE `t1` (
1673
 
  `v` mediumtext CHARACTER SET utf8
1674
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1675
 
drop table t1;
1676
 
create table t1 (v varchar(65535));
1677
 
ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs
1678
 
set storage_engine=MyISAM;
1679
 
set @save_concurrent_insert=@@concurrent_insert;
1680
 
set global concurrent_insert=1;
1681
 
create table t1 (a int);
1682
 
insert into t1 values (1),(2),(3),(4),(5);
1683
 
lock table t1 read local;
1684
 
insert into t1 values(6),(7);
1685
 
unlock tables;
1686
 
delete from t1 where a>=3 and a<=4;
1687
 
lock table t1 read local;
1688
 
set global concurrent_insert=2;
1689
 
insert into t1 values (8),(9);
1690
 
unlock tables;
1691
 
insert into t1 values (10),(11),(12);
1692
 
select * from t1;
1693
 
a
1694
 
1
1695
 
2
1696
 
11
1697
 
10
1698
 
5
1699
 
6
1700
 
7
1701
 
8
1702
 
9
1703
 
12
1704
 
check table t1;
1705
 
Table   Op      Msg_type        Msg_text
1706
 
test.t1 check   status  OK
1707
 
drop table t1;
1708
 
create table t1 (a int, b varchar(30) default "hello");
1709
 
insert into t1 (a) values (1),(2),(3),(4),(5);
1710
 
lock table t1 read local;
1711
 
insert into t1 (a) values(6),(7);
1712
 
unlock tables;
1713
 
delete from t1 where a>=3 and a<=4;
1714
 
lock table t1 read local;
1715
 
set global concurrent_insert=2;
1716
 
insert into t1 (a) values (8),(9);
1717
 
unlock tables;
1718
 
insert into t1 (a) values (10),(11),(12);
1719
 
select a from t1;
1720
 
a
1721
 
1
1722
 
2
1723
 
11
1724
 
10
1725
 
5
1726
 
6
1727
 
7
1728
 
8
1729
 
9
1730
 
12
1731
 
check table t1;
1732
 
Table   Op      Msg_type        Msg_text
1733
 
test.t1 check   status  OK
1734
 
drop table t1;
1735
 
set global concurrent_insert=@save_concurrent_insert;
 
1378
create temporary table t1 (v varchar(65530), key(v));
 
1379
ERROR 42000: Column length too big for column 'v' (max = 16383); use BLOB or TEXT instead
 
1380
create temporary table t1 (v varchar(65536));
 
1381
ERROR 42000: Column length too big for column 'v' (max = 16383); use BLOB or TEXT instead
 
1382
create temporary table t1 (v varchar(65530));
 
1383
ERROR 42000: Column length too big for column 'v' (max = 16383); use BLOB or TEXT instead
 
1384
create temporary table t1 (v varchar(65535));
 
1385
ERROR 42000: Column length too big for column 'v' (max = 16383); use BLOB or TEXT instead
 
1386
set storage_engine=InnoDB;
1736
1387
create table t1 (a int, key(a));
1737
1388
insert into t1 values (1),(2),(3),(4),(NULL),(NULL),(NULL),(NULL);
1738
1389
analyze table t1;
1742
1393
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
1743
1394
t1      1       a       1       a       A       8       NULL    NULL    YES     BTREE           
1744
1395
alter table t1 disable keys;
 
1396
Warnings:
 
1397
Note    1031    Table storage engine for 't1' doesn't have this option
1745
1398
alter table t1 enable keys;
 
1399
Warnings:
 
1400
Note    1031    Table storage engine for 't1' doesn't have this option
1746
1401
show keys from t1;
1747
1402
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
1748
1403
t1      1       a       1       a       A       8       NULL    NULL    YES     BTREE           
1749
1404
drop table t1;
1750
 
create table t1 (c1 int) engine=myisam pack_keys=0;
1751
 
create table t2 (c1 int) engine=myisam pack_keys=1;
1752
 
create table t3 (c1 int) engine=myisam pack_keys=default;
1753
 
create table t4 (c1 int) engine=myisam pack_keys=2;
1754
 
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2' at line 1
1755
 
drop table t1, t2, t3;
1756
 
CREATE TABLE t1(a INT, b INT, KEY inx (a), UNIQUE KEY uinx (b)) ENGINE=MyISAM;
 
1405
CREATE TEMPORARY TABLE t1(a INT, b INT, KEY inx (a), UNIQUE KEY uinx (b)) ENGINE=MyISAM;
1757
1406
INSERT INTO t1(a,b) VALUES (1,1),(2,2),(3,3),(4,4),(5,5);
1758
1407
SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1;
1759
1408
a
1779
1428
a
1780
1429
1
1781
1430
DROP TABLE t1;
1782
 
CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE INDEX (c1), INDEX (c2)) ENGINE=MYISAM;
 
1431
CREATE TEMPORARY TABLE t1 (c1 INT, c2 INT, UNIQUE INDEX (c1), INDEX (c2)) ENGINE=MYISAM;
1783
1432
SHOW TABLE STATUS LIKE 't1';
1784
 
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
1785
 
t1      MyISAM  10      Fixed   0       #       #       #       1024    #       #       #       #       #       #       #               
 
1433
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 Plugin_name
1786
1434
INSERT INTO t1 VALUES (1,1);
1787
1435
SHOW TABLE STATUS LIKE 't1';
1788
 
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
1789
 
t1      MyISAM  10      Fixed   1       #       #       #       3072    #       #       #       #       #       #       #               
1790
 
ALTER TABLE t1 DISABLE KEYS;
1791
 
SHOW TABLE STATUS LIKE 't1';
1792
 
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
1793
 
t1      MyISAM  10      Fixed   1       #       #       #       3072    #       #       #       #       #       #       #               
1794
 
ALTER TABLE t1 ENABLE KEYS;
1795
 
SHOW TABLE STATUS LIKE 't1';
1796
 
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
1797
 
t1      MyISAM  10      Fixed   1       #       #       #       3072    #       #       #       #       #       #       #               
1798
 
ALTER TABLE t1 DISABLE KEYS;
1799
 
SHOW TABLE STATUS LIKE 't1';
1800
 
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
1801
 
t1      MyISAM  10      Fixed   1       #       #       #       3072    #       #       #       #       #       #       #               
1802
 
ALTER TABLE t1 ENABLE KEYS;
1803
 
SHOW TABLE STATUS LIKE 't1';
1804
 
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
1805
 
t1      MyISAM  10      Fixed   1       #       #       #       3072    #       #       #       #       #       #       #               
 
1436
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 Plugin_name
 
1437
ALTER TABLE t1 DISABLE KEYS;
 
1438
SHOW TABLE STATUS LIKE 't1';
 
1439
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 Plugin_name
 
1440
ALTER TABLE t1 ENABLE KEYS;
 
1441
SHOW TABLE STATUS LIKE 't1';
 
1442
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 Plugin_name
 
1443
ALTER TABLE t1 DISABLE KEYS;
 
1444
SHOW TABLE STATUS LIKE 't1';
 
1445
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 Plugin_name
 
1446
ALTER TABLE t1 ENABLE KEYS;
 
1447
SHOW TABLE STATUS LIKE 't1';
 
1448
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 Plugin_name
1806
1449
# Enable keys with parallel repair
1807
 
SET @@myisam_repair_threads=2;
 
1450
SET GLOBAL myisam_repair_threads=2;
1808
1451
ALTER TABLE t1 DISABLE KEYS;
1809
1452
ALTER TABLE t1 ENABLE KEYS;
1810
 
SET @@myisam_repair_threads=1;
1811
 
CHECK TABLE t1 EXTENDED;
 
1453
SET GLOBAL myisam_repair_threads=1;
 
1454
CHECK TABLE t1;
1812
1455
Table   Op      Msg_type        Msg_text
1813
1456
test.t1 check   status  OK
1814
1457
DROP TABLE t1;
1815
 
CREATE TABLE t1 (id int NOT NULL, ref int NOT NULL, INDEX (id)) ENGINE=MyISAM;
 
1458
CREATE TABLE t1 (id int NOT NULL, ref int NOT NULL, INDEX (id));
1816
1459
CREATE TABLE t2 LIKE t1;
1817
1460
INSERT INTO t2 (id, ref) VALUES (1,3), (2,1), (3,2), (4,5), (4,4);
1818
1461
INSERT INTO t1 SELECT * FROM t2;
1826
1469
3       2
1827
1470
4       5
1828
1471
4       4
1829
 
DELETE FROM a USING t1 AS a INNER JOIN t1 AS b USING (id) WHERE a.ref < b.ref;
1830
 
SELECT * FROM t1;
1831
 
id      ref
1832
 
1       3
1833
 
2       1
1834
 
3       2
1835
 
4       5
1836
1472
DROP TABLE t1, t2;
1837
1473
End of 5.0 tests
1838
 
create table t1 (a int not null, key `a` (a) key_block_size=1024);
 
1474
create temporary table t1 (a int not null, key `a` (a) key_block_size=1024) ENGINE=MyISAM;
1839
1475
show create table t1;
1840
1476
Table   Create Table
1841
 
t1      CREATE TABLE `t1` (
1842
 
  `a` int(11) NOT NULL,
 
1477
t1      CREATE TEMPORARY TABLE `t1` (
 
1478
  `a` int NOT NULL,
1843
1479
  KEY `a` (`a`) KEY_BLOCK_SIZE=1024
1844
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1480
) ENGINE=MyISAM
1845
1481
drop table t1;
1846
 
create table t1 (a int not null, key `a` (a) key_block_size=2048);
 
1482
create temporary table t1 (a int not null, key `a` (a) key_block_size=2048) ENGINE=MyISAM;
1847
1483
show create table t1;
1848
1484
Table   Create Table
1849
 
t1      CREATE TABLE `t1` (
1850
 
  `a` int(11) NOT NULL,
 
1485
t1      CREATE TEMPORARY TABLE `t1` (
 
1486
  `a` int NOT NULL,
1851
1487
  KEY `a` (`a`) KEY_BLOCK_SIZE=2048
1852
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1853
 
drop table t1;
1854
 
create table t1 (a varchar(2048), key `a` (a));
1855
 
Warnings:
1856
 
Warning 1071    Specified key was too long; max key length is 1332 bytes
1857
 
show create table t1;
1858
 
Table   Create Table
1859
 
t1      CREATE TABLE `t1` (
1860
 
  `a` varchar(2048) DEFAULT NULL,
1861
 
  KEY `a` (`a`(1332))
1862
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1863
 
drop table t1;
1864
 
create table t1 (a varchar(2048), key `a` (a) key_block_size=1024);
1865
 
Warnings:
1866
 
Warning 1071    Specified key was too long; max key length is 1332 bytes
1867
 
show create table t1;
1868
 
Table   Create Table
1869
 
t1      CREATE TABLE `t1` (
1870
 
  `a` varchar(2048) DEFAULT NULL,
1871
 
  KEY `a` (`a`(1332)) KEY_BLOCK_SIZE=6144
1872
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1873
 
drop table t1;
1874
 
create table t1 (a int not null, b varchar(2048), key (a), key(b)) key_block_size=1024;
1875
 
Warnings:
1876
 
Warning 1071    Specified key was too long; max key length is 1332 bytes
1877
 
show create table t1;
1878
 
Table   Create Table
1879
 
t1      CREATE TABLE `t1` (
1880
 
  `a` int(11) NOT NULL,
 
1488
) ENGINE=MyISAM
 
1489
drop table t1;
 
1490
create temporary table t1 (a varchar(2048), key `a` (a)) ENGINE=MyISAM;
 
1491
Warnings:
 
1492
Warning 1071    Specified key was too long; max key length is 1332 bytes
 
1493
show create table t1;
 
1494
Table   Create Table
 
1495
t1      CREATE TEMPORARY TABLE `t1` (
 
1496
  `a` varchar(2048) DEFAULT NULL,
 
1497
  KEY `a` (`a`(333))
 
1498
) ENGINE=MyISAM
 
1499
drop table t1;
 
1500
create temporary table t1 (a varchar(2048), key `a` (a) key_block_size=1024) ENGINE=MyISAM;
 
1501
Warnings:
 
1502
Warning 1071    Specified key was too long; max key length is 1332 bytes
 
1503
show create table t1;
 
1504
Table   Create Table
 
1505
t1      CREATE TEMPORARY TABLE `t1` (
 
1506
  `a` varchar(2048) DEFAULT NULL,
 
1507
  KEY `a` (`a`(333)) KEY_BLOCK_SIZE=6144
 
1508
) ENGINE=MyISAM
 
1509
drop table t1;
 
1510
create temporary table t1 (a int not null, b varchar(2048), key (a), key(b)) ENGINE=MyISAM key_block_size=1024;
 
1511
Warnings:
 
1512
Warning 1071    Specified key was too long; max key length is 1332 bytes
 
1513
show create table t1;
 
1514
Table   Create Table
 
1515
t1      CREATE TEMPORARY TABLE `t1` (
 
1516
  `a` int NOT NULL,
1881
1517
  `b` varchar(2048) DEFAULT NULL,
1882
1518
  KEY `a` (`a`),
1883
 
  KEY `b` (`b`(1332)) KEY_BLOCK_SIZE=6144
1884
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=1024
 
1519
  KEY `b` (`b`(333)) KEY_BLOCK_SIZE=6144
 
1520
) ENGINE=MyISAM KEY_BLOCK_SIZE=1024
1885
1521
alter table t1 key_block_size=2048;
1886
1522
show create table t1;
1887
1523
Table   Create Table
1888
 
t1      CREATE TABLE `t1` (
1889
 
  `a` int(11) NOT NULL,
 
1524
t1      CREATE TEMPORARY TABLE `t1` (
 
1525
  `a` int NOT NULL,
1890
1526
  `b` varchar(2048) DEFAULT NULL,
1891
1527
  KEY `a` (`a`) KEY_BLOCK_SIZE=1024,
1892
 
  KEY `b` (`b`(1332)) KEY_BLOCK_SIZE=8192
1893
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=2048
 
1528
  KEY `b` (`b`(333)) KEY_BLOCK_SIZE=8192
 
1529
) ENGINE=MyISAM KEY_BLOCK_SIZE=2048
1894
1530
alter table t1 add c int, add key (c);
1895
1531
show create table t1;
1896
1532
Table   Create Table
1897
 
t1      CREATE TABLE `t1` (
1898
 
  `a` int(11) NOT NULL,
 
1533
t1      CREATE TEMPORARY TABLE `t1` (
 
1534
  `a` int NOT NULL,
1899
1535
  `b` varchar(2048) DEFAULT NULL,
1900
 
  `c` int(11) DEFAULT NULL,
 
1536
  `c` int DEFAULT NULL,
1901
1537
  KEY `a` (`a`) KEY_BLOCK_SIZE=1024,
1902
 
  KEY `b` (`b`(1332)) KEY_BLOCK_SIZE=8192,
 
1538
  KEY `b` (`b`(333)) KEY_BLOCK_SIZE=8192,
1903
1539
  KEY `c` (`c`)
1904
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=2048
 
1540
) ENGINE=MyISAM KEY_BLOCK_SIZE=2048
1905
1541
alter table t1 key_block_size=0;
1906
1542
alter table t1 add d int, add key (d);
1907
1543
show create table t1;
1908
1544
Table   Create Table
1909
 
t1      CREATE TABLE `t1` (
1910
 
  `a` int(11) NOT NULL,
 
1545
t1      CREATE TEMPORARY TABLE `t1` (
 
1546
  `a` int NOT NULL,
1911
1547
  `b` varchar(2048) DEFAULT NULL,
1912
 
  `c` int(11) DEFAULT NULL,
1913
 
  `d` int(11) DEFAULT NULL,
 
1548
  `c` int DEFAULT NULL,
 
1549
  `d` int DEFAULT NULL,
1914
1550
  KEY `a` (`a`) KEY_BLOCK_SIZE=1024,
1915
 
  KEY `b` (`b`(1332)) KEY_BLOCK_SIZE=8192,
 
1551
  KEY `b` (`b`(333)) KEY_BLOCK_SIZE=8192,
1916
1552
  KEY `c` (`c`) KEY_BLOCK_SIZE=2048,
1917
1553
  KEY `d` (`d`)
1918
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1554
) ENGINE=MyISAM
1919
1555
drop table t1;
1920
 
create table t1 (a int not null, b varchar(2048), key (a), key(b)) key_block_size=8192;
 
1556
create temporary table t1 (a int not null, b varchar(2048), key (a), key(b)) ENGINE=MyISAM key_block_size=8192;
1921
1557
Warnings:
1922
1558
Warning 1071    Specified key was too long; max key length is 1332 bytes
1923
1559
show create table t1;
1924
1560
Table   Create Table
1925
 
t1      CREATE TABLE `t1` (
1926
 
  `a` int(11) NOT NULL,
 
1561
t1      CREATE TEMPORARY TABLE `t1` (
 
1562
  `a` int NOT NULL,
1927
1563
  `b` varchar(2048) DEFAULT NULL,
1928
1564
  KEY `a` (`a`),
1929
 
  KEY `b` (`b`(1332))
1930
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=8192
 
1565
  KEY `b` (`b`(333))
 
1566
) ENGINE=MyISAM KEY_BLOCK_SIZE=8192
1931
1567
drop table t1;
1932
 
create table t1 (a int not null, b varchar(2048), key (a) key_block_size=1024, key(b)) key_block_size=8192;
 
1568
create temporary table t1 (a int not null, b varchar(2048), key (a) key_block_size=1024, key(b)) ENGINE=MyISAM key_block_size=8192;
1933
1569
Warnings:
1934
1570
Warning 1071    Specified key was too long; max key length is 1332 bytes
1935
1571
show create table t1;
1936
1572
Table   Create Table
1937
 
t1      CREATE TABLE `t1` (
1938
 
  `a` int(11) NOT NULL,
 
1573
t1      CREATE TEMPORARY TABLE `t1` (
 
1574
  `a` int NOT NULL,
1939
1575
  `b` varchar(2048) DEFAULT NULL,
1940
1576
  KEY `a` (`a`) KEY_BLOCK_SIZE=1024,
1941
 
  KEY `b` (`b`(1332))
1942
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=8192
 
1577
  KEY `b` (`b`(333))
 
1578
) ENGINE=MyISAM KEY_BLOCK_SIZE=8192
1943
1579
drop table t1;
1944
 
create table t1 (a int not null, b int, key (a) key_block_size=1024, key(b) key_block_size=8192) key_block_size=16384;
 
1580
create temporary table t1 (a int not null, b int, key (a) key_block_size=1024, key(b) key_block_size=8192) ENGINE=MyISAM key_block_size=16384;
1945
1581
show create table t1;
1946
1582
Table   Create Table
1947
 
t1      CREATE TABLE `t1` (
1948
 
  `a` int(11) NOT NULL,
1949
 
  `b` int(11) DEFAULT NULL,
 
1583
t1      CREATE TEMPORARY TABLE `t1` (
 
1584
  `a` int NOT NULL,
 
1585
  `b` int DEFAULT NULL,
1950
1586
  KEY `a` (`a`) KEY_BLOCK_SIZE=1024,
1951
1587
  KEY `b` (`b`) KEY_BLOCK_SIZE=8192
1952
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=16384
 
1588
) ENGINE=MyISAM KEY_BLOCK_SIZE=16384
1953
1589
drop table t1;
1954
 
create table t1 (a int not null, key `a` (a) key_block_size=512);
 
1590
create temporary table t1 (a int not null, key `a` (a) key_block_size=512) ENGINE=MyISAM;
1955
1591
show create table t1;
1956
1592
Table   Create Table
1957
 
t1      CREATE TABLE `t1` (
1958
 
  `a` int(11) NOT NULL,
 
1593
t1      CREATE TEMPORARY TABLE `t1` (
 
1594
  `a` int NOT NULL,
1959
1595
  KEY `a` (`a`) KEY_BLOCK_SIZE=1024
1960
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1596
) ENGINE=MyISAM
1961
1597
drop table t1;
1962
 
create table t1 (a varchar(2048), key `a` (a) key_block_size=1000000000000000000);
 
1598
create temporary table t1 (a varchar(2048), key `a` (a) key_block_size=1000000000000000000) ENGINE=MyISAM;
1963
1599
Warnings:
1964
1600
Warning 1071    Specified key was too long; max key length is 1332 bytes
1965
1601
show create table t1;
1966
1602
Table   Create Table
1967
 
t1      CREATE TABLE `t1` (
 
1603
t1      CREATE TEMPORARY TABLE `t1` (
1968
1604
  `a` varchar(2048) DEFAULT NULL,
1969
 
  KEY `a` (`a`(1332)) KEY_BLOCK_SIZE=6144
1970
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1605
  KEY `a` (`a`(333)) KEY_BLOCK_SIZE=6144
 
1606
) ENGINE=MyISAM
1971
1607
drop table t1;
1972
 
create table t1 (a int not null, key `a` (a) key_block_size=1025);
 
1608
create temporary table t1 (a int not null, key `a` (a) key_block_size=1025) ENGINE=MyISAM;
1973
1609
show create table t1;
1974
1610
Table   Create Table
1975
 
t1      CREATE TABLE `t1` (
1976
 
  `a` int(11) NOT NULL,
 
1611
t1      CREATE TEMPORARY TABLE `t1` (
 
1612
  `a` int NOT NULL,
1977
1613
  KEY `a` (`a`) KEY_BLOCK_SIZE=2048
1978
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1614
) ENGINE=MyISAM
1979
1615
drop table t1;
1980
 
create table t1 (a int not null, key key_block_size=1024 (a));
1981
 
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=1024 (a))' at line 1
1982
 
create table t1 (a int not null, key `a` key_block_size=1024 (a));
1983
 
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key_block_size=1024 (a))' at line 1
1984
 
CREATE TABLE t1 (
 
1616
create temporary table t1 (a int not null, key key_block_size=1024 (a)) ENGINE=MyISAM;
 
1617
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near '=1024 (a)) ENGINE=MyISAM' at line 1
 
1618
create temporary table t1 (a int not null, key `a` key_block_size=1024 (a)) ENGINE=MyISAM;
 
1619
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near 'key_block_size=1024 (a)) ENGINE=MyISAM' at line 1
 
1620
CREATE temporary TABLE t1 (
1985
1621
c1 INT,
1986
1622
c2 VARCHAR(300),
1987
1623
KEY (c1) KEY_BLOCK_SIZE 1024,
1988
1624
KEY (c2) KEY_BLOCK_SIZE 8192
1989
 
);
 
1625
) ENGINE=MyISAM;
1990
1626
INSERT INTO t1 VALUES (10, REPEAT('a', CEIL(RAND(10) * 300))),
1991
1627
(11, REPEAT('b', CEIL(RAND() * 300))),
1992
1628
(12, REPEAT('c', CEIL(RAND() * 300))),
2013
1649
(33, REPEAT('x', CEIL(RAND() * 300))),
2014
1650
(34, REPEAT('y', CEIL(RAND() * 300))),
2015
1651
(35, REPEAT('z', CEIL(RAND() * 300)));
2016
 
INSERT INTO t1 SELECT * FROM t1;
2017
 
INSERT INTO t1 SELECT * FROM t1;
 
1652
CREATE TEMPORARY TABLE t2 AS SELECT * FROM t1;
 
1653
INSERT INTO t1 SELECT * FROM t2;
 
1654
DROP TABLE t2;
 
1655
CREATE TEMPORARY TABLE t2 AS SELECT * FROM t1;
 
1656
INSERT INTO t1 SELECT * FROM t2;
 
1657
DROP TABLE t2;
2018
1658
CHECK TABLE t1;
2019
1659
Table   Op      Msg_type        Msg_text
2020
1660
test.t1 check   status  OK
2021
 
REPAIR TABLE t1;
2022
 
Table   Op      Msg_type        Msg_text
2023
 
test.t1 repair  status  OK
2024
1661
DELETE FROM t1 WHERE c1 >= 10;
2025
1662
CHECK TABLE t1;
2026
1663
Table   Op      Msg_type        Msg_text
2027
1664
test.t1 check   status  OK
2028
1665
DROP TABLE t1;
2029
 
CREATE TABLE t1 (
2030
 
c1 CHAR(130),
2031
 
c2 VARCHAR(1)
2032
 
) ENGINE=MyISAM;
2033
 
INSERT INTO t1 VALUES(REPEAT("a",128), 'b');
2034
 
SELECT COUNT(*) FROM t1;
2035
 
COUNT(*)
2036
 
1
2037
 
CHECK TABLE t1;
2038
 
Table   Op      Msg_type        Msg_text
2039
 
test.t1 check   status  OK
2040
 
REPAIR TABLE t1;
2041
 
Table   Op      Msg_type        Msg_text
2042
 
test.t1 repair  status  OK
2043
 
SELECT COUNT(*) FROM t1;
2044
 
COUNT(*)
2045
 
1
2046
 
CHECK TABLE t1;
2047
 
Table   Op      Msg_type        Msg_text
2048
 
test.t1 check   status  OK
2049
 
DROP TABLE t1;
2050
 
CREATE TABLE t1 (
2051
 
c1 CHAR(130),
2052
 
c2 VARCHAR(1)
2053
 
) ENGINE=MyISAM;
2054
 
INSERT INTO t1 VALUES(REPEAT("a",128), 'b');
2055
 
SELECT COUNT(*) FROM t1;
2056
 
COUNT(*)
2057
 
1
2058
 
CHECK TABLE t1 EXTENDED;
2059
 
Table   Op      Msg_type        Msg_text
2060
 
test.t1 check   status  OK
2061
 
REPAIR TABLE t1 EXTENDED;
2062
 
Table   Op      Msg_type        Msg_text
2063
 
test.t1 repair  status  OK
2064
 
SELECT COUNT(*) FROM t1;
2065
 
COUNT(*)
2066
 
1
2067
 
CHECK TABLE t1 EXTENDED;
2068
 
Table   Op      Msg_type        Msg_text
2069
 
test.t1 check   status  OK
2070
 
DROP TABLE t1;
2071
 
CREATE TABLE t1 (
 
1666
CREATE temporary TABLE t1 (
 
1667
c1 CHAR(130),
 
1668
c2 VARCHAR(1)
 
1669
) ENGINE=MyISAM;
 
1670
INSERT INTO t1 VALUES(REPEAT("a",128), 'b');
 
1671
SELECT COUNT(*) FROM t1;
 
1672
COUNT(*)
 
1673
1
 
1674
CHECK TABLE t1;
 
1675
Table   Op      Msg_type        Msg_text
 
1676
test.t1 check   status  OK
 
1677
SELECT COUNT(*) FROM t1;
 
1678
COUNT(*)
 
1679
1
 
1680
CHECK TABLE t1;
 
1681
Table   Op      Msg_type        Msg_text
 
1682
test.t1 check   status  OK
 
1683
DROP TABLE t1;
 
1684
CREATE temporary TABLE t1 (
 
1685
c1 CHAR(130),
 
1686
c2 VARCHAR(1)
 
1687
) ENGINE=MyISAM;
 
1688
INSERT INTO t1 VALUES(REPEAT("a",128), 'b');
 
1689
SELECT COUNT(*) FROM t1;
 
1690
COUNT(*)
 
1691
1
 
1692
CHECK TABLE t1;
 
1693
Table   Op      Msg_type        Msg_text
 
1694
test.t1 check   status  OK
 
1695
SELECT COUNT(*) FROM t1;
 
1696
COUNT(*)
 
1697
1
 
1698
CHECK TABLE t1;
 
1699
Table   Op      Msg_type        Msg_text
 
1700
test.t1 check   status  OK
 
1701
DROP TABLE t1;
 
1702
CREATE temporary TABLE t1 (
2072
1703
c1 CHAR(130),
2073
1704
c2 VARCHAR(1)
2074
1705
) ENGINE=MyISAM;
2079
1710
SELECT COUNT(*) FROM t1;
2080
1711
COUNT(*)
2081
1712
2
2082
 
OPTIMIZE TABLE t1;
2083
 
Table   Op      Msg_type        Msg_text
2084
 
test.t1 optimize        status  OK
 
1713
ALTER TABLE t1 ENGINE=MyISAM;
2085
1714
SELECT COUNT(*) FROM t1;
2086
1715
COUNT(*)
2087
1716
2
2088
1717
DROP TABLE t1;
2089
 
CREATE TABLE t1 (
 
1718
CREATE temporary TABLE t1 (
2090
1719
c1 CHAR(130),
2091
1720
c2 VARCHAR(1),
2092
1721
KEY (c1)
2103
1732
CHECK TABLE t1;
2104
1733
Table   Op      Msg_type        Msg_text
2105
1734
test.t1 check   status  OK
2106
 
CHECK TABLE t1 EXTENDED;
2107
 
Table   Op      Msg_type        Msg_text
2108
 
test.t1 check   status  OK
2109
 
DROP TABLE t1;
2110
 
CREATE TABLE t1 (
2111
 
c1 CHAR(50),
2112
 
c2 VARCHAR(1)
2113
 
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
2114
 
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
2115
 
SELECT COUNT(*) FROM t1;
2116
 
COUNT(*)
2117
 
1
2118
 
CHECK TABLE t1;
2119
 
Table   Op      Msg_type        Msg_text
2120
 
test.t1 check   status  OK
2121
 
REPAIR TABLE t1;
2122
 
Table   Op      Msg_type        Msg_text
2123
 
test.t1 repair  status  OK
2124
 
SELECT COUNT(*) FROM t1;
2125
 
COUNT(*)
2126
 
1
2127
 
CHECK TABLE t1;
2128
 
Table   Op      Msg_type        Msg_text
2129
 
test.t1 check   status  OK
2130
 
DROP TABLE t1;
2131
 
CREATE TABLE t1 (
2132
 
c1 CHAR(50),
2133
 
c2 VARCHAR(1)
2134
 
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
2135
 
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
2136
 
SELECT COUNT(*) FROM t1;
2137
 
COUNT(*)
2138
 
1
2139
 
CHECK TABLE t1 EXTENDED;
2140
 
Table   Op      Msg_type        Msg_text
2141
 
test.t1 check   status  OK
2142
 
REPAIR TABLE t1 EXTENDED;
2143
 
Table   Op      Msg_type        Msg_text
2144
 
test.t1 repair  status  OK
2145
 
SELECT COUNT(*) FROM t1;
2146
 
COUNT(*)
2147
 
1
2148
 
CHECK TABLE t1 EXTENDED;
2149
 
Table   Op      Msg_type        Msg_text
2150
 
test.t1 check   status  OK
2151
 
DROP TABLE t1;
2152
 
CREATE TABLE t1 (
2153
 
c1 CHAR(50),
2154
 
c2 VARCHAR(1)
2155
 
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
2156
 
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
 
1735
CHECK TABLE t1;
 
1736
Table   Op      Msg_type        Msg_text
 
1737
test.t1 check   status  OK
 
1738
DROP TABLE t1;
 
1739
CREATE temporary TABLE t1 (
 
1740
c1 CHAR(50),
 
1741
c2 VARCHAR(1)
 
1742
) ENGINE=MyISAM;
 
1743
INSERT INTO t1 VALUES(REPEAT( x'e0ae85',43), 'b');
 
1744
SELECT COUNT(*) FROM t1;
 
1745
COUNT(*)
 
1746
1
 
1747
CHECK TABLE t1;
 
1748
Table   Op      Msg_type        Msg_text
 
1749
test.t1 check   status  OK
 
1750
SELECT COUNT(*) FROM t1;
 
1751
COUNT(*)
 
1752
1
 
1753
CHECK TABLE t1;
 
1754
Table   Op      Msg_type        Msg_text
 
1755
test.t1 check   status  OK
 
1756
DROP TABLE t1;
 
1757
CREATE temporary TABLE t1 (
 
1758
c1 CHAR(50),
 
1759
c2 VARCHAR(1)
 
1760
) ENGINE=MyISAM;
 
1761
INSERT INTO t1 VALUES(REPEAT( x'e0ae85',43), 'b');
 
1762
SELECT COUNT(*) FROM t1;
 
1763
COUNT(*)
 
1764
1
 
1765
CHECK TABLE t1;
 
1766
Table   Op      Msg_type        Msg_text
 
1767
test.t1 check   status  OK
 
1768
SELECT COUNT(*) FROM t1;
 
1769
COUNT(*)
 
1770
1
 
1771
CHECK TABLE t1;
 
1772
Table   Op      Msg_type        Msg_text
 
1773
test.t1 check   status  OK
 
1774
DROP TABLE t1;
 
1775
CREATE temporary TABLE t1 (
 
1776
c1 CHAR(50),
 
1777
c2 VARCHAR(1)
 
1778
) ENGINE=MyISAM;
 
1779
INSERT INTO t1 VALUES(REPEAT( x'e0ae85',43), 'b');
2157
1780
INSERT INTO t1 VALUES('b', 'b');
2158
1781
INSERT INTO t1 VALUES('c', 'b');
2159
1782
DELETE FROM t1 WHERE c1='b';
2160
1783
SELECT COUNT(*) FROM t1;
2161
1784
COUNT(*)
2162
1785
2
2163
 
OPTIMIZE TABLE t1;
2164
 
Table   Op      Msg_type        Msg_text
2165
 
test.t1 optimize        status  OK
 
1786
ALTER TABLE t1 ENGINE=MyISAM;
2166
1787
SELECT COUNT(*) FROM t1;
2167
1788
COUNT(*)
2168
1789
2
2169
1790
DROP TABLE t1;
2170
 
CREATE TABLE t1 (
 
1791
CREATE temporary TABLE t1 (
2171
1792
c1 CHAR(50),
2172
1793
c2 VARCHAR(1),
2173
1794
KEY (c1)
2174
 
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
 
1795
) ENGINE=MyISAM;
2175
1796
# Insert 100 rows. Query log disabled.
2176
 
UPDATE t1 SET c1=REPEAT(_utf8 x'e0ae85',43) LIMIT 90;
 
1797
UPDATE t1 SET c1=REPEAT( x'e0ae85',43) LIMIT 90;
2177
1798
SELECT COUNT(*) FROM t1;
2178
1799
COUNT(*)
2179
1800
100
2184
1805
CHECK TABLE t1;
2185
1806
Table   Op      Msg_type        Msg_text
2186
1807
test.t1 check   status  OK
2187
 
CHECK TABLE t1 EXTENDED;
 
1808
CHECK TABLE t1;
2188
1809
Table   Op      Msg_type        Msg_text
2189
1810
test.t1 check   status  OK
2190
1811
DROP TABLE t1;
2191
 
CREATE TABLE t1 (
2192
 
c1 VARCHAR(10) NOT NULL,
2193
 
c2 CHAR(10) DEFAULT NULL,
2194
 
c3 VARCHAR(10) NOT NULL,
2195
 
KEY (c1),
2196
 
KEY (c2)
2197
 
) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=0;
2198
 
 
2199
 
MyISAM file:         MYSQLTEST_VARDIR/master-data/test/t1
2200
 
Record format:       Packed
2201
 
Character set:       utf8_general_ci (45)
2202
 
Data records:                    0  Deleted blocks:                 0
2203
 
Recordlength:                  124
2204
 
 
2205
 
table description:
2206
 
Key Start Len Index   Type
2207
 
1   2     40  multip. varchar              
2208
 
2   43    40  multip. char NULL            
2209
 
DROP TABLE t1;
2210
1812
End of 5.1 tests