~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysql-test/t/myisam.test

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
# Test problem with CHECK TABLE;
13
13
#
14
14
 
15
 
CREATE TEMPORARY TABLE t1 (
 
15
CREATE TABLE t1 (
16
16
  STRING_DATA char(255) default NULL,
17
17
  KEY string_data (STRING_DATA)
18
18
) ENGINE=MyISAM;
30
30
# Test problem with rows that are 65517-65520 bytes long
31
31
#
32
32
 
33
 
create table t1 (a int not null auto_increment, b blob not null, primary key (a));
 
33
create table t1 (a tinyint not null auto_increment, b blob not null, primary key (a));
34
34
 
35
35
let $1=100;
36
36
disable_query_log;
45
45
--enable_warnings
46
46
enable_query_log;
47
47
check table t1;
48
 
 
49
 
# @TODO Because there are no notes on what the heck this
50
 
# is actually testing (which bug?), it's difficult to tell
51
 
# what the below DELETE statement is doing.  Since we don't
52
 
# support bitwise operators, I am replacing the delete statement
53
 
# with a version we support.
54
 
#delete from t1 where (a & 1);
55
 
delete from t1 where (a mod 2) = 1;
 
48
repair table t1;
 
49
delete from t1 where (a & 1);
 
50
check table t1;
 
51
repair table t1;
56
52
check table t1;
57
53
drop table t1;
58
54
 
60
56
# Test bug: Two optimize in a row reset index cardinality
61
57
#
62
58
 
63
 
create TEMPORARY table t1 (a int not null auto_increment, b int not null, primary key (a), index(b)) ENGINE=MYISAM;
 
59
create table t1 (a int not null auto_increment, b int not null, primary key (a), index(b));
64
60
insert into t1 (b) values (1),(2),(2),(2),(2);
65
 
alter table t1 engine=MYISAM;
 
61
optimize table t1;
66
62
show index from t1;
67
 
alter table t1 engine=MyISAM;
 
63
optimize table t1;
68
64
show index from t1;
69
65
drop table t1;
70
66
 
72
68
# Test of how ORDER BY works when doing it on the whole table
73
69
#
74
70
 
75
 
create temporary table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=myisam;
 
71
create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=myisam;
76
72
insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
77
73
explain select * from t1 order by a;
78
74
explain select * from t1 order by b;
85
81
drop table t1;
86
82
 
87
83
#
 
84
# Test of OPTIMIZE of locked and modified tables
 
85
#
 
86
CREATE TABLE t1 (a INT);
 
87
INSERT INTO  t1 VALUES (1), (2), (3);
 
88
LOCK TABLES t1 WRITE;
 
89
INSERT INTO  t1 VALUES (1), (2), (3);
 
90
OPTIMIZE TABLE t1;
 
91
DROP TABLE t1;
 
92
 
 
93
#
88
94
# Test of optimize, when only mi_sort_index (but not mi_repair*) is done
89
95
# in ha_myisam::repair, and index size is changed (decreased).
90
96
#
91
97
 
92
 
create temporary table t1 ( t1 char(255), key(t1(250))) ENGINE=MYISAM;
 
98
create table t1 ( t1 char(255), key(t1(250)));
93
99
insert t1 values ('137513751375137513751375137513751375137569516951695169516951695169516951695169');
94
100
insert t1 values ('178417841784178417841784178417841784178403420342034203420342034203420342034203');
95
101
insert t1 values ('213872387238723872387238723872387238723867376737673767376737673767376737673767');
119
125
insert t1 values ('70'), ('84'), ('60'), ('20'), ('76'), ('89'), ('49'), ('50'),
120
126
('88'), ('61'), ('42'), ('98'), ('39'), ('30'), ('25'), ('66'), ('61'), ('48'),
121
127
('80'), ('84'), ('98'), ('19'), ('91'), ('42'), ('47');
122
 
alter table t1 ENGINE=myisam;
 
128
optimize table t1;
123
129
check table t1;
124
130
drop table t1;
125
131
 
127
133
# test of myisam with huge number of packed fields
128
134
#
129
135
 
130
 
create temporary table t1 (i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8
 
136
create table t1 (i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8
131
137
int, i9 int, i10 int, i11 int, i12 int, i13 int, i14 int, i15 int, i16 int, i17
132
138
int, i18 int, i19 int, i20 int, i21 int, i22 int, i23 int, i24 int, i25 int,
133
139
i26 int, i27 int, i28 int, i29 int, i30 int, i31 int, i32 int, i33 int, i34
251
257
int, i975 int, i976 int, i977 int, i978 int, i979 int, i980 int, i981 int, i982
252
258
int, i983 int, i984 int, i985 int, i986 int, i987 int, i988 int, i989 int, i990
253
259
int, i991 int, i992 int, i993 int, i994 int, i995 int, i996 int, i997 int, i998
254
 
int, i999 int, i1000 int, b blob) engine=myisam row_format=dynamic;
 
260
int, i999 int, i1000 int, b blob) row_format=dynamic;
255
261
insert into t1 values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
256
262
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,
257
263
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,
302
308
#
303
309
# Test of REPAIR that once failed
304
310
#
305
 
CREATE TEMPORARY TABLE `t1` (
306
 
  `post_id` int NOT NULL auto_increment,
307
 
  `topic_id` int NOT NULL default '0',
308
 
  `post_time` datetime,
 
311
CREATE TABLE `t1` (
 
312
  `post_id` mediumint(8) unsigned NOT NULL auto_increment,
 
313
  `topic_id` mediumint(8) unsigned NOT NULL default '0',
 
314
  `post_time` datetime NOT NULL default '0000-00-00 00:00:00',
309
315
  `post_text` text NOT NULL,
310
316
  `icon_url` varchar(10) NOT NULL default '',
311
 
  `sign` int NOT NULL default '0',
 
317
  `sign` tinyint(1) unsigned NOT NULL default '0',
312
318
  `post_edit` varchar(150) NOT NULL default '',
313
319
  `poster_login` varchar(35) NOT NULL default '',
314
320
  `ip` varchar(15) NOT NULL default '',
316
322
  KEY `post_time` (`post_time`),
317
323
  KEY `ip` (`ip`),
318
324
  KEY `poster_login` (`poster_login`),
319
 
  KEY `topic_id` (`topic_id`)
320
 
#  FULLTEXT KEY `post_text` (`post_text`)
 
325
  KEY `topic_id` (`topic_id`),
 
326
  FULLTEXT KEY `post_text` (`post_text`)
321
327
) ENGINE=MyISAM;
322
328
 
323
329
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');
324
330
 
 
331
REPAIR TABLE t1;
325
332
CHECK TABLE t1;
326
333
drop table t1;
327
334
 
330
337
#
331
338
 
332
339
--error 1071
333
 
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;
334
 
CREATE TEMPORARY TABLE t1 (a varchar(300), b varchar(300), c varchar(300), d varchar(300), e varchar(300)) ENGINE=MyISAM;
 
340
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));
 
341
CREATE TABLE t1 (a varchar(300), b varchar(300), c varchar(300), d varchar(300), e varchar(300));
335
342
--error 1071
336
343
ALTER TABLE t1 ADD INDEX t1 (a, b, c, d, e);
337
344
DROP TABLE t1;
340
347
# Test of cardinality of keys with NULL
341
348
#
342
349
 
343
 
CREATE TEMPORARY TABLE t1 (a int not null, b int, c int, key(b), key(c), key(a,b), key(c,a)) ENGINE=MyISAM;
 
350
CREATE TABLE t1 (a int not null, b int, c int, key(b), key(c), key(a,b), key(c,a));
344
351
INSERT into t1 values (0, null, 0), (0, null, 1), (0, null, 2), (0, null,3), (1,1,4);
345
352
create table t2 (a int not null, b int, c int, key(b), key(c), key(a));
346
353
INSERT into t2 values (1,1,1), (2,2,2);
347
 
alter table t1 ENGINE=MYISAM;
 
354
optimize table t1;
348
355
show index from t1;
349
356
explain select * from t1,t2 where t1.a=t2.a;
350
357
explain select * from t1,t2 force index(a) where t1.a=t2.a;
364
371
create table t1 (a int not null auto_increment primary key, b varchar(255));
365
372
insert into t1 (b) values (repeat('a',100)),(repeat('b',100)),(repeat('c',100));
366
373
update t1 set b=repeat(left(b,1),200) where a=1;
367
 
 
368
 
# @TODO Because there are no notes on what the heck this
369
 
# is actually testing (which bug?), it's difficult to tell
370
 
# what the below DELETE statement is doing.  Since we don't
371
 
# support bitwise operators, I am replacing the delete statement
372
 
# with a version we support.
373
 
#delete from t1 where (a & 1)= 0;
374
 
delete from t1 where (a mod 2) = 0;
 
374
delete from t1 where (a & 1)= 0;
375
375
update t1 set b=repeat('e',200) where a=1;
376
376
flush tables;
377
377
check table t1;
384
384
let $1 = 100;
385
385
while ($1)
386
386
{
387
 
  eval insert into t1 (b) values (repeat(char
388
 
    (
389
 
      if($1 < 32, 0, 
390
 
        if($1 >= 64 and $1 <= 95, 0, 32)
391
 
      )
392
 
    +65), $1));
 
387
  eval insert into t1 (b) values (repeat(char(($1 & 32)+65), $1));
393
388
  dec $1;
394
389
}
395
390
enable_query_log;
406
401
#
407
402
# two bugs in myisam-space-stripping feature
408
403
#
409
 
create temporary table t1 ( a text not null, key a (a(20))) engine=myisam;
 
404
create table t1 ( a text not null, key a (a(20)));
410
405
insert into t1 values ('aaa   '),('aaa'),('aa');
411
406
check table t1;
 
407
repair table t1;
412
408
select concat(a,'.') from t1 where a='aaa';
413
409
select concat(a,'.') from t1 where binary a='aaa';
414
410
update t1 set a='bbb' where a='aaa';
419
415
# Third bug in the same code (BUG#2295)
420
416
#
421
417
 
422
 
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;
 
418
create table t1(a text not null, b text not null, c text not null, index (a(10),b(10),c(10)));
423
419
insert into t1 values('807780', '477', '165');
424
420
insert into t1 values('807780', '477', '162');
425
421
insert into t1 values('807780', '472', '162');
430
426
# space-stripping in _mi_prefix_search: BUG#5284
431
427
#
432
428
DROP TABLE IF EXISTS t1;
433
 
CREATE TEMPORARY TABLE t1 (a varchar(150) NOT NULL, KEY (a)) ENGINE=MyISAM; 
 
429
CREATE TABLE t1 (a varchar(150) NOT NULL, KEY (a)); 
434
430
INSERT t1 VALUES ("can \tcan"); 
435
431
INSERT t1 VALUES ("can   can"); 
436
432
INSERT t1 VALUES ("can"); 
483
479
#
484
480
# Bug#14616 - Freshly imported table returns error 124 when using LIMIT
485
481
#
486
 
create temporary table t1 (
 
482
create table t1 (
487
483
  c1 varchar(32),
488
484
  key (c1)
489
485
) engine=myisam;
492
488
select c1 from t1 order by c1 limit 1;
493
489
drop table t1;
494
490
 
 
491
#
 
492
# Bug #14400  Join could miss concurrently inserted row
 
493
#
 
494
# Partial key.
 
495
create table t1 (a int not null, primary key(a));
 
496
create table t2 (a int not null, b int not null, primary key(a,b));
 
497
insert into t1 values (1),(2),(3),(4),(5),(6);
 
498
insert into t2 values (1,1),(2,1);
 
499
lock tables t1 read local, t2 read local;
 
500
select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
 
501
connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
 
502
insert into t2 values(2,0);
 
503
disconnect root;
 
504
connection default;
 
505
select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
 
506
unlock tables;
 
507
drop table t1,t2;
 
508
#
 
509
# Full key.
 
510
CREATE TABLE t1 (c1 varchar(250) NOT NULL);
 
511
CREATE TABLE t2 (c1 varchar(250) NOT NULL, PRIMARY KEY (c1));
 
512
INSERT INTO t1 VALUES ('test000001'), ('test000002'), ('test000003');
 
513
INSERT INTO t2 VALUES ('test000002'), ('test000003'), ('test000004');
 
514
LOCK TABLES t1 READ LOCAL, t2 READ LOCAL;
 
515
SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
 
516
  WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
 
517
connect (con1,localhost,root,,);
 
518
connection con1;
 
519
INSERT INTO t2 VALUES ('test000001'), ('test000005');
 
520
disconnect con1;
 
521
connection default;
 
522
SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
 
523
  WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
 
524
UNLOCK TABLES;
 
525
DROP TABLE t1,t2;
 
526
 
495
527
# End of 4.0 tests
496
528
 
497
 
create table t1 (a int, b varchar(200), c text not null);
498
 
create table t2 (a int, b varchar(200), c text not null);
 
529
#
 
530
# Test RTREE index
 
531
#
 
532
--error 1235, 1289
 
533
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;
 
534
# INSERT INTO t1 VALUES (1,1),(1,1);
 
535
# DELETE FROM rt WHERE a<1;
 
536
# DROP TABLE IF EXISTS t1;
 
537
 
 
538
create table t1 (a int, b varchar(200), c text not null) checksum=1;
 
539
create table t2 (a int, b varchar(200), c text not null) checksum=0;
499
540
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
500
541
insert t2 select * from t1;
501
 
checksum table t1, t2, t3;
502
 
checksum table t1, t2, t3;
503
 
checksum table t1, t2, t3;
 
542
checksum table t1, t2, t3 quick;
 
543
checksum table t1, t2, t3;
 
544
checksum table t1, t2, t3 extended;
504
545
#show table status;
505
546
drop table t1,t2;
506
547
 
507
 
#@TODO Figure out what the heck the below is testing.
508
 
#      It bombs the test with unknown system variables...
509
 
#
510
 
#create table t1 (a int, key (a));
511
 
#show keys from t1;
512
 
#alter table t1 disable keys;
513
 
#show keys from t1;
514
 
#create table t2 (a int);
515
 
#let $i=1000;
516
 
#set @@rand_seed1=31415926,@@rand_seed2=2718281828;
517
 
#--disable_query_log
518
 
#while ($i)
519
 
#{
520
 
#  dec $i;
521
 
#  insert t2 values (rand()*100000);
522
 
#}
523
 
#--enable_query_log
524
 
#insert t1 select * from t2;
525
 
#show keys from t1;
526
 
#alter table t1 enable keys;
527
 
#show keys from t1;
528
 
#alter table t1 engine=MEMORY;
529
 
#alter table t1 disable keys;
530
 
#show keys from t1;
531
 
#drop table t1,t2;
 
548
create table t1 (a int, key (a));
 
549
show keys from t1;
 
550
alter table t1 disable keys;
 
551
show keys from t1;
 
552
create table t2 (a int);
 
553
let $i=1000;
 
554
set @@rand_seed1=31415926,@@rand_seed2=2718281828;
 
555
--disable_query_log
 
556
while ($i)
 
557
{
 
558
  dec $i;
 
559
  insert t2 values (rand()*100000);
 
560
}
 
561
--enable_query_log
 
562
insert t1 select * from t2;
 
563
show keys from t1;
 
564
alter table t1 enable keys;
 
565
show keys from t1;
 
566
alter table t1 engine=heap;
 
567
alter table t1 disable keys;
 
568
show keys from t1;
 
569
drop table t1,t2;
532
570
 
533
571
#
534
572
# index search for NULL in blob. Bug #4816
543
581
# bug9188 - Corruption Can't open file: 'table.MYI' (errno: 145)
544
582
#
545
583
create table t1 (c1 int, c2 varchar(4) not null default '',
546
 
                 key(c2(3)));
 
584
                 key(c2(3))) default charset=utf8;
547
585
insert into t1 values (1,'A'), (2, 'B'), (3, 'A');
548
586
update t1 set c2='A  B' where c1=2;
549
587
check table t1;
565
603
checksum table t2;
566
604
drop table t1, t2;
567
605
 
 
606
#
 
607
# BUG#12232: New myisam_stats_method variable.
 
608
#
 
609
 
 
610
show variables like 'myisam_stats_method';
 
611
 
 
612
create table t1 (a int, key(a));
 
613
insert into t1 values (0),(1),(2),(3),(4);
 
614
insert into t1 select NULL from t1;
 
615
 
 
616
# default: NULLs considered inequal
 
617
analyze table t1; 
 
618
show index from t1;
 
619
insert into t1 values (11);
 
620
delete from t1 where a=11;
 
621
check table t1;
 
622
show index from t1;
 
623
 
 
624
# Set nulls to be equal:
 
625
set myisam_stats_method=nulls_equal;
 
626
show variables like 'myisam_stats_method';
 
627
insert into t1 values (11);
 
628
delete from t1 where a=11;
 
629
 
 
630
analyze table t1; 
 
631
show index from t1;
 
632
 
 
633
insert into t1 values (11);
 
634
delete from t1 where a=11;
 
635
 
 
636
check table t1;
 
637
show index from t1;
 
638
 
 
639
# Set nulls back to be equal 
 
640
set myisam_stats_method=DEFAULT;
 
641
show variables like 'myisam_stats_method';
 
642
insert into t1 values (11);
 
643
delete from t1 where a=11;
 
644
 
 
645
analyze table t1; 
 
646
show index from t1;
 
647
 
 
648
insert into t1 values (11);
 
649
delete from t1 where a=11;
 
650
 
 
651
check table t1;
 
652
show index from t1;
 
653
 
 
654
drop table t1;
 
655
 
 
656
# WL#2609, CSC#XXXX: MyISAM 
 
657
set myisam_stats_method=nulls_ignored;
 
658
show variables like 'myisam_stats_method';
 
659
 
 
660
create table t1 (
 
661
  a char(3), b char(4), c char(5), d char(6),
 
662
  key(a,b,c,d)
 
663
);
 
664
insert into t1 values ('bcd','def1', NULL, 'zz');
 
665
insert into t1 values ('bcd','def2', NULL, 'zz');
 
666
insert into t1 values ('bce','def1', 'yuu', NULL);
 
667
insert into t1 values ('bce','def2', NULL, 'quux');
 
668
analyze table t1;
 
669
show index from t1;
 
670
delete from t1;
 
671
analyze table t1;
 
672
show index from t1;
 
673
 
 
674
set myisam_stats_method=DEFAULT;
 
675
drop table t1;
 
676
 
568
677
# BUG#13814 - key value packed incorrectly for TINYBLOBs
569
678
 
570
679
create table t1(
571
680
  cip INT NOT NULL,
 
681
  time TIME NOT NULL,
572
682
  score INT NOT NULL DEFAULT 0,
573
683
  bob TINYBLOB
574
684
);
575
685
 
576
 
insert into t1 (cip) VALUES (1), (2), (3);
577
 
insert into t1 (cip, bob) VALUES (4, 'a' ), (5, 'b'), 
578
 
                                       (6, 'c');
 
686
insert into t1 (cip, time) VALUES (1, '00:01'), (2, '00:02'), (3,'00:03');
 
687
insert into t1 (cip, bob, time) VALUES (4, 'a', '00:04'), (5, 'b', '00:05'), 
 
688
                                       (6, 'c', '00:06');
579
689
select * from t1 where bob is null and cip=1;
580
 
create index bug on t1 (bob(22), cip);
 
690
create index bug on t1 (bob(22), cip, time);
581
691
select * from t1 where bob is null and cip=1;
582
692
drop table t1;
583
693
 
584
694
#
585
695
# Bug#14980 - COUNT(*) incorrect on MyISAM table with certain INDEX
586
696
#
587
 
create temporary table t1 (
 
697
create table t1 (
588
698
  id1 int not null auto_increment,
589
699
  id2 int not null default '0',
590
700
  t text not null,
603
713
# BUG##20357 - Got error 124 from storage engine using MIN and MAX functions
604
714
#              in queries
605
715
#
606
 
CREATE TEMPORARY TABLE t1(a int, KEY(a)) ENGINE=MyISAM;
 
716
CREATE TABLE t1(a TINYINT, KEY(a)) ENGINE=MyISAM;
607
717
INSERT INTO t1 VALUES(1);
608
718
SELECT MAX(a) FROM t1 IGNORE INDEX(a);
609
719
ALTER TABLE t1 DISABLE KEYS;
612
722
DROP TABLE t1;
613
723
 
614
724
#
 
725
# BUG#18036 - update of table joined to self reports table as crashed
 
726
#
 
727
CREATE TABLE t1(a CHAR(9), b VARCHAR(7)) ENGINE=MyISAM;
 
728
INSERT INTO t1(a) VALUES('xxxxxxxxx'),('xxxxxxxxx');
 
729
UPDATE t1 AS ta1,t1 AS ta2 SET ta1.b='aaaaaa',ta2.b='bbbbbb';
 
730
SELECT * FROM t1;
 
731
DROP TABLE t1;
 
732
 
 
733
#
615
734
# Bug#8283 - OPTIMIZE TABLE causes data loss
616
735
#
617
 
SET GLOBAL myisam_repair_threads=2;
 
736
SET @@myisam_repair_threads=2;
618
737
SHOW VARIABLES LIKE 'myisam_repair%';
619
738
#
620
739
# Test OPTIMIZE. This creates a new data file.
621
 
CREATE TEMPORARY TABLE t1 (
622
 
  `_id` int NOT NULL default '0',
623
 
  `url` text,
624
 
  `email` text,
625
 
  `description` text,
626
 
  `loverlap` int default NULL,
627
 
  `roverlap` int default NULL,
628
 
  `lneighbor_id` int default NULL,
629
 
  `rneighbor_id` int default NULL,
630
 
  `length_` int default NULL,
631
 
  `sequence` text,
632
 
  `name` text,
633
 
  `_obj_class` text NOT NULL,
634
 
  PRIMARY KEY  (`_id`),
635
 
  UNIQUE KEY `sequence_name_index` (`name`(50)),
636
 
  KEY (`length_`)
637
 
) ENGINE=MyISAM;
638
 
 
639
 
INSERT INTO t1 VALUES
640
 
  (1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample1',''),
641
 
  (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample2',''),
642
 
  (3,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample3',''),
643
 
  (4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample4',''),
644
 
  (5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample5',''),
645
 
  (6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample6',''),
646
 
  (7,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample7',''),
647
 
  (8,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample8',''),
648
 
  (9,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample9','');
649
 
#
650
 
SELECT _id FROM t1;
651
 
DELETE FROM t1 WHERE _id < 8;
652
 
--replace_column 6 # 7 # 8 # 9 # 11 # 12 # 13 # 14 # 15 # 16 #
653
 
SHOW TABLE STATUS LIKE 't1';
654
 
CHECK TABLE t1;
655
 
ALTER TABLE t1 ENGINE=MYISAM;
656
 
CHECK TABLE t1;
657
 
--replace_column 6 # 7 # 8 # 9 # 11 # 12 # 13 # 14 # 15 # 16 #
658
 
SHOW TABLE STATUS LIKE 't1';
659
 
SELECT _id FROM t1;
660
 
DROP TABLE t1;
661
 
#
662
 
SET GLOBAL myisam_repair_threads=1;
 
740
CREATE TABLE t1 (
 
741
  `_id` int(11) NOT NULL default '0',
 
742
  `url` text,
 
743
  `email` text,
 
744
  `description` text,
 
745
  `loverlap` int(11) default NULL,
 
746
  `roverlap` int(11) default NULL,
 
747
  `lneighbor_id` int(11) default NULL,
 
748
  `rneighbor_id` int(11) default NULL,
 
749
  `length_` int(11) default NULL,
 
750
  `sequence` mediumtext,
 
751
  `name` text,
 
752
  `_obj_class` text NOT NULL,
 
753
  PRIMARY KEY  (`_id`),
 
754
  UNIQUE KEY `sequence_name_index` (`name`(50)),
 
755
  KEY (`length_`)
 
756
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 
757
#
 
758
INSERT INTO t1 VALUES
 
759
  (1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample1',''),
 
760
  (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample2',''),
 
761
  (3,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample3',''),
 
762
  (4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample4',''),
 
763
  (5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample5',''),
 
764
  (6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample6',''),
 
765
  (7,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample7',''),
 
766
  (8,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample8',''),
 
767
  (9,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample9','');
 
768
#
 
769
SELECT _id FROM t1;
 
770
DELETE FROM t1 WHERE _id < 8;
 
771
--replace_column 6 # 7 # 8 # 9 # 11 # 12 # 13 # 14 # 15 # 16 #
 
772
SHOW TABLE STATUS LIKE 't1';
 
773
CHECK TABLE t1 EXTENDED;
 
774
OPTIMIZE TABLE t1;
 
775
CHECK TABLE t1 EXTENDED;
 
776
--replace_column 6 # 7 # 8 # 9 # 11 # 12 # 13 # 14 # 15 # 16 #
 
777
SHOW TABLE STATUS LIKE 't1';
 
778
SELECT _id FROM t1;
 
779
DROP TABLE t1;
 
780
#
 
781
# Test REPAIR QUICK. This retains the old data file.
 
782
CREATE TABLE t1 (
 
783
  `_id` int(11) NOT NULL default '0',
 
784
  `url` text,
 
785
  `email` text,
 
786
  `description` text,
 
787
  `loverlap` int(11) default NULL,
 
788
  `roverlap` int(11) default NULL,
 
789
  `lneighbor_id` int(11) default NULL,
 
790
  `rneighbor_id` int(11) default NULL,
 
791
  `length_` int(11) default NULL,
 
792
  `sequence` mediumtext,
 
793
  `name` text,
 
794
  `_obj_class` text NOT NULL,
 
795
  PRIMARY KEY  (`_id`),
 
796
  UNIQUE KEY `sequence_name_index` (`name`(50)),
 
797
  KEY (`length_`)
 
798
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 
799
#
 
800
INSERT INTO t1 VALUES
 
801
  (1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample1',''),
 
802
  (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample2',''),
 
803
  (3,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample3',''),
 
804
  (4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample4',''),
 
805
  (5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample5',''),
 
806
  (6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample6',''),
 
807
  (7,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample7',''),
 
808
  (8,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample8',''),
 
809
  (9,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample9','');
 
810
#
 
811
SELECT _id FROM t1;
 
812
DELETE FROM t1 WHERE _id < 8;
 
813
--replace_column 6 # 7 # 8 # 9 # 11 # 12 # 13 # 14 # 15 # 16 #
 
814
SHOW TABLE STATUS LIKE 't1';
 
815
CHECK TABLE t1 EXTENDED;
 
816
REPAIR TABLE t1 QUICK;
 
817
CHECK TABLE t1 EXTENDED;
 
818
--replace_column 6 # 7 # 8 # 9 # 11 # 12 # 13 # 14 # 15 # 16 #
 
819
SHOW TABLE STATUS LIKE 't1';
 
820
SELECT _id FROM t1;
 
821
DROP TABLE t1;
 
822
#
 
823
SET @@myisam_repair_threads=1;
663
824
SHOW VARIABLES LIKE 'myisam_repair%';
664
825
 
665
826
#
 
827
# BUG#21310 - Trees in SQL causing a "crashed" table with MyISAM storage
 
828
#             engine
 
829
#
 
830
 
 
831
# A simplified test case that reflect crashed table issue.
 
832
CREATE TABLE t1(a VARCHAR(16));
 
833
INSERT INTO t1 VALUES('aaaaaaaa'),(NULL);
 
834
UPDATE t1 AS ta1, t1 AS ta2 SET ta1.a='aaaaaaaaaaaaaaaa';
 
835
SELECT * FROM t1;
 
836
DROP TABLE t1;
 
837
 
 
838
# A test case that reflect wrong result set.
 
839
CREATE TABLE t1(a INT);
 
840
INSERT INTO t1 VALUES(1),(2);
 
841
UPDATE t1,t1 AS t2 SET t1.a=t1.a+2 WHERE t1.a=t2.a-1;
 
842
SELECT * FROM t1 ORDER BY a;
 
843
DROP TABLE t1;
 
844
 
 
845
#
666
846
# Bug#24607 - MyISAM pointer size determined incorrectly
667
847
#
668
 
CREATE TEMPORARY TABLE t1 (c1 TEXT) ENGINE=MyISAM;
 
848
CREATE TABLE t1 (c1 TEXT) AVG_ROW_LENGTH=70100 MAX_ROWS=4100100100;
669
849
--replace_column 5 X 6 X 7 X 9 X 10 X 11 X 12 X 13 X 14 X 16 X
670
850
SHOW TABLE STATUS LIKE 't1';
671
851
DROP TABLE t1;
674
854
# Bug#26231 - select count(*) on myisam table returns wrong value
675
855
#             when index is used
676
856
#
677
 
CREATE TEMPORARY TABLE t1 (c1 TEXT NOT NULL, KEY c1 (c1(10))) ENGINE=MyISAM;
 
857
CREATE TABLE t1 (c1 TEXT NOT NULL, KEY c1 (c1(10))) ENGINE=MyISAM;
678
858
# Fill at least two key blocks. "Tab, A" must be in both blocks. 
679
859
INSERT INTO t1 VALUES
680
860
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
822
1002
 
823
1003
let $default=`select @@storage_engine`;
824
1004
set storage_engine=MyISAM;
825
 
let $temp= TEMPORARY;
826
1005
source include/varchar.inc;
827
1006
 
828
1007
#
829
1008
# Some errors/warnings on create
830
1009
#
831
1010
 
832
 
--error 1074
833
 
create temporary table t1 (v varchar(65530), key(v));
834
 
--error 1074
835
 
create temporary table t1 (v varchar(65536));
836
 
--error 1074
837
 
create temporary table t1 (v varchar(65530));
 
1011
create table t1 (v varchar(65530), key(v));
 
1012
drop table if exists t1;
 
1013
create table t1 (v varchar(65536));
 
1014
show create table t1;
 
1015
drop table t1;
 
1016
create table t1 (v varchar(65530) character set utf8);
 
1017
show create table t1;
 
1018
drop table t1;
838
1019
 
839
1020
# MyISAM specific varchar tests
840
 
--error 1074
841
 
create temporary table t1 (v varchar(65535));
 
1021
--error 1118
 
1022
create table t1 (v varchar(65535));
842
1023
 
843
1024
eval set storage_engine=$default;
844
1025
 
 
1026
#
 
1027
# Test concurrent insert
 
1028
# First with static record length
 
1029
#
 
1030
set @save_concurrent_insert=@@concurrent_insert;
 
1031
set global concurrent_insert=1;
 
1032
create table t1 (a int);
 
1033
insert into t1 values (1),(2),(3),(4),(5);
 
1034
lock table t1 read local;
 
1035
connect (con1,localhost,root,,);
 
1036
connection con1;
 
1037
# Insert in table without hole
 
1038
insert into t1 values(6),(7);
 
1039
connection default;
 
1040
unlock tables;
 
1041
delete from t1 where a>=3 and a<=4;
 
1042
lock table t1 read local;
 
1043
connection con1;
 
1044
set global concurrent_insert=2;
 
1045
# Insert in table with hole -> Should insert at end
 
1046
insert into t1 values (8),(9);
 
1047
connection default;
 
1048
unlock tables;
 
1049
# Insert into hole
 
1050
insert into t1 values (10),(11),(12);
 
1051
select * from t1;
 
1052
check table t1;
 
1053
drop table t1;
 
1054
disconnect con1;
 
1055
 
 
1056
# Same test with dynamic record length
 
1057
create table t1 (a int, b varchar(30) default "hello");
 
1058
insert into t1 (a) values (1),(2),(3),(4),(5);
 
1059
lock table t1 read local;
 
1060
connect (con1,localhost,root,,);
 
1061
connection con1;
 
1062
# Insert in table without hole
 
1063
insert into t1 (a) values(6),(7);
 
1064
connection default;
 
1065
unlock tables;
 
1066
delete from t1 where a>=3 and a<=4;
 
1067
lock table t1 read local;
 
1068
connection con1;
 
1069
set global concurrent_insert=2;
 
1070
# Insert in table with hole -> Should insert at end
 
1071
insert into t1 (a) values (8),(9);
 
1072
connection default;
 
1073
unlock tables;
 
1074
# Insert into hole
 
1075
insert into t1 (a) values (10),(11),(12);
 
1076
select a from t1;
 
1077
check table t1;
 
1078
drop table t1;
 
1079
disconnect con1;
 
1080
set global concurrent_insert=@save_concurrent_insert;
 
1081
 
845
1082
 
846
1083
# BUG#9622 - ANALYZE TABLE and ALTER TABLE .. ENABLE INDEX produce
847
1084
# different statistics on the same table with NULL values.
859
1096
 
860
1097
 
861
1098
#
 
1099
# Bug#10056 - PACK_KEYS option take values greater than 1 while creating table
 
1100
#
 
1101
create table t1 (c1 int) engine=myisam pack_keys=0;
 
1102
create table t2 (c1 int) engine=myisam pack_keys=1;
 
1103
create table t3 (c1 int) engine=myisam pack_keys=default;
 
1104
--error 1064
 
1105
create table t4 (c1 int) engine=myisam pack_keys=2;
 
1106
drop table t1, t2, t3;
 
1107
 
 
1108
 
 
1109
#
862
1110
# Bug#28476: force index on a disabled myisam index gives error 124
863
1111
#
864
 
CREATE TEMPORARY TABLE t1(a INT, b INT, KEY inx (a), UNIQUE KEY uinx (b)) ENGINE=MyISAM;
 
1112
CREATE TABLE t1(a INT, b INT, KEY inx (a), UNIQUE KEY uinx (b)) ENGINE=MyISAM;
865
1113
INSERT INTO t1(a,b) VALUES (1,1),(2,2),(3,3),(4,4),(5,5);
866
1114
SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1;
867
1115
ALTER TABLE t1 DISABLE KEYS;
877
1125
#
878
1126
# Bug#4692 - DISABLE/ENABLE KEYS waste a space
879
1127
#
880
 
CREATE TEMPORARY TABLE t1 (c1 INT, c2 INT, UNIQUE INDEX (c1), INDEX (c2)) ENGINE=MYISAM;
 
1128
CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE INDEX (c1), INDEX (c2)) ENGINE=MYISAM;
881
1129
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
882
1130
SHOW TABLE STATUS LIKE 't1';
883
1131
INSERT INTO t1 VALUES (1,1);
899
1147
#--exec myisamchk -dvv var/master-data/test/t1.MYI
900
1148
#--exec myisamchk -iev var/master-data/test/t1.MYI
901
1149
--echo # Enable keys with parallel repair
902
 
SET GLOBAL myisam_repair_threads=2;
 
1150
SET @@myisam_repair_threads=2;
903
1151
ALTER TABLE t1 DISABLE KEYS;
904
1152
ALTER TABLE t1 ENABLE KEYS;
905
 
SET GLOBAL myisam_repair_threads=1;
906
 
CHECK TABLE t1;
 
1153
SET @@myisam_repair_threads=1;
 
1154
CHECK TABLE t1 EXTENDED;
907
1155
DROP TABLE t1;
908
1156
 
909
1157
#
910
1158
# Bug#28837: MyISAM storage engine error (134) doing delete with self-join
911
1159
#
912
 
# DRIZZLE NOTE: Cannot self join on temp tables.
913
 
CREATE TABLE t1 (id int NOT NULL, ref int NOT NULL, INDEX (id));
 
1160
 
 
1161
CREATE TABLE t1 (id int NOT NULL, ref int NOT NULL, INDEX (id)) ENGINE=MyISAM;
914
1162
CREATE TABLE t2 LIKE t1;
915
1163
 
916
1164
INSERT INTO t2 (id, ref) VALUES (1,3), (2,1), (3,2), (4,5), (4,4);
918
1166
 
919
1167
SELECT * FROM t1 AS a INNER JOIN t1 AS b USING (id) WHERE a.ref < b.ref;
920
1168
SELECT * FROM t1;
 
1169
DELETE FROM a USING t1 AS a INNER JOIN t1 AS b USING (id) WHERE a.ref < b.ref;
 
1170
SELECT * FROM t1;
921
1171
 
922
1172
DROP TABLE t1, t2;
923
1173
 
928
1178
# Test of key_block_size
929
1179
#
930
1180
 
931
 
create temporary table t1 (a int not null, key `a` (a) key_block_size=1024) ENGINE=MyISAM;
932
 
show create table t1;
933
 
drop table t1;
934
 
 
935
 
create temporary table t1 (a int not null, key `a` (a) key_block_size=2048) ENGINE=MyISAM;
936
 
show create table t1;
937
 
drop table t1;
938
 
 
939
 
create temporary table t1 (a varchar(2048), key `a` (a)) ENGINE=MyISAM;
940
 
show create table t1;
941
 
drop table t1;
942
 
 
943
 
create temporary table t1 (a varchar(2048), key `a` (a) key_block_size=1024) ENGINE=MyISAM;
944
 
show create table t1;
945
 
drop table t1;
946
 
 
947
 
create temporary table t1 (a int not null, b varchar(2048), key (a), key(b)) ENGINE=MyISAM key_block_size=1024;
 
1181
create table t1 (a int not null, key `a` (a) key_block_size=1024);
 
1182
show create table t1;
 
1183
drop table t1;
 
1184
 
 
1185
create table t1 (a int not null, key `a` (a) key_block_size=2048);
 
1186
show create table t1;
 
1187
drop table t1;
 
1188
 
 
1189
create table t1 (a varchar(2048), key `a` (a));
 
1190
show create table t1;
 
1191
drop table t1;
 
1192
 
 
1193
create table t1 (a varchar(2048), key `a` (a) key_block_size=1024);
 
1194
show create table t1;
 
1195
drop table t1;
 
1196
 
 
1197
create table t1 (a int not null, b varchar(2048), key (a), key(b)) key_block_size=1024;
948
1198
show create table t1;
949
1199
alter table t1 key_block_size=2048;
950
1200
show create table t1;
955
1205
show create table t1;
956
1206
drop table t1;
957
1207
 
958
 
create temporary table t1 (a int not null, b varchar(2048), key (a), key(b)) ENGINE=MyISAM key_block_size=8192;
959
 
show create table t1;
960
 
drop table t1;
961
 
 
962
 
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;
963
 
show create table t1;
964
 
drop table t1;
965
 
 
966
 
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;
 
1208
create table t1 (a int not null, b varchar(2048), key (a), key(b)) key_block_size=8192;
 
1209
show create table t1;
 
1210
drop table t1;
 
1211
 
 
1212
create table t1 (a int not null, b varchar(2048), key (a) key_block_size=1024, key(b)) key_block_size=8192;
 
1213
show create table t1;
 
1214
drop table t1;
 
1215
 
 
1216
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;
967
1217
show create table t1;
968
1218
drop table t1;
969
1219
 
970
1220
 
971
1221
# Test limits and errors of key_block_size
972
1222
 
973
 
create temporary table t1 (a int not null, key `a` (a) key_block_size=512) ENGINE=MyISAM;
974
 
show create table t1;
975
 
drop table t1;
976
 
 
977
 
create temporary table t1 (a varchar(2048), key `a` (a) key_block_size=1000000000000000000) ENGINE=MyISAM;
978
 
show create table t1;
979
 
drop table t1;
980
 
 
981
 
create temporary table t1 (a int not null, key `a` (a) key_block_size=1025) ENGINE=MyISAM;
982
 
show create table t1;
983
 
drop table t1;
984
 
 
985
 
--error 1064
986
 
create temporary table t1 (a int not null, key key_block_size=1024 (a)) ENGINE=MyISAM;
987
 
--error 1064
988
 
create temporary table t1 (a int not null, key `a` key_block_size=1024 (a)) ENGINE=MyISAM;
 
1223
create table t1 (a int not null, key `a` (a) key_block_size=512);
 
1224
show create table t1;
 
1225
drop table t1;
 
1226
 
 
1227
create table t1 (a varchar(2048), key `a` (a) key_block_size=1000000000000000000);
 
1228
show create table t1;
 
1229
drop table t1;
 
1230
 
 
1231
create table t1 (a int not null, key `a` (a) key_block_size=1025);
 
1232
show create table t1;
 
1233
drop table t1;
 
1234
 
 
1235
--error 1064
 
1236
create table t1 (a int not null, key key_block_size=1024 (a));
 
1237
--error 1064
 
1238
create table t1 (a int not null, key `a` key_block_size=1024 (a));
989
1239
 
990
1240
#
991
1241
# Bug#22119 - Changing MI_KEY_BLOCK_LENGTH makes a wrong myisamchk
992
1242
#
993
 
CREATE temporary TABLE t1 (
 
1243
CREATE TABLE t1 (
994
1244
  c1 INT,
995
1245
  c2 VARCHAR(300),
996
1246
  KEY (c1) KEY_BLOCK_SIZE 1024,
997
1247
  KEY (c2) KEY_BLOCK_SIZE 8192
998
 
  ) ENGINE=MyISAM;
 
1248
  );
999
1249
INSERT INTO t1 VALUES (10, REPEAT('a', CEIL(RAND(10) * 300))),
1000
1250
  (11, REPEAT('b', CEIL(RAND() * 300))),
1001
1251
  (12, REPEAT('c', CEIL(RAND() * 300))),
1022
1272
  (33, REPEAT('x', CEIL(RAND() * 300))),
1023
1273
  (34, REPEAT('y', CEIL(RAND() * 300))),
1024
1274
  (35, REPEAT('z', CEIL(RAND() * 300)));
1025
 
CREATE TEMPORARY TABLE t2 AS SELECT * FROM t1;
1026
 
INSERT INTO t1 SELECT * FROM t2;
1027
 
DROP TABLE t2;
1028
 
CREATE TEMPORARY TABLE t2 AS SELECT * FROM t1;
1029
 
INSERT INTO t1 SELECT * FROM t2;
1030
 
DROP TABLE t2;
 
1275
INSERT INTO t1 SELECT * FROM t1;
 
1276
INSERT INTO t1 SELECT * FROM t1;
1031
1277
CHECK TABLE t1;
 
1278
REPAIR TABLE t1;
1032
1279
DELETE FROM t1 WHERE c1 >= 10;
1033
1280
CHECK TABLE t1;
1034
1281
DROP TABLE t1;
1040
1287
# Test #1 - CHECK TABLE sees wrong record, REPAR TABLE deletes it.
1041
1288
# Using a CHAR column that can have > 127 characters.
1042
1289
# Using a VARCHAR to create a table with dynamic row format.
1043
 
CREATE temporary TABLE t1 (
 
1290
CREATE TABLE t1 (
1044
1291
  c1 CHAR(130),
1045
1292
  c2 VARCHAR(1)
1046
1293
) ENGINE=MyISAM;
1047
1294
INSERT INTO t1 VALUES(REPEAT("a",128), 'b');
1048
1295
SELECT COUNT(*) FROM t1;
1049
1296
CHECK TABLE t1;
 
1297
REPAIR TABLE t1;
1050
1298
SELECT COUNT(*) FROM t1;
1051
1299
CHECK TABLE t1;
1052
1300
DROP TABLE t1;
1054
1302
# Test #2 - same as test #1, but using EXTENDED.
1055
1303
# Using a CHAR column that can have > 127 characters.
1056
1304
# Using a VARCHAR to create a table with dynamic row format.
1057
 
CREATE temporary TABLE t1 (
 
1305
CREATE TABLE t1 (
1058
1306
  c1 CHAR(130),
1059
1307
  c2 VARCHAR(1)
1060
1308
) ENGINE=MyISAM;
1061
1309
INSERT INTO t1 VALUES(REPEAT("a",128), 'b');
1062
1310
SELECT COUNT(*) FROM t1;
1063
 
CHECK TABLE t1;
 
1311
CHECK TABLE t1 EXTENDED;
 
1312
REPAIR TABLE t1 EXTENDED;
1064
1313
SELECT COUNT(*) FROM t1;
1065
 
CHECK TABLE t1;
 
1314
CHECK TABLE t1 EXTENDED;
1066
1315
DROP TABLE t1;
1067
1316
#
1068
1317
# Test #3 - same as test #1, but using OPTIMIZE TABLE.
1069
1318
# Using a CHAR column that can have > 127 characters.
1070
1319
# Using a VARCHAR to create a table with dynamic row format.
1071
 
CREATE temporary TABLE t1 (
 
1320
CREATE TABLE t1 (
1072
1321
  c1 CHAR(130),
1073
1322
  c2 VARCHAR(1)
1074
1323
) ENGINE=MyISAM;
1078
1327
INSERT INTO t1 VALUES('c', 'b');
1079
1328
DELETE FROM t1 WHERE c1='b';
1080
1329
SELECT COUNT(*) FROM t1;
1081
 
ALTER TABLE t1 ENGINE=MyISAM;
 
1330
OPTIMIZE TABLE t1;
1082
1331
SELECT COUNT(*) FROM t1;
1083
1332
DROP TABLE t1;
1084
1333
#
1086
1335
# Using a CHAR column that can have > 127 characters.
1087
1336
# Using a VARCHAR to create a table with dynamic row format.
1088
1337
# Using an index which can be disabled during bulk insert.
1089
 
CREATE temporary TABLE t1 (
 
1338
CREATE TABLE t1 (
1090
1339
  c1 CHAR(130),
1091
1340
  c2 VARCHAR(1),
1092
1341
  KEY (c1)
1113
1362
# With bug present, this shows that all long rows are gone.
1114
1363
SELECT COUNT(*) FROM t1;
1115
1364
CHECK TABLE t1;
1116
 
CHECK TABLE t1;
 
1365
CHECK TABLE t1 EXTENDED;
1117
1366
DROP TABLE t1;
1118
1367
#
1119
1368
# Test #5 - same as test #1 but UTF-8.
1120
1369
# Using a CHAR column that can have > 127 characters.
1121
1370
# Using a VARCHAR to create a table with dynamic row format.
1122
 
CREATE temporary TABLE t1 (
 
1371
CREATE TABLE t1 (
1123
1372
  c1 CHAR(50),
1124
1373
  c2 VARCHAR(1)
1125
 
) ENGINE=MyISAM;
 
1374
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
1126
1375
# Using Tamil Letter A, Unicode U+0B85
1127
 
INSERT INTO t1 VALUES(REPEAT( x'e0ae85',43), 'b');
 
1376
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
1128
1377
SELECT COUNT(*) FROM t1;
1129
1378
CHECK TABLE t1;
 
1379
REPAIR TABLE t1;
1130
1380
SELECT COUNT(*) FROM t1;
1131
1381
CHECK TABLE t1;
1132
1382
DROP TABLE t1;
1134
1384
# Test #6 - same as test #2, but UTF-8.
1135
1385
# Using a CHAR column that can have > 127 characters.
1136
1386
# Using a VARCHAR to create a table with dynamic row format.
1137
 
CREATE temporary TABLE t1 (
 
1387
CREATE TABLE t1 (
1138
1388
  c1 CHAR(50),
1139
1389
  c2 VARCHAR(1)
1140
 
) ENGINE=MyISAM;
 
1390
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
1141
1391
# Using Tamil Letter A, Unicode U+0B85
1142
 
INSERT INTO t1 VALUES(REPEAT( x'e0ae85',43), 'b');
1143
 
SELECT COUNT(*) FROM t1;
1144
 
CHECK TABLE t1;
1145
 
SELECT COUNT(*) FROM t1;
1146
 
CHECK TABLE t1;
 
1392
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
 
1393
SELECT COUNT(*) FROM t1;
 
1394
CHECK TABLE t1 EXTENDED;
 
1395
REPAIR TABLE t1 EXTENDED;
 
1396
SELECT COUNT(*) FROM t1;
 
1397
CHECK TABLE t1 EXTENDED;
1147
1398
DROP TABLE t1;
1148
1399
#
1149
1400
# Test #7 - same as test #3, but UTF-8.
1150
1401
# Using a CHAR column that can have > 127 characters.
1151
1402
# Using a VARCHAR to create a table with dynamic row format.
1152
 
CREATE temporary TABLE t1 (
 
1403
CREATE TABLE t1 (
1153
1404
  c1 CHAR(50),
1154
1405
  c2 VARCHAR(1)
1155
 
) ENGINE=MyISAM;
 
1406
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
1156
1407
# Using Tamil Letter A, Unicode U+0B85
1157
 
INSERT INTO t1 VALUES(REPEAT( x'e0ae85',43), 'b');
 
1408
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
1158
1409
# Insert more rows and delete one in the middle to force optimize.
1159
1410
INSERT INTO t1 VALUES('b', 'b');
1160
1411
INSERT INTO t1 VALUES('c', 'b');
1161
1412
DELETE FROM t1 WHERE c1='b';
1162
1413
SELECT COUNT(*) FROM t1;
1163
 
ALTER TABLE t1 ENGINE=MyISAM;
 
1414
OPTIMIZE TABLE t1;
1164
1415
SELECT COUNT(*) FROM t1;
1165
1416
DROP TABLE t1;
1166
1417
#
1168
1419
# Using a CHAR column that can have > 42 UTF-8 characters.
1169
1420
# Using a VARCHAR to create a table with dynamic row format.
1170
1421
# Using an index which can be disabled during bulk insert.
1171
 
CREATE temporary TABLE t1 (
 
1422
CREATE TABLE t1 (
1172
1423
  c1 CHAR(50),
1173
1424
  c2 VARCHAR(1),
1174
1425
  KEY (c1)
1175
 
) ENGINE=MyISAM;
 
1426
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
1176
1427
#
1177
1428
# Insert 100 rows. This turns bulk insert on during the copy phase of
1178
1429
# ALTER TABLE. Bulk insert disables keys before the insert and re-enables
1189
1440
#
1190
1441
# Change most of the rows into long character values with > 42 characters.
1191
1442
# Using Tamil Letter A, Unicode U+0B85
1192
 
UPDATE t1 SET c1=REPEAT( x'e0ae85',43) LIMIT 90;
 
1443
UPDATE t1 SET c1=REPEAT(_utf8 x'e0ae85',43) LIMIT 90;
1193
1444
SELECT COUNT(*) FROM t1;
1194
1445
ALTER TABLE t1 ENGINE=MyISAM;
1195
1446
#
1196
1447
# With bug present, this shows that all long rows are gone.
1197
1448
SELECT COUNT(*) FROM t1;
1198
1449
CHECK TABLE t1;
1199
 
CHECK TABLE t1;
1200
 
DROP TABLE t1;
 
1450
CHECK TABLE t1 EXTENDED;
 
1451
DROP TABLE t1;
 
1452
 
 
1453
#
 
1454
# Bug#29182 - MyISAMCHK reports wrong character set
 
1455
#
 
1456
CREATE TABLE t1 (
 
1457
  c1 VARCHAR(10) NOT NULL,
 
1458
  c2 CHAR(10) DEFAULT NULL,
 
1459
  c3 VARCHAR(10) NOT NULL,
 
1460
  KEY (c1),
 
1461
  KEY (c2)
 
1462
) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=0;
 
1463
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 
1464
--exec $MYISAMCHK -d $MYSQLTEST_VARDIR/master-data/test/t1
 
1465
DROP TABLE t1;
 
1466
 
1201
1467
--echo End of 5.1 tests
1202
1468