List:Commits« Previous MessageNext Message »
From:Dao-Gang.Qu Date:June 24 2010 7:35am
Subject:bzr commit into mysql-5.1-rep+2 branch (Dao-Gang.Qu:3186) WL#5404
View as plain text  
#At file:///home/daogangqu/mysql/bzrwork/wl5404/mysql-5.1-rep%2B2/ based on revid:dao-gang.qu@stripped

 3186 Dao-Gang.Qu@stripped	2010-06-24
      WL#5404 Propagation of Rows_query log event when using a relay
      
      Using BINLOG statement to ship the Rows_query log event so that
      it can be applied and relayed.
     @ mysql-test/std_data/words3.dat
        Added the file to test load data infile for Rows_query log event
     @ mysql-test/suite/rpl/r/rpl_ignorable_event.result
        Test result for WL#5404.
     @ 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/slave.cc
        Added code 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 delay to delete the Rows_query log event
        untill all its rows event is applied on server side

    added:
      mysql-test/std_data/words3.dat
      mysql-test/suite/rpl/t/rpl_ignorable_event-slave.opt
    modified:
      mysql-test/suite/rpl/r/rpl_ignorable_event.result
      mysql-test/suite/rpl/t/rpl_ignorable_event.test
      sql/log_event.cc
      sql/log_event.h
      sql/rpl_rli.cc
      sql/rpl_rli.h
      sql/slave.cc
      sql/sql_binlog.cc
=== added file 'mysql-test/std_data/words3.dat'
--- a/mysql-test/std_data/words3.dat	1970-01-01 00:00:00 +0000
+++ b/mysql-test/std_data/words3.dat	2010-06-24 07:35:06 +0000
@@ -0,0 +1,120 @@
+Aarhus
+Aaron
+Ababa
+aback
+abaft
+abandon
+abandoned
+abandoning
+abandonment
+abandons
+Aarhus
+Aaron
+Ababa
+aback
+abaft
+abandon
+abandoned
+abandoning
+abandonment
+abandons
+abase
+abased
+abasement
+abasements
+abases
+abash
+abashed
+abashes
+abashing
+abasing
+abate
+abated
+abatement
+abatements
+abater
+abates
+abating
+Abba
+abbe
+abbey
+abbeys
+abbot
+abbots
+Abbott
+abbreviate
+abbreviated
+abbreviates
+abbreviating
+abbreviation
+abbreviations
+Abby
+abdomen
+abdomens
+abdominal
+abduct
+abducted
+abduction
+abductions
+abductor
+abductors
+abducts
+Abe
+abed
+Abel
+Abelian
+Abelson
+Aberdeen
+Abernathy
+aberrant
+aberration
+abase
+abased
+abasement
+abasements
+abases
+abash
+abashed
+abashes
+abashing
+abasing
+abate
+abated
+abatement
+abatements
+abater
+abates
+abating
+Abba
+abbe
+abbey
+abbeys
+abbot
+abbots
+Abbott
+abbreviate
+abbreviated
+abbreviates
+abbreviating
+abbreviation
+abbreviations
+Abby
+abdomen
+abdomens
+abdominal
+abduct
+abducted
+abduction
+abductions
+abductor
+abductors
+abducts
+Abe
+abed
+Abel
+Abelian
+Abelson
+Aberdeen
+Abernathy
+aberrant
+aberration

=== modified file 'mysql-test/suite/rpl/r/rpl_ignorable_event.result'
--- a/mysql-test/suite/rpl/r/rpl_ignorable_event.result	2010-06-18 09:16:24 +0000
+++ b/mysql-test/suite/rpl/r/rpl_ignorable_event.result	2010-06-24 07:35:06 +0000
@@ -12,14 +12,14 @@ set session binlog_rows_query_log_events
 select @@session.binlog_rows_query_log_events;
 @@session.binlog_rows_query_log_events
 1
-create table t1(i1 int not null auto_increment, a int, b int, primary key(i1));
+# Test non-transaction
+create table t1(a int, b int);
 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;
 insert into t1(a,b) values(1,2);
-insert into t1(a,b) values(1,3);
-insert into t1(a,b) values(1,4),(1,5),(1,5),(1,5),(1,5),(1,5),(1,5),(1,5),(1,5),(1,5);
-update t1 set a = a + 5 where b = 2;
+insert into t1(a,b) values(1,4),(1,5);
+# Test transaction
 create table t2(a int, b int) engine=innodb;
 begin;
 insert into t2(a,b) values(2,1),(3,1);
@@ -27,8 +27,9 @@ insert into t2(a,b) values(2,2);
 insert into t2(a,b) values(2,3);
 update t2 set a = a + 5 where b = 1;
 delete from t2 where a = 7;
-insert into t2(a,b) values(2,4),(2,4),(2,4),(2,4),(2,4),(2,4),(2,4),(2,4),(2,4);
+insert into t2(a,b) values(2,4),(2,5),(2,6);
 commit;
+# Test mixed transaction
 begin;
 insert into t1(a,b) values(1,5);
 insert into t1(a,b) values(1,6);
@@ -36,12 +37,16 @@ insert into t2(a,b) values(2,4);
 insert into t2(a,b) values(2,5);
 insert into t1(a,b) values(1,7);
 commit;
-insert delayed into t1(a,b) values(1,5),(1,6),(1,7),(1,8),(1,9),(1,10);
+# Test insert delayed ...
+insert delayed into t1(a,b) values(1,5),(1,6),(1,7);
+# Test load data infile
 create table t3(a VARCHAR(60));
-load data infile '../../std_data/words.dat' into table t3;
+load data infile '../../std_data/words3.dat' into table t3;
+drop table t1, t2, t3;
+# 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(i1 int not null auto_increment, a int, b int, primary key(i1))
+master-bin.000001	#	Query	#	#	use `test`; create table t1(a int, b int)
 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)
@@ -63,20 +68,97 @@ master-bin.000001	#	Table_map	#	#	table_
 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,3)
+master-bin.000001	#	Rows_query	#	#	# insert into t1(a,b) values(1,4),(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	#	#	use `test`; create table t2(a int, b int) engine=innodb
 master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Rows_query	#	#	# insert into t1(a,b) values(1,4),(1,5),(1,5),(1,5),(1,5),(1,5),(1,5),(1,5),(1,5),(1,5)
+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	#	#	# insert into t2(a,b) values(2,2)
+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,3)
+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	#	Rows_query	#	#	# insert into t2(a,b) values(2,4),(2,5),(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	#	#	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	#	#	# update t1 set a = a + 5 where b = 2
+master-bin.000001	#	Rows_query	#	#	# insert into t1(a,b) values(1,6)
+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,4)
+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,5)
+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	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert delayed into t1(a,b) values(1,5),(1,6),(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	#	#	use `test`; create table t3(a VARCHAR(60))
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# load data infile '../../std_data/words3.dat' into table t3
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t3)
+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 t1, t2, t3
+# 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)
+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	#	#	BEGIN
+master-bin.000001	#	Rows_query	#	#	# insert into t1(a,b) values(1,2)
+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,4),(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	#	#	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)
@@ -94,7 +176,7 @@ master-bin.000001	#	Update_rows	#	#	tabl
 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	#	Rows_query	#	#	# insert into t2(a,b) values(2,4),(2,4),(2,4),(2,4),(2,4),(2,4),(2,4),(2,4),(2,4)
+master-bin.000001	#	Rows_query	#	#	# insert into t2(a,b) values(2,4),(2,5),(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 */
@@ -122,16 +204,19 @@ master-bin.000001	#	Table_map	#	#	table_
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Xid	#	#	COMMIT /* XID */
 master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Rows_query	#	#	# insert delayed into t1(a,b) values(1,5),(1,6),(1,7),(1,8),(1,9),(1,10)
+master-bin.000001	#	Rows_query	#	#	# insert delayed into t1(a,b) values(1,5),(1,6),(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	#	#	use `test`; create table t3(a VARCHAR(60))
 master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Rows_query	#	#	# load data infile '../../std_data/words.dat' into table t3
+master-bin.000001	#	Rows_query	#	#	# load data infile '../../std_data/words3.dat' into table t3
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t3)
+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 t1, t2, t3
+# 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 /*!*/;
@@ -151,7 +236,7 @@ SET @@session.auto_increment_increment=1
 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(i1 int not null auto_increment, a int, b int, primary key(i1))
+create table t1(a int, b int)
 /*!*/;
 # at #
 #server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
@@ -167,14 +252,12 @@ BEGIN
 #server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
 ### INSERT INTO test.t1
 ### SET
-###   @1=1 /* INT meta=0 nullable=0 is_null=0 */
+###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
 ###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=1 /* INT meta=0 nullable=1 is_null=0 */
 ### INSERT INTO test.t1
 ### SET
-###   @1=2 /* INT meta=0 nullable=0 is_null=0 */
-###   @2=2 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=1 /* INT meta=0 nullable=1 is_null=0 */
+###   @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/*!*/;
@@ -194,13 +277,11 @@ BEGIN
 #server id #  end_log_pos # 	Update_rows: table id # flags: STMT_END_F
 ### UPDATE test.t1
 ### WHERE
-###   @1=1 /* INT meta=0 nullable=0 is_null=0 */
+###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
 ###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=1 /* INT meta=0 nullable=1 is_null=0 */
 ### SET
-###   @1=1 /* INT meta=0 nullable=0 is_null=0 */
-###   @2=6 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=1 /* INT meta=0 nullable=1 is_null=0 */
+###   @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/*!*/;
@@ -220,31 +301,8 @@ BEGIN
 #server id #  end_log_pos # 	Delete_rows: table id # flags: STMT_END_F
 ### DELETE FROM test.t1
 ### WHERE
-###   @1=1 /* INT meta=0 nullable=0 is_null=0 */
-###   @2=6 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=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 t1(a,b) values(1,2)
-# 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=3 /* INT meta=0 nullable=0 is_null=0 */
+###   @1=6 /* INT meta=0 nullable=1 is_null=0 */
 ###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=2 /* INT meta=0 nullable=1 is_null=0 */
 # at #
 #server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
 SET TIMESTAMP=t/*!*/;
@@ -257,16 +315,15 @@ BEGIN
 /*!*/;
 # at #
 #server id #  end_log_pos # 	Rows_query
-# insert into t1(a,b) values(1,3)
+# insert into t1(a,b) values(1,2)
 # 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=4 /* INT meta=0 nullable=0 is_null=0 */
-###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=3 /* INT meta=0 nullable=1 is_null=0 */
+###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=2 /* INT meta=0 nullable=1 is_null=0 */
 # at #
 #server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
 SET TIMESTAMP=t/*!*/;
@@ -279,87 +336,19 @@ BEGIN
 /*!*/;
 # at #
 #server id #  end_log_pos # 	Rows_query
-# insert into t1(a,b) values(1,4),(1,5),(1,5),(1,5),(1,5),(1,5),(1,5),(1,5),(1,5),(1,5)
+# insert into t1(a,b) values(1,4),(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=5 /* INT meta=0 nullable=0 is_null=0 */
-###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=4 /* INT meta=0 nullable=1 is_null=0 */
-### INSERT INTO test.t1
-### SET
-###   @1=6 /* INT meta=0 nullable=0 is_null=0 */
-###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=5 /* INT meta=0 nullable=1 is_null=0 */
-### INSERT INTO test.t1
-### SET
-###   @1=7 /* INT meta=0 nullable=0 is_null=0 */
-###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=5 /* INT meta=0 nullable=1 is_null=0 */
-### INSERT INTO test.t1
-### SET
-###   @1=8 /* INT meta=0 nullable=0 is_null=0 */
-###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=5 /* INT meta=0 nullable=1 is_null=0 */
-### INSERT INTO test.t1
-### SET
-###   @1=9 /* INT meta=0 nullable=0 is_null=0 */
-###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=5 /* INT meta=0 nullable=1 is_null=0 */
-### INSERT INTO test.t1
-### SET
-###   @1=10 /* INT meta=0 nullable=0 is_null=0 */
-###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=5 /* INT meta=0 nullable=1 is_null=0 */
-### INSERT INTO test.t1
-### SET
-###   @1=11 /* INT meta=0 nullable=0 is_null=0 */
-###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=5 /* INT meta=0 nullable=1 is_null=0 */
-### INSERT INTO test.t1
-### SET
-###   @1=12 /* INT meta=0 nullable=0 is_null=0 */
-###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=5 /* INT meta=0 nullable=1 is_null=0 */
-### INSERT INTO test.t1
-### SET
-###   @1=13 /* INT meta=0 nullable=0 is_null=0 */
-###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=5 /* INT meta=0 nullable=1 is_null=0 */
+###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=4 /* INT meta=0 nullable=1 is_null=0 */
 ### INSERT INTO test.t1
 ### SET
-###   @1=14 /* INT meta=0 nullable=0 is_null=0 */
-###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=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
-# update t1 set a = a + 5 where b = 2
-# 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=3 /* INT meta=0 nullable=0 is_null=0 */
-###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=2 /* INT meta=0 nullable=1 is_null=0 */
-### SET
-###   @1=3 /* INT meta=0 nullable=0 is_null=0 */
-###   @2=6 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=2 /* INT meta=0 nullable=1 is_null=0 */
+###   @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/*!*/;
@@ -446,7 +435,7 @@ BEGIN
 ###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
 # at #
 #server id #  end_log_pos # 	Rows_query
-# insert into t2(a,b) values(2,4),(2,4),(2,4),(2,4),(2,4),(2,4),(2,4),(2,4),(2,4)
+# insert into t2(a,b) values(2,4),(2,5),(2,6)
 # at #
 # at #
 #server id #  end_log_pos # 	Table_map: `test`.`t2` mapped to number #
@@ -458,35 +447,11 @@ BEGIN
 ### INSERT INTO test.t2
 ### SET
 ###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
-###   @2=4 /* INT meta=0 nullable=1 is_null=0 */
-### INSERT INTO test.t2
-### SET
-###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
-###   @2=4 /* INT meta=0 nullable=1 is_null=0 */
-### INSERT INTO test.t2
-### SET
-###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
-###   @2=4 /* INT meta=0 nullable=1 is_null=0 */
-### INSERT INTO test.t2
-### SET
-###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
-###   @2=4 /* INT meta=0 nullable=1 is_null=0 */
-### INSERT INTO test.t2
-### SET
-###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
-###   @2=4 /* INT meta=0 nullable=1 is_null=0 */
-### INSERT INTO test.t2
-### SET
-###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
-###   @2=4 /* INT meta=0 nullable=1 is_null=0 */
-### INSERT INTO test.t2
-### SET
-###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
-###   @2=4 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=5 /* INT meta=0 nullable=1 is_null=0 */
 ### INSERT INTO test.t2
 ### SET
 ###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
-###   @2=4 /* 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/*!*/;
@@ -504,9 +469,8 @@ BEGIN
 #server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
 ### INSERT INTO test.t1
 ### SET
-###   @1=15 /* INT meta=0 nullable=0 is_null=0 */
-###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=5 /* INT meta=0 nullable=1 is_null=0 */
+###   @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/*!*/;
@@ -526,9 +490,8 @@ BEGIN
 #server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
 ### INSERT INTO test.t1
 ### SET
-###   @1=16 /* INT meta=0 nullable=0 is_null=0 */
-###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=6 /* INT meta=0 nullable=1 is_null=0 */
+###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=6 /* INT meta=0 nullable=1 is_null=0 */
 # at #
 #server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=#
 SET TIMESTAMP=t/*!*/;
@@ -548,9 +511,8 @@ BEGIN
 #server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
 ### INSERT INTO test.t1
 ### SET
-###   @1=17 /* INT meta=0 nullable=0 is_null=0 */
-###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=7 /* INT meta=0 nullable=1 is_null=0 */
+###   @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/*!*/;
@@ -593,41 +555,23 @@ BEGIN
 /*!*/;
 # at #
 #server id #  end_log_pos # 	Rows_query
-# insert delayed into t1(a,b) values(1,5),(1,6),(1,7),(1,8),(1,9),(1,10)
+# insert delayed into t1(a,b) values(1,5),(1,6),(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=18 /* INT meta=0 nullable=0 is_null=0 */
-###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=5 /* INT meta=0 nullable=1 is_null=0 */
-### INSERT INTO test.t1
-### SET
-###   @1=19 /* INT meta=0 nullable=0 is_null=0 */
-###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=6 /* INT meta=0 nullable=1 is_null=0 */
-### INSERT INTO test.t1
-### SET
-###   @1=20 /* INT meta=0 nullable=0 is_null=0 */
-###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=7 /* INT meta=0 nullable=1 is_null=0 */
-### INSERT INTO test.t1
-### SET
-###   @1=21 /* INT meta=0 nullable=0 is_null=0 */
-###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=8 /* INT meta=0 nullable=1 is_null=0 */
+###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=5 /* INT meta=0 nullable=1 is_null=0 */
 ### INSERT INTO test.t1
 ### SET
-###   @1=22 /* INT meta=0 nullable=0 is_null=0 */
-###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=9 /* INT meta=0 nullable=1 is_null=0 */
+###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
+###   @2=6 /* INT meta=0 nullable=1 is_null=0 */
 ### INSERT INTO test.t1
 ### SET
-###   @1=23 /* INT meta=0 nullable=0 is_null=0 */
-###   @2=1 /* INT meta=0 nullable=1 is_null=0 */
-###   @3=10 /* INT meta=0 nullable=1 is_null=0 */
+###   @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/*!*/;
@@ -645,10 +589,12 @@ BEGIN
 /*!*/;
 # at #
 #server id #  end_log_pos # 	Rows_query
-# load data infile '../../std_data/words.dat' into table t3
+# load data infile '../../std_data/words3.dat' into table t3
+# at #
 # at #
 # at #
 #server id #  end_log_pos # 	Table_map: `test`.`t3` 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.t3
 ### SET
@@ -860,14 +806,255 @@ BEGIN
 ### INSERT INTO test.t3
 ### SET
 ###   @1='aberration' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abase' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abased' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abasement' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abasements' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abases' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abash' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abashed' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abashes' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abashing' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abasing' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abate' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abated' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abatement' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abatements' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abater' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abates' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abating' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='Abba' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abbe' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abbey' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abbeys' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abbot' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abbots' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='Abbott' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abbreviate' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abbreviated' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abbreviates' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abbreviating' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abbreviation' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abbreviations' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='Abby' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abdomen' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abdomens' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abdominal' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abduct' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abducted' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abduction' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abductions' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abductor' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abductors' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abducts' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='Abe' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='abed' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='Abel' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='Abelian' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='Abelson' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='Aberdeen' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='Abernathy' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### SET
+###   @1='aberrant' /* VARSTRING(60) meta=60 nullable=1 is_null=0 */
+### INSERT INTO test.t3
+### 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 t1, t2, t3
+/*!*/;
 DELIMITER ;
 # End of log file
 ROLLBACK /* added by mysqlbinlog */;
 /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
 set session binlog_rows_query_log_events= off;
-drop table t1, t2, t3;
+# 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)
+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	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# insert into t1(a,b) values(1,2)
+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,4),(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	#	#	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	#	#	# insert into t2(a,b) values(2,2)
+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,3)
+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	#	Rows_query	#	#	# insert into t2(a,b) values(2,4),(2,5),(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	#	#	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,6)
+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,4)
+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,5)
+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	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# insert delayed into t1(a,b) values(1,5),(1,6),(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	#	#	use `test`; create table t3(a VARCHAR(60))
+slave-bin.000001	#	Query	#	#	BEGIN
+slave-bin.000001	#	Rows_query	#	#	# load data infile '../../std_data/words3.dat' into table t3
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t3)
+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 t1, t2, t3

=== 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-06-24 07:35:06 +0000
@@ -0,0 +1 @@
+--binlog-rows-query-log-events=1

=== modified file 'mysql-test/suite/rpl/t/rpl_ignorable_event.test'
--- a/mysql-test/suite/rpl/t/rpl_ignorable_event.test	2010-06-18 09:16:24 +0000
+++ b/mysql-test/suite/rpl/t/rpl_ignorable_event.test	2010-06-24 07:35:06 +0000
@@ -1,9 +1,12 @@
 #
-# WL#4033
+# 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;
@@ -13,18 +16,16 @@ select @@session.binlog_rows_query_log_e
 set session binlog_rows_query_log_events= on;
 select @@session.binlog_rows_query_log_events;
 
-# Test non-transaction
+--echo # Test non-transaction
 let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
-create table t1(i1 int not null auto_increment, a int, b int, primary key(i1));
+create table t1(a int, b int);
 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;
 insert into t1(a,b) values(1,2);
-insert into t1(a,b) values(1,3);
-insert into t1(a,b) values(1,4),(1,5),(1,5),(1,5),(1,5),(1,5),(1,5),(1,5),(1,5),(1,5);
-update t1 set a = a + 5 where b = 2;
+insert into t1(a,b) values(1,4),(1,5);
 
-# Test transaction
+-- echo # Test transaction
 create table t2(a int, b int) engine=innodb;
 begin;
 insert into t2(a,b) values(2,1),(3,1);
@@ -32,10 +33,10 @@ insert into t2(a,b) values(2,2);
 insert into t2(a,b) values(2,3);
 update t2 set a = a + 5 where b = 1;
 delete from t2 where a = 7;
-insert into t2(a,b) values(2,4),(2,4),(2,4),(2,4),(2,4),(2,4),(2,4),(2,4),(2,4);
+insert into t2(a,b) values(2,4),(2,5),(2,6);
 commit;
 
-# Test mixed transaction
+--echo # Test mixed transaction
 begin;
 insert into t1(a,b) values(1,5);
 insert into t1(a,b) values(1,6);
@@ -44,15 +45,24 @@ insert into t2(a,b) values(2,5);
 insert into t1(a,b) values(1,7);
 commit;
 
-# Test insert delayed ...
-insert delayed into t1(a,b) values(1,5),(1,6),(1,7),(1,8),(1,9),(1,10);
+--echo # Test insert delayed ...
+insert delayed into t1(a,b) values(1,5),(1,6),(1,7);
 
-# Test load data infile
+--echo # Test load data infile
 create table t3(a VARCHAR(60));
-load data infile '../../std_data/words.dat' into table t3;
+load data infile '../../std_data/words3.dat' into table t3;
+drop table t1, t2, t3;
+
+--echo # SHOW BINLOG EVENTS ON MASTER before '--exec MYSQL_BINLOG'
+source include/show_binlog_events.inc;
 
+--echo # Test the Rows_query log event can be applied
+--exec $MYSQL_BINLOG -v -v $MYSQLD_DATADIR/master-bin.000001 | $MYSQL test 2>&1
+
+--echo # SHOW BINLOG EVENTS ON MASTER after '--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/
@@ -60,6 +70,9 @@ let $MYSQLD_DATADIR= `select @@datadir`;
 
 set session binlog_rows_query_log_events= off;
 
-drop table t1, t2, t3;
 sync_slave_with_master;
 
+--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-06-18 09:16:24 +0000
+++ b/sql/log_event.cc	2010-06-24 07:35:06 +0000
@@ -9730,8 +9730,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) + 1;
+  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
 
@@ -9746,7 +9752,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);
@@ -9756,10 +9762,21 @@ Rows_query_log_event::print(FILE *file,
 bool
 Rows_query_log_event::write_data_body(IO_CACHE *file)
 {
-  DBUG_ENTER("Rows_query_log_event::Rows_query_log_event");
+  DBUG_ENTER("Rows_query_log_event::write_data_body");
   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-06-18 09:16:24 +0000
+++ b/sql/log_event.h	2010-06-24 07:35:06 +0000
@@ -4067,10 +4067,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;
   }
@@ -4098,6 +4097,9 @@ public:
   }
 
 private:
+#if !defined(MYSQL_CLIENT)
+  virtual int do_apply_event(Relay_log_info const* rli);
+#endif
 
   char * m_rows_query;
 };

=== modified file 'sql/rpl_rli.cc'
--- a/sql/rpl_rli.cc	2010-02-12 23:30:44 +0000
+++ b/sql/rpl_rli.cc	2010-06-24 07:35:06 +0000
@@ -44,7 +44,7 @@ Relay_log_info::Relay_log_info(bool is_s
    inited(0), abort_slave(0), slave_running(0), until_condition(UNTIL_NONE),
    until_log_pos(0), retried_trans(0),
    tables_to_lock(0), tables_to_lock_count(0),
-   last_event_start_time(0), m_flags(0)
+   last_event_start_time(0), m_flags(0), rows_query_ev(NULL)
 {
   DBUG_ENTER("Relay_log_info::Relay_log_info");
 

=== modified file 'sql/rpl_rli.h'
--- a/sql/rpl_rli.h	2010-02-12 23:30:44 +0000
+++ b/sql/rpl_rli.h	2010-06-24 07:35:06 +0000
@@ -332,6 +332,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/slave.cc'
--- a/sql/slave.cc	2010-02-12 23:30:44 +0000
+++ b/sql/slave.cc	2010-06-24 07:35:06 +0000
@@ -2420,10 +2420,25 @@ static int exec_relay_log_event(THD* thd
       used to read info about the relay log's format; it will be deleted when
       the SQL thread does not need it, i.e. when this thread terminates.
     */
-    if (ev->get_type_code() != FORMAT_DESCRIPTION_EVENT)
+    Log_event_type ev_type= ev->get_type_code();
+    if (ev_type != FORMAT_DESCRIPTION_EVENT)
     {
       DBUG_PRINT("info", ("Deleting the event after it has been executed"));
-      delete ev;
+
+      /* Delete the Rows_query log event after its last rows event is 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 untill all its rows event is applied */
+      if (ev_type == ROWS_QUERY_LOG_EVENT)
+        rli->rows_query_ev= (Rows_query_log_event*) ev;
+      else
+        delete ev;
     }
 
     /*

=== modified file 'sql/sql_binlog.cc'
--- a/sql/sql_binlog.cc	2009-11-06 16:35:04 +0000
+++ b/sql/sql_binlog.cc	2010-06-24 07:35:06 +0000
@@ -221,8 +221,26 @@ void mysql_client_binlog_statement(THD* 
         will be deleted when the SQL thread does not need it,
         i.e. when this thread terminates.
       */
-      if (ev->get_type_code() != FORMAT_DESCRIPTION_EVENT)
-        delete ev; 
+      Log_event_type ev_type= ev->get_type_code();
+      if (ev_type != FORMAT_DESCRIPTION_EVENT)
+      {
+        DBUG_PRINT("info", ("Deleting the event after it has been executed"));
+
+        /* Delete the Rows_query log event after its last rows event is 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 untill all its rows event is applied */
+        if (ev_type == ROWS_QUERY_LOG_EVENT)
+          rli->rows_query_ev= (Rows_query_log_event*) ev;
+        else
+          delete ev;
+      }
       ev= 0;
       if (err)
       {


Attachment: [text/bzr-bundle] bzr/dao-gang.qu@sun.com-20100624073506-2ew9xh11x7dibb9e.bundle
Thread
bzr commit into mysql-5.1-rep+2 branch (Dao-Gang.Qu:3186) WL#5404Dao-Gang.Qu24 Jun