~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/myisam.test

  • Committer: Mark Atwood
  • Date: 2008-10-16 11:33:16 UTC
  • mto: (520.1.13 drizzle)
  • mto: This revision was merged to the branch mainline in revision 530.
  • Revision ID: mark@fallenpegasus.com-20081016113316-ff6jdt31ck90sjdh
an implemention of the errmsg plugin

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;
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) NOT NULL auto_increment,
 
313
  `topic_id` mediumint(8) 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` int(1) 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
 
329
336
# Test of creating table with too long key
330
337
#
331
338
 
332
 
--error ER_TOO_LONG_KEY
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;
335
 
--error ER_TOO_LONG_KEY
 
339
--error 1071
 
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));
 
342
--error 1071
336
343
ALTER TABLE t1 ADD INDEX t1 (a, b, c, d, e);
337
344
DROP TABLE t1;
338
345
 
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
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
502
 
show table status;
 
542
checksum table t1, t2, t3 quick;
 
543
checksum table t1, t2, t3;
 
544
checksum table t1, t2, t3 extended;
 
545
#show table status;
503
546
drop table t1,t2;
504
547
 
505
 
#@TODO Figure out what the heck the below is testing.
506
 
#      It bombs the test with unknown system variables...
507
 
#
508
 
#create table t1 (a int, key (a));
509
 
#show keys from t1;
510
 
#alter table t1 disable keys;
511
 
#show keys from t1;
512
 
#create table t2 (a int);
513
 
#let $i=1000;
514
 
#set @@rand_seed1=31415926,@@rand_seed2=2718281828;
515
 
#--disable_query_log
516
 
#while ($i)
517
 
#{
518
 
#  dec $i;
519
 
#  insert t2 values (rand()*100000);
520
 
#}
521
 
#--enable_query_log
522
 
#insert t1 select * from t2;
523
 
#show keys from t1;
524
 
#alter table t1 enable keys;
525
 
#show keys from t1;
526
 
#alter table t1 engine=MEMORY;
527
 
#alter table t1 disable keys;
528
 
#show keys from t1;
529
 
#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;
530
570
 
531
571
#
532
572
# index search for NULL in blob. Bug #4816
541
581
# bug9188 - Corruption Can't open file: 'table.MYI' (errno: 145)
542
582
#
543
583
create table t1 (c1 int, c2 varchar(4) not null default '',
544
 
                 key(c2(3)));
 
584
                 key(c2(3))) default charset=utf8;
545
585
insert into t1 values (1,'A'), (2, 'B'), (3, 'A');
546
586
update t1 set c2='A  B' where c1=2;
547
587
check table t1;
548
588
drop table t1;
549
589
 
 
590
 
 
591
#
 
592
# Bug#12296 - CHECKSUM TABLE reports 0 for the table
 
593
# This happened if the first record was marked as deleted.
 
594
#
 
595
create table t1 (c1 int);
 
596
insert into t1 values (1),(2),(3),(4);
 
597
checksum table t1;
 
598
delete from t1 where c1 = 1;
 
599
create table t2 as select * from t1;
 
600
# The following returns 0 with the bug in place.
 
601
checksum table t1;
 
602
# The above should give the same number as the following.
 
603
checksum table t2;
 
604
drop table t1, t2;
 
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
 
550
677
# BUG#13814 - key value packed incorrectly for TINYBLOBs
551
678
 
552
679
create table t1(
553
680
  cip INT NOT NULL,
 
681
  time TIME NOT NULL,
554
682
  score INT NOT NULL DEFAULT 0,
555
683
  bob TINYBLOB
556
684
);
557
685
 
558
 
insert into t1 (cip) VALUES (1), (2), (3);
559
 
insert into t1 (cip, bob) VALUES (4, 'a' ), (5, 'b'), 
560
 
                                       (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');
561
689
select * from t1 where bob is null and cip=1;
562
 
create index bug on t1 (bob(22), cip);
 
690
create index bug on t1 (bob(22), cip, time);
563
691
select * from t1 where bob is null and cip=1;
564
692
drop table t1;
565
693
 
566
694
#
567
695
# Bug#14980 - COUNT(*) incorrect on MyISAM table with certain INDEX
568
696
#
569
 
create temporary table t1 (
 
697
create table t1 (
570
698
  id1 int not null auto_increment,
571
699
  id2 int not null default '0',
572
700
  t text not null,
585
713
# BUG##20357 - Got error 124 from storage engine using MIN and MAX functions
586
714
#              in queries
587
715
#
588
 
CREATE TEMPORARY TABLE t1(a int, KEY(a)) ENGINE=MyISAM;
 
716
CREATE TABLE t1(a int, KEY(a)) ENGINE=MyISAM;
589
717
INSERT INTO t1 VALUES(1);
590
718
SELECT MAX(a) FROM t1 IGNORE INDEX(a);
591
719
ALTER TABLE t1 DISABLE KEYS;
594
722
DROP TABLE t1;
595
723
 
596
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
#
597
734
# Bug#8283 - OPTIMIZE TABLE causes data loss
598
735
#
 
736
SET @@myisam_repair_threads=2;
 
737
SHOW VARIABLES LIKE 'myisam_repair%';
 
738
#
599
739
# Test OPTIMIZE. This creates a new data file.
600
 
CREATE TEMPORARY TABLE t1 (
601
 
  `_id` int NOT NULL default '0',
602
 
  `url` text,
603
 
  `email` text,
604
 
  `description` text,
605
 
  `loverlap` int default NULL,
606
 
  `roverlap` int default NULL,
607
 
  `lneighbor_id` int default NULL,
608
 
  `rneighbor_id` int default NULL,
609
 
  `length_` int default NULL,
610
 
  `sequence` text,
611
 
  `name` text,
612
 
  `_obj_class` text NOT NULL,
613
 
  PRIMARY KEY  (`_id`),
614
 
  UNIQUE KEY `sequence_name_index` (`name`(50)),
615
 
  KEY (`length_`)
616
 
) ENGINE=MyISAM;
617
 
 
618
 
INSERT INTO t1 VALUES
619
 
  (1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample1',''),
620
 
  (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample2',''),
621
 
  (3,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample3',''),
622
 
  (4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample4',''),
623
 
  (5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample5',''),
624
 
  (6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample6',''),
625
 
  (7,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample7',''),
626
 
  (8,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample8',''),
627
 
  (9,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample9','');
628
 
#
629
 
SELECT _id FROM t1;
630
 
DELETE FROM t1 WHERE _id < 8;
631
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
632
 
show table status LIKE 't1';
633
 
CHECK TABLE t1;
634
 
ALTER TABLE t1 ENGINE=MYISAM;
635
 
CHECK TABLE t1;
636
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
637
 
show table status LIKE 't1';
638
 
SELECT _id FROM t1;
 
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;
 
824
SHOW VARIABLES LIKE 'myisam_repair%';
 
825
 
 
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;
639
843
DROP TABLE t1;
640
844
 
641
845
#
642
846
# Bug#24607 - MyISAM pointer size determined incorrectly
643
847
#
644
 
CREATE TEMPORARY TABLE t1 (c1 TEXT) ENGINE=MyISAM;
645
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
646
 
show table status like 't1';
 
848
CREATE TABLE t1 (c1 TEXT) AVG_ROW_LENGTH=70100 MAX_ROWS=4100100100;
 
849
--replace_column 5 X 6 X 7 X 9 X 10 X 11 X 12 X 13 X 14 X 16 X
 
850
SHOW TABLE STATUS LIKE 't1';
647
851
DROP TABLE t1;
648
852
 
649
853
#
650
854
# Bug#26231 - select count(*) on myisam table returns wrong value
651
855
#             when index is used
652
856
#
653
 
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;
654
858
# Fill at least two key blocks. "Tab, A" must be in both blocks. 
655
859
INSERT INTO t1 VALUES
656
860
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
798
1002
 
799
1003
let $default=`select @@storage_engine`;
800
1004
set storage_engine=MyISAM;
801
 
let $temp= TEMPORARY;
802
1005
source include/varchar.inc;
803
1006
 
804
1007
#
805
1008
# Some errors/warnings on create
806
1009
#
807
1010
 
808
 
--error ER_TOO_BIG_FIELDLENGTH
809
 
create temporary table t1 (v varchar(65530), key(v));
810
 
--error ER_TOO_BIG_FIELDLENGTH
811
 
create temporary table t1 (v varchar(65536));
812
 
--error ER_TOO_BIG_FIELDLENGTH
813
 
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;
814
1019
 
815
1020
# MyISAM specific varchar tests
816
 
--error ER_TOO_BIG_FIELDLENGTH
817
 
create temporary table t1 (v varchar(65535));
 
1021
--error 1118
 
1022
create table t1 (v varchar(65535));
818
1023
 
819
1024
eval set storage_engine=$default;
820
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
 
821
1082
 
822
1083
# BUG#9622 - ANALYZE TABLE and ALTER TABLE .. ENABLE INDEX produce
823
1084
# different statistics on the same table with NULL values.
835
1096
 
836
1097
 
837
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
#
838
1110
# Bug#28476: force index on a disabled myisam index gives error 124
839
1111
#
840
 
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;
841
1113
INSERT INTO t1(a,b) VALUES (1,1),(2,2),(3,3),(4,4),(5,5);
842
1114
SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1;
843
1115
ALTER TABLE t1 DISABLE KEYS;
853
1125
#
854
1126
# Bug#4692 - DISABLE/ENABLE KEYS waste a space
855
1127
#
856
 
CREATE TEMPORARY TABLE t1 (c1 INT, c2 INT, UNIQUE INDEX (c1), INDEX (c2)) ENGINE=MYISAM;
857
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
858
 
show table status like 't1';
 
1128
CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE INDEX (c1), INDEX (c2)) ENGINE=MYISAM;
 
1129
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
 
1130
SHOW TABLE STATUS LIKE 't1';
859
1131
INSERT INTO t1 VALUES (1,1);
860
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
861
 
show table status like 't1';
862
 
ALTER TABLE t1 DISABLE KEYS;
863
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
864
 
show table status like 't1';
865
 
ALTER TABLE t1 ENABLE KEYS;
866
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
867
 
show table status like 't1';
868
 
ALTER TABLE t1 DISABLE KEYS;
869
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
870
 
show table status like 't1';
871
 
ALTER TABLE t1 ENABLE KEYS;
872
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
873
 
show table status like 't1';
 
1132
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
 
1133
SHOW TABLE STATUS LIKE 't1';
 
1134
ALTER TABLE t1 DISABLE KEYS;
 
1135
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
 
1136
SHOW TABLE STATUS LIKE 't1';
 
1137
ALTER TABLE t1 ENABLE KEYS;
 
1138
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
 
1139
SHOW TABLE STATUS LIKE 't1';
 
1140
ALTER TABLE t1 DISABLE KEYS;
 
1141
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
 
1142
SHOW TABLE STATUS LIKE 't1';
 
1143
ALTER TABLE t1 ENABLE KEYS;
 
1144
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
 
1145
SHOW TABLE STATUS LIKE 't1';
874
1146
#--exec ls -log var/master-data/test/t1.MYI
875
1147
#--exec myisamchk -dvv var/master-data/test/t1.MYI
876
1148
#--exec myisamchk -iev var/master-data/test/t1.MYI
877
1149
--echo # Enable keys with parallel repair
 
1150
SET @@myisam_repair_threads=2;
878
1151
ALTER TABLE t1 DISABLE KEYS;
879
1152
ALTER TABLE t1 ENABLE KEYS;
880
 
CHECK TABLE t1;
 
1153
SET @@myisam_repair_threads=1;
 
1154
CHECK TABLE t1 EXTENDED;
881
1155
DROP TABLE t1;
882
1156
 
883
1157
#
884
1158
# Bug#28837: MyISAM storage engine error (134) doing delete with self-join
885
1159
#
886
 
# DRIZZLE NOTE: Cannot self join on temp tables.
887
 
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;
888
1162
CREATE TABLE t2 LIKE t1;
889
1163
 
890
1164
INSERT INTO t2 (id, ref) VALUES (1,3), (2,1), (3,2), (4,5), (4,4);
892
1166
 
893
1167
SELECT * FROM t1 AS a INNER JOIN t1 AS b USING (id) WHERE a.ref < b.ref;
894
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;
895
1171
 
896
1172
DROP TABLE t1, t2;
897
1173
 
899
1175
 
900
1176
 
901
1177
#
 
1178
# Test of key_block_size
 
1179
#
 
1180
 
 
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;
 
1198
show create table t1;
 
1199
alter table t1 key_block_size=2048;
 
1200
show create table t1;
 
1201
alter table t1 add c int, add key (c);
 
1202
show create table t1;
 
1203
alter table t1 key_block_size=0;
 
1204
alter table t1 add d int, add key (d);
 
1205
show create table t1;
 
1206
drop table t1;
 
1207
 
 
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;
 
1217
show create table t1;
 
1218
drop table t1;
 
1219
 
 
1220
 
 
1221
# Test limits and errors of key_block_size
 
1222
 
 
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));
 
1239
 
 
1240
#
902
1241
# Bug#22119 - Changing MI_KEY_BLOCK_LENGTH makes a wrong myisamchk
903
1242
#
904
 
CREATE temporary TABLE t1 (
 
1243
CREATE TABLE t1 (
905
1244
  c1 INT,
906
1245
  c2 VARCHAR(300),
907
1246
  KEY (c1) KEY_BLOCK_SIZE 1024,
908
1247
  KEY (c2) KEY_BLOCK_SIZE 8192
909
 
  ) ENGINE=MyISAM;
 
1248
  );
910
1249
INSERT INTO t1 VALUES (10, REPEAT('a', CEIL(RAND(10) * 300))),
911
1250
  (11, REPEAT('b', CEIL(RAND() * 300))),
912
1251
  (12, REPEAT('c', CEIL(RAND() * 300))),
933
1272
  (33, REPEAT('x', CEIL(RAND() * 300))),
934
1273
  (34, REPEAT('y', CEIL(RAND() * 300))),
935
1274
  (35, REPEAT('z', CEIL(RAND() * 300)));
936
 
CREATE TEMPORARY TABLE t2 AS SELECT * FROM t1;
937
 
INSERT INTO t1 SELECT * FROM t2;
938
 
DROP TABLE t2;
939
 
CREATE TEMPORARY TABLE t2 AS SELECT * FROM t1;
940
 
INSERT INTO t1 SELECT * FROM t2;
941
 
DROP TABLE t2;
 
1275
INSERT INTO t1 SELECT * FROM t1;
 
1276
INSERT INTO t1 SELECT * FROM t1;
942
1277
CHECK TABLE t1;
 
1278
REPAIR TABLE t1;
943
1279
DELETE FROM t1 WHERE c1 >= 10;
944
1280
CHECK TABLE t1;
945
1281
DROP TABLE t1;
951
1287
# Test #1 - CHECK TABLE sees wrong record, REPAR TABLE deletes it.
952
1288
# Using a CHAR column that can have > 127 characters.
953
1289
# Using a VARCHAR to create a table with dynamic row format.
954
 
CREATE temporary TABLE t1 (
 
1290
CREATE TABLE t1 (
955
1291
  c1 CHAR(130),
956
1292
  c2 VARCHAR(1)
957
1293
) ENGINE=MyISAM;
958
1294
INSERT INTO t1 VALUES(REPEAT("a",128), 'b');
959
1295
SELECT COUNT(*) FROM t1;
960
1296
CHECK TABLE t1;
 
1297
REPAIR TABLE t1;
961
1298
SELECT COUNT(*) FROM t1;
962
1299
CHECK TABLE t1;
963
1300
DROP TABLE t1;
965
1302
# Test #2 - same as test #1, but using EXTENDED.
966
1303
# Using a CHAR column that can have > 127 characters.
967
1304
# Using a VARCHAR to create a table with dynamic row format.
968
 
CREATE temporary TABLE t1 (
 
1305
CREATE TABLE t1 (
969
1306
  c1 CHAR(130),
970
1307
  c2 VARCHAR(1)
971
1308
) ENGINE=MyISAM;
972
1309
INSERT INTO t1 VALUES(REPEAT("a",128), 'b');
973
1310
SELECT COUNT(*) FROM t1;
974
 
CHECK TABLE t1;
 
1311
CHECK TABLE t1 EXTENDED;
 
1312
REPAIR TABLE t1 EXTENDED;
975
1313
SELECT COUNT(*) FROM t1;
976
 
CHECK TABLE t1;
 
1314
CHECK TABLE t1 EXTENDED;
977
1315
DROP TABLE t1;
978
1316
#
979
1317
# Test #3 - same as test #1, but using OPTIMIZE TABLE.
980
1318
# Using a CHAR column that can have > 127 characters.
981
1319
# Using a VARCHAR to create a table with dynamic row format.
982
 
CREATE temporary TABLE t1 (
 
1320
CREATE TABLE t1 (
983
1321
  c1 CHAR(130),
984
1322
  c2 VARCHAR(1)
985
1323
) ENGINE=MyISAM;
989
1327
INSERT INTO t1 VALUES('c', 'b');
990
1328
DELETE FROM t1 WHERE c1='b';
991
1329
SELECT COUNT(*) FROM t1;
992
 
ALTER TABLE t1 ENGINE=MyISAM;
 
1330
OPTIMIZE TABLE t1;
993
1331
SELECT COUNT(*) FROM t1;
994
1332
DROP TABLE t1;
995
1333
#
997
1335
# Using a CHAR column that can have > 127 characters.
998
1336
# Using a VARCHAR to create a table with dynamic row format.
999
1337
# Using an index which can be disabled during bulk insert.
1000
 
CREATE temporary TABLE t1 (
 
1338
CREATE TABLE t1 (
1001
1339
  c1 CHAR(130),
1002
1340
  c2 VARCHAR(1),
1003
1341
  KEY (c1)
1024
1362
# With bug present, this shows that all long rows are gone.
1025
1363
SELECT COUNT(*) FROM t1;
1026
1364
CHECK TABLE t1;
1027
 
CHECK TABLE t1;
 
1365
CHECK TABLE t1 EXTENDED;
1028
1366
DROP TABLE t1;
1029
1367
#
1030
1368
# Test #5 - same as test #1 but UTF-8.
1031
1369
# Using a CHAR column that can have > 127 characters.
1032
1370
# Using a VARCHAR to create a table with dynamic row format.
1033
 
CREATE temporary TABLE t1 (
 
1371
CREATE TABLE t1 (
1034
1372
  c1 CHAR(50),
1035
1373
  c2 VARCHAR(1)
1036
 
) ENGINE=MyISAM;
 
1374
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
1037
1375
# Using Tamil Letter A, Unicode U+0B85
1038
 
INSERT INTO t1 VALUES(REPEAT( x'e0ae85',43), 'b');
 
1376
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
1039
1377
SELECT COUNT(*) FROM t1;
1040
1378
CHECK TABLE t1;
 
1379
REPAIR TABLE t1;
1041
1380
SELECT COUNT(*) FROM t1;
1042
1381
CHECK TABLE t1;
1043
1382
DROP TABLE t1;
1045
1384
# Test #6 - same as test #2, but UTF-8.
1046
1385
# Using a CHAR column that can have > 127 characters.
1047
1386
# Using a VARCHAR to create a table with dynamic row format.
1048
 
CREATE temporary TABLE t1 (
 
1387
CREATE TABLE t1 (
1049
1388
  c1 CHAR(50),
1050
1389
  c2 VARCHAR(1)
1051
 
) ENGINE=MyISAM;
 
1390
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
1052
1391
# Using Tamil Letter A, Unicode U+0B85
1053
 
INSERT INTO t1 VALUES(REPEAT( x'e0ae85',43), 'b');
1054
 
SELECT COUNT(*) FROM t1;
1055
 
CHECK TABLE t1;
1056
 
SELECT COUNT(*) FROM t1;
1057
 
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;
1058
1398
DROP TABLE t1;
1059
1399
#
1060
1400
# Test #7 - same as test #3, but UTF-8.
1061
1401
# Using a CHAR column that can have > 127 characters.
1062
1402
# Using a VARCHAR to create a table with dynamic row format.
1063
 
CREATE temporary TABLE t1 (
 
1403
CREATE TABLE t1 (
1064
1404
  c1 CHAR(50),
1065
1405
  c2 VARCHAR(1)
1066
 
) ENGINE=MyISAM;
 
1406
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
1067
1407
# Using Tamil Letter A, Unicode U+0B85
1068
 
INSERT INTO t1 VALUES(REPEAT( x'e0ae85',43), 'b');
 
1408
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
1069
1409
# Insert more rows and delete one in the middle to force optimize.
1070
1410
INSERT INTO t1 VALUES('b', 'b');
1071
1411
INSERT INTO t1 VALUES('c', 'b');
1072
1412
DELETE FROM t1 WHERE c1='b';
1073
1413
SELECT COUNT(*) FROM t1;
1074
 
ALTER TABLE t1 ENGINE=MyISAM;
 
1414
OPTIMIZE TABLE t1;
1075
1415
SELECT COUNT(*) FROM t1;
1076
1416
DROP TABLE t1;
1077
1417
#
1079
1419
# Using a CHAR column that can have > 42 UTF-8 characters.
1080
1420
# Using a VARCHAR to create a table with dynamic row format.
1081
1421
# Using an index which can be disabled during bulk insert.
1082
 
CREATE temporary TABLE t1 (
 
1422
CREATE TABLE t1 (
1083
1423
  c1 CHAR(50),
1084
1424
  c2 VARCHAR(1),
1085
1425
  KEY (c1)
1086
 
) ENGINE=MyISAM;
 
1426
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
1087
1427
#
1088
1428
# Insert 100 rows. This turns bulk insert on during the copy phase of
1089
1429
# ALTER TABLE. Bulk insert disables keys before the insert and re-enables
1100
1440
#
1101
1441
# Change most of the rows into long character values with > 42 characters.
1102
1442
# Using Tamil Letter A, Unicode U+0B85
1103
 
UPDATE t1 SET c1=REPEAT( x'e0ae85',43) LIMIT 90;
 
1443
UPDATE t1 SET c1=REPEAT(_utf8 x'e0ae85',43) LIMIT 90;
1104
1444
SELECT COUNT(*) FROM t1;
1105
1445
ALTER TABLE t1 ENGINE=MyISAM;
1106
1446
#
1107
1447
# With bug present, this shows that all long rows are gone.
1108
1448
SELECT COUNT(*) FROM t1;
1109
1449
CHECK TABLE t1;
1110
 
CHECK TABLE t1;
1111
 
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
 
1112
1467
--echo End of 5.1 tests
1113
1468