607
# Test of multi-table-delete
611
number bigint NOT NULL default '0',
612
cname char(15) NOT NULL default '',
613
carrier_id int NOT NULL default '0',
614
privacy int NOT NULL default '0',
615
last_mod_date timestamp NOT NULL,
616
last_mod_id int NOT NULL default '0',
617
last_app_date timestamp NULL,
618
last_app_id int default '-1',
619
version int NOT NULL default '0',
620
assigned_scps int default '0',
621
status int default '0'
623
INSERT INTO t1 VALUES (4077711111,'SeanWheeler',90,2,20020111112846,500,NULL,-1,2,3,1);
624
INSERT INTO t1 VALUES (9197722223,'berry',90,3,20020111112809,500,20020102114532,501,4,10,0);
625
INSERT INTO t1 VALUES (650,'San Francisco',0,0,20011227111336,342,NULL,-1,1,24,1);
626
INSERT INTO t1 VALUES (302467,'Sue\'s Subshop',90,3,20020109113241,500,20020102115111,501,7,24,0);
627
INSERT INTO t1 VALUES (6014911113,'SudzCarwash',520,1,20020102115234,500,20020102115259,501,33,32768,0);
628
INSERT INTO t1 VALUES (333,'tubs',99,2,20020109113440,501,20020109113440,500,3,10,0);
630
number bigint NOT NULL default '0',
631
cname char(15) NOT NULL default '',
632
carrier_id int NOT NULL default '0',
633
privacy int NOT NULL default '0',
634
last_mod_date timestamp NOT NULL,
635
last_mod_id int NOT NULL default '0',
636
last_app_date timestamp NULL,
637
last_app_id int default '-1',
638
version int NOT NULL default '0',
639
assigned_scps int default '0',
640
status int default '0'
642
INSERT INTO t2 VALUES (4077711111,'SeanWheeler',0,2,20020111112853,500,NULL,-1,2,3,1);
643
INSERT INTO t2 VALUES (9197722223,'berry',90,3,20020111112818,500,20020102114532,501,4,10,0);
644
INSERT INTO t2 VALUES (650,'San Francisco',90,0,20020109113158,342,NULL,-1,1,24,1);
645
INSERT INTO t2 VALUES (333,'tubs',99,2,20020109113453,501,20020109113453,500,3,10,0);
648
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);
608
655
# A simple test with some isolation levels
609
656
# TODO: Make this into a test using replication to really test how
658
717
create table t2 (a int not null, b int, primary key (a)) engine = innodb;
659
718
insert into t1 values (10, 20);
660
719
insert into t2 values (10, 20);
720
update t1, t2 set t1.b = 150, t2.b = t1.b where t2.a = t1.a and t1.a = 10;
661
721
drop table t1,t2;
724
# Test of multi-table-delete with foreign key constraints
727
CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
728
CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (t1_id) REFERENCES t1(id) ON DELETE CASCADE ) ENGINE=INNODB;
729
insert into t1 set id=1;
730
insert into t2 set id=1, t1_id=1;
731
delete t1,t2 from t1,t2 where t1.id=t2.t1_id;
735
CREATE TABLE t1(id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
736
CREATE TABLE t2(id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id) ) ENGINE=INNODB;
737
INSERT INTO t1 VALUES(1);
738
INSERT INTO t2 VALUES(1, 1);
740
UPDATE t1,t2 SET t1.id=t1.id+1, t2.t1_id=t1.id+1;
742
UPDATE t1,t2 SET t1.id=t1.id+1 where t1.id!=t2.id;
664
747
# Test of range_optimizer
790
# Test multi update with different join methods
793
CREATE TABLE t1 (a int not null primary key, b int not null, key (b)) engine=innodb;
794
CREATE TABLE t2 (a int not null primary key, b int not null, key (b)) engine=innodb;
795
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);
796
INSERT INTO t2 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
798
# Full join, without key
799
update t1,t2 set t1.a=t1.a+100;
803
update t1,t2 set t1.a=t1.a+100 where t1.a=101;
807
update t1,t2 set t1.b=t1.b+10 where t1.b=2;
811
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;
816
CREATE TEMPORARY TABLE t2 ( NEXT_T BIGINT NOT NULL PRIMARY KEY) ENGINE=MyISAM;
817
CREATE TABLE t1 ( B_ID INTEGER NOT NULL PRIMARY KEY) ENGINE=InnoDB;
819
INSERT INTO t1 ( B_ID ) VALUES ( 1 );
820
INSERT INTO t2 ( NEXT_T ) VALUES ( 1 );
824
create table t1 ( pk int primary key, parent int not null, child int not null, index (parent) ) engine = innodb;
825
insert into t1 values (1,0,4), (2,1,3), (3,2,1), (4,1,2);
826
select distinct parent,child from t1 order by parent;
707
830
# Test that MySQL priorities clustered indexes
709
832
create table t1 (a int not null auto_increment primary key, b int, c int, key(c)) engine=innodb;
875
# Test of multi-table-updates (bug #1980).
878
create table t1 ( c char(8) not null ) engine=innodb;
879
insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9');
880
insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F');
882
alter table t1 add b char(8) not null;
883
alter table t1 add a char(8) not null;
884
alter table t1 add primary key (a,b,c);
885
update t1 set a=c, b=c;
887
create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)) engine=innodb;
888
insert into t2 select * from t1;
890
delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b;
752
894
# test autoincrement with TRUNCATE
770
912
drop table t2,t1;
915
# Test of multi updated and foreign keys
918
create table `t1` (`id` int not null ,primary key ( `id` )) engine = innodb;
919
insert into `t1`values ( 1 ) ;
920
create table `t2` (`id` int not null default '0',unique key `id` ( `id` ) ,constraint `t1_id_fk` foreign key ( `id` ) references `t1` (`id` )) engine = innodb;
921
insert into `t2`values ( 1 ) ;
922
create table `t3` (`id` int not null default '0',key `id` ( `id` ) ,constraint `t2_id_fk` foreign key ( `id` ) references `t2` (`id` )) engine = innodb;
923
insert into `t3`values ( 1 ) ;
925
delete t3,t2,t1 from t1,t2,t3 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
927
update t1,t2,t3 set t3.id=5, t2.id=6, t1.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
929
update t3 set t3.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
773
933
# test for recursion depth limit
830
990
ON (t2.id = lbl.id_object) INNER JOIN t1 ON (t2.id = t1.id_object);
831
991
drop table t1,t2;
833
create TEMPORARY table t1 (a int, b varchar(200), c text not null) engine=myisam;
834
create table t2 (a int, b varchar(200), c text not null) engine=innodb;
835
create table t3 (a int, b varchar(200), c text not null) engine=innodb;
993
create TEMPORARY table t1 (a int, b varchar(200), c text not null) checksum=1 engine=myisam;
994
create table t2 (a int, b varchar(200), c text not null) checksum=0 engine=innodb;
995
create table t3 (a int, b varchar(200), c text not null) checksum=1 engine=innodb;
836
996
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
837
997
insert t2 select * from t1;
838
998
insert t3 select * from t1;
839
--replace_column 1 # 6 # 7 # 8 # 9 # 10 #
999
checksum table t1, t2, t3, t4 quick;
1000
checksum table t1, t2, t3, t4;
1001
checksum table t1, t2, t3, t4 extended;
840
1003
drop table t1,t2,t3;
923
1086
# Bug #6126: Duplicate columns in keys gives misleading error message
925
--error ER_DUP_FIELDNAME
926
1089
create table t1 (c char(10), index (c,c)) engine=innodb;
927
--error ER_DUP_FIELDNAME
928
1091
create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=innodb;
929
--error ER_DUP_FIELDNAME
930
1093
create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=innodb;
931
--error ER_DUP_FIELDNAME
932
1095
create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=innodb;
933
1096
create table t1 (c1 char(10), c2 char(10)) engine=innodb;
934
--error ER_DUP_FIELDNAME
935
1098
alter table t1 add key (c1,c1);
936
--error ER_DUP_FIELDNAME
937
1100
alter table t1 add key (c2,c1,c1);
938
--error ER_DUP_FIELDNAME
939
1102
alter table t1 add key (c1,c2,c1);
940
--error ER_DUP_FIELDNAME
941
1104
alter table t1 add key (c1,c1,c2);
1027
1190
## Not deterministic.
1028
1191
# Test for testable InnoDB status variables. This test
1029
1192
# uses previous ones(pages_created, rows_deleted, ...).
1030
--replace_column 2 #
1031
show status like "Innodb_buffer_pool_pages_total";
1032
--replace_column 2 #
1033
show status like "Innodb_page_size";
1034
--replace_column 2 #
1035
show status like "Innodb_rows_deleted";
1036
--replace_column 2 #
1037
show status like "Innodb_rows_inserted";
1038
--replace_column 2 #
1039
show status like "Innodb_rows_updated";
1193
#show status like "Innodb_buffer_pool_pages_total";
1194
#show status like "Innodb_page_size";
1195
#show status like "Innodb_rows_deleted";
1196
#show status like "Innodb_rows_inserted";
1197
#show status like "Innodb_rows_updated";
1041
1199
## Test for row locks InnoDB status variables.
1042
--replace_column 2 #
1043
show status like "Innodb_row_lock_waits";
1044
--replace_column 2 #
1045
show status like "Innodb_row_lock_current_waits";
1046
--replace_column 2 #
1047
show status like "Innodb_row_lock_time";
1048
--replace_column 2 #
1049
show status like "Innodb_row_lock_time_max";
1050
--replace_column 2 #
1051
show status like "Innodb_row_lock_time_avg";
1200
#show status like "Innodb_row_lock_waits";
1201
#show status like "Innodb_row_lock_current_waits";
1202
#show status like "Innodb_row_lock_time";
1203
#show status like "Innodb_row_lock_time_max";
1204
#show status like "Innodb_row_lock_time_avg";
1053
1206
# Test for innodb_sync_spin_loops variable
1054
1207
show variables like "innodb_sync_spin_loops";
1278
1454
CONSTRAINT c1 FOREIGN KEY (v) REFERENCES t1(id)
1279
1455
) ENGINE=InnoDB;
1281
--error ER_NO_REFERENCED_ROW_2
1282
1458
INSERT INTO t2 VALUES(2);
1284
1460
INSERT INTO t1 VALUES(1);
1285
1461
INSERT INTO t2 VALUES(1);
1287
--error ER_ROW_IS_REFERENCED_2
1288
1464
DELETE FROM t1 WHERE id = 1;
1290
--error ER_ROW_IS_REFERENCED
1293
1469
SET FOREIGN_KEY_CHECKS=0;
1295
1471
SET FOREIGN_KEY_CHECKS=1;
1297
--error ER_NO_REFERENCED_ROW_2
1298
1474
INSERT INTO t2 VALUES(3);
1478
# Test that checksum table uses a consistent read Bug #12669
1480
connect (a,localhost,root,,);
1481
connect (b,localhost,root,,);
1483
create table t1(a int not null) engine=innodb;
1484
insert into t1 values (1),(2);
1488
insert into t1 values(3);
1491
# Here checksum should not see insert
1503
create table t1(a int not null) engine=innodb;
1504
insert into t1 values (1),(2);
1509
insert into t1 values(3);
1512
# Here checksum sees insert
1302
1521
# tests for bugs #9802 and #13778