133
127
# test of myisam with huge number of packed fields
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,
309
303
# Test of REPAIR that once failed
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 '',
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;
343
336
ALTER TABLE t1 ADD INDEX t1 (a, b, c, d, e);
347
340
# Test of cardinality of keys with NULL
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);
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;
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;
488
492
select c1 from t1 order by c1 limit 1;
492
# Bug #14400 Join could miss concurrently inserted row
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);
505
select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
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,,);
519
INSERT INTO t2 VALUES ('test000001'), ('test000005');
522
SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
523
WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
527
495
# End of 4.0 tests
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;
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
501
checksum table t1, t2, t3 quick;
545
504
#show table status;
546
505
drop table t1,t2;
548
create table t1 (a int, key (a));
550
alter table t1 disable keys;
552
create table t2 (a int);
554
set @@rand_seed1=31415926,@@rand_seed2=2718281828;
559
insert t2 values (rand()*100000);
562
insert t1 select * from t2;
564
alter table t1 enable keys;
566
alter table t1 engine=heap;
567
alter table t1 disable keys;
507
#@TODO Figure out what the heck the below is testing.
508
# It bombs the test with unknown system variables...
510
#create table t1 (a int, key (a));
512
#alter table t1 disable keys;
514
#create table t2 (a int);
516
#set @@rand_seed1=31415926,@@rand_seed2=2718281828;
521
# insert t2 values (rand()*100000);
524
#insert t1 select * from t2;
526
#alter table t1 enable keys;
528
#alter table t1 engine=heap;
529
#alter table t1 disable keys;
572
534
# index search for NULL in blob. Bug #4816
603
565
checksum table t2;
604
566
drop table t1, t2;
607
# BUG#12232: New myisam_stats_method variable.
610
show variables like 'myisam_stats_method';
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;
616
# default: NULLs considered inequal
619
insert into t1 values (11);
620
delete from t1 where a=11;
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;
633
insert into t1 values (11);
634
delete from t1 where a=11;
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;
648
insert into t1 values (11);
649
delete from t1 where a=11;
656
# WL#2609, CSC#XXXX: MyISAM
657
set myisam_stats_method=nulls_ignored;
658
show variables like 'myisam_stats_method';
661
a char(3), b char(4), c char(5), d char(6),
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');
674
set myisam_stats_method=DEFAULT;
677
568
# BUG#13814 - key value packed incorrectly for TINYBLOBs
680
571
cip INT NOT NULL,
682
572
score INT NOT NULL DEFAULT 0,
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'),
576
insert into t1 (cip) VALUES (1), (2), (3);
577
insert into t1 (cip, bob) VALUES (4, 'a' ), (5, 'b'),
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;
695
585
# Bug#14980 - COUNT(*) incorrect on MyISAM table with certain INDEX
587
create temporary table t1 (
698
588
id1 int not null auto_increment,
699
589
id2 int not null default '0',
725
# BUG#18036 - update of table joined to self reports table as crashed
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';
734
615
# Bug#8283 - OPTIMIZE TABLE causes data loss
736
SET @@myisam_repair_threads=2;
617
SET GLOBAL myisam_repair_threads=2;
737
618
SHOW VARIABLES LIKE 'myisam_repair%';
739
620
# Test OPTIMIZE. This creates a new data file.
741
`_id` int(11) NOT NULL default '0',
621
CREATE TEMPORARY TABLE t1 (
622
`_id` int NOT NULL default '0',
744
625
`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,
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,
752
633
`_obj_class` text NOT NULL,
753
634
PRIMARY KEY (`_id`),
754
635
UNIQUE KEY `sequence_name_index` (`name`(50)),
756
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
758
639
INSERT INTO t1 VALUES
759
640
(1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample1',''),
760
641
(2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample2',''),
778
659
SELECT _id FROM t1;
781
# Test REPAIR QUICK. This retains the old data file.
783
`_id` int(11) NOT NULL default '0',
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,
794
`_obj_class` text NOT NULL,
796
UNIQUE KEY `sequence_name_index` (`name`(50)),
798
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
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','');
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';
823
SET @@myisam_repair_threads=1;
662
SET GLOBAL myisam_repair_threads=1;
824
663
SHOW VARIABLES LIKE 'myisam_repair%';
827
# BUG#21310 - Trees in SQL causing a "crashed" table with MyISAM storage
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';
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;
846
666
# Bug#24607 - MyISAM pointer size determined incorrectly
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';
1003
823
let $default=`select @@storage_engine`;
1004
824
set storage_engine=MyISAM;
825
let $temp= TEMPORARY;
1005
826
source include/varchar.inc;
1008
829
# Some errors/warnings on create
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;
1016
create table t1 (v varchar(65530) character set utf8);
1017
show create table t1;
833
create temporary table t1 (v varchar(65530), key(v));
835
create temporary table t1 (v varchar(65536));
837
create temporary table t1 (v varchar(65530));
1020
839
# MyISAM specific varchar tests
1022
create table t1 (v varchar(65535));
841
create temporary table t1 (v varchar(65535));
1024
843
eval set storage_engine=$default;
1027
# Test concurrent insert
1028
# First with static record length
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,,);
1037
# Insert in table without hole
1038
insert into t1 values(6),(7);
1041
delete from t1 where a>=3 and a<=4;
1042
lock table t1 read local;
1044
set global concurrent_insert=2;
1045
# Insert in table with hole -> Should insert at end
1046
insert into t1 values (8),(9);
1050
insert into t1 values (10),(11),(12);
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,,);
1062
# Insert in table without hole
1063
insert into t1 (a) values(6),(7);
1066
delete from t1 where a>=3 and a<=4;
1067
lock table t1 read local;
1069
set global concurrent_insert=2;
1070
# Insert in table with hole -> Should insert at end
1071
insert into t1 (a) values (8),(9);
1075
insert into t1 (a) values (10),(11),(12);
1080
set global concurrent_insert=@save_concurrent_insert;
1083
846
# BUG#9622 - ANALYZE TABLE and ALTER TABLE .. ENABLE INDEX produce
1084
847
# different statistics on the same table with NULL values.
1099
# Bug#10056 - PACK_KEYS option take values greater than 1 while creating table
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;
1105
create table t4 (c1 int) engine=myisam pack_keys=2;
1106
drop table t1, t2, t3;
1110
862
# Bug#28476: force index on a disabled myisam index gives error 124
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;
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;
905
SET GLOBAL myisam_repair_threads=1;
1154
906
CHECK TABLE t1 EXTENDED;
1158
910
# Bug#28837: MyISAM storage engine error (134) doing delete with self-join
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;
1164
916
INSERT INTO t2 (id, ref) VALUES (1,3), (2,1), (3,2), (4,5), (4,4);
1178
928
# Test of key_block_size
1181
create table t1 (a int not null, key `a` (a) key_block_size=1024);
1182
show create table t1;
1185
create table t1 (a int not null, key `a` (a) key_block_size=2048);
1186
show create table t1;
1189
create table t1 (a varchar(2048), key `a` (a));
1190
show create table t1;
1193
create table t1 (a varchar(2048), key `a` (a) key_block_size=1024);
1194
show create table t1;
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;
935
create temporary table t1 (a int not null, key `a` (a) key_block_size=2048) ENGINE=MyISAM;
936
show create table t1;
939
create temporary table t1 (a varchar(2048), key `a` (a)) ENGINE=MyISAM;
940
show create table t1;
943
create temporary table t1 (a varchar(2048), key `a` (a) key_block_size=1024) ENGINE=MyISAM;
944
show create table t1;
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;
1208
create table t1 (a int not null, b varchar(2048), key (a), key(b)) key_block_size=8192;
1209
show create table t1;
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;
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;
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;
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;
1221
971
# Test limits and errors of key_block_size
1223
create table t1 (a int not null, key `a` (a) key_block_size=512);
1224
show create table t1;
1227
create table t1 (a varchar(2048), key `a` (a) key_block_size=1000000000000000000);
1228
show create table t1;
1231
create table t1 (a int not null, key `a` (a) key_block_size=1025);
1232
show create table t1;
1236
create table t1 (a int not null, key key_block_size=1024 (a));
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;
977
create temporary table t1 (a varchar(2048), key `a` (a) key_block_size=1000000000000000000) ENGINE=MyISAM;
978
show create table t1;
981
create temporary table t1 (a int not null, key `a` (a) key_block_size=1025) ENGINE=MyISAM;
982
show create table t1;
986
create temporary table t1 (a int not null, key key_block_size=1024 (a)) ENGINE=MyISAM;
988
create temporary table t1 (a int not null, key `a` key_block_size=1024 (a)) ENGINE=MyISAM;
1241
991
# Bug#22119 - Changing MI_KEY_BLOCK_LENGTH makes a wrong myisamchk
993
CREATE temporary TABLE t1 (
1245
995
c2 VARCHAR(300),
1246
996
KEY (c1) KEY_BLOCK_SIZE 1024,
1247
997
KEY (c2) KEY_BLOCK_SIZE 8192
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))),