List:Commits« Previous MessageNext Message »
From:Dao-Gang.Qu Date:July 14 2010 3:34am
Subject:bzr commit into mysql-next-mr branch (Dao-Gang.Qu:3166) WL#5404
View as plain text  
#At file:///home/daogangqu/mysql/bzrwork1/wl5404/mysql-next-mr-wl4033/ based on revid:dao-gang.qu@stripped

 3166 Dao-Gang.Qu@stripped	2010-07-14
      WL#5404 Propagation of Rows_query log event when using a relay
             
      Rows_query was introduced to record the original query for rows events
      in RBR, but the Rows query will be lost when replicating on slave or
      re-applying the statments dumped by mysqlbinlog. This worklog will fix
      that.
     @ mysql-test/suite/rpl/r/rpl_ignorable_event.result
        Test result for WL#5404.
     @ mysql-test/suite/rpl/t/rpl_ignorable_event-master.opt
        Added the file to set the value of '--binlog-row-event-max-size',
        so that the load data statement can be logged in two rows and
        test that the Rows_query log event will work fine with the case.
     @ mysql-test/suite/rpl/t/rpl_ignorable_event-slave.opt
        Added the file to test replicate filter rules.
     @ mysql-test/suite/rpl/t/rpl_ignorable_event.test
        Added test to verify if the Rows_query log event can be
        applied and relayed.
     @ sql/log_event.cc
        Added code to make that the Rows_query log event can be applied
        and relayed
     @ sql/rpl_rli.cc
        Added code to clear the last Rows_query log event recorded
        in Relay_log_info when the SQL thread is stopped before
        executing its rows event
     @ sql/rpl_slave.cc
        Added code to invoke 'handle_rows_query_log_event' func to delay to
        delete the Rows_query log event untill all its rows event is applied
        on slave side
     @ sql/sql_binlog.cc
        Added code to invoke 'handle_rows_query_log_event' func to delay to
        delete the Rows_query log event untill all its rows event is applied
        on server side

    added:
      mysql-test/suite/rpl/r/rpl_ignorable_event.result
      mysql-test/suite/rpl/t/rpl_ignorable_event-master.opt
      mysql-test/suite/rpl/t/rpl_ignorable_event-slave.opt
      mysql-test/suite/rpl/t/rpl_ignorable_event.test
    modified:
      sql/log_event.cc
      sql/log_event.h
      sql/rpl_rli.cc
      sql/rpl_rli.h
      sql/rpl_slave.cc
      sql/sql_binlog.cc
=== added file 'mysql-test/suite/rpl/r/rpl_ignorable_event.result'
--- a/mysql-test/suite/rpl/r/rpl_ignorable_event.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_ignorable_event.result	2010-07-14 03:34:17 +0000
@@ -0,0 +1,962 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+# Test non-transaction
+create table t1(a int, b int) engine= myisam;
+insert into t1(a,b) values(1,1),(2,1);
+update t1 set a = a + 5 where b = 1 LIMIT 1;
+delete from t1 where a = 6;
+# Test transaction
+create table t2(a int, b int) engine=innodb;
+begin;
+insert into t2(a,b) values(2,1),(3,1);
+update t2 set a = a + 5 where b = 1;
+delete from t2 where a = 7;
+commit;
+# Test mixed transaction
+begin;
+insert into t1(a,b) values(1,5);
+insert into t2(a,b) values(2,5);
+insert into t2(a,b) values(2,6);
+insert into t1(a,b) values(1,7);
+commit;
+drop table t1, t2;
+create table t3(a int, b int) engine= myisam;
+create table t4(a int, b int) engine= myisam;
+create table t5(a int, b int) engine= myisam;
+insert into t3(a, b) values(1,1);
+# Test the Rows_query log event will be filtered out if slave applys
+# '--replicate-ignore-table' option on the table
+insert into t4(a, b) values(2,1);
+# Test the Rows_query log event will be relayed if slave
+# filters out part Rows event from a rows statement
+update t3,t4 set t3.a=3, t4.a=4 where t3.b=t4.b;
+# Test the Rows_query log event will be filtered out if slave applys
+# '--replicate-wild-ignore-table' option on the table
+insert into t5(a, b) values(3,1);
+# Test the Rows_query log event will be filtered out if slave filters
+# out all its related tables by replication filtering rules
+update t4,t5 set t4.a=4, t5.a=5 where t4.b=t5.b;
+# Test insert delayed ...
+insert delayed into t3(a,b) values(1,5),(1,6),(1,7);
+# Test load data infile
+create table t6(a VARCHAR(60)) engine= myisam;
+load data infile '../../std_data/words.dat' into table t6;
+drop table t3, t6;
+drop table t4, t5;
+# SHOW BINLOG EVENTS ON MASTER before '--exec MYSQL_BINLOG'
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	use `test`; create table t1(a int, b int) engine= myisam
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert into t1(a,b) values(1,1),(2,1)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# update t1 set a = a + 5 where b = 1 LIMIT 1
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# delete from t1 where a = 6
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Delete_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	use `test`; create table t2(a int, b int) engine=innodb
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert into t2(a,b) values(2,1),(3,1)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Rows_query	#	#	# update t2 set a = a + 5 where b = 1
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+master-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Rows_query	#	#	# delete from t2 where a = 7
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+master-bin.000001	#	Delete_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert into t1(a,b) values(1,5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert into t1(a,b) values(1,7)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert into t2(a,b) values(2,5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Rows_query	#	#	# insert into t2(a,b) values(2,6)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	use `test`; drop table t1, t2
+master-bin.000001	#	Query	#	#	use `test`; create table t3(a int, b int) engine= myisam
+master-bin.000001	#	Query	#	#	use `test`; create table t4(a int, b int) engine= myisam
+master-bin.000001	#	Query	#	#	use `test`; create table t5(a int, b int) engine= myisam
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert into t3(a, b) values(1,1)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t3)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert into t4(a, b) values(2,1)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t4)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# update t3,t4 set t3.a=3, t4.a=4 where t3.b=t4.b
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t3)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t4)
+master-bin.000001	#	Update_rows	#	#	table_id: #
+master-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert into t5(a, b) values(3,1)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t5)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# update t4,t5 set t4.a=4, t5.a=5 where t4.b=t5.b
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t4)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t5)
+master-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert delayed into t3(a,b) values(1,5),(1,6),(1,7)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t3)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	use `test`; create table t6(a VARCHAR(60)) engine= myisam
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# load data infile '../../std_data/words.dat' into table t6
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t6)
+master-bin.000001	#	Write_rows	#	#	table_id: #
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	use `test`; drop table t3, t6
+master-bin.000001	#	Query	#	#	use `test`; drop table t4, t5
+# MYSQL_BINLOG output base on master-bin.000001
+/*!40019 SET @@session.max_insert_delayed_threads=0*/;
+/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
+DELIMITER /*!*/;
+# at #
+#server id #  end_log_pos # 	Start: binlog v#, server v #.##.## created # #:#:# at startup
+# Warning: this binlog is either in use or was not closed properly.
+ROLLBACK/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+use test/*!*/;
+SET TIMESTAMP=t/*!*/;
+SET @@session.pseudo_thread_id=#/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.sql_mode=0/*!*/;
+SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
+/*!\C latin1 *//*!*/;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
+SET @@session.lc_time_names=0/*!*/;
+SET @@session.collation_database=DEFAULT/*!*/;
+create table t1(a int, b int) engine= myisam
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# insert into t1(a,b) values(1,1),(2,1)
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t1` mapped to number #
+#server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
+### INSERT INTO test.t1
+### SET
+###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+### INSERT INTO test.t1
+### SET
+###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+COMMIT
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# update t1 set a = a + 5 where b = 1 LIMIT 1
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t1` mapped to number #
+#server id #  end_log_pos # 	Update_rows: table id # flags: STMT_END_F
+### UPDATE test.t1
+### WHERE
+###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+### SET
+###   @1=6 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+COMMIT
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# delete from t1 where a = 6
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t1` mapped to number #
+#server id #  end_log_pos # 	Delete_rows: table id # flags: STMT_END_F
+### DELETE FROM test.t1
+### WHERE
+###   @1=6 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+COMMIT
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+create table t2(a int, b int) engine=innodb
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# insert into t2(a,b) values(2,1),(3,1)
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t2` mapped to number #
+#server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
+### INSERT INTO test.t2
+### SET
+###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+### INSERT INTO test.t2
+### SET
+###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Rows_query
+# update t2 set a = a + 5 where b = 1
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t2` mapped to number #
+#server id #  end_log_pos # 	Update_rows: table id # flags: STMT_END_F
+### UPDATE test.t2
+### WHERE
+###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+### SET
+###   @1=7 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+### UPDATE test.t2
+### WHERE
+###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+### SET
+###   @1=8 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Rows_query
+# delete from t2 where a = 7
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t2` mapped to number #
+#server id #  end_log_pos # 	Delete_rows: table id # flags: STMT_END_F
+### DELETE FROM test.t2
+### WHERE
+###   @1=7 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Xid = #
+COMMIT/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# insert into t1(a,b) values(1,5)
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t1` mapped to number #
+#server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
+### INSERT INTO test.t1
+### SET
+###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=5 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+COMMIT
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# insert into t1(a,b) values(1,7)
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t1` mapped to number #
+#server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
+### INSERT INTO test.t1
+### SET
+###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=7 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+COMMIT
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# insert into t2(a,b) values(2,5)
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t2` mapped to number #
+#server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
+### INSERT INTO test.t2
+### SET
+###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=5 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Rows_query
+# insert into t2(a,b) values(2,6)
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t2` mapped to number #
+#server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
+### INSERT INTO test.t2
+### SET
+###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=6 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Xid = #
+COMMIT/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+drop table t1, t2
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+create table t3(a int, b int) engine= myisam
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+create table t4(a int, b int) engine= myisam
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+create table t5(a int, b int) engine= myisam
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# insert into t3(a, b) values(1,1)
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t3` mapped to number #
+#server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
+### INSERT INTO test.t3
+### SET
+###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+COMMIT
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# insert into t4(a, b) values(2,1)
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t4` mapped to number #
+#server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
+### INSERT INTO test.t4
+### SET
+###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+COMMIT
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# update t3,t4 set t3.a=3, t4.a=4 where t3.b=t4.b
+# at #
+# at #
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t3` mapped to number #
+#server id #  end_log_pos # 	Table_map: `test`.`t4` mapped to number #
+#server id #  end_log_pos # 	Update_rows: table id #
+#server id #  end_log_pos # 	Update_rows: table id # flags: STMT_END_F
+### UPDATE test.t3
+### WHERE
+###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+### SET
+###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+### UPDATE test.t4
+### WHERE
+###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+### SET
+###   @1=4 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+COMMIT
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# insert into t5(a, b) values(3,1)
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t5` mapped to number #
+#server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
+### INSERT INTO test.t5
+### SET
+###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+COMMIT
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# update t4,t5 set t4.a=4, t5.a=5 where t4.b=t5.b
+# at #
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t4` mapped to number #
+#server id #  end_log_pos # 	Table_map: `test`.`t5` mapped to number #
+#server id #  end_log_pos # 	Update_rows: table id # flags: STMT_END_F
+### UPDATE test.t5
+### WHERE
+###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+### SET
+###   @1=5 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+COMMIT
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# insert delayed into t3(a,b) values(1,5),(1,6),(1,7)
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t3` mapped to number #
+#server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
+### INSERT INTO test.t3
+### SET
+###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=5 /* INT meta=0 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=6 /* INT meta=0 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=7 /* INT meta=0 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+COMMIT
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+create table t6(a VARCHAR(60)) engine= myisam
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+BEGIN
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Rows_query
+# load data infile '../../std_data/words.dat' into table t6
+# at #
+# at #
+# at #
+#server id #  end_log_pos # 	Table_map: `test`.`t6` mapped to number #
+#server id #  end_log_pos # 	Write_rows: table id #
+#server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
+### INSERT INTO test.t6
+### SET
+###   @1='Aarhus' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Aaron' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Ababa' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='aback' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abaft' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abandon' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abandoned' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abandoning' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abandonment' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abandons' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Aarhus' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Aaron' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Ababa' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='aback' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abaft' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abandon' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abandoned' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abandoning' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abandonment' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abandons' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abase' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abased' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abasement' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abasements' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abases' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abash' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abashed' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abashes' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abashing' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abasing' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abate' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abated' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abatement' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abatements' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abater' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abates' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abating' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Abba' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abbe' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abbey' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abbeys' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abbot' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abbots' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Abbott' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abbreviate' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abbreviated' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abbreviates' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abbreviating' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abbreviation' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abbreviations' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Abby' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abdomen' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abdomens' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abdominal' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abduct' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abducted' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abduction' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abductions' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abductor' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abductors' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abducts' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Abe' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='abed' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Abel' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Abelian' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Abelson' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Aberdeen' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='Abernathy' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='aberrant' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t6
+### SET
+###   @1='aberration' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+COMMIT
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+drop table t3, t6
+/*!*/;
+# at #
+#server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
+SET TIMESTAMP=t/*!*/;
+drop table t4, t5
+/*!*/;
+DELIMITER ;
+# End of log file
+ROLLBACK /* added by mysqlbinlog */;
+/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+# Test the Rows_query log event can be applied
+# SHOW BINLOG EVENTS ON MASTER after '--exec MYSQL_BINLOG'
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	use `test`; create table t1(a int, b int) engine= myisam
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert into t1(a,b) values(1,1),(2,1)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# update t1 set a = a + 5 where b = 1 LIMIT 1
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# delete from t1 where a = 6
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Delete_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	use `test`; create table t2(a int, b int) engine=innodb
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert into t2(a,b) values(2,1),(3,1)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Rows_query	#	#	# update t2 set a = a + 5 where b = 1
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+master-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Rows_query	#	#	# delete from t2 where a = 7
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+master-bin.000001	#	Delete_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert into t1(a,b) values(1,5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert into t1(a,b) values(1,7)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert into t2(a,b) values(2,5)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Rows_query	#	#	# insert into t2(a,b) values(2,6)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	use `test`; drop table t1, t2
+# Test The Rows_query log event can be relayed.
+# SHOW BINLOG EVENTS ON SLAVE
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+slave-bin.000001	#	Query	#	#	use `test`; create table t1(a int, b int) engine= myisam
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# insert into t1(a,b) values(1,1),(2,1)
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	COMMIT
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# update t1 set a = a + 5 where b = 1 LIMIT 1
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	COMMIT
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# delete from t1 where a = 6
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Delete_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	COMMIT
+slave-bin.000001	#	Query	#	#	use `test`; create table t2(a int, b int) engine=innodb
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# insert into t2(a,b) values(2,1),(3,1)
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Rows_query	#	#	# update t2 set a = a + 5 where b = 1
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+slave-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Rows_query	#	#	# delete from t2 where a = 7
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+slave-bin.000001	#	Delete_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Xid	#	#	COMMIT /* XID */
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# insert into t1(a,b) values(1,5)
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	COMMIT
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# insert into t1(a,b) values(1,7)
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	COMMIT
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# insert into t2(a,b) values(2,5)
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Rows_query	#	#	# insert into t2(a,b) values(2,6)
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Xid	#	#	COMMIT /* XID */
+slave-bin.000001	#	Query	#	#	use `test`; drop table t1, t2
+slave-bin.000001	#	Query	#	#	use `test`; create table t3(a int, b int) engine= myisam
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# insert into t3(a, b) values(1,1)
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t3)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	COMMIT
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# update t3,t4 set t3.a=3, t4.a=4 where t3.b=t4.b
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t3)
+slave-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	COMMIT
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# insert delayed into t3(a,b) values(1,5),(1,6),(1,7)
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t3)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	COMMIT
+slave-bin.000001	#	Query	#	#	use `test`; create table t6(a VARCHAR(60)) engine= myisam
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# load data infile '../../std_data/words.dat' into table t6
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t6)
+slave-bin.000001	#	Write_rows	#	#	table_id: #
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	COMMIT
+slave-bin.000001	#	Query	#	#	use `test`; drop table t3, t6
+slave-bin.000001	#	Query	#	#	use `test`; create table t1(a int, b int) engine= myisam
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# insert into t1(a,b) values(1,1),(2,1)
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	COMMIT
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# update t1 set a = a + 5 where b = 1 LIMIT 1
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	COMMIT
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# delete from t1 where a = 6
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Delete_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	COMMIT
+slave-bin.000001	#	Query	#	#	use `test`; create table t2(a int, b int) engine=innodb
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# insert into t2(a,b) values(2,1),(3,1)
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Rows_query	#	#	# update t2 set a = a + 5 where b = 1
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+slave-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Rows_query	#	#	# delete from t2 where a = 7
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+slave-bin.000001	#	Delete_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Xid	#	#	COMMIT /* XID */
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# insert into t1(a,b) values(1,5)
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	COMMIT
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# insert into t1(a,b) values(1,7)
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	COMMIT
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# insert into t2(a,b) values(2,5)
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Rows_query	#	#	# insert into t2(a,b) values(2,6)
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Xid	#	#	COMMIT /* XID */
+slave-bin.000001	#	Query	#	#	use `test`; drop table t1, t2

=== added file 'mysql-test/suite/rpl/t/rpl_ignorable_event-master.opt'
--- a/mysql-test/suite/rpl/t/rpl_ignorable_event-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_ignorable_event-master.opt	2010-07-14 03:34:17 +0000
@@ -0,0 +1 @@
+--binlog-row-event-max-size=512 --binlog-rows-query-log-events=1

=== added file 'mysql-test/suite/rpl/t/rpl_ignorable_event-slave.opt'
--- a/mysql-test/suite/rpl/t/rpl_ignorable_event-slave.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_ignorable_event-slave.opt	2010-07-14 03:34:17 +0000
@@ -0,0 +1 @@
+--binlog-row-event-max-size=512 --binlog-rows-query-log-events=1 --replicate-ignore-table=test.t4 --replicate-wild-ignore-table=test.t5

=== added file 'mysql-test/suite/rpl/t/rpl_ignorable_event.test'
--- a/mysql-test/suite/rpl/t/rpl_ignorable_event.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_ignorable_event.test	2010-07-14 03:34:17 +0000
@@ -0,0 +1,90 @@
+#
+# WL#4033 & WL#5404
+# This test verifies if the query of the rows event
+# is displayed with its row event as comment in RBR
+# by SHOW BINLOG EVENTS and MYSQLBINLOG DUMP.
+# Verifies if the Rows_query log event can be applied
+# and relayed 
+#
+
+source include/have_binlog_format_row.inc;
+source include/master-slave.inc;
+source include/have_innodb.inc;
+
+--echo # Test non-transaction
+let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
+let $master_binlog= query_get_value(SHOW MASTER STATUS, File, 1);
+create table t1(a int, b int) engine= myisam;
+insert into t1(a,b) values(1,1),(2,1);
+update t1 set a = a + 5 where b = 1 LIMIT 1;
+delete from t1 where a = 6;
+
+-- echo # Test transaction
+create table t2(a int, b int) engine=innodb;
+begin;
+insert into t2(a,b) values(2,1),(3,1);
+update t2 set a = a + 5 where b = 1;
+delete from t2 where a = 7;
+commit;
+
+--echo # Test mixed transaction
+begin;
+insert into t1(a,b) values(1,5);
+insert into t2(a,b) values(2,5);
+insert into t2(a,b) values(2,6);
+insert into t1(a,b) values(1,7);
+commit;
+
+drop table t1, t2;
+let $end_pos= query_get_value("SHOW MASTER STATUS", Position, 1);
+
+create table t3(a int, b int) engine= myisam;
+create table t4(a int, b int) engine= myisam;
+create table t5(a int, b int) engine= myisam;
+insert into t3(a, b) values(1,1);
+--echo # Test the Rows_query log event will be filtered out if slave applys
+--echo # '--replicate-ignore-table' option on the table
+insert into t4(a, b) values(2,1);
+--echo # Test the Rows_query log event will be relayed if slave
+--echo # filters out part Rows event from a rows statement
+update t3,t4 set t3.a=3, t4.a=4 where t3.b=t4.b;
+
+--echo # Test the Rows_query log event will be filtered out if slave applys
+--echo # '--replicate-wild-ignore-table' option on the table
+insert into t5(a, b) values(3,1);
+--echo # Test the Rows_query log event will be filtered out if slave filters
+--echo # out all its related tables by replication filtering rules
+update t4,t5 set t4.a=4, t5.a=5 where t4.b=t5.b;
+
+--echo # Test insert delayed ...
+insert delayed into t3(a,b) values(1,5),(1,6),(1,7);
+
+--echo # Test load data infile
+create table t6(a VARCHAR(60)) engine= myisam;
+load data infile '../../std_data/words.dat' into table t6;
+
+drop table t3, t6;
+drop table t4, t5;
+
+--echo # SHOW BINLOG EVENTS ON MASTER before '--exec MYSQL_BINLOG'
+source include/show_binlog_events.inc;
+
+--echo # MYSQL_BINLOG output base on master-bin.000001
+let $MYSQLD_DATADIR= `select @@datadir`;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--replace_regex /TIMESTAMP=[0-9]*/TIMESTAMP=t/ /#[0-9]*[ ]*[0-9]*:[0-9]*:[0-9]* server id [0-9]*/#server id #/ /exec_time=[0-9]*/exec_time=#/ /error_code=[0-9]*/error_code=#/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /Xid = [0-9]*/Xid = #/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /server v [^ ]*/server v #.##.##/ /Start: binlog v [0-9]*/Start: binlog v#/ /created [0-9]*[ ]*[0-9]*:[0-9]*:[0-9]* at startup/created # #:#:# at startup/
+--exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $MYSQLD_DATADIR/$master_binlog
+
+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
+--echo # Test the Rows_query log event can be applied
+--exec $MYSQL_BINLOG -v -v --stop-position=$end_pos $MYSQLD_DATADIR/$master_binlog | $MYSQL test 2>&1
+
+--echo # SHOW BINLOG EVENTS ON MASTER after '--exec MYSQL_BINLOG'
+source include/show_binlog_events.inc;
+
+sync_slave_with_master;
+--let $binlog_start= query_get_value(SHOW BINLOG EVENTS LIMIT 1, End_log_pos, 1)
+--echo # Test The Rows_query log event can be relayed.
+--echo # SHOW BINLOG EVENTS ON SLAVE
+source include/show_binlog_events.inc;
+

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2010-07-07 06:48:50 +0000
+++ b/sql/log_event.cc	2010-07-14 03:34:17 +0000
@@ -126,6 +126,36 @@ static const char *HA_ERR(int i)
 }
 
 /**
+  Delay to delete the Rows_query log event until all its rows event are applied
+
+  @param ev    log event should be deleted
+  @param rli   Relay_log_info structure for the slave IO thread.
+*/
+void handle_rows_query_log_event(Log_event *ev, Relay_log_info *rli)
+{
+  DBUG_ENTER("handle_rows_query_log_event");
+  Log_event_type ev_type= ev->get_type_code();
+
+  /* Delete the Rows_query log event after its last rows event are applied */
+  if ((ev_type == WRITE_ROWS_EVENT || ev_type == DELETE_ROWS_EVENT ||
+       ev_type == UPDATE_ROWS_EVENT) && rli->rows_query_ev != NULL &&
+      ((Rows_log_event*) ev)->get_flags(Rows_log_event::STMT_END_F))
+  {
+    delete rli->rows_query_ev;
+    rli->rows_query_ev= NULL;
+  }
+
+  /* Record the Rows_query log event until all its rows event are applied */
+  if (ev_type == ROWS_QUERY_LOG_EVENT)
+  {
+    DBUG_ASSERT(rli->rows_query_ev == NULL);
+    rli->rows_query_ev= (Rows_query_log_event*) ev;
+  }
+
+  DBUG_VOID_RETURN;
+}
+
+/**
    Error reporting facility for Rows_log_event::do_apply_event
 
    @param level     error, warning or info
@@ -9750,8 +9780,14 @@ Rows_query_log_event::~Rows_query_log_ev
 #ifndef MYSQL_CLIENT
 void Rows_query_log_event::pack_info(Protocol *protocol)
 {
-  protocol->store(m_rows_query, (uint) strlen(m_rows_query),
-                  &my_charset_bin);
+  char *buf;
+  size_t bytes;
+  ulong len= sizeof("# ") + (ulong) strlen(m_rows_query);
+  if (!(buf= (char*) my_malloc(len, MYF(MY_WME))))
+    return;
+  bytes= my_snprintf(buf, len, "# %s", m_rows_query);
+  protocol->store(buf, bytes, &my_charset_bin);
+  my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
 }
 #endif
 
@@ -9766,7 +9802,7 @@ Rows_query_log_event::print(FILE *file,
   Write_on_release_cache cache(&print_event_info->head_cache, file);
   print_header(&cache, print_event_info, FALSE);
   my_b_printf(&cache, "\tRows_query\n");
-  my_b_printf(&cache, "%s\n", m_rows_query);
+  my_b_printf(&cache, "# %s\n", m_rows_query);
 
   IO_CACHE *const body= &print_event_info->body_cache;
   print_base64(body, print_event_info, true);
@@ -9780,6 +9816,17 @@ Rows_query_log_event::write_data_body(IO
   DBUG_RETURN(write_str(file, m_rows_query, (uint) strlen(m_rows_query)));
 }
 
+#ifndef MYSQL_CLIENT
+int Rows_query_log_event::do_apply_event(Relay_log_info const *rli)
+{
+  DBUG_ENTER("Rows_query_log_event::do_apply_event");
+  DBUG_ASSERT(rli->sql_thd == thd);
+  /* Set query for writing Rows_query log event into binlog later.*/
+  thd->set_query(m_rows_query, (uint32) strlen(m_rows_query));
+  DBUG_RETURN(0);
+}
+#endif /* !MYSQL_CLIENT */
+
 
 #ifdef MYSQL_CLIENT
 /**

=== modified file 'sql/log_event.h'
--- a/sql/log_event.h	2010-07-07 06:48:50 +0000
+++ b/sql/log_event.h	2010-07-14 03:34:17 +0000
@@ -4105,10 +4105,9 @@ public:
     : Ignorable_log_event(thd_arg)
   {
     DBUG_ENTER("Rows_query_log_event::Rows_query_log_event");
-    ulong len= sizeof("# ") + query_len + 1;
-    if (!(m_rows_query= (char*) my_malloc(len, MYF(MY_WME))))
+    if (!(m_rows_query= (char*) my_malloc(query_len + 1, MYF(MY_WME))))
       return;
-    my_snprintf(m_rows_query, len, "# %s", query);
+    my_snprintf(m_rows_query, query_len + 1, "%s", query);
     DBUG_PRINT("enter", ("%s", m_rows_query));
     DBUG_VOID_RETURN;
   }
@@ -4136,6 +4135,9 @@ public:
   }
 
 private:
+#if !defined(MYSQL_CLIENT)
+  virtual int do_apply_event(Relay_log_info const* rli);
+#endif
 
   char * m_rows_query;
 };
@@ -4189,6 +4191,7 @@ private:
 int append_query_string(CHARSET_INFO *csinfo,
                         String const *from, String *to);
 bool sqlcom_can_generate_row_events(const THD *thd);
+void handle_rows_query_log_event(Log_event *ev, Relay_log_info *rli);
 
 /**
   @} (end of group Replication)

=== modified file 'sql/rpl_rli.cc'
--- a/sql/rpl_rli.cc	2010-06-22 12:58:10 +0000
+++ b/sql/rpl_rli.cc	2010-07-14 03:34:17 +0000
@@ -47,7 +47,7 @@ Relay_log_info::Relay_log_info(bool is_s
    tables_to_lock(0), tables_to_lock_count(0),
    last_event_start_time(0),
    sql_delay(0), sql_delay_end(0),
-   m_flags(0)
+   m_flags(0), rows_query_ev(NULL)
 {
   DBUG_ENTER("Relay_log_info::Relay_log_info");
 
@@ -1290,6 +1290,11 @@ void Relay_log_info::cleanup_context(THD
   {
     trans_rollback_stmt(thd); // if a "statement transaction"
     trans_rollback(thd);      // if a "real transaction"
+    if (rows_query_ev)
+    {
+      delete rows_query_ev;
+      rows_query_ev= NULL;
+    }
   }
   m_table_map.clear_tables();
   slave_close_thread_tables(thd);

=== modified file 'sql/rpl_rli.h'
--- a/sql/rpl_rli.h	2010-06-22 12:58:10 +0000
+++ b/sql/rpl_rli.h	2010-07-14 03:34:17 +0000
@@ -357,6 +357,8 @@ public:
   RPL_TABLE_LIST *tables_to_lock;           /* RBR: Tables to lock  */
   uint tables_to_lock_count;        /* RBR: Count of tables to lock */
   table_mapping m_table_map;      /* RBR: Mapping table-id to table */
+  /* RBR: Record Rows_query log event */
+  Rows_query_log_event* rows_query_ev;
 
   bool get_table_data(TABLE *table_arg, table_def **tabledef_var, TABLE **conv_table_var) const
   {

=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc	2010-06-23 09:56:24 +0000
+++ b/sql/rpl_slave.cc	2010-07-14 03:34:17 +0000
@@ -2740,8 +2740,15 @@ static int exec_relay_log_event(THD* thd
     */
     if (ev->get_type_code() != FORMAT_DESCRIPTION_EVENT)
     {
+      if (thd->variables.binlog_rows_query_log_events)
+        handle_rows_query_log_event(ev, rli);
+
       DBUG_PRINT("info", ("Deleting the event after it has been executed"));
-      delete ev;
+      if (ev->get_type_code() != ROWS_QUERY_LOG_EVENT)
+      {
+        delete ev;
+        ev= NULL;
+      }
     }
 
     /*

=== modified file 'sql/sql_binlog.cc'
--- a/sql/sql_binlog.cc	2010-06-22 12:58:10 +0000
+++ b/sql/sql_binlog.cc	2010-07-14 03:34:17 +0000
@@ -75,7 +75,8 @@ static int check_event_type(int type, Re
 
     /* It is always allowed to execute FD events. */
     return 0;
-    
+
+  case ROWS_QUERY_LOG_EVENT:
   case TABLE_MAP_EVENT:
   case WRITE_ROWS_EVENT:
   case UPDATE_ROWS_EVENT:
@@ -280,8 +281,15 @@ void mysql_client_binlog_statement(THD* 
         i.e. when this thread terminates.
       */
       if (ev->get_type_code() != FORMAT_DESCRIPTION_EVENT)
-        delete ev; 
-      ev= 0;
+      {
+        if (thd->variables.binlog_rows_query_log_events)
+          handle_rows_query_log_event(ev, rli);
+        if (ev->get_type_code() != ROWS_QUERY_LOG_EVENT)
+        {
+          delete ev;
+          ev= NULL;
+        }
+      }
       if (err)
       {
         /*
@@ -299,6 +307,11 @@ void mysql_client_binlog_statement(THD* 
   my_ok(thd);
 
 end:
+  if ((error || err) && rli->rows_query_ev)
+  {
+    delete rli->rows_query_ev;
+    rli->rows_query_ev= NULL;
+  }
   rli->slave_close_thread_tables(thd);
   my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
   DBUG_VOID_RETURN;


Attachment: [text/bzr-bundle] bzr/dao-gang.qu@sun.com-20100714033417-bru3jyszj7q3b0yt.bundle
Thread
bzr commit into mysql-next-mr branch (Dao-Gang.Qu:3166) WL#5404Dao-Gang.Qu14 Jul