summaryrefslogtreecommitdiff
path: root/mysql-test/suite/rpl/t/rpl_trigger.test
diff options
context:
space:
mode:
authorMats Kindahl <mats@sun.com>2008-12-03 20:55:49 +0100
committerMats Kindahl <mats@sun.com>2008-12-03 20:55:49 +0100
commit43e9d5b3d561e980b41e7ebea1fc09b3ad700c74 (patch)
tree930df0fa8aac6d031f6463171fdbc4a5c7b1a42f /mysql-test/suite/rpl/t/rpl_trigger.test
parentc780c2a24ce4077c6fdf12c1af14d825fefa8a51 (diff)
downloadmariadb-git-43e9d5b3d561e980b41e7ebea1fc09b3ad700c74.tar.gz
Bug #40116: Uncommited changes are replicated and stay on slave
after rollback on master When starting a transaction with a statement containing changes to both transactional tables and non-transactional tables, the statement is considered as non-transactional and is therefore written directly to the binary log. This behaviour was present in 5.0, and has propagated to 5.1. If a trigger containing a change of a non-transactional table is added to a transactional table, any changes to the transactional table is "tainted" as non-transactional. This patch solves the problem by removing the existing "hack" that allows non-transactional statements appearing first in a transaction to be written directly to the binary log. Instead, anything inside a transaction is treaded as part of the transaction and not written to the binary log until the transaction is committed. mysql-test/suite/rpl/t/rpl_row_create_table.test: Removing positions from SHOW BINLOG EVENTS and using reset_master_and_slave to start on a fresh binary log each time. mysql-test/suite/rpl/t/rpl_slave_skip.test: Adding explicit commit in AUTOCOMMIT=0 to make test work correctly. mysql-test/suite/rpl/t/rpl_trigger.test: Adding test case for BUG#40116. sql/log.cc: Changing commit logic in binlog_commit() to only commit when committing a real transaction or committing a punch transaction.
Diffstat (limited to 'mysql-test/suite/rpl/t/rpl_trigger.test')
-rw-r--r--mysql-test/suite/rpl/t/rpl_trigger.test40
1 files changed, 33 insertions, 7 deletions
diff --git a/mysql-test/suite/rpl/t/rpl_trigger.test b/mysql-test/suite/rpl/t/rpl_trigger.test
index 911110d17dc..8e911178dcc 100644
--- a/mysql-test/suite/rpl/t/rpl_trigger.test
+++ b/mysql-test/suite/rpl/t/rpl_trigger.test
@@ -467,20 +467,46 @@ drop trigger if exists t1_bi;
insert into t1 values (3, "c");
select * from t1;
+sync_slave_with_master;
+select * from t1;
-save_master_pos;
-connection slave;
-sync_with_master;
+connection master;
+
+drop table t1;
+sync_slave_with_master;
+
+#
+# Bug#40116: Uncommited changes are replicated and stay on slave after
+# rollback on master
+#
+
+source include/master-slave-reset.inc;
+source include/have_innodb.inc;
+
+connection master;
+create table t1 ( f int ) engine = innodb;
+create table log ( r int ) engine = myisam;
+create trigger tr
+ after insert on t1
+ for each row insert into log values ( new.f );
+
+set autocommit = 0;
+insert into t1 values ( 1 );
select * from t1;
+sync_slave_with_master;
+select * from t1;
connection master;
+rollback;
+select * from t1;
+sync_slave_with_master;
+select * from t1;
-drop table t1;
+connection master;
+drop table t1, log;
+sync_slave_with_master;
#
# End of tests
#
-save_master_pos;
-connection slave;
-sync_with_master;