~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/myisam.test

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:
12
12
# Test problem with CHECK TABLE;
13
13
#
14
14
 
15
 
CREATE TABLE t1 (
 
15
CREATE TEMPORARY 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 tinyint not null auto_increment, b blob not null, primary key (a));
 
33
create table t1 (a int 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
 
repair table t1;
49
 
delete from t1 where (a & 1);
50
 
check table t1;
51
 
repair 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;
52
56
check table t1;
53
57
drop table t1;
54
58
 
56
60
# Test bug: Two optimize in a row reset index cardinality
57
61
#
58
62
 
59
 
create table t1 (a int not null auto_increment, b int not null, primary key (a), index(b));
 
63
create TEMPORARY table t1 (a int not null auto_increment, b int not null, primary key (a), index(b)) ENGINE=MYISAM;
60
64
insert into t1 (b) values (1),(2),(2),(2),(2);
61
 
optimize table t1;
 
65
alter table t1 engine=MYISAM;
62
66
show index from t1;
63
 
optimize table t1;
 
67
alter table t1 engine=MyISAM;
64
68
show index from t1;
65
69
drop table t1;
66
70
 
68
72
# Test of how ORDER BY works when doing it on the whole table
69
73
#
70
74
 
71
 
create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=myisam;
 
75
create temporary table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=myisam;
72
76
insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
73
77
explain select * from t1 order by a;
74
78
explain select * from t1 order by b;
81
85
drop table t1;
82
86
 
83
87
#
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
 
#
94
88
# Test of optimize, when only mi_sort_index (but not mi_repair*) is done
95
89
# in ha_myisam::repair, and index size is changed (decreased).
96
90
#
97
91
 
98
 
create table t1 ( t1 char(255), key(t1(250)));
 
92
create temporary table t1 ( t1 char(255), key(t1(250))) ENGINE=MYISAM;
99
93
insert t1 values ('137513751375137513751375137513751375137569516951695169516951695169516951695169');
100
94
insert t1 values ('178417841784178417841784178417841784178403420342034203420342034203420342034203');
101
95
insert t1 values ('213872387238723872387238723872387238723867376737673767376737673767376737673767');
125
119
insert t1 values ('70'), ('84'), ('60'), ('20'), ('76'), ('89'), ('49'), ('50'),
126
120
('88'), ('61'), ('42'), ('98'), ('39'), ('30'), ('25'), ('66'), ('61'), ('48'),
127
121
('80'), ('84'), ('98'), ('19'), ('91'), ('42'), ('47');
128
 
optimize table t1;
 
122
alter table t1 ENGINE=myisam;
129
123
check table t1;
130
124
drop table t1;
131
125
 
133
127
# test of myisam with huge number of packed fields
134
128
#
135
129
 
136
 
create table t1 (i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8
 
130
create temporary table t1 (i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8
137
131
int, i9 int, i10 int, i11 int, i12 int, i13 int, i14 int, i15 int, i16 int, i17
138
132
int, i18 int, i19 int, i20 int, i21 int, i22 int, i23 int, i24 int, i25 int,
139
133
i26 int, i27 int, i28 int, i29 int, i30 int, i31 int, i32 int, i33 int, i34
257
251
int, i975 int, i976 int, i977 int, i978 int, i979 int, i980 int, i981 int, i982
258
252
int, i983 int, i984 int, i985 int, i986 int, i987 int, i988 int, i989 int, i990
259
253
int, i991 int, i992 int, i993 int, i994 int, i995 int, i996 int, i997 int, i998
260
 
int, i999 int, i1000 int, b blob) row_format=dynamic;
 
254
int, i999 int, i1000 int, b blob) engine=myisam row_format=dynamic;
261
255
insert into t1 values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
262
256
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,
263
257
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,
308
302
#
309
303
# Test of REPAIR that once failed
310
304
#
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',
 
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,
315
309
  `post_text` text NOT NULL,
316
310
  `icon_url` varchar(10) NOT NULL default '',
317
 
  `sign` tinyint(1) unsigned NOT NULL default '0',
 
311
  `sign` int NOT NULL default '0',
318
312
  `post_edit` varchar(150) NOT NULL default '',
319
313
  `poster_login` varchar(35) NOT NULL default '',
320
314
  `ip` varchar(15) NOT NULL default '',
322
316
  KEY `post_time` (`post_time`),
323
317
  KEY `ip` (`ip`),
324
318
  KEY `poster_login` (`poster_login`),
325
 
  KEY `topic_id` (`topic_id`),
326
 
  FULLTEXT KEY `post_text` (`post_text`)
 
319
  KEY `topic_id` (`topic_id`)
 
320
#  FULLTEXT KEY `post_text` (`post_text`)
327
321
) ENGINE=MyISAM;
328
322
 
329
323
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');
330
324
 
331
 
REPAIR TABLE t1;
332
325
CHECK TABLE t1;
333
326
drop table t1;
334
327
 
337
330
#
338
331
 
339
332
--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));
 
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;
342
335
--error 1071
343
336
ALTER TABLE t1 ADD INDEX t1 (a, b, c, d, e);
344
337
DROP TABLE t1;
347
340
# Test of cardinality of keys with NULL
348
341
#
349
342
 
350
 
CREATE TABLE t1 (a int not null, b int, c int, key(b), key(c), key(a,b), key(c,a));
 
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;
351
344
INSERT into t1 values (0, null, 0), (0, null, 1), (0, null, 2), (0, null,3), (1,1,4);
352
345
create table t2 (a int not null, b int, c int, key(b), key(c), key(a));
353
346
INSERT into t2 values (1,1,1), (2,2,2);
354
 
optimize table t1;
 
347
alter table t1 ENGINE=MYISAM;
355
348
show index from t1;
356
349
explain select * from t1,t2 where t1.a=t2.a;
357
350
explain select * from t1,t2 force index(a) where t1.a=t2.a;
371
364
create table t1 (a int not null auto_increment primary key, b varchar(255));
372
365
insert into t1 (b) values (repeat('a',100)),(repeat('b',100)),(repeat('c',100));
373
366
update t1 set b=repeat(left(b,1),200) where a=1;
374
 
delete from t1 where (a & 1)= 0;
 
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;
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(($1 & 32)+65), $1));
 
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));
388
393
  dec $1;
389
394
}
390
395
enable_query_log;
401
406
#
402
407
# two bugs in myisam-space-stripping feature
403
408
#
404
 
create table t1 ( a text not null, key a (a(20)));
 
409
create temporary table t1 ( a text not null, key a (a(20))) engine=myisam;
405
410
insert into t1 values ('aaa   '),('aaa'),('aa');
406
411
check table t1;
407
 
repair table t1;
408
412
select concat(a,'.') from t1 where a='aaa';
409
413
select concat(a,'.') from t1 where binary a='aaa';
410
414
update t1 set a='bbb' where a='aaa';
415
419
# Third bug in the same code (BUG#2295)
416
420
#
417
421
 
418
 
create table t1(a text not null, b text not null, c text not null, index (a(10),b(10),c(10)));
 
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;
419
423
insert into t1 values('807780', '477', '165');
420
424
insert into t1 values('807780', '477', '162');
421
425
insert into t1 values('807780', '472', '162');
426
430
# space-stripping in _mi_prefix_search: BUG#5284
427
431
#
428
432
DROP TABLE IF EXISTS t1;
429
 
CREATE TABLE t1 (a varchar(150) NOT NULL, KEY (a)); 
 
433
CREATE TEMPORARY TABLE t1 (a varchar(150) NOT NULL, KEY (a)) ENGINE=MyISAM; 
430
434
INSERT t1 VALUES ("can \tcan"); 
431
435
INSERT t1 VALUES ("can   can"); 
432
436
INSERT t1 VALUES ("can"); 
479
483
#
480
484
# Bug#14616 - Freshly imported table returns error 124 when using LIMIT
481
485
#
482
 
create table t1 (
 
486
create temporary table t1 (
483
487
  c1 varchar(32),
484
488
  key (c1)
485
489
) engine=myisam;
488
492
select c1 from t1 order by c1 limit 1;
489
493
drop table t1;
490
494
 
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
 
 
527
495
# End of 4.0 tests
528
496
 
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;
 
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);
540
499
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
541
500
insert t2 select * from t1;
542
 
checksum table t1, t2, t3 quick;
543
 
checksum table t1, t2, t3;
544
 
checksum table t1, t2, t3 extended;
 
501
checksum table t1, t2, t3;
 
502
checksum table t1, t2, t3;
 
503
checksum table t1, t2, t3;
545
504
#show table status;
546
505
drop table t1,t2;
547
506
 
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;
 
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;
570
532
 
571
533
#
572
534
# index search for NULL in blob. Bug #4816
581
543
# bug9188 - Corruption Can't open file: 'table.MYI' (errno: 145)
582
544
#
583
545
create table t1 (c1 int, c2 varchar(4) not null default '',
584
 
                 key(c2(3))) default charset=utf8;
 
546
                 key(c2(3)));
585
547
insert into t1 values (1,'A'), (2, 'B'), (3, 'A');
586
548
update t1 set c2='A  B' where c1=2;
587
549
check table t1;
603
565
checksum table t2;
604
566
drop table t1, t2;
605
567
 
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
 
 
677
568
# BUG#13814 - key value packed incorrectly for TINYBLOBs
678
569
 
679
570
create table t1(
680
571
  cip INT NOT NULL,
681
 
  time TIME NOT NULL,
682
572
  score INT NOT NULL DEFAULT 0,
683
573
  bob TINYBLOB
684
574
);
685
575
 
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');
 
576
insert into t1 (cip) VALUES (1), (2), (3);
 
577
insert into t1 (cip, bob) VALUES (4, 'a' ), (5, 'b'), 
 
578
                                       (6, 'c');
689
579
select * from t1 where bob is null and cip=1;
690
 
create index bug on t1 (bob(22), cip, time);
 
580
create index bug on t1 (bob(22), cip);
691
581
select * from t1 where bob is null and cip=1;
692
582
drop table t1;
693
583
 
694
584
#
695
585
# Bug#14980 - COUNT(*) incorrect on MyISAM table with certain INDEX
696
586
#
697
 
create table t1 (
 
587
create temporary table t1 (
698
588
  id1 int not null auto_increment,
699
589
  id2 int not null default '0',
700
590
  t text not null,
713
603
# BUG##20357 - Got error 124 from storage engine using MIN and MAX functions
714
604
#              in queries
715
605
#
716
 
CREATE TABLE t1(a TINYINT, KEY(a)) ENGINE=MyISAM;
 
606
CREATE TEMPORARY TABLE t1(a int, KEY(a)) ENGINE=MyISAM;
717
607
INSERT INTO t1 VALUES(1);
718
608
SELECT MAX(a) FROM t1 IGNORE INDEX(a);
719
609
ALTER TABLE t1 DISABLE KEYS;
722
612
DROP TABLE t1;
723
613
 
724
614
#
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
 
#
734
615
# Bug#8283 - OPTIMIZE TABLE causes data loss
735
616
#
736
 
SET @@myisam_repair_threads=2;
 
617
SET GLOBAL myisam_repair_threads=2;
737
618
SHOW VARIABLES LIKE 'myisam_repair%';
738
619
#
739
620
# Test OPTIMIZE. This creates a new data file.
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;
 
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;
824
663
SHOW VARIABLES LIKE 'myisam_repair%';
825
664
 
826
665
#
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
 
#
846
666
# Bug#24607 - MyISAM pointer size determined incorrectly
847
667
#
848
 
CREATE TABLE t1 (c1 TEXT) AVG_ROW_LENGTH=70100 MAX_ROWS=4100100100;
 
668
CREATE TEMPORARY TABLE t1 (c1 TEXT) ENGINE=MyISAM;
849
669
--replace_column 5 X 6 X 7 X 9 X 10 X 11 X 12 X 13 X 14 X 16 X
850
670
SHOW TABLE STATUS LIKE 't1';
851
671
DROP TABLE t1;
854
674
# Bug#26231 - select count(*) on myisam table returns wrong value
855
675
#             when index is used
856
676
#
857
 
CREATE TABLE t1 (c1 TEXT NOT NULL, KEY c1 (c1(10))) ENGINE=MyISAM;
 
677
CREATE TEMPORARY TABLE t1 (c1 TEXT NOT NULL, KEY c1 (c1(10))) ENGINE=MyISAM;
858
678
# Fill at least two key blocks. "Tab, A" must be in both blocks. 
859
679
INSERT INTO t1 VALUES
860
680
  (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
1002
822
 
1003
823
let $default=`select @@storage_engine`;
1004
824
set storage_engine=MyISAM;
 
825
let $temp= TEMPORARY;
1005
826
source include/varchar.inc;
1006
827
 
1007
828
#
1008
829
# Some errors/warnings on create
1009
830
#
1010
831
 
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;
 
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));
1019
838
 
1020
839
# MyISAM specific varchar tests
1021
 
--error 1118
1022
 
create table t1 (v varchar(65535));
 
840
--error 1074
 
841
create temporary table t1 (v varchar(65535));
1023
842
 
1024
843
eval set storage_engine=$default;
1025
844
 
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
 
 
1082
845
 
1083
846
# BUG#9622 - ANALYZE TABLE and ALTER TABLE .. ENABLE INDEX produce
1084
847
# different statistics on the same table with NULL values.
1096
859
 
1097
860
 
1098
861
#
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
 
#
1110
862
# Bug#28476: force index on a disabled myisam index gives error 124
1111
863
#
1112
 
CREATE TABLE t1(a INT, b INT, KEY inx (a), UNIQUE KEY uinx (b)) ENGINE=MyISAM;
 
864
CREATE TEMPORARY TABLE t1(a INT, b INT, KEY inx (a), UNIQUE KEY uinx (b)) ENGINE=MyISAM;
1113
865
INSERT INTO t1(a,b) VALUES (1,1),(2,2),(3,3),(4,4),(5,5);
1114
866
SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1;
1115
867
ALTER TABLE t1 DISABLE KEYS;
1125
877
#
1126
878
# Bug#4692 - DISABLE/ENABLE KEYS waste a space
1127
879
#
1128
 
CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE INDEX (c1), INDEX (c2)) ENGINE=MYISAM;
 
880
CREATE TEMPORARY TABLE t1 (c1 INT, c2 INT, UNIQUE INDEX (c1), INDEX (c2)) ENGINE=MYISAM;
1129
881
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
1130
882
SHOW TABLE STATUS LIKE 't1';
1131
883
INSERT INTO t1 VALUES (1,1);
1147
899
#--exec myisamchk -dvv var/master-data/test/t1.MYI
1148
900
#--exec myisamchk -iev var/master-data/test/t1.MYI
1149
901
--echo # Enable keys with parallel repair
1150
 
SET @@myisam_repair_threads=2;
 
902
SET GLOBAL myisam_repair_threads=2;
1151
903
ALTER TABLE t1 DISABLE KEYS;
1152
904
ALTER TABLE t1 ENABLE KEYS;
1153
 
SET @@myisam_repair_threads=1;
1154
 
CHECK TABLE t1 EXTENDED;
 
905
SET GLOBAL myisam_repair_threads=1;
 
906
CHECK TABLE t1;
1155
907
DROP TABLE t1;
1156
908
 
1157
909
#
1158
910
# Bug#28837: MyISAM storage engine error (134) doing delete with self-join
1159
911
#
1160
 
 
1161
 
CREATE TABLE t1 (id int NOT NULL, ref int NOT NULL, INDEX (id)) ENGINE=MyISAM;
 
912
# DRIZZLE NOTE: Cannot self join on temp tables.
 
913
CREATE TABLE t1 (id int NOT NULL, ref int NOT NULL, INDEX (id));
1162
914
CREATE TABLE t2 LIKE t1;
1163
915
 
1164
916
INSERT INTO t2 (id, ref) VALUES (1,3), (2,1), (3,2), (4,5), (4,4);
1166
918
 
1167
919
SELECT * FROM t1 AS a INNER JOIN t1 AS b USING (id) WHERE a.ref < b.ref;
1168
920
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;
1171
921
 
1172
922
DROP TABLE t1, t2;
1173
923
 
1178
928
# Test of key_block_size
1179
929
#
1180
930
 
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;
 
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;
1198
948
show create table t1;
1199
949
alter table t1 key_block_size=2048;
1200
950
show create table t1;
1205
955
show create table t1;
1206
956
drop table t1;
1207
957
 
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;
 
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;
1217
967
show create table t1;
1218
968
drop table t1;
1219
969
 
1220
970
 
1221
971
# Test limits and errors of key_block_size
1222
972
 
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));
 
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;
1239
989
 
1240
990
#
1241
991
# Bug#22119 - Changing MI_KEY_BLOCK_LENGTH makes a wrong myisamchk
1242
992
#
1243
 
CREATE TABLE t1 (
 
993
CREATE temporary TABLE t1 (
1244
994
  c1 INT,
1245
995
  c2 VARCHAR(300),
1246
996
  KEY (c1) KEY_BLOCK_SIZE 1024,
1247
997
  KEY (c2) KEY_BLOCK_SIZE 8192
1248
 
  );
 
998
  ) ENGINE=MyISAM;
1249
999
INSERT INTO t1 VALUES (10, REPEAT('a', CEIL(RAND(10) * 300))),
1250
1000
  (11, REPEAT('b', CEIL(RAND() * 300))),
1251
1001
  (12, REPEAT('c', CEIL(RAND() * 300))),
1272
1022
  (33, REPEAT('x', CEIL(RAND() * 300))),
1273
1023
  (34, REPEAT('y', CEIL(RAND() * 300))),
1274
1024
  (35, REPEAT('z', CEIL(RAND() * 300)));
1275
 
INSERT INTO t1 SELECT * FROM t1;
1276
 
INSERT INTO t1 SELECT * FROM t1;
 
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;
1277
1031
CHECK TABLE t1;
1278
 
REPAIR TABLE t1;
1279
1032
DELETE FROM t1 WHERE c1 >= 10;
1280
1033
CHECK TABLE t1;
1281
1034
DROP TABLE t1;
1287
1040
# Test #1 - CHECK TABLE sees wrong record, REPAR TABLE deletes it.
1288
1041
# Using a CHAR column that can have > 127 characters.
1289
1042
# Using a VARCHAR to create a table with dynamic row format.
1290
 
CREATE TABLE t1 (
 
1043
CREATE temporary TABLE t1 (
1291
1044
  c1 CHAR(130),
1292
1045
  c2 VARCHAR(1)
1293
1046
) ENGINE=MyISAM;
1294
1047
INSERT INTO t1 VALUES(REPEAT("a",128), 'b');
1295
1048
SELECT COUNT(*) FROM t1;
1296
1049
CHECK TABLE t1;
1297
 
REPAIR TABLE t1;
1298
1050
SELECT COUNT(*) FROM t1;
1299
1051
CHECK TABLE t1;
1300
1052
DROP TABLE t1;
1302
1054
# Test #2 - same as test #1, but using EXTENDED.
1303
1055
# Using a CHAR column that can have > 127 characters.
1304
1056
# Using a VARCHAR to create a table with dynamic row format.
1305
 
CREATE TABLE t1 (
 
1057
CREATE temporary TABLE t1 (
1306
1058
  c1 CHAR(130),
1307
1059
  c2 VARCHAR(1)
1308
1060
) ENGINE=MyISAM;
1309
1061
INSERT INTO t1 VALUES(REPEAT("a",128), 'b');
1310
1062
SELECT COUNT(*) FROM t1;
1311
 
CHECK TABLE t1 EXTENDED;
1312
 
REPAIR TABLE t1 EXTENDED;
 
1063
CHECK TABLE t1;
1313
1064
SELECT COUNT(*) FROM t1;
1314
 
CHECK TABLE t1 EXTENDED;
 
1065
CHECK TABLE t1;
1315
1066
DROP TABLE t1;
1316
1067
#
1317
1068
# Test #3 - same as test #1, but using OPTIMIZE TABLE.
1318
1069
# Using a CHAR column that can have > 127 characters.
1319
1070
# Using a VARCHAR to create a table with dynamic row format.
1320
 
CREATE TABLE t1 (
 
1071
CREATE temporary TABLE t1 (
1321
1072
  c1 CHAR(130),
1322
1073
  c2 VARCHAR(1)
1323
1074
) ENGINE=MyISAM;
1327
1078
INSERT INTO t1 VALUES('c', 'b');
1328
1079
DELETE FROM t1 WHERE c1='b';
1329
1080
SELECT COUNT(*) FROM t1;
1330
 
OPTIMIZE TABLE t1;
 
1081
ALTER TABLE t1 ENGINE=MyISAM;
1331
1082
SELECT COUNT(*) FROM t1;
1332
1083
DROP TABLE t1;
1333
1084
#
1335
1086
# Using a CHAR column that can have > 127 characters.
1336
1087
# Using a VARCHAR to create a table with dynamic row format.
1337
1088
# Using an index which can be disabled during bulk insert.
1338
 
CREATE TABLE t1 (
 
1089
CREATE temporary TABLE t1 (
1339
1090
  c1 CHAR(130),
1340
1091
  c2 VARCHAR(1),
1341
1092
  KEY (c1)
1362
1113
# With bug present, this shows that all long rows are gone.
1363
1114
SELECT COUNT(*) FROM t1;
1364
1115
CHECK TABLE t1;
1365
 
CHECK TABLE t1 EXTENDED;
 
1116
CHECK TABLE t1;
1366
1117
DROP TABLE t1;
1367
1118
#
1368
1119
# Test #5 - same as test #1 but UTF-8.
1369
1120
# Using a CHAR column that can have > 127 characters.
1370
1121
# Using a VARCHAR to create a table with dynamic row format.
1371
 
CREATE TABLE t1 (
 
1122
CREATE temporary TABLE t1 (
1372
1123
  c1 CHAR(50),
1373
1124
  c2 VARCHAR(1)
1374
 
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
 
1125
) ENGINE=MyISAM;
1375
1126
# Using Tamil Letter A, Unicode U+0B85
1376
 
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
 
1127
INSERT INTO t1 VALUES(REPEAT( x'e0ae85',43), 'b');
1377
1128
SELECT COUNT(*) FROM t1;
1378
1129
CHECK TABLE t1;
1379
 
REPAIR TABLE t1;
1380
1130
SELECT COUNT(*) FROM t1;
1381
1131
CHECK TABLE t1;
1382
1132
DROP TABLE t1;
1384
1134
# Test #6 - same as test #2, but UTF-8.
1385
1135
# Using a CHAR column that can have > 127 characters.
1386
1136
# Using a VARCHAR to create a table with dynamic row format.
1387
 
CREATE TABLE t1 (
 
1137
CREATE temporary TABLE t1 (
1388
1138
  c1 CHAR(50),
1389
1139
  c2 VARCHAR(1)
1390
 
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
 
1140
) ENGINE=MyISAM;
1391
1141
# Using Tamil Letter A, Unicode U+0B85
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;
 
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;
1398
1147
DROP TABLE t1;
1399
1148
#
1400
1149
# Test #7 - same as test #3, but UTF-8.
1401
1150
# Using a CHAR column that can have > 127 characters.
1402
1151
# Using a VARCHAR to create a table with dynamic row format.
1403
 
CREATE TABLE t1 (
 
1152
CREATE temporary TABLE t1 (
1404
1153
  c1 CHAR(50),
1405
1154
  c2 VARCHAR(1)
1406
 
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
 
1155
) ENGINE=MyISAM;
1407
1156
# Using Tamil Letter A, Unicode U+0B85
1408
 
INSERT INTO t1 VALUES(REPEAT(_utf8 x'e0ae85',43), 'b');
 
1157
INSERT INTO t1 VALUES(REPEAT( x'e0ae85',43), 'b');
1409
1158
# Insert more rows and delete one in the middle to force optimize.
1410
1159
INSERT INTO t1 VALUES('b', 'b');
1411
1160
INSERT INTO t1 VALUES('c', 'b');
1412
1161
DELETE FROM t1 WHERE c1='b';
1413
1162
SELECT COUNT(*) FROM t1;
1414
 
OPTIMIZE TABLE t1;
 
1163
ALTER TABLE t1 ENGINE=MyISAM;
1415
1164
SELECT COUNT(*) FROM t1;
1416
1165
DROP TABLE t1;
1417
1166
#
1419
1168
# Using a CHAR column that can have > 42 UTF-8 characters.
1420
1169
# Using a VARCHAR to create a table with dynamic row format.
1421
1170
# Using an index which can be disabled during bulk insert.
1422
 
CREATE TABLE t1 (
 
1171
CREATE temporary TABLE t1 (
1423
1172
  c1 CHAR(50),
1424
1173
  c2 VARCHAR(1),
1425
1174
  KEY (c1)
1426
 
) ENGINE=MyISAM DEFAULT CHARSET UTF8;
 
1175
) ENGINE=MyISAM;
1427
1176
#
1428
1177
# Insert 100 rows. This turns bulk insert on during the copy phase of
1429
1178
# ALTER TABLE. Bulk insert disables keys before the insert and re-enables
1440
1189
#
1441
1190
# Change most of the rows into long character values with > 42 characters.
1442
1191
# Using Tamil Letter A, Unicode U+0B85
1443
 
UPDATE t1 SET c1=REPEAT(_utf8 x'e0ae85',43) LIMIT 90;
 
1192
UPDATE t1 SET c1=REPEAT( x'e0ae85',43) LIMIT 90;
1444
1193
SELECT COUNT(*) FROM t1;
1445
1194
ALTER TABLE t1 ENGINE=MyISAM;
1446
1195
#
1447
1196
# With bug present, this shows that all long rows are gone.
1448
1197
SELECT COUNT(*) FROM t1;
1449
1198
CHECK 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
 
 
 
1199
CHECK TABLE t1;
 
1200
DROP TABLE t1;
1467
1201
--echo End of 5.1 tests
1468
1202