60
60
# Test bug: Two optimize in a row reset index cardinality
63
create TEMPORARY table t1 (a int not null auto_increment, b int not null, primary key (a), index(b)) ENGINE=MYISAM;
63
create table t1 (a int not null auto_increment, b int not null, primary key (a), index(b));
64
64
insert into t1 (b) values (1),(2),(2),(2),(2);
65
alter table t1 engine=MYISAM;
66
66
show index from t1;
67
alter table t1 engine=MyISAM;
68
68
show index from t1;
72
72
# Test of how ORDER BY works when doing it on the whole table
75
create temporary table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=myisam;
75
create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=myisam;
76
76
insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
77
77
explain select * from t1 order by a;
78
78
explain select * from t1 order by b;
119
119
insert t1 values ('70'), ('84'), ('60'), ('20'), ('76'), ('89'), ('49'), ('50'),
120
120
('88'), ('61'), ('42'), ('98'), ('39'), ('30'), ('25'), ('66'), ('61'), ('48'),
121
121
('80'), ('84'), ('98'), ('19'), ('91'), ('42'), ('47');
122
alter table t1 ENGINE=myisam;
127
127
# test of myisam with huge number of packed fields
130
create temporary table t1 (i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8
130
create table t1 (i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8
131
131
int, i9 int, i10 int, i11 int, i12 int, i13 int, i14 int, i15 int, i16 int, i17
132
132
int, i18 int, i19 int, i20 int, i21 int, i22 int, i23 int, i24 int, i25 int,
133
133
i26 int, i27 int, i28 int, i29 int, i30 int, i31 int, i32 int, i33 int, i34
329
329
# Test of creating table with too long key
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
333
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)) ENGINE=MyISAM;
334
CREATE TABLE t1 (a varchar(300), b varchar(300), c varchar(300), d varchar(300), e varchar(300)) ENGINE=MyISAM;
336
336
ALTER TABLE t1 ADD INDEX t1 (a, b, c, d, e);
340
340
# Test of cardinality of keys with NULL
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;
343
CREATE TABLE t1 (a int not null, b int, c int, key(b), key(c), key(a,b), key(c,a)) ENGINE=MyISAM;
344
344
INSERT into t1 values (0, null, 0), (0, null, 1), (0, null, 2), (0, null,3), (1,1,4);
345
create temporary table t2 (a int not null, b int, c int, key(b), key(c), key(a)) engine=myisam;
345
create table t2 (a int not null, b int, c int, key(b), key(c), key(a));
346
346
INSERT into t2 values (1,1,1), (2,2,2);
347
alter table t1 ENGINE=MYISAM;
348
348
show index from t1;
349
349
explain select * from t1,t2 where t1.a=t2.a;
350
350
explain select * from t1,t2 force index(a) where t1.a=t2.a;
419
419
# Third bug in the same code (BUG#2295)
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;
422
create table t1(a text not null, b text not null, c text not null, index (a(10),b(10),c(10)));
423
423
insert into t1 values('807780', '477', '165');
424
424
insert into t1 values('807780', '477', '162');
425
425
insert into t1 values('807780', '472', '162');
495
495
# End of 4.0 tests
497
create temporary table t1 (a int, b varchar(200), c text not null) engine=myisam;
498
create temporary table t2 (a int, b varchar(200), c text not null) engine=myisam;
497
create table t1 (a int, b varchar(200), c text not null) checksum=1;
498
create table t2 (a int, b varchar(200), c text not null) checksum=0;
499
499
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
500
500
insert t2 select * from t1;
501
--replace_column 1 # 6 # 7 # 8 # 9 # 10 #
501
checksum table t1, t2, t3 quick;
502
checksum table t1, t2, t3;
503
checksum table t1, t2, t3 extended;
503
505
drop table t1,t2;
505
507
#@TODO Figure out what the heck the below is testing.
541
543
# bug9188 - Corruption Can't open file: 'table.MYI' (errno: 145)
543
create temporary table t1 (c1 int, c2 varchar(4) not null default '',
544
key(c2(3))) engine=myisam;
545
create table t1 (c1 int, c2 varchar(4) not null default '',
545
547
insert into t1 values (1,'A'), (2, 'B'), (3, 'A');
546
548
update t1 set c2='A B' where c1=2;
554
# Bug#12296 - CHECKSUM TABLE reports 0 for the table
555
# This happened if the first record was marked as deleted.
557
create table t1 (c1 int);
558
insert into t1 values (1),(2),(3),(4);
560
delete from t1 where c1 = 1;
561
create table t2 as select * from t1;
562
# The following returns 0 with the bug in place.
564
# The above should give the same number as the following.
569
# BUG#12232: New myisam_stats_method variable.
571
# @TODO The following segfaults. Disabling for now - JRP
573
#show variables like 'myisam_stats_method';
575
#create table t1 (a int, key(a));
576
#insert into t1 values (0),(1),(2),(3),(4);
577
#insert into t1 select NULL from t1;
579
# default: NULLs considered inequal
582
#insert into t1 values (11);
583
#delete from t1 where a=11;
587
# Set nulls to be equal:
588
#set myisam_stats_method=nulls_equal;
589
#show variables like 'myisam_stats_method';
590
#insert into t1 values (11);
591
#delete from t1 where a=11;
596
#insert into t1 values (11);
597
#delete from t1 where a=11;
602
# Set nulls back to be equal
603
#set myisam_stats_method=DEFAULT;
604
#show variables like 'myisam_stats_method';
605
#insert into t1 values (11);
606
#delete from t1 where a=11;
611
#insert into t1 values (11);
612
#delete from t1 where a=11;
619
# WL#2609, CSC#XXXX: MyISAM
620
#set myisam_stats_method=nulls_ignored;
621
#show variables like 'myisam_stats_method';
624
# a char(3), b char(4), c char(5), d char(6),
627
#insert into t1 values ('bcd','def1', NULL, 'zz');
628
#insert into t1 values ('bcd','def2', NULL, 'zz');
629
#insert into t1 values ('bce','def1', 'yuu', NULL);
630
#insert into t1 values ('bce','def2', NULL, 'quux');
637
#set myisam_stats_method=DEFAULT;
550
640
# BUG#13814 - key value packed incorrectly for TINYBLOBs
552
create temporary table t1(
553
643
cip INT NOT NULL,
554
644
score INT NOT NULL DEFAULT 0,
558
648
insert into t1 (cip) VALUES (1), (2), (3);
559
649
insert into t1 (cip, bob) VALUES (4, 'a' ), (5, 'b'),
687
# BUG#18036 - update of table joined to self reports table as crashed
689
CREATE TABLE t1(a CHAR(9), b VARCHAR(7)) ENGINE=MyISAM;
690
INSERT INTO t1(a) VALUES('xxxxxxxxx'),('xxxxxxxxx');
691
UPDATE t1 AS ta1,t1 AS ta2 SET ta1.b='aaaaaa',ta2.b='bbbbbb';
597
696
# Bug#8283 - OPTIMIZE TABLE causes data loss
698
SET GLOBAL myisam_repair_threads=2;
699
SHOW VARIABLES LIKE 'myisam_repair%';
599
701
# Test OPTIMIZE. This creates a new data file.
600
CREATE TEMPORARY TABLE t1 (
601
703
`_id` int NOT NULL default '0',
629
731
SELECT _id FROM t1;
630
732
DELETE FROM t1 WHERE _id < 8;
631
--replace_column 1 # 6 # 7 # 8 # 9 # 10 #
632
show table status LIKE 't1';
634
ALTER TABLE t1 ENGINE=MYISAM;
636
--replace_column 1 # 6 # 7 # 8 # 9 # 10 #
637
show table status LIKE 't1';
733
--replace_column 6 # 7 # 8 # 9 # 11 # 12 # 13 # 14 # 15 # 16 #
734
SHOW TABLE STATUS LIKE 't1';
735
CHECK TABLE t1 EXTENDED;
737
CHECK TABLE t1 EXTENDED;
738
--replace_column 6 # 7 # 8 # 9 # 11 # 12 # 13 # 14 # 15 # 16 #
739
SHOW TABLE STATUS LIKE 't1';
638
740
SELECT _id FROM t1;
743
SET GLOBAL myisam_repair_threads=1;
744
SHOW VARIABLES LIKE 'myisam_repair%';
747
# BUG#21310 - Trees in SQL causing a "crashed" table with MyISAM storage
751
# A simplified test case that reflect crashed table issue.
752
CREATE TABLE t1(a VARCHAR(16)) ENGINE=MyISAM;
753
INSERT INTO t1 VALUES('aaaaaaaa'),(NULL);
754
UPDATE t1 AS ta1, t1 AS ta2 SET ta1.a='aaaaaaaaaaaaaaaa';
758
# A test case that reflect wrong result set.
759
CREATE TABLE t1(a INT) ENGINE=MyISAM;
760
INSERT INTO t1 VALUES(1),(2);
761
UPDATE t1,t1 AS t2 SET t1.a=t1.a+2 WHERE t1.a=t2.a-1;
762
SELECT * FROM t1 ORDER BY a;
642
766
# Bug#24607 - MyISAM pointer size determined incorrectly
644
CREATE TEMPORARY TABLE t1 (c1 TEXT) ENGINE=MyISAM;
645
--replace_column 1 # 6 # 7 # 8 # 9 # 10 #
646
show table status like 't1';
768
CREATE TABLE t1 (c1 TEXT) ENGINE=MyISAM AVG_ROW_LENGTH=70100 MAX_ROWS=4100100100;
769
--replace_column 5 X 6 X 7 X 9 X 10 X 11 X 12 X 13 X 14 X 16 X
770
SHOW TABLE STATUS LIKE 't1';
650
774
# Bug#26231 - select count(*) on myisam table returns wrong value
651
775
# when index is used
653
CREATE TEMPORARY TABLE t1 (c1 TEXT NOT NULL, KEY c1 (c1(10))) ENGINE=MyISAM;
777
CREATE TABLE t1 (c1 TEXT NOT NULL, KEY c1 (c1(10))) ENGINE=MyISAM;
654
778
# Fill at least two key blocks. "Tab, A" must be in both blocks.
655
779
INSERT INTO t1 VALUES
656
780
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
799
923
let $default=`select @@storage_engine`;
800
924
set storage_engine=MyISAM;
801
let $temp= TEMPORARY;
802
925
source include/varchar.inc;
805
928
# Some errors/warnings on create
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));
932
create table t1 (v varchar(65530), key(v));
934
create table t1 (v varchar(65536));
936
create table t1 (v varchar(65530));
815
938
# MyISAM specific varchar tests
816
--error ER_TOO_BIG_FIELDLENGTH
817
create temporary table t1 (v varchar(65535));
940
create table t1 (v varchar(65535));
819
942
eval set storage_engine=$default;
822
945
# BUG#9622 - ANALYZE TABLE and ALTER TABLE .. ENABLE INDEX produce
823
946
# different statistics on the same table with NULL values.
824
create temporary table t1 (a int, key(a)) engine=myisam;
947
create table t1 (a int, key(a));
826
949
insert into t1 values (1),(2),(3),(4),(NULL),(NULL),(NULL),(NULL);
827
950
analyze table t1;
961
# Bug#10056 - PACK_KEYS option take values greater than 1 while creating table
963
create table t1 (c1 int) engine=myisam pack_keys=0;
964
create table t2 (c1 int) engine=myisam pack_keys=1;
965
create table t3 (c1 int) engine=myisam pack_keys=default;
967
create table t4 (c1 int) engine=myisam pack_keys=2;
968
drop table t1, t2, t3;
838
972
# Bug#28476: force index on a disabled myisam index gives error 124
840
CREATE TEMPORARY TABLE t1(a INT, b INT, KEY inx (a), UNIQUE KEY uinx (b)) ENGINE=MyISAM;
974
CREATE TABLE t1(a INT, b INT, KEY inx (a), UNIQUE KEY uinx (b)) ENGINE=MyISAM;
841
975
INSERT INTO t1(a,b) VALUES (1,1),(2,2),(3,3),(4,4),(5,5);
842
976
SELECT a FROM t1 FORCE INDEX (inx) WHERE a=1;
843
977
ALTER TABLE t1 DISABLE KEYS;
854
988
# Bug#4692 - DISABLE/ENABLE KEYS waste a space
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';
990
CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE INDEX (c1), INDEX (c2)) ENGINE=MYISAM;
991
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
992
SHOW TABLE STATUS LIKE 't1';
859
993
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';
994
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
995
SHOW TABLE STATUS LIKE 't1';
996
ALTER TABLE t1 DISABLE KEYS;
997
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
998
SHOW TABLE STATUS LIKE 't1';
999
ALTER TABLE t1 ENABLE KEYS;
1000
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
1001
SHOW TABLE STATUS LIKE 't1';
1002
ALTER TABLE t1 DISABLE KEYS;
1003
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
1004
SHOW TABLE STATUS LIKE 't1';
1005
ALTER TABLE t1 ENABLE KEYS;
1006
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
1007
SHOW TABLE STATUS LIKE 't1';
874
1008
#--exec ls -log var/master-data/test/t1.MYI
875
1009
#--exec myisamchk -dvv var/master-data/test/t1.MYI
876
1010
#--exec myisamchk -iev var/master-data/test/t1.MYI
877
1011
--echo # Enable keys with parallel repair
1012
SET GLOBAL myisam_repair_threads=2;
878
1013
ALTER TABLE t1 DISABLE KEYS;
879
1014
ALTER TABLE t1 ENABLE KEYS;
1015
SET GLOBAL myisam_repair_threads=1;
1016
CHECK TABLE t1 EXTENDED;
884
1020
# Bug#28837: MyISAM storage engine error (134) doing delete with self-join
886
# DRIZZLE NOTE: Cannot self join on temp tables.
887
CREATE TABLE t1 (id int NOT NULL, ref int NOT NULL, INDEX (id));
1023
CREATE TABLE t1 (id int NOT NULL, ref int NOT NULL, INDEX (id)) ENGINE=MyISAM;
888
1024
CREATE TABLE t2 LIKE t1;
890
1026
INSERT INTO t2 (id, ref) VALUES (1,3), (2,1), (3,2), (4,5), (4,4);
1040
# Test of key_block_size
1043
create table t1 (a int not null, key `a` (a) key_block_size=1024) ENGINE=MyISAM;
1044
show create table t1;
1047
create table t1 (a int not null, key `a` (a) key_block_size=2048) ENGINE=MyISAM;
1048
show create table t1;
1051
create table t1 (a varchar(2048), key `a` (a)) ENGINE=MyISAM;
1052
show create table t1;
1055
create table t1 (a varchar(2048), key `a` (a) key_block_size=1024) ENGINE=MyISAM;
1056
show create table t1;
1059
create table t1 (a int not null, b varchar(2048), key (a), key(b)) ENGINE=MyISAM key_block_size=1024;
1060
show create table t1;
1061
alter table t1 key_block_size=2048;
1062
show create table t1;
1063
alter table t1 add c int, add key (c);
1064
show create table t1;
1065
alter table t1 key_block_size=0;
1066
alter table t1 add d int, add key (d);
1067
show create table t1;
1070
create table t1 (a int not null, b varchar(2048), key (a), key(b)) ENGINE=MyISAM key_block_size=8192;
1071
show create table t1;
1074
create table t1 (a int not null, b varchar(2048), key (a) key_block_size=1024, key(b)) ENGINE=MyISAM key_block_size=8192;
1075
show create table t1;
1078
create 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;
1079
show create table t1;
1083
# Test limits and errors of key_block_size
1085
create table t1 (a int not null, key `a` (a) key_block_size=512) ENGINE=MyISAM;
1086
show create table t1;
1089
create table t1 (a varchar(2048), key `a` (a) key_block_size=1000000000000000000) ENGINE=MyISAM;
1090
show create table t1;
1093
create table t1 (a int not null, key `a` (a) key_block_size=1025) ENGINE=MyISAM;
1094
show create table t1;
1098
create table t1 (a int not null, key key_block_size=1024 (a)) ENGINE=MyISAM;
1100
create table t1 (a int not null, key `a` key_block_size=1024 (a)) ENGINE=MyISAM;
902
1103
# Bug#22119 - Changing MI_KEY_BLOCK_LENGTH makes a wrong myisamchk
904
CREATE temporary TABLE t1 (
906
1107
c2 VARCHAR(300),
907
1108
KEY (c1) KEY_BLOCK_SIZE 1024,
933
1134
(33, REPEAT('x', CEIL(RAND() * 300))),
934
1135
(34, REPEAT('y', CEIL(RAND() * 300))),
935
1136
(35, REPEAT('z', CEIL(RAND() * 300)));
936
CREATE TEMPORARY TABLE t2 AS SELECT * FROM t1;
937
INSERT INTO t1 SELECT * FROM t2;
939
CREATE TEMPORARY TABLE t2 AS SELECT * FROM t1;
940
INSERT INTO t1 SELECT * FROM t2;
1137
INSERT INTO t1 SELECT * FROM t1;
1138
INSERT INTO t1 SELECT * FROM t1;
943
1140
DELETE FROM t1 WHERE c1 >= 10;
965
1162
# Test #2 - same as test #1, but using EXTENDED.
966
1163
# Using a CHAR column that can have > 127 characters.
967
1164
# Using a VARCHAR to create a table with dynamic row format.
968
CREATE temporary TABLE t1 (
971
1168
) ENGINE=MyISAM;
972
1169
INSERT INTO t1 VALUES(REPEAT("a",128), 'b');
973
1170
SELECT COUNT(*) FROM t1;
1171
CHECK TABLE t1 EXTENDED;
975
1172
SELECT COUNT(*) FROM t1;
1173
CHECK TABLE t1 EXTENDED;
979
1176
# Test #3 - same as test #1, but using OPTIMIZE TABLE.
980
1177
# Using a CHAR column that can have > 127 characters.
981
1178
# Using a VARCHAR to create a table with dynamic row format.
982
CREATE temporary TABLE t1 (
985
1182
) ENGINE=MyISAM;
1045
1242
# Test #6 - same as test #2, but UTF-8.
1046
1243
# Using a CHAR column that can have > 127 characters.
1047
1244
# Using a VARCHAR to create a table with dynamic row format.
1048
CREATE temporary TABLE t1 (
1051
1248
) ENGINE=MyISAM;
1052
1249
# Using Tamil Letter A, Unicode U+0B85
1053
1250
INSERT INTO t1 VALUES(REPEAT( x'e0ae85',43), 'b');
1054
1251
SELECT COUNT(*) FROM t1;
1252
CHECK TABLE t1 EXTENDED;
1056
1253
SELECT COUNT(*) FROM t1;
1254
CHECK TABLE t1 EXTENDED;
1060
1257
# Test #7 - same as test #3, but UTF-8.
1061
1258
# Using a CHAR column that can have > 127 characters.
1062
1259
# Using a VARCHAR to create a table with dynamic row format.
1063
CREATE temporary TABLE t1 (
1066
1263
) ENGINE=MyISAM;
1107
1304
# With bug present, this shows that all long rows are gone.
1108
1305
SELECT COUNT(*) FROM t1;
1109
1306
CHECK TABLE t1;
1307
CHECK TABLE t1 EXTENDED;
1311
# Bug#29182 - MyISAMCHK reports wrong character set
1313
#@TODO Disabling the below, as no myisamcheck program
1315
# c1 VARCHAR(10) NOT NULL,
1316
# c2 CHAR(10) DEFAULT NULL,
1317
# c3 VARCHAR(10) NOT NULL,
1320
#) ENGINE=MyISAM PACK_KEYS=0;
1321
#--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
1322
#--exec $DRIZZLECHK -d $MYSQLTEST_VARDIR/master-data/test/t1
1112
1325
--echo End of 5.1 tests