382
382
eval create $temp table t1 (
383
383
id int NOT NULL auto_increment,
384
ggid varchar(32) DEFAULT '' NOT NULL,
384
ggid varchar(32) binary DEFAULT '' NOT NULL,
385
385
email varchar(64) DEFAULT '' NOT NULL,
386
passwd varchar(32) DEFAULT '' NOT NULL,
386
passwd varchar(32) binary DEFAULT '' NOT NULL,
387
387
PRIMARY KEY (id),
388
388
UNIQUE ggid (ggid)
389
389
) ENGINE=$engine_type;
391
391
insert into t1 (ggid,passwd) values ('test1','xxx');
392
392
insert into t1 (ggid,passwd) values ('test2','yyy');
393
-- error ER_DUP_ENTRY
394
394
insert into t1 (ggid,passwd) values ('test2','this will fail');
395
-- error ER_DUP_ENTRY
396
396
insert into t1 (ggid,id) values ('this will fail',1);
398
398
select * from t1 where ggid='test1';
690
689
eval create $temp table t1 (t int not null default 1, key (t)) engine=$engine_type;
694
# Test of multi-table-delete
697
eval create $temp table t1 (
698
number bigint NOT NULL default '0',
699
cname char(15) NOT NULL default '',
700
carrier_id int NOT NULL default '0',
701
privacy int NOT NULL default '0',
702
last_mod_date timestamp NOT NULL,
703
last_mod_id int NOT NULL default '0',
704
last_app_date timestamp NULL,
705
last_app_id int default '-1',
706
version int NOT NULL default '0',
707
assigned_scps int default '0',
708
status int default '0'
709
) ENGINE=$engine_type;
710
INSERT INTO t1 VALUES (4077711111,'SeanWheeler',90,2,20020111112846,500,NULL,-1,2,3,1);
711
INSERT INTO t1 VALUES (9197722223,'berry',90,3,20020111112809,500,20020102114532,501,4,10,0);
712
INSERT INTO t1 VALUES (650,'San Francisco',0,0,20011227111336,342,NULL,-1,1,24,1);
713
INSERT INTO t1 VALUES (302467,'Sue\'s Subshop',90,3,20020109113241,500,20020102115111,501,7,24,0);
714
INSERT INTO t1 VALUES (6014911113,'SudzCarwash',520,1,20020102115234,500,20020102115259,501,33,32768,0);
715
INSERT INTO t1 VALUES (333,'tubs',99,2,20020109113440,501,20020109113440,500,3,10,0);
716
eval create $temp table t2 (
717
number bigint NOT NULL default '0',
718
cname char(15) NOT NULL default '',
719
carrier_id int NOT NULL default '0',
720
privacy int NOT NULL default '0',
721
last_mod_date timestamp NOT NULL,
722
last_mod_id int NOT NULL default '0',
723
last_app_date timestamp NULL,
724
last_app_id int default '-1',
725
version int NOT NULL default '0',
726
assigned_scps int default '0',
727
status int default '0'
728
) ENGINE=$engine_type;
729
INSERT INTO t2 VALUES (4077711111,'SeanWheeler',0,2,20020111112853,500,NULL,-1,2,3,1);
730
INSERT INTO t2 VALUES (9197722223,'berry',90,3,20020111112818,500,20020102114532,501,4,10,0);
731
INSERT INTO t2 VALUES (650,'San Francisco',90,0,20020109113158,342,NULL,-1,1,24,1);
732
INSERT INTO t2 VALUES (333,'tubs',99,2,20020109113453,501,20020109113453,500,3,10,0);
735
delete t1, t2 from t1 left join t2 on t1.number=t2.number where (t1.carrier_id=90 and t1.number=t2.number) or (t2.carrier_id=90 and t1.number=t2.number) or (t1.carrier_id=90 and t2.number is null);
695
742
# A simple test with some isolation levels
696
743
# TODO: Make this into a test using replication to really test how
885
# Test multi update with different join methods
888
eval create $temp table t1 (a int not null primary key, b int not null, key (b)) engine=$engine_type;
889
eval create $temp table t2 (a int not null primary key, b int not null, key (b)) engine=$engine_type;
890
INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10),(11,11),(12,12);
891
INSERT INTO t2 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
893
# Full join, without key
894
update t1,t2 set t1.a=t1.a+100;
898
update t1,t2 set t1.a=t1.a+100 where t1.a=101;
902
update t1,t2 set t1.b=t1.b+10 where t1.b=2;
906
update t1,t2 set t1.b=t1.b+2,t2.b=t1.b+10 where t1.b between 3 and 5 and t1.a=t2.a+100;
911
eval create $temp table t2 ( NEXT_T BIGINT NOT NULL PRIMARY KEY) ENGINE=$other_non_trans_engine_type;
912
eval create $temp table t1 ( B_ID INTEGER NOT NULL PRIMARY KEY) ENGINE=$engine_type;
914
INSERT INTO t1 ( B_ID ) VALUES ( 1 );
915
INSERT INTO t2 ( NEXT_T ) VALUES ( 1 );
919
eval create $temp table t1 ( pk int primary key, parent int not null, child int not null, index (parent) ) engine = $engine_type;
920
insert into t1 values (1,0,4), (2,1,3), (3,2,1), (4,1,2);
921
select distinct parent,child from t1 order by parent;
812
925
# Test that MySQL priorities clustered indexes
814
927
eval create $temp table t1 (a int not null auto_increment primary key, b int, c int, key(c)) engine=$engine_type;
978
# Test of multi-table-updates (bug #1980).
981
eval create $temp table t1 ( c char(8) not null ) engine=$engine_type;
982
insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9');
983
insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F');
985
alter table t1 add b char(8) not null;
986
alter table t1 add a char(8) not null;
987
alter table t1 add primary key (a,b,c);
988
update t1 set a=c, b=c;
990
eval create $temp table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)) engine=$engine_type;
991
insert into t2 select * from t1;
993
delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b;
865
997
# test autoincrement with TRUNCATE
913
1045
foreign key(pid) references t1(id) on delete cascade) engine=$engine_type;
914
1046
insert into t1 values(0,0),(1,0),(2,1),(3,2),(4,3),(5,4),(6,5),(7,6),
915
1047
(8,7),(9,8),(10,9),(11,10),(12,11),(13,12),(14,13),(15,14);
916
--error ER_ROW_IS_REFERENCED_2
917
1049
delete from t1 where id=0;
918
1050
delete from t1 where id=15;
919
1051
delete from t1 where id=0;
930
1062
eval create $temp table t2 (col1 int,stamp TIMESTAMP,INDEX stamp_idx
931
1063
(stamp))ENGINE=$engine_type;
932
1064
insert into t1 values (1),(2),(3);
933
insert into t2 values (1, 20020204130000);
934
insert into t2 values (2, 20020204130000);
935
--error ER_INVALID_TIMESTAMP_VALUE # Bad timestamp
936
insert into t2 values (4, 20020204310000);
937
insert into t2 values (5, 20020204230000);
938
SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp < '20020204120000' GROUP BY col1;
1065
# Note that timestamp 3 is wrong
1066
--error 1685 # Bad timestamp
1067
insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 ),(5,20020204230000);
1068
SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp <
1069
'20020204120000' GROUP BY col1;
939
1070
drop table t1,t2;
975
1106
# Live checksum feature available + enabled
976
eval create $temp table t1 (a int, b varchar(200), c text not null) engine=$other_live_chks_engine_type;
1107
eval create $temp table t1 (a int, b varchar(200), c text not null) checksum=1 engine=$other_live_chks_engine_type;
977
1108
# Live checksum feature available + disabled
978
eval create $temp table t2 (a int, b varchar(200), c text not null) engine=$other_live_chks_engine_type;
1109
eval create $temp table t2 (a int, b varchar(200), c text not null) checksum=0 engine=$other_live_chks_engine_type;
980
1111
# Live checksum feature not available + enabled
981
eval create $temp table t3 (a int, b varchar(200), c varchar(200) not null) engine=$other_non_live_chks_engine_type;
1112
eval create $temp table t3 (a int, b varchar(200), c varchar(200) not null) checksum=1 engine=$other_non_live_chks_engine_type;
982
1113
# Live checksum feature not available + disabled
983
eval create $temp table t4 (a int, b varchar(200), c varchar(200) not null) engine=$other_non_live_chks_engine_type;
1114
eval create $temp table t4 (a int, b varchar(200), c varchar(200) not null) checksum=0 engine=$other_non_live_chks_engine_type;
985
1116
# Live checksum feature probably available + enabled
986
eval create $temp table t5 (a int, b varchar(200), c text not null) engine=$engine_type;
1117
eval create $temp table t5 (a int, b varchar(200), c text not null) checksum=1 engine=$engine_type;
987
1118
# Live checksum feature probably available + disabled
988
eval create $temp table t6 (a int, b varchar(200), c text not null) engine=$engine_type;
1119
eval create $temp table t6 (a int, b varchar(200), c text not null) checksum=0 engine=$engine_type;
990
1121
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
991
1122
insert t2 select * from t1;
993
1124
insert t4 select * from t1;
994
1125
insert t5 select * from t1;
995
1126
insert t6 select * from t1;
1127
checksum table t1, t2, t3, t4, t5, t6, t7 quick;
1128
checksum table t1, t2, t3, t4, t5, t6, t7;
1129
checksum table t1, t2, t3, t4, t5, t6, t7 extended;
996
1130
# #show table status;
997
1131
drop table t1,t2,t3, t4, t5, t6;
1125
1257
# Bug #6126: Duplicate columns in keys gives misleading error message
1127
--error ER_DUP_FIELDNAME
1128
1260
eval create $temp table t1 (c char(10), index (c,c)) engine=$engine_type;
1129
--error ER_DUP_FIELDNAME
1130
1262
eval create $temp table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=$engine_type;
1131
--error ER_DUP_FIELDNAME
1132
1264
eval create $temp table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=$engine_type;
1133
--error ER_DUP_FIELDNAME
1134
1266
eval create $temp table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=$engine_type;
1135
1267
eval create $temp table t1 (c1 char(10), c2 char(10)) engine=$engine_type;
1136
--error ER_DUP_FIELDNAME
1137
1269
alter table t1 add key (c1,c1);
1138
--error ER_DUP_FIELDNAME
1139
1271
alter table t1 add key (c2,c1,c1);
1140
--error ER_DUP_FIELDNAME
1141
1273
alter table t1 add key (c1,c2,c1);
1142
--error ER_DUP_FIELDNAME
1143
1275
alter table t1 add key (c1,c1,c2);
1541
1684
CONSTRAINT c1 FOREIGN KEY (v) REFERENCES t1(id)
1542
1685
) ENGINE=$engine_type;
1544
--error ER_NO_REFERENCED_ROW_2
1545
1688
INSERT INTO t2 VALUES(2);
1547
1690
INSERT INTO t1 VALUES(1);
1548
1691
INSERT INTO t2 VALUES(1);
1550
--error ER_ROW_IS_REFERENCED_2
1551
1694
DELETE FROM t1 WHERE id = 1;
1553
--error ER_ROW_IS_REFERENCED
1556
1699
SET FOREIGN_KEY_CHECKS=0;
1558
1701
SET FOREIGN_KEY_CHECKS=1;
1560
--error ER_NO_REFERENCED_ROW_2
1561
1704
INSERT INTO t2 VALUES(3);
1565
1708
# End of FOREIGN tests
1710
if ($test_transactions)
1713
# Test that checksum table uses a consistent read Bug #12669
1715
connect (a,localhost,root,,);
1716
connect (b,localhost,root,,);
1718
eval create $temp table t1(a int not null) engine=$engine_type DEFAULT CHARSET=latin1;
1719
insert into t1 values (1),(2);
1723
insert into t1 values(3);
1726
# Here checksum should not see insert
1738
eval create $temp table t1(a int not null) engine=$engine_type DEFAULT CHARSET=latin1;
1739
insert into t1 values (1),(2);
1744
insert into t1 values(3);
1747
# Here checksum sees insert
1567
1757
# tests for bugs #9802 and #13778
1569
1759
if ($test_foreign_keys)
1685
1875
eval create $temp table t1 (s1 varbinary(2),primary key (s1)) engine=$engine_type;
1686
1876
eval create $temp table t2 (s1 binary(2),primary key (s1)) engine=$engine_type;
1687
eval create $temp table t3 (s1 varchar(2),primary key (s1)) engine=$engine_type;
1688
eval create $temp table t4 (s1 char(2),primary key (s1)) engine=$engine_type;
1877
eval create $temp table t3 (s1 varchar(2) binary,primary key (s1)) engine=$engine_type;
1878
eval create $temp table t4 (s1 char(2) binary,primary key (s1)) engine=$engine_type;
1690
1880
insert into t1 values (0x41),(0x4120),(0x4100);
1691
--error ER_DUP_ENTRY
1881
-- error ER_DUP_ENTRY
1692
1882
insert into t2 values (0x41),(0x4120),(0x4100);
1693
1883
insert into t2 values (0x41),(0x4120);
1694
--error ER_DUP_ENTRY
1884
-- error ER_DUP_ENTRY
1695
1885
insert into t3 values (0x41),(0x4120),(0x4100);
1696
1886
insert into t3 values (0x41),(0x4100);
1697
--error ER_DUP_ENTRY
1887
-- error ER_DUP_ENTRY
1698
1888
insert into t4 values (0x41),(0x4120),(0x4100);
1699
1889
insert into t4 values (0x41),(0x4100);
1700
1890
select hex(s1) from t1;
1710
1900
eval create $temp table t2 (s1 binary(2) not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=$engine_type;
1712
1902
insert into t1 values(1,0x4100),(2,0x41),(3,0x4120),(4,0x42);
1713
--error ER_NO_REFERENCED_ROW_2
1714
1904
insert into t2 values(0x42);
1715
1905
insert into t2 values(0x41);
1716
1906
select hex(s1) from t2;
1717
1907
update t1 set s1=0x123456 where a=2;
1718
1908
select hex(s1) from t2;
1719
--error ER_ROW_IS_REFERENCED_2
1720
1910
update t1 set s1=0x12 where a=1;
1721
--error ER_ROW_IS_REFERENCED_2
1722
1912
update t1 set s1=0x12345678 where a=1;
1723
--error ER_ROW_IS_REFERENCED_2
1724
1914
update t1 set s1=0x123457 where a=1;
1725
1915
update t1 set s1=0x1220 where a=1;
1726
1916
select hex(s1) from t2;