diff options
author | Sergei Golubchik <serg@mariadb.org> | 2017-09-26 11:05:27 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2017-10-03 20:23:33 +0200 |
commit | b6a5be9eaa715c190d05d370998f6ef4f72acaab (patch) | |
tree | 39769f6170eea791a2acfffddaa20e42fb9ed5c9 | |
parent | 1641879387d80d7fd9d4c23ce7a363b910b3cf74 (diff) | |
download | mariadb-git-b6a5be9eaa715c190d05d370998f6ef4f72acaab.tar.gz |
cleanup: split multi_update test in two
move binlog-dependent part (~6%) into a separate file, to be able
to run the rest of multi_update with embedded server
(include/have_log_bin.inc disables embedded)
-rw-r--r-- | mysql-test/r/multi_update.result | 62 | ||||
-rw-r--r-- | mysql-test/r/multi_update_binlog.result | 61 | ||||
-rw-r--r-- | mysql-test/t/multi_update.test | 85 | ||||
-rw-r--r-- | mysql-test/t/multi_update_binlog.test | 82 |
4 files changed, 145 insertions, 145 deletions
diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result index 634b3897ba0..2a0a6677c6f 100644 --- a/mysql-test/r/multi_update.result +++ b/mysql-test/r/multi_update.result @@ -1,4 +1,3 @@ -CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT."); create table t1(id1 int not null auto_increment primary key, t char(12)); create table t2(id2 int not null, t char(12)); create table t3(id3 int not null, t char(12), index(id3)); @@ -429,6 +428,7 @@ connection root; revoke all privileges on mysqltest.t1 from mysqltest_1@localhost; revoke all privileges on mysqltest.* from mysqltest_1@localhost; delete from mysql.user where user=_binary'mysqltest_1'; +flush privileges; drop database mysqltest; connection default; disconnect user1; @@ -565,66 +565,6 @@ id c1 c2 2 test t ppc 9 abc ppc drop table t1, t2; -CREATE TABLE `t1` ( -`a` int(11) NOT NULL auto_increment, -`b` int(11) default NULL, -PRIMARY KEY (`a`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 ; -CREATE TABLE `t2` ( -`a` int(11) NOT NULL auto_increment, -`b` int(11) default NULL, -PRIMARY KEY (`a`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 ; -set @sav_binlog_format= @@session.binlog_format; -set @@session.binlog_format= mixed; -insert into t1 values (1,1),(2,2); -insert into t2 values (1,1),(4,4); -reset master; -UPDATE t2,t1 SET t2.a=t1.a+2; -ERROR 23000: Duplicate entry '3' for key 'PRIMARY' -select * from t2 /* must be (3,1), (4,4) */; -a b -3 1 -4 4 -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Annotate_rows # # UPDATE t2,t1 SET t2.a=t1.a+2 -master-bin.000001 # Table_map # # table_id: # (test.t2) -master-bin.000001 # Update_rows_v1 # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # COMMIT -delete from t1; -delete from t2; -insert into t1 values (1,2),(3,4),(4,4); -insert into t2 values (1,2),(3,4),(4,4); -reset master; -UPDATE t2,t1 SET t2.a=t2.b where t2.a=t1.a; -ERROR 23000: Duplicate entry '4' for key 'PRIMARY' -include/show_binlog_events.inc -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 # Gtid # # BEGIN GTID #-#-# -master-bin.000001 # Annotate_rows # # UPDATE t2,t1 SET t2.a=t2.b where t2.a=t1.a -master-bin.000001 # Table_map # # table_id: # (test.t2) -master-bin.000001 # Update_rows_v1 # # table_id: # flags: STMT_END_F -master-bin.000001 # Query # # COMMIT -drop table t1, t2; -set @@session.binlog_format= @sav_binlog_format; -CREATE TABLE t1 (a int, PRIMARY KEY (a)); -CREATE TABLE t2 (a int, PRIMARY KEY (a)); -CREATE TABLE t3 (a int, PRIMARY KEY (a)) ENGINE=MyISAM; -create trigger trg_del_t3 before delete on t3 for each row insert into t1 values (1); -insert into t2 values (1),(2); -insert into t3 values (1),(2); -reset master; -delete t3.* from t2,t3 where t2.a=t3.a; -ERROR 23000: Duplicate entry '1' for key 'PRIMARY' -select count(*) from t1 /* must be 1 */; -count(*) -1 -select count(*) from t3 /* must be 1 */; -count(*) -1 -drop table t1, t2, t3; # # Bug#49534: multitable IGNORE update with sql_safe_updates error # causes debug assertion diff --git a/mysql-test/r/multi_update_binlog.result b/mysql-test/r/multi_update_binlog.result new file mode 100644 index 00000000000..e77a4530dbf --- /dev/null +++ b/mysql-test/r/multi_update_binlog.result @@ -0,0 +1,61 @@ +CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT."); +CREATE TABLE `t1` ( +`a` int(11) NOT NULL auto_increment, +`b` int(11) default NULL, +PRIMARY KEY (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 ; +CREATE TABLE `t2` ( +`a` int(11) NOT NULL auto_increment, +`b` int(11) default NULL, +PRIMARY KEY (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 ; +set @sav_binlog_format= @@session.binlog_format; +set @@session.binlog_format= mixed; +insert into t1 values (1,1),(2,2); +insert into t2 values (1,1),(4,4); +reset master; +UPDATE t2,t1 SET t2.a=t1.a+2; +ERROR 23000: Duplicate entry '3' for key 'PRIMARY' +select * from t2 /* must be (3,1), (4,4) */; +a b +3 1 +4 4 +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Annotate_rows # # UPDATE t2,t1 SET t2.a=t1.a+2 +master-bin.000001 # Table_map # # table_id: # (test.t2) +master-bin.000001 # Update_rows_v1 # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +delete from t1; +delete from t2; +insert into t1 values (1,2),(3,4),(4,4); +insert into t2 values (1,2),(3,4),(4,4); +reset master; +UPDATE t2,t1 SET t2.a=t2.b where t2.a=t1.a; +ERROR 23000: Duplicate entry '4' for key 'PRIMARY' +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Annotate_rows # # UPDATE t2,t1 SET t2.a=t2.b where t2.a=t1.a +master-bin.000001 # Table_map # # table_id: # (test.t2) +master-bin.000001 # Update_rows_v1 # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +drop table t1, t2; +set @@session.binlog_format= @sav_binlog_format; +CREATE TABLE t1 (a int, PRIMARY KEY (a)); +CREATE TABLE t2 (a int, PRIMARY KEY (a)); +CREATE TABLE t3 (a int, PRIMARY KEY (a)) ENGINE=MyISAM; +create trigger trg_del_t3 before delete on t3 for each row insert into t1 values (1); +insert into t2 values (1),(2); +insert into t3 values (1),(2); +reset master; +delete t3.* from t2,t3 where t2.a=t3.a; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +select count(*) from t1 /* must be 1 */; +count(*) +1 +select count(*) from t3 /* must be 1 */; +count(*) +1 +drop table t1, t2, t3; diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index 64e61f7c0b5..0a7e6b221eb 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -2,12 +2,6 @@ # Test of update statement that uses many tables. # -# Requires grants, so won't work with embedded server test -source include/not_embedded.inc; -source include/have_log_bin.inc; - -CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT."); - create table t1(id1 int not null auto_increment primary key, t char(12)); create table t2(id2 int not null, t char(12)); create table t3(id3 int not null, t char(12), index(id3)); @@ -376,6 +370,7 @@ connection root; revoke all privileges on mysqltest.t1 from mysqltest_1@localhost; revoke all privileges on mysqltest.* from mysqltest_1@localhost; delete from mysql.user where user=_binary'mysqltest_1'; +flush privileges; drop database mysqltest; connection default; disconnect user1; @@ -497,84 +492,6 @@ select * from t1 order by i1; select * from t2 order by id; drop table t1, t2; -# -# Bug#27716 multi-update did partially and has not binlogged -# - -CREATE TABLE `t1` ( - `a` int(11) NOT NULL auto_increment, - `b` int(11) default NULL, - PRIMARY KEY (`a`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 ; - -CREATE TABLE `t2` ( - `a` int(11) NOT NULL auto_increment, - `b` int(11) default NULL, - PRIMARY KEY (`a`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 ; - -# as the test is about to see erroed queries in binlog -set @sav_binlog_format= @@session.binlog_format; -set @@session.binlog_format= mixed; - - -# A. testing multi_update::send_error() effective update -insert into t1 values (1,1),(2,2); -insert into t2 values (1,1),(4,4); -reset master; ---error ER_DUP_ENTRY -UPDATE t2,t1 SET t2.a=t1.a+2; -# check -select * from t2 /* must be (3,1), (4,4) */; -source include/show_binlog_events.inc; - -# B. testing multi_update::send_error() ineffective update -# (as there is a policy described at mysql_update() still go to binlog) -delete from t1; -delete from t2; -insert into t1 values (1,2),(3,4),(4,4); -insert into t2 values (1,2),(3,4),(4,4); -reset master; ---error ER_DUP_ENTRY -UPDATE t2,t1 SET t2.a=t2.b where t2.a=t1.a; -source include/show_binlog_events.inc; - -# cleanup -drop table t1, t2; -set @@session.binlog_format= @sav_binlog_format; - -# -# Bug#29136 erred multi-delete on trans table does not rollback -# - -# prepare -CREATE TABLE t1 (a int, PRIMARY KEY (a)); -CREATE TABLE t2 (a int, PRIMARY KEY (a)); -CREATE TABLE t3 (a int, PRIMARY KEY (a)) ENGINE=MyISAM; -create trigger trg_del_t3 before delete on t3 for each row insert into t1 values (1); - -insert into t2 values (1),(2); -insert into t3 values (1),(2); -reset master; - -# exec cases B, A - see innodb.test - -# B. send_eof() and send_error() afterward - ---error ER_DUP_ENTRY -delete t3.* from t2,t3 where t2.a=t3.a; - -# check -select count(*) from t1 /* must be 1 */; -select count(*) from t3 /* must be 1 */; - -# cleanup -drop table t1, t2, t3; - -# -# Add further tests from here -# - --echo # --echo # Bug#49534: multitable IGNORE update with sql_safe_updates error --echo # causes debug assertion diff --git a/mysql-test/t/multi_update_binlog.test b/mysql-test/t/multi_update_binlog.test new file mode 100644 index 00000000000..16155aa1af3 --- /dev/null +++ b/mysql-test/t/multi_update_binlog.test @@ -0,0 +1,82 @@ +# +# Test of update statement that uses many tables. +# + +source include/have_log_bin.inc; + +CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT."); + +# +# Bug#27716 multi-update did partially and has not binlogged +# + +CREATE TABLE `t1` ( + `a` int(11) NOT NULL auto_increment, + `b` int(11) default NULL, + PRIMARY KEY (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 ; + +CREATE TABLE `t2` ( + `a` int(11) NOT NULL auto_increment, + `b` int(11) default NULL, + PRIMARY KEY (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 ; + +# as the test is about to see erroed queries in binlog +set @sav_binlog_format= @@session.binlog_format; +set @@session.binlog_format= mixed; + + +# A. testing multi_update::send_error() effective update +insert into t1 values (1,1),(2,2); +insert into t2 values (1,1),(4,4); +reset master; +--error ER_DUP_ENTRY +UPDATE t2,t1 SET t2.a=t1.a+2; +# check +select * from t2 /* must be (3,1), (4,4) */; +source include/show_binlog_events.inc; + +# B. testing multi_update::send_error() ineffective update +# (as there is a policy described at mysql_update() still go to binlog) +delete from t1; +delete from t2; +insert into t1 values (1,2),(3,4),(4,4); +insert into t2 values (1,2),(3,4),(4,4); +reset master; +--error ER_DUP_ENTRY +UPDATE t2,t1 SET t2.a=t2.b where t2.a=t1.a; +source include/show_binlog_events.inc; + +# cleanup +drop table t1, t2; +set @@session.binlog_format= @sav_binlog_format; + +# +# Bug#29136 erred multi-delete on trans table does not rollback +# + +# prepare +CREATE TABLE t1 (a int, PRIMARY KEY (a)); +CREATE TABLE t2 (a int, PRIMARY KEY (a)); +CREATE TABLE t3 (a int, PRIMARY KEY (a)) ENGINE=MyISAM; +create trigger trg_del_t3 before delete on t3 for each row insert into t1 values (1); + +insert into t2 values (1),(2); +insert into t3 values (1),(2); +reset master; + +# exec cases B, A - see innodb.test + +# B. send_eof() and send_error() afterward + +--error ER_DUP_ENTRY +delete t3.* from t2,t3 where t2.a=t3.a; + +# check +select count(*) from t1 /* must be 1 */; +select count(*) from t3 /* must be 1 */; + +# cleanup +drop table t1, t2, t3; + |