492
510
select c1 from t1 order by c1 limit 1;
514
# Bug #14400 Join could miss concurrently inserted row
517
create table t1 (a int not null, primary key(a));
518
create table t2 (a int not null, b int not null, primary key(a,b));
519
insert into t1 values (1),(2),(3),(4),(5),(6);
520
insert into t2 values (1,1),(2,1);
521
lock tables t1 read local, t2 read local;
522
select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
523
connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
524
insert into t2 values(2,0);
527
select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
532
CREATE TABLE t1 (c1 varchar(250) NOT NULL);
533
CREATE TABLE t2 (c1 varchar(250) NOT NULL, PRIMARY KEY (c1));
534
INSERT INTO t1 VALUES ('test000001'), ('test000002'), ('test000003');
535
INSERT INTO t2 VALUES ('test000002'), ('test000003'), ('test000004');
536
LOCK TABLES t1 READ LOCAL, t2 READ LOCAL;
537
SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
538
WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
539
connect (con1,localhost,root,,);
541
INSERT INTO t2 VALUES ('test000001'), ('test000005');
544
SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
545
WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
495
549
# 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;
555
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;
556
# INSERT INTO t1 VALUES (1,1),(1,1);
557
# DELETE FROM rt WHERE a<1;
558
# DROP TABLE IF EXISTS t1;
560
create table t1 (a int, b varchar(200), c text not null) checksum=1;
561
create table t2 (a int, b varchar(200), c text not null) checksum=0;
499
562
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
500
563
insert t2 select * from t1;
501
--replace_column 1 # 6 # 7 # 8 # 9 # 10 #
564
checksum table t1, t2, t3 quick;
565
checksum table t1, t2, t3;
566
checksum table t1, t2, t3 extended;
503
568
drop table t1,t2;
505
#@TODO Figure out what the heck the below is testing.
506
# It bombs the test with unknown system variables...
508
#create table t1 (a int, key (a));
510
#alter table t1 disable keys;
512
#create table t2 (a int);
514
#set @@rand_seed1=31415926,@@rand_seed2=2718281828;
519
# insert t2 values (rand()*100000);
522
#insert t1 select * from t2;
524
#alter table t1 enable keys;
526
#alter table t1 engine=MEMORY;
527
#alter table t1 disable keys;
570
create table t1 (a int, key (a));
572
alter table t1 disable keys;
574
create table t2 (a int);
576
set @@rand_seed1=31415926,@@rand_seed2=2718281828;
581
insert t2 values (rand()*100000);
584
insert t1 select * from t2;
586
alter table t1 enable keys;
588
alter table t1 engine=heap;
589
alter table t1 disable keys;
532
594
# index search for NULL in blob. Bug #4816
534
create temporary table t1 ( a tinytext, b char(1), index idx (a(1),b) ) engine=myisam;
596
create table t1 ( a tinytext, b char(1), index idx (a(1),b) );
535
597
insert into t1 values (null,''), (null,'');
536
598
explain select count(*) from t1 where a is null;
537
599
select count(*) from t1 where a is null;
541
603
# 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;
605
create table t1 (c1 int, c2 varchar(4) not null default '',
606
key(c2(3))) default charset=utf8;
545
607
insert into t1 values (1,'A'), (2, 'B'), (3, 'A');
546
608
update t1 set c2='A B' where c1=2;
614
# Bug#12296 - CHECKSUM TABLE reports 0 for the table
615
# This happened if the first record was marked as deleted.
617
create table t1 (c1 int);
618
insert into t1 values (1),(2),(3),(4);
620
delete from t1 where c1 = 1;
621
create table t2 as select * from t1;
622
# The following returns 0 with the bug in place.
624
# The above should give the same number as the following.
629
# BUG#12232: New myisam_stats_method variable.
632
show variables like 'myisam_stats_method';
634
create table t1 (a int, key(a));
635
insert into t1 values (0),(1),(2),(3),(4);
636
insert into t1 select NULL from t1;
638
# default: NULLs considered inequal
641
insert into t1 values (11);
642
delete from t1 where a=11;
646
# Set nulls to be equal:
647
set myisam_stats_method=nulls_equal;
648
show variables like 'myisam_stats_method';
649
insert into t1 values (11);
650
delete from t1 where a=11;
655
insert into t1 values (11);
656
delete from t1 where a=11;
661
# Set nulls back to be equal
662
set myisam_stats_method=DEFAULT;
663
show variables like 'myisam_stats_method';
664
insert into t1 values (11);
665
delete from t1 where a=11;
670
insert into t1 values (11);
671
delete from t1 where a=11;
678
# WL#2609, CSC#XXXX: MyISAM
679
set myisam_stats_method=nulls_ignored;
680
show variables like 'myisam_stats_method';
683
a char(3), b char(4), c char(5), d char(6),
686
insert into t1 values ('bcd','def1', NULL, 'zz');
687
insert into t1 values ('bcd','def2', NULL, 'zz');
688
insert into t1 values ('bce','def1', 'yuu', NULL);
689
insert into t1 values ('bce','def2', NULL, 'quux');
696
set myisam_stats_method=DEFAULT;
550
699
# BUG#13814 - key value packed incorrectly for TINYBLOBs
552
create temporary table t1(
553
702
cip INT NOT NULL,
554
704
score INT NOT NULL DEFAULT 0,
558
insert into t1 (cip) VALUES (1), (2), (3);
559
insert into t1 (cip, bob) VALUES (4, 'a' ), (5, 'b'),
708
insert into t1 (cip, time) VALUES (1, '00:01'), (2, '00:02'), (3,'00:03');
709
insert into t1 (cip, bob, time) VALUES (4, 'a', '00:04'), (5, 'b', '00:05'),
561
711
select * from t1 where bob is null and cip=1;
562
create index bug on t1 (bob(22), cip);
712
create index bug on t1 (bob(22), cip, time);
563
713
select * from t1 where bob is null and cip=1;
567
717
# Bug#14980 - COUNT(*) incorrect on MyISAM table with certain INDEX
569
create temporary table t1 (
570
720
id1 int not null auto_increment,
571
721
id2 int not null default '0',
747
# BUG#18036 - update of table joined to self reports table as crashed
749
CREATE TABLE t1(a CHAR(9), b VARCHAR(7)) ENGINE=MyISAM;
750
INSERT INTO t1(a) VALUES('xxxxxxxxx'),('xxxxxxxxx');
751
UPDATE t1 AS ta1,t1 AS ta2 SET ta1.b='aaaaaa',ta2.b='bbbbbb';
597
756
# Bug#8283 - OPTIMIZE TABLE causes data loss
758
SET @@myisam_repair_threads=2;
759
SHOW VARIABLES LIKE 'myisam_repair%';
599
761
# Test OPTIMIZE. This creates a new data file.
600
CREATE TEMPORARY TABLE t1 (
601
`_id` int NOT NULL default '0',
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,
612
`_obj_class` text NOT NULL,
614
UNIQUE KEY `sequence_name_index` (`name`(50)),
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','');
630
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';
763
`_id` int NOT NULL default '0',
767
`loverlap` int default NULL,
768
`roverlap` int default NULL,
769
`lneighbor_id` int default NULL,
770
`rneighbor_id` int default NULL,
771
`length_` int default NULL,
772
`sequence` mediumtext,
774
`_obj_class` text NOT NULL,
776
UNIQUE KEY `sequence_name_index` (`name`(50)),
778
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
780
INSERT INTO t1 VALUES
781
(1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample1',''),
782
(2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample2',''),
783
(3,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample3',''),
784
(4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample4',''),
785
(5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample5',''),
786
(6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample6',''),
787
(7,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample7',''),
788
(8,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample8',''),
789
(9,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample9','');
792
DELETE FROM t1 WHERE _id < 8;
793
--replace_column 6 # 7 # 8 # 9 # 11 # 12 # 13 # 14 # 15 # 16 #
794
SHOW TABLE STATUS LIKE 't1';
795
CHECK TABLE t1 EXTENDED;
797
CHECK TABLE t1 EXTENDED;
798
--replace_column 6 # 7 # 8 # 9 # 11 # 12 # 13 # 14 # 15 # 16 #
799
SHOW TABLE STATUS LIKE 't1';
803
# Test REPAIR QUICK. This retains the old data file.
805
`_id` int NOT NULL default '0',
809
`loverlap` int default NULL,
810
`roverlap` int default NULL,
811
`lneighbor_id` int default NULL,
812
`rneighbor_id` int default NULL,
813
`length_` int default NULL,
814
`sequence` mediumtext,
816
`_obj_class` text NOT NULL,
818
UNIQUE KEY `sequence_name_index` (`name`(50)),
820
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
822
INSERT INTO t1 VALUES
823
(1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample1',''),
824
(2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample2',''),
825
(3,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample3',''),
826
(4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample4',''),
827
(5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample5',''),
828
(6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample6',''),
829
(7,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample7',''),
830
(8,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample8',''),
831
(9,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample9','');
834
DELETE FROM t1 WHERE _id < 8;
835
--replace_column 6 # 7 # 8 # 9 # 11 # 12 # 13 # 14 # 15 # 16 #
836
SHOW TABLE STATUS LIKE 't1';
837
CHECK TABLE t1 EXTENDED;
838
REPAIR TABLE t1 QUICK;
839
CHECK TABLE t1 EXTENDED;
840
--replace_column 6 # 7 # 8 # 9 # 11 # 12 # 13 # 14 # 15 # 16 #
841
SHOW TABLE STATUS LIKE 't1';
845
SET @@myisam_repair_threads=1;
846
SHOW VARIABLES LIKE 'myisam_repair%';
849
# BUG#21310 - Trees in SQL causing a "crashed" table with MyISAM storage
853
# A simplified test case that reflect crashed table issue.
854
CREATE TABLE t1(a VARCHAR(16));
855
INSERT INTO t1 VALUES('aaaaaaaa'),(NULL);
856
UPDATE t1 AS ta1, t1 AS ta2 SET ta1.a='aaaaaaaaaaaaaaaa';
860
# A test case that reflect wrong result set.
861
CREATE TABLE t1(a INT);
862
INSERT INTO t1 VALUES(1),(2);
863
UPDATE t1,t1 AS t2 SET t1.a=t1.a+2 WHERE t1.a=t2.a-1;
864
SELECT * FROM t1 ORDER BY a;
642
868
# 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';
870
CREATE TABLE t1 (c1 TEXT) AVG_ROW_LENGTH=70100 MAX_ROWS=4100100100;
871
--replace_column 5 X 6 X 7 X 9 X 10 X 11 X 12 X 13 X 14 X 16 X
872
SHOW TABLE STATUS LIKE 't1';
650
876
# Bug#26231 - select count(*) on myisam table returns wrong value
651
877
# when index is used
653
CREATE TEMPORARY TABLE t1 (c1 TEXT NOT NULL, KEY c1 (c1(10))) ENGINE=MyISAM;
879
CREATE TABLE t1 (c1 TEXT NOT NULL, KEY c1 (c1(10))) ENGINE=MyISAM;
654
880
# Fill at least two key blocks. "Tab, A" must be in both blocks.
655
881
INSERT INTO t1 VALUES
656
882
(CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)), (CHAR(9,65)),
799
1025
let $default=`select @@storage_engine`;
800
1026
set storage_engine=MyISAM;
801
let $temp= TEMPORARY;
802
1027
source include/varchar.inc;
805
1030
# 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));
1033
create table t1 (v varchar(65530), key(v));
1034
drop table if exists t1;
1035
create table t1 (v varchar(65536));
1036
show create table t1;
1038
create table t1 (v varchar(65530) character set utf8);
1039
show create table t1;
815
1042
# MyISAM specific varchar tests
816
--error ER_TOO_BIG_FIELDLENGTH
817
create temporary table t1 (v varchar(65535));
1044
create table t1 (v varchar(65535));
819
1046
eval set storage_engine=$default;
1049
# Test concurrent insert
1050
# First with static record length
1052
set @save_concurrent_insert=@@concurrent_insert;
1053
set global concurrent_insert=1;
1054
create table t1 (a int);
1055
insert into t1 values (1),(2),(3),(4),(5);
1056
lock table t1 read local;
1057
connect (con1,localhost,root,,);
1059
# Insert in table without hole
1060
insert into t1 values(6),(7);
1063
delete from t1 where a>=3 and a<=4;
1064
lock table t1 read local;
1066
set global concurrent_insert=2;
1067
# Insert in table with hole -> Should insert at end
1068
insert into t1 values (8),(9);
1072
insert into t1 values (10),(11),(12);
1078
# Same test with dynamic record length
1079
create table t1 (a int, b varchar(30) default "hello");
1080
insert into t1 (a) values (1),(2),(3),(4),(5);
1081
lock table t1 read local;
1082
connect (con1,localhost,root,,);
1084
# Insert in table without hole
1085
insert into t1 (a) values(6),(7);
1088
delete from t1 where a>=3 and a<=4;
1089
lock table t1 read local;
1091
set global concurrent_insert=2;
1092
# Insert in table with hole -> Should insert at end
1093
insert into t1 (a) values (8),(9);
1097
insert into t1 (a) values (10),(11),(12);
1102
set global concurrent_insert=@save_concurrent_insert;
822
1105
# BUG#9622 - ANALYZE TABLE and ALTER TABLE .. ENABLE INDEX produce
823
1106
# different statistics on the same table with NULL values.
824
create temporary table t1 (a int, key(a)) engine=myisam;
1107
create table t1 (a int, key(a));
826
1109
insert into t1 values (1),(2),(3),(4),(NULL),(NULL),(NULL),(NULL);
827
1110
analyze table t1;
854
1148
# 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';
1150
CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE INDEX (c1), INDEX (c2)) ENGINE=MYISAM;
1151
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
1152
SHOW TABLE STATUS LIKE 't1';
859
1153
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';
1154
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
1155
SHOW TABLE STATUS LIKE 't1';
1156
ALTER TABLE t1 DISABLE KEYS;
1157
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
1158
SHOW TABLE STATUS LIKE 't1';
1159
ALTER TABLE t1 ENABLE KEYS;
1160
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
1161
SHOW TABLE STATUS LIKE 't1';
1162
ALTER TABLE t1 DISABLE KEYS;
1163
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
1164
SHOW TABLE STATUS LIKE 't1';
1165
ALTER TABLE t1 ENABLE KEYS;
1166
--replace_column 6 # 7 # 8 # 10 # 11 # 12 # 13 # 14 # 15 # 16 #
1167
SHOW TABLE STATUS LIKE 't1';
874
1168
#--exec ls -log var/master-data/test/t1.MYI
875
1169
#--exec myisamchk -dvv var/master-data/test/t1.MYI
876
1170
#--exec myisamchk -iev var/master-data/test/t1.MYI
877
1171
--echo # Enable keys with parallel repair
1172
SET @@myisam_repair_threads=2;
878
1173
ALTER TABLE t1 DISABLE KEYS;
879
1174
ALTER TABLE t1 ENABLE KEYS;
1175
SET @@myisam_repair_threads=1;
1176
CHECK TABLE t1 EXTENDED;
884
1180
# 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));
1183
CREATE TABLE t1 (id int NOT NULL, ref int NOT NULL, INDEX (id)) ENGINE=MyISAM;
888
1184
CREATE TABLE t2 LIKE t1;
890
1186
INSERT INTO t2 (id, ref) VALUES (1,3), (2,1), (3,2), (4,5), (4,4);