=== modified file 'patches/mysql-test-rnt.diff'
--- patches/mysql-test-rnt.diff	2012-02-06 06:00:16 +0000
+++ patches/mysql-test-rnt.diff	2012-02-08 08:48:30 +0000
@@ -1,27 +1,3 @@
---- a/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test
-+++ b/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test
-@@ -321,14 +321,19 @@
- # we check that the error code of the "ROLLBACK" event is 0 and not
- # ER_SERVER_SHUTDOWN (i.e. disconnection just rolls back transaction
- # and does not make slave to stop)
-+
-+-- source include/binlog_start_pos.inc
-+
- if (`select @@binlog_format = 'ROW'`)
- {
--  --exec $MYSQL_BINLOG --start-position=524 $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output
-+  let $start_pos= `select @binlog_start_pos + 418`;
-+  --exec $MYSQL_BINLOG --start-position=$start_pos $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output
- }
- 
- if (`select @@binlog_format = 'STATEMENT' || @@binlog_format = 'MIXED'`)
- {
--  --exec $MYSQL_BINLOG --start-position=555 $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output
-+  let $start_pos= `select @binlog_start_pos + 449`;
-+  --exec $MYSQL_BINLOG --start-position=$start_pos $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output
- }
- 
- --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 --- /dev/null
 +++ b/mysql-test/extra/rpl_tests/check_type.inc
 @@ -0,0 +1,52 @@
@@ -259,16 +235,6 @@
  --let $slave_skip_counter= 2
  --let $show_slave_sql_error= 1
  --source include/wait_for_slave_sql_error_and_skip.inc
---- a/mysql-test/extra/rpl_tests/rpl_log.test
-+++ b/mysql-test/extra/rpl_tests/rpl_log.test
-@@ -14,6 +14,7 @@
- reset master;
- reset slave;
- source include/start_slave.inc;
-+source include/binlog_start_pos.inc;
- 
- let $VERSION=`select version()`;
- 
 --- a/mysql-test/extra/rpl_tests/rpl_mixing_engines.inc
 +++ b/mysql-test/extra/rpl_tests/rpl_mixing_engines.inc
 @@ -532,6 +532,16 @@
@@ -288,165 +254,6 @@
    --disable_query_log
    SET @commands= LTRIM(SUBSTRING(@commands, LENGTH(@command) + 1));
    inc $stmt_id;
---- /dev/null
-+++ b/mysql-test/extra/rpl_tests/rpl_row_annotate.test
-@@ -0,0 +1,156 @@
-+########################################################################
-+# WL47: Store in binlog text of statements that caused RBR events
-+# new event          : ANNOTATE_ROWS_EVENT
-+# new master option  : --binlog-annotate-rows-events
-+# new slave option   : --replicate-annotate-rows-events
-+########################################################################
-+--source include/master-slave.inc
-+connect (master2,127.0.0.1,root,,test,$MASTER_MYPORT,);
-+
-+connection master;
-+--disable_query_log
-+
-+--disable_warnings
-+DROP DATABASE IF EXISTS test1;
-+--enable_warnings
-+
-+CREATE DATABASE test1;
-+USE test1;
-+
-+CREATE TABLE t1(a int primary key, b int);
-+CREATE TABLE t2(a int, b int);
-+CREATE TABLE t3(a int, b int);
-+CREATE TABLE t4(a int, b int);
-+CREATE TABLE xt1(a int, b int);
-+CREATE TABLE xt2(a int, b int);
-+
-+CREATE TABLE t5 (
-+    a INT PRIMARY KEY AUTO_INCREMENT,
-+    b VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_bin
-+);
-+
-+SET SESSION binlog_annotate_rows_events = OFF;
-+
-+INSERT INTO t1 VALUES (0,0), (1,1);
-+
-+SET SESSION binlog_annotate_rows_events = ON;
-+
-+UPDATE t1 SET b = b + 1;
-+REPLACE t1 VALUES (1,1), (2,2), (3,3);
-+
-+INSERT INTO t2 VALUES (1,1), (2,2), (3,3);
-+INSERT INTO t3 VALUES (1,1), (2,2), (3,3);
-+DELETE t1, t2 FROM t1 INNER JOIN t2 INNER JOIN t3 WHERE t1.a=t2.a AND t2.a=t3.a;
-+
-+INSERT INTO xt1 VALUES (1,1), (2,2), (3,3);
-+INSERT INTO t2 VALUES (1,1), (2,2), (3,3);
-+DELETE xt1, t2 FROM xt1 INNER JOIN t2 INNER JOIN t3 WHERE xt1.a=t2.a AND t2.a=t3.a;
-+
-+INSERT INTO xt1 VALUES (1,1), (2,2), (3,3);
-+INSERT INTO xt2 VALUES (1,1), (2,2), (3,3);
-+DELETE xt1, xt2 FROM xt1 INNER JOIN xt2 INNER JOIN t3 WHERE xt1.a=xt2.a AND xt2.a=t3.a;
-+
-+INSERT INTO t5(b) VALUES ('foo'), ('bar'), ('baz');
-+SET NAMES latin1;
-+INSERT INTO t5(b) VALUES ('gås');
-+SET NAMES utf8;
-+INSERT INTO t5(b) VALUES ('gÃ¥s');
-+SET NAMES latin1;
-+
-+FLUSH LOGS;
-+
-+--echo ########################################################################
-+--echo # TABLES ON MASTER
-+--echo ########################################################################
-+--enable_query_log
-+
-+SELECT * FROM t1 ORDER BY a;
-+SELECT * FROM t2 ORDER BY a;
-+SELECT * FROM t3 ORDER BY a;
-+SELECT * FROM t5 ORDER BY a;
-+
-+sync_slave_with_master;
-+--echo ########################################################################
-+--echo # TABLES ON SLAVE: should be the same as on master
-+--echo ########################################################################
-+--disable_query_log
-+USE test1;
-+--enable_query_log
-+
-+SELECT * FROM t1 ORDER BY a;
-+SELECT * FROM t2 ORDER BY a;
-+SELECT * FROM t3 ORDER BY a;
-+SELECT * FROM t5 ORDER BY a;
-+
-+--echo ########################################################################
-+--echo # EVENTS ON SLAVE
-+let $annotate= `select @@global.replicate_annotate_rows_events`;
-+if ($annotate)
-+{
-+  --echo # The following Annotate_rows events should appear below:
-+  --echo # - UPDATE t1 SET b = b + 1;
-+  --echo # - REPLACE t1 VALUES (1,1), (2,2), (3,3);
-+  --echo # - INSERT INTO t2 VALUES (1,1), (2,2), (3,3)
-+  --echo # - INSERT INTO t3 VALUES (1,1), (2,2), (3,3)
-+  --echo # - DELETE t1, t2 FROM <...>
-+  --echo # - INSERT INTO t2 VALUES (1,1), (2,2), (3,3)
-+  --echo # - DELETE xt1, t2 FROM <...>
-+  --echo # - INSERT INTO t5(b) VALUES <...> (3 instances)
-+}
-+if (!$annotate)
-+{
-+  --echo # No Annotate_rows events should appear below
-+}
-+--echo ########################################################################
-+FLUSH LOGS;
-+
-+--source include/binlog_start_pos.inc
-+let $start_pos= `select @binlog_start_pos`;
-+--replace_column 2 # 5 #
-+--replace_result $start_pos <start_pos>
-+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
-+--eval show binlog events in 'slave-bin.000001' from $start_pos
-+
-+--echo # 
-+--echo ########################################################################
-+--echo # INSERTs DELAYED ON MASTERs
-+--echo ########################################################################
-+connection master;
-+SET SESSION binlog_annotate_rows_events = ON;
-+INSERT DELAYED INTO test1.t4 VALUES (1,1);
-+FLUSH TABLES;
-+SELECT * FROM test1.t4 ORDER BY a;
-+
-+sync_slave_with_master;
-+connection master;
-+sync_slave_with_master;
-+
-+--echo ########################################################################
-+--echo # ON SLAVE
-+--echo # No Annotate_rows events should appear below
-+--echo ########################################################################
-+FLUSH LOGS;
-+
-+--exec $MYSQL --host=127.0.0.1 --port=$SLAVE_MYPORT test -e "show binlog events in 'slave-bin.000002'" > $MYSQLTEST_VARDIR/tmp/annotated_events.txt
-+perl;
-+    open F, '<', "$ENV{MYSQLTEST_VARDIR}/tmp/annotated_events.txt" or die;
-+    binmode STDOUT;
-+    while (defined ($_ = <F>)) {
-+        if (/Annotate_rows/) {
-+            s/[0-9]+\sAnnotate_rows\s[0-9]+\s[0-9]+/# Annotate_rows # #/;
-+            print($_);
-+            $_ = <F>;
-+            s/[0-9]+\sTable_map\s[0-9]+\s[0-9]+\stable_id:\s[0-9]+/# Table_map # # table_id: #/;
-+            print($_);
-+        }
-+    }
-+EOF
-+
-+# Clean-up
-+connection master;
-+--disable_query_log
-+DROP DATABASE test1;
-+sync_slave_with_master;
-+--enable_query_log
-+
-+--source include/rpl_end.inc
 --- a/mysql-test/extra/rpl_tests/rpl_row_basic.test
 +++ b/mysql-test/extra/rpl_tests/rpl_row_basic.test
 @@ -6,6 +6,10 @@
@@ -1490,54 +1297,6 @@
 +source include/rpl_reset.inc;
 +enable_warnings;
 +enable_query_log;
---- /dev/null
-+++ b/mysql-test/include/binlog_start_pos.inc
-@@ -0,0 +1,26 @@
-+##############################################################################
-+#
-+# binlog_start_pos is the postion of the the first event in the binary log
-+# which follows the Format description event. Intended to reduce test suite
-+# dependance on the Format description event length changes (e.g. in case
-+# of adding new events). Evaluated as:
-+#  
-+#   binlog_start_pos = 4  /* binlog header */ +
-+#                      (Format_description_log_event length)
-+#
-+#   Format_description_log_event length = 
-+#                      19 /* event common header */ +
-+#                      57 /* misc stuff in the Format description header */ +
-+#                      number of events.
-+# 
-+# With current number of events = 160,
-+#
-+#   binlog_start_pos = 4 + 19 + 57 + 160 = 240.
-+#
-+##############################################################################
-+
-+let $binlog_start_pos=240;
-+--disable_query_log
-+SET @binlog_start_pos=240;
-+--enable_query_log
-+
---- a/mysql-test/include/show_binlog_events2.inc
-+++ b/mysql-test/include/show_binlog_events2.inc
-@@ -1,4 +1,4 @@
----let $binlog_start=106
-+--let $binlog_start=240
- --replace_result $binlog_start <binlog_start>
- --replace_column 2 # 5 #
- --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
---- a/mysql-test/include/show_binlog_events.inc
-+++ b/mysql-test/include/show_binlog_events.inc
-@@ -3,7 +3,7 @@
- #
- # Useage: 
- # let $binlog_file= master-bin.000002; 
--# let $binlog_start= 106; 
-+# let $binlog_start= 240; 
- # let $binlog_limit= 1, 3; 
- # source include/show_binlog_events.inc;
- #
 --- a/mysql-test/include/test_fieldsize.inc
 +++ b/mysql-test/include/test_fieldsize.inc
 @@ -22,7 +22,7 @@
@@ -1549,69 +1308,6 @@
  --let $show_slave_sql_error= 1
  --source include/wait_for_slave_sql_error.inc
  
---- a/mysql-test/r/ctype_cp932_binlog_stm.result
-+++ b/mysql-test/r/ctype_cp932_binlog_stm.result
-@@ -44,9 +44,6 @@
- master-bin.000001	#	Query	#	#	use `test`; DROP PROCEDURE bug18293
- master-bin.000001	#	Query	#	#	use `test`; DROP TABLE t4
- End of 5.0 tests
--call mtr.add_suppression("Error in Log_event::read_log_event\\\(\\\): 'Sanity check failed', data_len: 258, event_type: 49");
--SHOW BINLOG EVENTS FROM 365;
--ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error
- Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment.
- CREATE TABLE t1 (a varchar(16)) character set cp932;
- INSERT INTO t1 VALUES (0x8372835E),(0x8352835E);
---- a/mysql-test/r/mysqlbinlog.result
-+++ b/mysql-test/r/mysqlbinlog.result
-@@ -1,15 +1,17 @@
- reset master;
-+SET @save_binlog_size= @@global.max_binlog_size;
-+SET @@global.max_binlog_size= 4096;
- set timestamp=1000000000;
- drop table if exists t1,t2,t3,t4,t5,t03,t04;
- create table t1 (word varchar(20));
- create table t2 (id int auto_increment not null primary key);
- insert into t1 values ("abirvalg");
- insert into t2 values ();
--load data infile '../../std_data/words.dat' into table t1;
--load data infile '../../std_data/words.dat' into table t1;
--load data infile '../../std_data/words.dat' into table t1;
--load data infile '../../std_data/words.dat' into table t1;
--load data infile '../../std_data/words.dat' into table t1;
-+load data infile '../../std_data/words3.dat' into table t1;
-+load data infile '../../std_data/words3.dat' into table t1;
-+load data infile '../../std_data/words3.dat' into table t1;
-+load data infile '../../std_data/words3.dat' into table t1;
-+load data infile '../../std_data/words3.dat' into table t1;
- insert into t1 values ("Alas");
- flush logs;
- 
-@@ -255,6 +257,7 @@
- ROLLBACK /* added by mysqlbinlog */;
- /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
- drop table t1,t2;
-+SET @@global.max_binlog_size= @save_binlog_size;
- flush logs;
- flush logs;
- select * from t5  /* must be (1),(1) */;
-@@ -377,14 +380,14 @@
- /*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.collation_database=7/*!*/;
--LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-a-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`)
-+LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`)
- /*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- SET @@session.collation_database=DEFAULT/*!*/;
--LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-b-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`)
-+LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`)
- /*!*/;
- SET TIMESTAMP=1000000000/*!*/;
--LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-c-0' INTO TABLE `t1` CHARACTER SET koi8r FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`)
-+LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` CHARACTER SET koi8r FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`)
- /*!*/;
- SET TIMESTAMP=1000000000/*!*/;
- drop table t1
 --- /dev/null
 +++ b/mysql-test/r/percona_fast_alter_column.result
 @@ -0,0 +1,47 @@
@@ -1778,75 +1474,6 @@
 +DEFAULT(t2)
 +0000-00-00 00:00:00
 +DROP TABLE test;
---- /dev/null
-+++ b/mysql-test/std_data/words3.dat
-@@ -0,0 +1,66 @@
-+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
 --- a/mysql-test/suite/binlog/r/binlog_base64_flag.result
 +++ b/mysql-test/suite/binlog/r/binlog_base64_flag.result
 @@ -93,6 +93,7 @@
@@ -1857,26 +1484,6 @@
  #
  # Bug #54393: crash and/or valgrind errors in 
  # mysql_client_binlog_statement
---- a/mysql-test/suite/binlog/r/binlog_stm_binlog.result
-+++ b/mysql-test/suite/binlog/r/binlog_stm_binlog.result
-@@ -331,7 +331,7 @@
- master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 243 )
- master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 242 )
- master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 241 )
--master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 240 )
-+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( <binlog_start> )
- master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 239 )
- master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 238 )
- master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 237 )
-@@ -465,7 +465,7 @@
- master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 109 )
- master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 108 )
- master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 107 )
--master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( <binlog_start> )
-+master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 106 )
- master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 105 )
- master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 104 )
- master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 103 )
 --- a/mysql-test/suite/binlog/t/binlog_base64_flag.test
 +++ b/mysql-test/suite/binlog/t/binlog_base64_flag.test
 @@ -153,6 +153,7 @@
@@ -1887,258 +1494,6 @@
  
  --echo #
  --echo # Bug #54393: crash and/or valgrind errors in 
---- a/mysql-test/suite/binlog/t/binlog_incident.test
-+++ b/mysql-test/suite/binlog/t/binlog_incident.test
-@@ -4,6 +4,7 @@
- 
- source include/have_log_bin.inc;
- source include/have_debug.inc;
-+source include/binlog_start_pos.inc;
- 
- let $MYSQLD_DATADIR= `select @@datadir`;
- RESET MASTER;
-@@ -20,7 +21,7 @@
- DROP TABLE t1;
- FLUSH LOGS;
- 
--exec $MYSQL_BINLOG --start-position=106 $MYSQLD_DATADIR/master-bin.000001 >$MYSQLTEST_VARDIR/tmp/binlog_incident-bug44442.sql;
-+exec $MYSQL_BINLOG --start-position=$binlog_start_pos $MYSQLD_DATADIR/master-bin.000001 >$MYSQLTEST_VARDIR/tmp/binlog_incident-bug44442.sql;
- --disable_query_log
- eval SELECT cont LIKE '%RELOAD DATABASE; # Shall generate syntax error%' AS `Contain RELOAD DATABASE` FROM (SELECT load_file('$MYSQLTEST_VARDIR/tmp/binlog_incident-bug44442.sql') AS cont) AS tbl;
- --enable_query_log
---- a/mysql-test/suite/binlog/t/binlog_killed_simulate.test
-+++ b/mysql-test/suite/binlog/t/binlog_killed_simulate.test
-@@ -1,5 +1,6 @@
- -- source include/have_debug.inc
- -- source include/have_binlog_format_statement.inc
-+-- source include/binlog_start_pos.inc
- #
- # bug#27571 asynchronous setting mysql_$query()'s local error and 
- #           Query_log_event::error_code
-@@ -24,7 +25,7 @@
- #      for some constants like the offset of the first real event
- #      that is different between severs versions.
- let $MYSQLD_DATADIR= `select @@datadir`;
----exec $MYSQL_BINLOG --force-if-open --start-position=106 $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog
-+--exec $MYSQL_BINLOG --force-if-open --start-position=$binlog_start_pos $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog
- --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
- eval select
- (@a:=load_file("$MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
---- a/mysql-test/suite/binlog/t/binlog_killed.test
-+++ b/mysql-test/suite/binlog/t/binlog_killed.test
-@@ -1,5 +1,6 @@
- -- source include/have_innodb.inc
- -- source include/have_binlog_format_statement.inc
-+-- source include/binlog_start_pos.inc
- 
- # You cannot use `KILL' with the Embedded MySQL Server library,
- # because the embedded server merely runs inside the threads of the host
-@@ -51,7 +52,8 @@
- let $rows= `select count(*) from t2  /* must be 2 or 0 */`;
- 
- let $MYSQLD_DATADIR= `select @@datadir`;
----exec $MYSQL_BINLOG --force-if-open --start-position=134 $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog
-+let $start_pos= `select @binlog_start_pos + 28`;
-+--exec $MYSQL_BINLOG --force-if-open --start-position=$start_pos $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog
- --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
- eval select
- (@a:=load_file("$MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog"))
---- /dev/null
-+++ b/mysql-test/suite/binlog/t/binlog_row_annotate-master.opt
-@@ -0,0 +1 @@
-+--timezone=GMT-3 --binlog-do-db=test1 --binlog-do-db=test2 --binlog-do-db=test3
---- /dev/null
-+++ b/mysql-test/suite/binlog/t/binlog_row_annotate.test
-@@ -0,0 +1,189 @@
-+###############################################################################
-+# WL47: Store in binlog text of statements that caused RBR events
-+# new event:              ANNOTATE_ROWS_EVENT
-+# new master option:      --binlog-annotate-rows-events
-+# new mysqlbinlog option: --skip-annotate-rows-events
-+#
-+# Intended to test that:
-+# *** If the --binlog-annotate-rows-events option is switched on on master
-+#     then Annotate_rows events:
-+#     - are generated;
-+#     - are genrated only once for "multi-table-maps" rbr queries;
-+#     - are not generated when the corresponding queries are filtered away;
-+#     - are generated when the corresponding queries are filtered away partialy
-+#       (e.g. in case of multi-delete).
-+# *** Annotate_rows events are printed by mysqlbinlog started without
-+#     --skip-annotate-rows-events options both in remote and local cases.
-+# *** Annotate_rows events are not printed by mysqlbinlog started with
-+#     --skip-annotate-rows-events options both in remote and local cases.
-+###############################################################################
-+
-+--source include/have_log_bin.inc
-+--source include/have_binlog_format_row.inc
-+--source include/binlog_start_pos.inc
-+
-+--disable_query_log
-+
-+# Fix timestamp to avoid varying results
-+SET timestamp=1000000000;
-+
-+# Delete all existing binary logs
-+RESET MASTER;
-+
-+--disable_warnings
-+DROP DATABASE IF EXISTS test1;
-+DROP DATABASE IF EXISTS test2;
-+DROP DATABASE IF EXISTS test3;
-+DROP DATABASE IF EXISTS xtest1;
-+DROP DATABASE IF EXISTS xtest2;
-+--enable_warnings
-+
-+CREATE DATABASE test1;
-+CREATE TABLE test1.t1(a int);
-+
-+CREATE DATABASE test2;
-+CREATE TABLE test2.t2(a int);
-+CREATE VIEW  test2.v2 AS SELECT * FROM test2.t2;
-+
-+CREATE DATABASE test3;
-+CREATE TABLE test3.t3(a int);
-+
-+CREATE DATABASE xtest1;
-+CREATE TABLE xtest1.xt1(a int);
-+
-+CREATE DATABASE xtest2;
-+CREATE TABLE xtest2.xt2(a int);
-+
-+# By default SESSION binlog_annotate_rows_events = OFF
-+
-+INSERT INTO test1.t1 VALUES (1), (2), (3);
-+
-+SET SESSION binlog_annotate_rows_events = ON;
-+
-+INSERT INTO test2.t2 VALUES (1), (2), (3);
-+INSERT INTO test3.t3 VALUES (1), (2), (3);
-+
-+# This query generates two Table maps but the Annotate
-+# event should appear only once before the first Table map
-+DELETE test1.t1, test2.t2
-+  FROM test1.t1 INNER JOIN test2.t2 INNER JOIN test3.t3
-+  WHERE test1.t1.a=test2.t2.a AND test2.t2.a=test3.t3.a;
-+
-+# This event should be filtered out together with Annotate event
-+INSERT INTO xtest1.xt1 VALUES (1), (2), (3);
-+
-+# This event should pass the filter
-+INSERT INTO test2.v2 VALUES (1), (2), (3);
-+
-+# This event should pass the filter only for test2.t2 part
-+DELETE xtest1.xt1, test2.t2
-+  FROM xtest1.xt1 INNER JOIN test2.t2 INNER JOIN test3.t3
-+  WHERE xtest1.xt1.a=test2.t2.a AND test2.t2.a=test3.t3.a;
-+
-+# These events should be filtered out together with Annotate events
-+INSERT INTO xtest1.xt1 VALUES (1), (2), (3);
-+INSERT INTO xtest2.xt2 VALUES (1), (2), (3);
-+DELETE xtest1.xt1, xtest2.xt2
-+  FROM xtest1.xt1 INNER JOIN xtest2.xt2 INNER JOIN test3.t3
-+  WHERE xtest1.xt1.a=xtest2.xt2.a AND xtest2.xt2.a=test3.t3.a;
-+
-+FLUSH LOGS;
-+--enable_query_log
-+
-+--echo #####################################################################################
-+--echo # The following Annotate_rows events should appear below:
-+--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3)
-+--echo # - INSERT INTO test3.t3 VALUES (1), (2), (3)
-+--echo # - DELETE test1.t1, test2.t2 FROM <...>
-+--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3)
-+--echo # - DELETE xtest1.xt1, test2.t2 FROM <...>
-+--echo #####################################################################################
-+
-+let $start_pos= `select @binlog_start_pos`;
-+--replace_column 2 # 5 #
-+--replace_result $start_pos <start_pos>
-+--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
-+--eval show binlog events in 'master-bin.000001' from $start_pos
-+
-+--echo #
-+--echo #####################################################################################
-+--echo # mysqlbinlog
-+--echo # The following Annotates should appear in this output:
-+--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3)
-+--echo # - INSERT INTO test3.t3 VALUES (1), (2), (3)
-+--echo # - DELETE test1.t1, test2.t2 FROM <...> (with two subsequent Table maps)
-+--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3)
-+--echo # - DELETE xtest1.xt1, test2.t2 FROM <...> (with one subsequent Table map)
-+--echo #####################################################################################
-+
-+let $MYSQLD_DATADIR= `select @@datadir`;
-+--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/
-+--exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $MYSQLD_DATADIR/master-bin.000001
-+
-+--echo #
-+--echo #####################################################################################
-+--echo # mysqlbinlog --database=test1
-+--echo # The following Annotate should appear in this output:
-+--echo # - DELETE test1.t1, test2.t2 FROM <...>
-+--echo #####################################################################################
-+
-+let $MYSQLD_DATADIR= `select @@datadir`;
-+--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/
-+--exec $MYSQL_BINLOG --base64-output=decode-rows --database=test1 -v -v $MYSQLD_DATADIR/master-bin.000001
-+
-+--echo #
-+--echo #####################################################################################
-+--echo # mysqlbinlog --skip-annotate-rows-events
-+--echo # No Annotates should appear in this output
-+--echo #####################################################################################
-+
-+let $MYSQLD_DATADIR= `select @@datadir`;
-+--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/
-+--exec $MYSQL_BINLOG --base64-output=decode-rows --skip-annotate-rows-events -v -v $MYSQLD_DATADIR/master-bin.000001
-+
-+--echo #
-+--echo #####################################################################################
-+--echo # mysqlbinlog --read-from-remote-server
-+--echo # The following Annotates should appear in this output:
-+--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3)
-+--echo # - INSERT INTO test3.t3 VALUES (1), (2), (3)
-+--echo # - DELETE test1.t1, test2.t2 FROM <...> (with two subsequent Table maps)
-+--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3)
-+--echo # - DELETE xtest1.xt1, test2.t2 FROM <...> (with one subsequent Table map)
-+--echo #####################################################################################
-+
-+let $MYSQLD_DATADIR= `select @@datadir`;
-+--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/
-+--exec $MYSQL_BINLOG --base64-output=decode-rows -v -v --read-from-remote-server --user=root --host=localhost --port=$MASTER_MYPORT master-bin.000001
-+
-+--echo #
-+--echo #####################################################################################
-+--echo # mysqlbinlog --read-from-remote-server --database=test1
-+--echo # The following Annotate should appear in this output:
-+--echo # - DELETE test1.t1, test2.t2 FROM <...>
-+--echo #####################################################################################
-+
-+let $MYSQLD_DATADIR= `select @@datadir`;
-+--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/
-+--exec $MYSQL_BINLOG --base64-output=decode-rows --database=test1 -v -v --read-from-remote-server --user=root --host=localhost --port=$MASTER_MYPORT master-bin.000001
-+
-+--echo #
-+--echo #####################################################################################
-+--echo # mysqlbinlog --read-from-remote-server --skip-annotate-rows-events
-+--echo # No Annotates should appear in this output
-+--echo #####################################################################################
-+
-+let $MYSQLD_DATADIR= `select @@datadir`;
-+--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/
-+--exec $MYSQL_BINLOG --base64-output=decode-rows --skip-annotate-rows-events -v -v --read-from-remote-server --user=root --host=localhost --port=$MASTER_MYPORT master-bin.000001
-+
-+# Clean-up
-+
-+--disable_query_log
-+DROP DATABASE test1;
-+DROP DATABASE test2;
-+DROP DATABASE test3;
-+DROP DATABASE xtest1;
-+DROP DATABASE xtest2;
-+--enable_query_log
-+
 --- /dev/null
 +++ b/mysql-test/suite/rpl/r/percona_mixed_binlog_direct.result
 @@ -0,0 +1,1462 @@
@@ -6285,17 +5640,6 @@
  SELECT COUNT(*) FROM t1;
  COUNT(*)
  0
---- a/mysql-test/suite/rpl/r/rpl_row_conflicts.result
-+++ b/mysql-test/suite/rpl/r/rpl_row_conflicts.result
-@@ -21,7 +21,7 @@
- [on slave]
- ---- Wait until slave stops with an error ----
- include/wait_for_slave_sql_error.inc [errno=1062]
--Last_SQL_Error = Could not execute Write_rows event on table test.t1; Duplicate entry '1' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log master-bin.000001, end_log_pos 346 (expected "duplicate key" error)
-+Last_SQL_Error = Could not execute Write_rows event on table test.t1; Duplicate entry '1' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log master-bin.000001, end_log_pos 480 (expected "duplicate key" error)
- call mtr.add_suppression("Slave SQL.*Duplicate entry .1. for key .PRIMARY.* Error_code: 1062");
- SELECT * FROM t1;
- a
 --- a/mysql-test/suite/rpl/r/rpl_row_tabledefs_2myisam.result
 +++ b/mysql-test/suite/rpl/r/rpl_row_tabledefs_2myisam.result
 @@ -117,17 +117,17 @@
@@ -7426,47 +6770,6 @@
 +
  # END 5.1 Test Case
  --source include/rpl_end.inc
---- /dev/null
-+++ b/mysql-test/suite/rpl/t/rpl_row_annotate_dont-slave.opt
-@@ -0,0 +1 @@
-+--log-slave-updates --replicate-ignore-table=test1.xt1 --replicate-ignore-table=test1.xt2
-\ No newline at end of file
---- /dev/null
-+++ b/mysql-test/suite/rpl/t/rpl_row_annotate_dont.test
-@@ -0,0 +1,9 @@
-+###############################################################################
-+# WL47: Store in binlog text of statements that caused RBR events
-+# Wrapper for extra/rpl/rpl_row_annotate.test.
-+# Intended to test that if the --replicate-annotate-rows-events option
-+# is switched off on slave then Annotate_events are not reproduced.
-+###############################################################################
-+
-+--source include/have_binlog_format_row.inc
-+--source extra/rpl_tests/rpl_row_annotate.test
---- /dev/null
-+++ b/mysql-test/suite/rpl/t/rpl_row_annotate_do-slave.opt
-@@ -0,0 +1 @@
-+--log-slave-updates --replicate-annotate-rows-events --replicate-ignore-table=test1.xt1 --replicate-ignore-table=test1.xt2
-\ No newline at end of file
---- /dev/null
-+++ b/mysql-test/suite/rpl/t/rpl_row_annotate_do.test
-@@ -0,0 +1,16 @@
-+###############################################################################
-+# WL47: Store in binlog text of statements that caused RBR events
-+# Wrapper for extra/rpl/rpl_row_annotate.test.
-+# Intended to test that if the --replicate-annotate-rows-events option
-+# is switched on on slave then Annotate_events:
-+# - are reproduced on slave
-+# - are reproduced only once for "multi-table-maps" rbr queries
-+# - are not reproduced when the corresponding queries are filtered away
-+#   on replication
-+# - are reproduced when the corresponding queries are filtered away partialy
-+#   (e.g. in case of multi-delete)
-+# - are not generated on slave for queries that are not annotated on master.
-+###############################################################################
-+
-+--source include/have_binlog_format_row.inc
-+--source extra/rpl_tests/rpl_row_annotate.test
 --- a/mysql-test/suite/rpl/t/rpl_row_basic_3innodb.test
 +++ b/mysql-test/suite/rpl/t/rpl_row_basic_3innodb.test
 @@ -2,6 +2,8 @@
@@ -7491,89 +6794,6 @@
  --disable_warnings
  DROP TABLE IF EXISTS t1;
  --enable_warnings
---- a/mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test
-+++ b/mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test
-@@ -1,7 +1,8 @@
- # depends on the binlog output
- -- source include/have_binlog_format_row.inc
-+--source include/binlog_start_pos.inc
- 
--let $rename_event_pos= 897;
-+let $rename_event_pos= `select @binlog_start_pos + 791`;
- 
- # Bug#18326: Do not lock table for writing during prepare of statement
- # The use of the ps protocol causes extra table maps in the binlog, so
---- a/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test
-+++ b/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test
-@@ -162,15 +162,18 @@
- 
- remove_file $MYSQLTEST_VARDIR/tmp/master.sql;
- 
-+--source include/binlog_start_pos.inc
- 
- # this test for position option
--# By setting this position to 416, we should only get the create of t3
-+# By setting this position to start_binlog_pos + 310, we should only get the create of t3
-+let $start_pos= `select @binlog_start_pos + 310`;
-+let $stop_pos=  `select @binlog_start_pos + 463`;
- --disable_query_log
- select "--- Test 2 position test --" as "";
- --enable_query_log
- let $MYSQLD_DATADIR= `select @@datadir;`;
- --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
----exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=416 --stop-position=569 $MYSQLD_DATADIR/master-bin.000001
-+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=$start_pos --stop-position=$stop_pos $MYSQLD_DATADIR/master-bin.000001
- 
- # These are tests for remote binlog.
- # They should return the same as previous test.
-@@ -181,7 +184,7 @@
- 
- # This is broken now
- --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
----exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --stop-position=569 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
-+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --stop-position=$stop_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
- 
- # This part is disabled due to bug #17654
- 
-@@ -257,7 +260,7 @@
- select "--- Test 5 LOAD DATA --" as "";
- --enable_query_log
- --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
----exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --stop-position=106 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
-+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --stop-position=$binlog_start_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
- 
- # Bug#7853 (mysqlbinlog does not accept input from stdin)
- 
-@@ -265,14 +268,17 @@
- select "--- Test 6 reading stdin --" as "";
- --enable_query_log
- let $MYSQLD_DATADIR= `select @@datadir;`;
-+let $stop_pos= `select @binlog_start_pos + 463`;
- --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
----exec $MYSQL_BINLOG --short-form --stop-position=569 - < $MYSQLD_DATADIR/master-bin.000001
-+--exec $MYSQL_BINLOG --short-form --stop-position=$stop_pos - < $MYSQLD_DATADIR/master-bin.000001
- 
- --disable_query_log
- select "--- Test 7 reading stdin w/position --" as "";
- --enable_query_log
-+let $start_pos= `select @binlog_start_pos + 310`;
-+let $stop_pos= `select @binlog_start_pos + 463`;
- --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
----exec $MYSQL_BINLOG --short-form --position=416 --stop-position=569 - < $MYSQLD_DATADIR/master-bin.000001
-+--exec $MYSQL_BINLOG --short-form --position=$start_pos --stop-position=$stop_pos - < $MYSQLD_DATADIR/master-bin.000001
- 
- # Bug#16217 (mysql client did not know how not switch its internal charset)
- --disable_query_log
---- a/mysql-test/suite/rpl/t/rpl_stm_flsh_tbls.test
-+++ b/mysql-test/suite/rpl/t/rpl_stm_flsh_tbls.test
-@@ -1,5 +1,6 @@
- # depends on the binlog output
- --source include/have_binlog_format_mixed_or_statement.inc
-+--source include/binlog_start_pos.inc
- 
--let $rename_event_pos= 656;
-+let $rename_event_pos= `select @binlog_start_pos + 550`;
- -- source extra/rpl_tests/rpl_flsh_tbls.test
 --- /dev/null
 +++ b/mysql-test/suite/rpl/t/rpl_typeconv.test
 @@ -0,0 +1,75 @@
@@ -7652,436 +6872,6 @@
 +set global slave_type_conversions = @saved_slave_type_conversions;
 +
 +source include/rpl_end.inc;
---- a/mysql-test/t/ctype_cp932_binlog_stm.test
-+++ b/mysql-test/t/ctype_cp932_binlog_stm.test
-@@ -28,16 +28,6 @@
- 
- --echo End of 5.0 tests
- 
--#
--# #28436: Incorrect position in SHOW BINLOG EVENTS causes server coredump 
--# Note: 364 is a magic position (found experimentally, depends on 
--# the log's contents) that caused the server crash.
--
--call mtr.add_suppression("Error in Log_event::read_log_event\\\(\\\): 'Sanity check failed', data_len: 258, event_type: 49");
--
----error 1220
--SHOW BINLOG EVENTS FROM 365;
--
- --echo Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment.
- CREATE TABLE t1 (a varchar(16)) character set cp932;
- INSERT INTO t1 VALUES (0x8372835E),(0x8352835E);
---- a/mysql-test/t/mysqlbinlog2.test
-+++ b/mysql-test/t/mysqlbinlog2.test
-@@ -3,7 +3,7 @@
- 
- # TODO: Need to look at making row based version once new binlog client is complete.
- -- source include/have_binlog_format_mixed_or_statement.inc
--
-+-- source include/binlog_start_pos.inc
- 
- --disable_warnings
- drop table if exists t1;
-@@ -50,15 +50,19 @@
- --disable_query_log
- select "--- start-position --" as "";
- --enable_query_log
----exec $MYSQL_BINLOG --short-form --start-position=608 $MYSQLD_DATADIR/master-bin.000001 
-+let $start_pos= `select @binlog_start_pos + 502`;
-+--exec $MYSQL_BINLOG --short-form --start-position=$start_pos $MYSQLD_DATADIR/master-bin.000001 
- --disable_query_log
- select "--- stop-position --" as "";
- --enable_query_log
----exec $MYSQL_BINLOG --short-form --stop-position=608 $MYSQLD_DATADIR/master-bin.000001 
-+let $stop_pos= `select @binlog_start_pos + 502`;
-+--exec $MYSQL_BINLOG --short-form --stop-position=$stop_pos $MYSQLD_DATADIR/master-bin.000001 
- --disable_query_log
- select "--- start and stop positions ---" as "";
- --enable_query_log
----exec $MYSQL_BINLOG --short-form --start-position=608 --stop-position 725 $MYSQLD_DATADIR/master-bin.000001 
-+let $start_pos= `select @binlog_start_pos + 502`;
-+let $stop_pos= `select @binlog_start_pos + 619`;
-+--exec $MYSQL_BINLOG --short-form --start-position=$start_pos --stop-position $stop_pos $MYSQLD_DATADIR/master-bin.000001 
- --disable_query_log
- select "--- start-datetime --" as "";
- --enable_query_log
-@@ -84,11 +88,13 @@
- --disable_query_log
- select "--- start-position --" as "";
- --enable_query_log
----exec $MYSQL_BINLOG --short-form --start-position=608 $MYSQLD_DATADIR/master-bin.000001 $MYSQLD_DATADIR/master-bin.000002
-+let $start_pos= `select @binlog_start_pos + 502`;
-+--exec $MYSQL_BINLOG --short-form --start-position=$start_pos $MYSQLD_DATADIR/master-bin.000001 $MYSQLD_DATADIR/master-bin.000002
- --disable_query_log
- select "--- stop-position --" as "";
- --enable_query_log
----exec $MYSQL_BINLOG --short-form --stop-position=134 $MYSQLD_DATADIR/master-bin.000001 $MYSQLD_DATADIR/master-bin.000002
-+let $stop_pos= `select @binlog_start_pos + 28`;
-+--exec $MYSQL_BINLOG --short-form --stop-position=$stop_pos $MYSQLD_DATADIR/master-bin.000001 $MYSQLD_DATADIR/master-bin.000002
- --disable_query_log
- select "--- start-datetime --" as "";
- --enable_query_log
-@@ -111,15 +117,19 @@
- --disable_query_log
- select "--- start-position --" as "";
- --enable_query_log
----exec $MYSQL_BINLOG --short-form --start-position=608 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 
-+let $start_pos= `select @binlog_start_pos + 502`;
-+--exec $MYSQL_BINLOG --short-form --start-position=$start_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 
- --disable_query_log
- select "--- stop-position --" as "";
- --enable_query_log
----exec $MYSQL_BINLOG --short-form --stop-position=608 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 
-+let $stop_pos= `select @binlog_start_pos + 502`;
-+--exec $MYSQL_BINLOG --short-form --stop-position=$stop_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 
- --disable_query_log
- select "--- start and stop positions ---" as "";
- --enable_query_log
----exec $MYSQL_BINLOG --short-form --start-position=608 --stop-position 725 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
-+let $start_pos= `select @binlog_start_pos + 502`;
-+let $stop_pos= `select @binlog_start_pos + 619`;
-+--exec $MYSQL_BINLOG --short-form --start-position=$start_pos --stop-position $stop_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
- --disable_query_log
- select "--- start-datetime --" as "";
- --enable_query_log
-@@ -142,11 +152,13 @@
- --disable_query_log
- select "--- start-position --" as "";
- --enable_query_log
----exec $MYSQL_BINLOG --short-form --start-position=608 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001  master-bin.000002
-+let $start_pos= `select @binlog_start_pos + 502`;
-+--exec $MYSQL_BINLOG --short-form --start-position=$start_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001  master-bin.000002
- --disable_query_log
- select "--- stop-position --" as "";
- --enable_query_log
----exec $MYSQL_BINLOG --short-form --stop-position=134 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001  master-bin.000002
-+let $stop_pos= `select @binlog_start_pos + 28`;
-+--exec $MYSQL_BINLOG --short-form --stop-position=$stop_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001  master-bin.000002
- --disable_query_log
- select "--- start-datetime --" as "";
- --enable_query_log
---- a/mysql-test/t/mysqlbinlog-master.opt
-+++ b/mysql-test/t/mysqlbinlog-master.opt
-@@ -1,2 +1 @@
----max-binlog-size=4096
- --force-restart
---- a/mysql-test/t/mysqlbinlog.test
-+++ b/mysql-test/t/mysqlbinlog.test
-@@ -3,10 +3,18 @@
- -- source include/have_binlog_format_statement.inc
- 
- -- source include/have_log_bin.inc
-+-- source include/binlog_start_pos.inc
- 
- # Deletes all the binary logs
- reset master;
- 
-+# We need small binlog size to break the last LOAD DATA INFILE below so that
-+# the corresponding Begin_load_query will be written to master-bin.000001
-+# while the Execute_load_query will be written to master-bin.000002.
-+
-+SET @save_binlog_size= @@global.max_binlog_size;
-+SET @@global.max_binlog_size= 4096;
-+
- # we need this for getting fixed timestamps inside of this test
- set timestamp=1000000000;
- 
-@@ -26,13 +34,15 @@
- 
- # test for load data and load data distributed among the several
- # files (we need to fill up first binlog)
--load data infile '../../std_data/words.dat' into table t1;
--load data infile '../../std_data/words.dat' into table t1;
--load data infile '../../std_data/words.dat' into table t1;
--load data infile '../../std_data/words.dat' into table t1;
--load data infile '../../std_data/words.dat' into table t1;
-+load data infile '../../std_data/words3.dat' into table t1;
-+load data infile '../../std_data/words3.dat' into table t1;
-+load data infile '../../std_data/words3.dat' into table t1;
-+load data infile '../../std_data/words3.dat' into table t1;
-+load data infile '../../std_data/words3.dat' into table t1;
- # simple query to show more in second binlog
- insert into t1 values ("Alas");
-+
-+### Starting master-bin.000003
- flush logs;
- 
- # delimiters are for easier debugging in future
-@@ -46,7 +56,7 @@
- #
- let $MYSQLD_DATADIR= `select @@datadir`;
- --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
----replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
-+--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/
- --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLD_DATADIR/master-bin.000001
- 
- # this should not fail but shouldn't produce any working statements
-@@ -54,7 +64,7 @@
- select "--- Broken LOAD DATA --" as "";
- --enable_query_log
- --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
----replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
-+--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/
- --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLD_DATADIR/master-bin.000002 2> /dev/null
- 
- # this should show almost nothing
-@@ -62,17 +72,17 @@
- select "--- --database --" as "";
- --enable_query_log
- --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
----replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
-+--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/
- --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --database=nottest $MYSQLD_DATADIR/master-bin.000001 2> /dev/null
- 
- # this test for position option
- --disable_query_log
- select "--- --position --" as "";
- --enable_query_log
-+let $start_pos= `select @binlog_start_pos + 227`;
- --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
----replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
----exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=332 $MYSQLD_DATADIR/master-bin.000002
--
-+--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/
-+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=$start_pos $MYSQLD_DATADIR/master-bin.000002
- 
- # These are tests for remote binlog.
- # They should return the same as previous test.
-@@ -83,7 +93,7 @@
- 
- # This is broken now
- --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
----replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
-+--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/
- --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
- 
- # This is broken too
-@@ -91,7 +101,7 @@
- select "--- Broken LOAD DATA --" as "";
- --enable_query_log
- --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
----replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
-+--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/
- --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 2> /dev/null
- 
- # And this too ! (altough it is documented)
-@@ -99,34 +109,39 @@
- select "--- --database --" as "";
- --enable_query_log
- --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
----replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
-+--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/
- --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --database=nottest master-bin.000001 2> /dev/null
- 
- # Strangely but this works
- --disable_query_log
- select "--- --position --" as "";
- --enable_query_log
-+let $start_pos= `select @binlog_start_pos + 227`;
- --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
----replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
----exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --position=332 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
-+--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/
-+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --position=$start_pos --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
- 
- # Bug#7853 mysqlbinlog does not accept input from stdin
- --disable_query_log
- select "--- reading stdin --" as "";
- --enable_query_log
- --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
----replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
-+--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/
- --exec $MYSQL_BINLOG --short-form - < $MYSQL_TEST_DIR/std_data/trunc_binlog.000001
- 
- --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
----replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
-+--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/
- --exec $MYSQL_BINLOG --short-form --position=79 - < $MYSQL_TEST_DIR/std_data/trunc_binlog.000001
- drop table t1,t2;
- 
-+SET @@global.max_binlog_size= @save_binlog_size;
-+
- #
- # Bug#14157 utf8 encoding in binlog without set character_set_client
- #
-+### Starting master-bin.000004
- flush logs;
-+
- --write_file $MYSQLTEST_VARDIR/tmp/bug14157.sql
- create table if not exists t5 (a int);
- set names latin1;
-@@ -140,6 +155,8 @@
- # resulted binlog, parly consisting of multi-byte utf8 chars,
- # must be digestable for both client and server. In 4.1 the client
- # should use default-character-set same as the server.
-+
-+### Starting master-bin.000005
- flush logs;
- --exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000004 | $MYSQL
- select * from t5  /* must be (1),(1) */;
-@@ -150,6 +167,8 @@
- # Check that a dump created by mysqlbinlog reproduces
- # lc_time_names dependent values correctly
- #
-+
-+### Starting master-bin.000006
- flush logs;
- create table t5 (c1 int, c2 varchar(128) character set latin1 not null);
- insert into t5 values (1, date_format('2001-01-01','%W'));
-@@ -158,7 +177,10 @@
- set lc_time_names=en_US;
- insert into t5 values (3, date_format('2001-01-01','%W'));
- select * from t5 order by c1;
-+
-+### Starting master-bin.000007
- flush logs;
-+
- drop table t5;
- --exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000006 | $MYSQL
- select * from t5 order by c1;
-@@ -170,7 +192,10 @@
- --disable_warnings
- drop procedure if exists p1;
- --enable_warnings
-+
-+### Starting master-bin.000008
- flush logs;
-+
- delimiter //;
- create procedure p1()
- begin
-@@ -178,12 +203,15 @@
- end;
- //
- delimiter ;//
-+
-+### Starting master-bin.000009
- flush logs;
-+
- call p1();
- drop procedure p1;
- --error ER_SP_DOES_NOT_EXIST
- call p1();
----replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
-+--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/
- --exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000008
- --exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000008 | $MYSQL
- call p1();
-@@ -202,7 +230,9 @@
- # (LOAD DATA INFILE need it)
- #
- 
-+### Starting master-bin.000010
- flush logs;
-+
- create table t1 (a varchar(64) character set utf8);
- load data infile '../../std_data/loaddata6.dat' into table t1;
- set character_set_database=koi8r;
-@@ -217,9 +247,12 @@
- load data infile '../../std_data/loaddata6.dat' into table t1 character set koi8r;
- select hex(a) from t1;
- drop table t1;
-+
-+### Starting master-bin.000011
- flush logs;
-+
- --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
----replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
-+--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/
- --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLD_DATADIR/master-bin.000010
- 
- #
-@@ -229,9 +262,14 @@
- 
- CREATE TABLE t1 (c1 CHAR(10));
- # we need this for getting fixed timestamps inside of this test
-+### Starting master-bin.000012
- FLUSH LOGS;
-+
- INSERT INTO t1 VALUES ('0123456789');
-+
-+### Starting master-bin.000013
- FLUSH LOGS;
-+
- DROP TABLE t1;
- 
- # We create a table, patch, and load the output into it
-@@ -257,11 +295,16 @@
- #
- # Bug#29928 incorrect connection_id() restoring from mysqlbinlog out
- #
-+### Starting master-bin.000014
- FLUSH LOGS;
-+
- CREATE TABLE t1(a INT);
- INSERT INTO t1 VALUES(connection_id());
- let $a= `SELECT a FROM t1`;
-+
-+### Starting master-bin.000015
- FLUSH LOGS;
-+
- let $outfile= $MYSQLTEST_VARDIR/tmp/bug29928.sql;
- --exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000014 > $outfile
- DROP TABLE t1;
-@@ -281,11 +324,12 @@
- exec $MYSQL_BINLOG $MYSQL_TEST_DIR/std_data/corrupt-relay-bin.000624 > $MYSQLTEST_VARDIR/tmp/bug31793.sql;
- --remove_file $MYSQLTEST_VARDIR/tmp/bug31793.sql
- 
--
- #
- # Test --disable-force-if-open and --force-if-open
- #
-+### Starting master-bin.000016
- FLUSH LOGS;
-+
- --error 1
- --exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000016 >/dev/null 2>/dev/null
- --exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/master-bin.000016 >/dev/null 2>/dev/null
-@@ -300,9 +344,15 @@
- SHOW GRANTS FOR untrusted@localhost;
- USE mysqltest1;
- CREATE TABLE t1 (a INT, b CHAR(64));
-+
-+### Starting master-bin.000017
- flush logs;
-+
- INSERT INTO t1 VALUES (1,USER());
-+
-+### Starting master-bin.000018
- flush logs;
-+
- echo mysqlbinlog var/log/master-bin.000017 > var/tmp/bug31611.sql;
- exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000017 > $MYSQLTEST_VARDIR/tmp/bug31611.sql;
- connect (unsecure,localhost,untrusted,,mysqltest1);
-@@ -326,14 +376,20 @@
- connection default;
- USE test;
- SET BINLOG_FORMAT = STATEMENT;
-+
-+### Starting master-bin.000019
- FLUSH LOGS;
-+
- CREATE TABLE t1 (a_real FLOAT, an_int INT, a_decimal DECIMAL(5,2), a_string CHAR(32));
- SET @a_real = rand(20) * 1000;
- SET @an_int = 1000;
- SET @a_decimal = CAST(rand(19) * 999 AS DECIMAL(5,2));
- SET @a_string = 'Just a test';
- INSERT INTO t1 VALUES (@a_real, @an_int, @a_decimal, @a_string);
-+
-+### Starting master-bin.000020
- FLUSH LOGS;
-+
- query_vertical SELECT * FROM t1;
- DROP TABLE t1;
- 
-@@ -357,6 +413,7 @@
- 
- RESET MASTER;
- FLUSH LOGS;
-+
- --exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $binlog_file
- --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
- eval SELECT
 --- /dev/null
 +++ b/mysql-test/t/percona_fast_alter_column.test
 @@ -0,0 +1,65 @@
@@ -8248,15 +7038,7 @@
 +DROP TABLE test;
 --- a/mysql-test/r/percona_server_variables_debug.result
 +++ b/mysql-test/r/percona_server_variables_debug.result
-@@ -7,6 +7,7 @@
- BACK_LOG
- BASEDIR
- BIG_TABLES
-+BINLOG_ANNOTATE_ROWS_EVENTS
- BINLOG_CACHE_SIZE
- BINLOG_DIRECT_NON_TRANSACTIONAL_UPDATES
- BINLOG_FORMAT
-@@ -101,6 +102,7 @@
+@@ -102,6 +102,7 @@
  INNODB_EXTRA_RSEGMENTS
  INNODB_EXTRA_UNDOSLOTS
  INNODB_FAKE_CHANGES
@@ -8264,7 +7046,7 @@
  INNODB_FAST_CHECKSUM
  INNODB_FAST_RECOVERY
  INNODB_FAST_SHUTDOWN
-@@ -201,6 +203,7 @@
+@@ -202,6 +203,7 @@
  LOW_PRIORITY_UPDATES
  MAX_ALLOWED_PACKET
  MAX_BINLOG_CACHE_SIZE
@@ -8272,16 +7054,15 @@
  MAX_BINLOG_SIZE
  MAX_CONNECTIONS
  MAX_CONNECT_ERRORS
-@@ -273,6 +276,8 @@
- RELAY_LOG_INFO_FILE
+@@ -275,6 +277,7 @@
  RELAY_LOG_PURGE
  RELAY_LOG_SPACE_LIMIT
-+REPLICATE_ANNOTATE_ROWS_EVENTS
+ REPLICATE_ANNOTATE_ROWS_EVENTS
 +REPLICATION_SLAVE_SKIP_COLUMNS
  REPORT_HOST
  REPORT_PASSWORD
  REPORT_PORT
-@@ -291,6 +296,8 @@
+@@ -293,6 +296,8 @@
  SLAVE_NET_TIMEOUT
  SLAVE_SKIP_ERRORS
  SLAVE_TRANSACTION_RETRIES
@@ -8290,7 +7071,7 @@
  SLOW_LAUNCH_TIME
  SLOW_QUERY_LOG
  SLOW_QUERY_LOG_FILE
-@@ -312,6 +319,7 @@
+@@ -314,6 +319,7 @@
  SQL_SAFE_UPDATES
  SQL_SELECT_LIMIT
  SQL_SLAVE_SKIP_COUNTER
@@ -8300,15 +7081,7 @@
  SSL_CAPATH
 --- a/mysql-test/r/percona_server_variables_release.result
 +++ b/mysql-test/r/percona_server_variables_release.result
-@@ -7,6 +7,7 @@
- BACK_LOG
- BASEDIR
- BIG_TABLES
-+BINLOG_ANNOTATE_ROWS_EVENTS
- BINLOG_CACHE_SIZE
- BINLOG_DIRECT_NON_TRANSACTIONAL_UPDATES
- BINLOG_FORMAT
-@@ -99,6 +100,7 @@
+@@ -100,6 +100,7 @@
  INNODB_EXTRA_RSEGMENTS
  INNODB_EXTRA_UNDOSLOTS
  INNODB_FAKE_CHANGES
@@ -8316,7 +7089,7 @@
  INNODB_FAST_CHECKSUM
  INNODB_FAST_RECOVERY
  INNODB_FAST_SHUTDOWN
-@@ -199,6 +201,7 @@
+@@ -200,6 +201,7 @@
  LOW_PRIORITY_UPDATES
  MAX_ALLOWED_PACKET
  MAX_BINLOG_CACHE_SIZE
@@ -8324,16 +7097,15 @@
  MAX_BINLOG_SIZE
  MAX_CONNECTIONS
  MAX_CONNECT_ERRORS
-@@ -270,6 +273,8 @@
- RELAY_LOG_INFO_FILE
+@@ -272,6 +274,7 @@
  RELAY_LOG_PURGE
  RELAY_LOG_SPACE_LIMIT
-+REPLICATE_ANNOTATE_ROWS_EVENTS
+ REPLICATE_ANNOTATE_ROWS_EVENTS
 +REPLICATION_SLAVE_SKIP_COLUMNS
  REPORT_HOST
  REPORT_PASSWORD
  REPORT_PORT
-@@ -288,6 +293,8 @@
+@@ -290,6 +293,8 @@
  SLAVE_NET_TIMEOUT
  SLAVE_SKIP_ERRORS
  SLAVE_TRANSACTION_RETRIES
@@ -8342,7 +7114,7 @@
  SLOW_LAUNCH_TIME
  SLOW_QUERY_LOG
  SLOW_QUERY_LOG_FILE
-@@ -309,6 +316,7 @@
+@@ -311,6 +316,7 @@
  SQL_SAFE_UPDATES
  SQL_SELECT_LIMIT
  SQL_SLAVE_SKIP_COUNTER

=== modified file 'patches/wl47.patch'
--- patches/wl47.patch	2012-01-31 08:05:03 +0000
+++ patches/wl47.patch	2012-02-08 08:48:30 +0000
@@ -96,7 +96,7 @@
  static Exit_status dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
                                            const char* logname);
  static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
-@@ -947,6 +1012,19 @@
+@@ -956,6 +1021,19 @@
  	my_free(fname, MYF(MY_WME));
        break;
      }
@@ -116,7 +116,7 @@
      case TABLE_MAP_EVENT:
      {
        Table_map_log_event *map= ((Table_map_log_event *)ev);
-@@ -956,5 +1034,12 @@
+@@ -965,6 +1043,13 @@
          destroy_evt= FALSE;
          goto end;
        }
@@ -129,7 +129,8 @@
 +
        size_t      len_to= 0;
        const char* db_to=  binlog_filter->get_rewrite_db(map->get_db_name(),
-@@ -992,6 +1077,13 @@
+                                                         &len_to);
+@@ -1002,6 +1087,13 @@
            if (print_event_info->m_table_map_ignored.count() > 0)
              print_event_info->m_table_map_ignored.clear_tables();
  
@@ -143,7 +144,7 @@
            /* 
               One needs to take into account an event that gets
               filtered but was last event in the statement. If this is
-@@ -1227,6 +1319,11 @@
+@@ -1239,6 +1331,11 @@
     "Updates to a database with a different name than the original. \
  Example: rewrite-db='from->to'.",
     0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -155,7 +156,7 @@
    {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
  };
  
-@@ -1695,6 +1792,8 @@
+@@ -1707,6 +1804,8 @@
      cast to uint32.
    */
    int4store(buf, (uint32)start_position);
@@ -164,7 +165,7 @@
    int2store(buf + BIN_LOG_HEADER_SIZE, binlog_flags);
  
    size_t tlen = strlen(logname);
-@@ -1727,18 +1826,30 @@
+@@ -1739,18 +1838,30 @@
        break; // end of data
      DBUG_PRINT("info",( "len: %lu  net->read_pos[5]: %d\n",
  			len, net->read_pos[5]));
@@ -206,7 +207,7 @@
  
      Log_event_type type= ev->get_type_code();
      if (glob_description_event->binlog_version >= 3 ||
-@@ -2247,6 +2358,7 @@
+@@ -2259,6 +2370,7 @@
    if (result_file != stdout)
      my_fclose(result_file, MYF(0));
    cleanup();
@@ -214,6 +215,2809 @@
    delete binlog_filter;
    free_root(&s_mem_root, MYF(0));
    free_defaults(defaults_argv);
+--- a/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test
++++ b/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test
+@@ -321,14 +321,19 @@
+ # we check that the error code of the "ROLLBACK" event is 0 and not
+ # ER_SERVER_SHUTDOWN (i.e. disconnection just rolls back transaction
+ # and does not make slave to stop)
++
++-- source include/binlog_start_pos.inc
++
+ if (`select @@binlog_format = 'ROW'`)
+ {
+-  --exec $MYSQL_BINLOG --start-position=524 $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output
++  let $start_pos= `select @binlog_start_pos + 418`;
++  --exec $MYSQL_BINLOG --start-position=$start_pos $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output
+ }
+ 
+ if (`select @@binlog_format = 'STATEMENT' || @@binlog_format = 'MIXED'`)
+ {
+-  --exec $MYSQL_BINLOG --start-position=555 $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output
++  let $start_pos= `select @binlog_start_pos + 449`;
++  --exec $MYSQL_BINLOG --start-position=$start_pos $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output
+ }
+ 
+ --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--- a/mysql-test/extra/rpl_tests/rpl_log.test
++++ b/mysql-test/extra/rpl_tests/rpl_log.test
+@@ -14,6 +14,7 @@
+ reset master;
+ reset slave;
+ source include/start_slave.inc;
++source include/binlog_start_pos.inc;
+ 
+ let $VERSION=`select version()`;
+ 
+--- /dev/null
++++ b/mysql-test/extra/rpl_tests/rpl_row_annotate.test
+@@ -0,0 +1,156 @@
++########################################################################
++# WL47: Store in binlog text of statements that caused RBR events
++# new event          : ANNOTATE_ROWS_EVENT
++# new master option  : --binlog-annotate-rows-events
++# new slave option   : --replicate-annotate-rows-events
++########################################################################
++--source include/master-slave.inc
++connect (master2,127.0.0.1,root,,test,$MASTER_MYPORT,);
++
++connection master;
++--disable_query_log
++
++--disable_warnings
++DROP DATABASE IF EXISTS test1;
++--enable_warnings
++
++CREATE DATABASE test1;
++USE test1;
++
++CREATE TABLE t1(a int primary key, b int);
++CREATE TABLE t2(a int, b int);
++CREATE TABLE t3(a int, b int);
++CREATE TABLE t4(a int, b int);
++CREATE TABLE xt1(a int, b int);
++CREATE TABLE xt2(a int, b int);
++
++CREATE TABLE t5 (
++    a INT PRIMARY KEY AUTO_INCREMENT,
++    b VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_bin
++);
++
++SET SESSION binlog_annotate_rows_events = OFF;
++
++INSERT INTO t1 VALUES (0,0), (1,1);
++
++SET SESSION binlog_annotate_rows_events = ON;
++
++UPDATE t1 SET b = b + 1;
++REPLACE t1 VALUES (1,1), (2,2), (3,3);
++
++INSERT INTO t2 VALUES (1,1), (2,2), (3,3);
++INSERT INTO t3 VALUES (1,1), (2,2), (3,3);
++DELETE t1, t2 FROM t1 INNER JOIN t2 INNER JOIN t3 WHERE t1.a=t2.a AND t2.a=t3.a;
++
++INSERT INTO xt1 VALUES (1,1), (2,2), (3,3);
++INSERT INTO t2 VALUES (1,1), (2,2), (3,3);
++DELETE xt1, t2 FROM xt1 INNER JOIN t2 INNER JOIN t3 WHERE xt1.a=t2.a AND t2.a=t3.a;
++
++INSERT INTO xt1 VALUES (1,1), (2,2), (3,3);
++INSERT INTO xt2 VALUES (1,1), (2,2), (3,3);
++DELETE xt1, xt2 FROM xt1 INNER JOIN xt2 INNER JOIN t3 WHERE xt1.a=xt2.a AND xt2.a=t3.a;
++
++INSERT INTO t5(b) VALUES ('foo'), ('bar'), ('baz');
++SET NAMES latin1;
++INSERT INTO t5(b) VALUES ('gås');
++SET NAMES utf8;
++INSERT INTO t5(b) VALUES ('gÃ¥s');
++SET NAMES latin1;
++
++FLUSH LOGS;
++
++--echo ########################################################################
++--echo # TABLES ON MASTER
++--echo ########################################################################
++--enable_query_log
++
++SELECT * FROM t1 ORDER BY a;
++SELECT * FROM t2 ORDER BY a;
++SELECT * FROM t3 ORDER BY a;
++SELECT * FROM t5 ORDER BY a;
++
++sync_slave_with_master;
++--echo ########################################################################
++--echo # TABLES ON SLAVE: should be the same as on master
++--echo ########################################################################
++--disable_query_log
++USE test1;
++--enable_query_log
++
++SELECT * FROM t1 ORDER BY a;
++SELECT * FROM t2 ORDER BY a;
++SELECT * FROM t3 ORDER BY a;
++SELECT * FROM t5 ORDER BY a;
++
++--echo ########################################################################
++--echo # EVENTS ON SLAVE
++let $annotate= `select @@global.replicate_annotate_rows_events`;
++if ($annotate)
++{
++  --echo # The following Annotate_rows events should appear below:
++  --echo # - UPDATE t1 SET b = b + 1;
++  --echo # - REPLACE t1 VALUES (1,1), (2,2), (3,3);
++  --echo # - INSERT INTO t2 VALUES (1,1), (2,2), (3,3)
++  --echo # - INSERT INTO t3 VALUES (1,1), (2,2), (3,3)
++  --echo # - DELETE t1, t2 FROM <...>
++  --echo # - INSERT INTO t2 VALUES (1,1), (2,2), (3,3)
++  --echo # - DELETE xt1, t2 FROM <...>
++  --echo # - INSERT INTO t5(b) VALUES <...> (3 instances)
++}
++if (!$annotate)
++{
++  --echo # No Annotate_rows events should appear below
++}
++--echo ########################################################################
++FLUSH LOGS;
++
++--source include/binlog_start_pos.inc
++let $start_pos= `select @binlog_start_pos`;
++--replace_column 2 # 5 #
++--replace_result $start_pos <start_pos>
++--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
++--eval show binlog events in 'slave-bin.000001' from $start_pos
++
++--echo # 
++--echo ########################################################################
++--echo # INSERTs DELAYED ON MASTERs
++--echo ########################################################################
++connection master;
++SET SESSION binlog_annotate_rows_events = ON;
++INSERT DELAYED INTO test1.t4 VALUES (1,1);
++FLUSH TABLES;
++SELECT * FROM test1.t4 ORDER BY a;
++
++sync_slave_with_master;
++connection master;
++sync_slave_with_master;
++
++--echo ########################################################################
++--echo # ON SLAVE
++--echo # No Annotate_rows events should appear below
++--echo ########################################################################
++FLUSH LOGS;
++
++--exec $MYSQL --host=127.0.0.1 --port=$SLAVE_MYPORT test -e "show binlog events in 'slave-bin.000002'" > $MYSQLTEST_VARDIR/tmp/annotated_events.txt
++perl;
++    open F, '<', "$ENV{MYSQLTEST_VARDIR}/tmp/annotated_events.txt" or die;
++    binmode STDOUT;
++    while (defined ($_ = <F>)) {
++        if (/Annotate_rows/) {
++            s/[0-9]+\sAnnotate_rows\s[0-9]+\s[0-9]+/# Annotate_rows # #/;
++            print($_);
++            $_ = <F>;
++            s/[0-9]+\sTable_map\s[0-9]+\s[0-9]+\stable_id:\s[0-9]+/# Table_map # # table_id: #/;
++            print($_);
++        }
++    }
++EOF
++
++# Clean-up
++connection master;
++--disable_query_log
++DROP DATABASE test1;
++sync_slave_with_master;
++--enable_query_log
++
++--source include/rpl_end.inc
+--- /dev/null
++++ b/mysql-test/include/binlog_start_pos.inc
+@@ -0,0 +1,26 @@
++##############################################################################
++#
++# binlog_start_pos is the postion of the the first event in the binary log
++# which follows the Format description event. Intended to reduce test suite
++# dependance on the Format description event length changes (e.g. in case
++# of adding new events). Evaluated as:
++#  
++#   binlog_start_pos = 4  /* binlog header */ +
++#                      (Format_description_log_event length)
++#
++#   Format_description_log_event length = 
++#                      19 /* event common header */ +
++#                      57 /* misc stuff in the Format description header */ +
++#                      number of events.
++# 
++# With current number of events = 160,
++#
++#   binlog_start_pos = 4 + 19 + 57 + 160 = 240.
++#
++##############################################################################
++
++let $binlog_start_pos=240;
++--disable_query_log
++SET @binlog_start_pos=240;
++--enable_query_log
++
+--- a/mysql-test/include/show_binlog_events.inc
++++ b/mysql-test/include/show_binlog_events.inc
+@@ -3,7 +3,7 @@
+ #
+ # Useage: 
+ # let $binlog_file= master-bin.000002; 
+-# let $binlog_start= 106; 
++# let $binlog_start= 240; 
+ # let $binlog_limit= 1, 3; 
+ # source include/show_binlog_events.inc;
+ #
+--- a/mysql-test/include/show_binlog_events2.inc
++++ b/mysql-test/include/show_binlog_events2.inc
+@@ -1,4 +1,4 @@
+---let $binlog_start=106
++--let $binlog_start=240
+ --replace_result $binlog_start <binlog_start>
+ --replace_column 2 # 5 #
+ --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
+--- a/mysql-test/r/ctype_cp932_binlog_stm.result
++++ b/mysql-test/r/ctype_cp932_binlog_stm.result
+@@ -44,9 +44,6 @@
+ master-bin.000001	#	Query	#	#	use `test`; DROP PROCEDURE bug18293
+ master-bin.000001	#	Query	#	#	use `test`; DROP TABLE t4
+ End of 5.0 tests
+-call mtr.add_suppression("Error in Log_event::read_log_event\\\(\\\): 'Sanity check failed', data_len: 258, event_type: 49");
+-SHOW BINLOG EVENTS FROM 365;
+-ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error
+ Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment.
+ CREATE TABLE t1 (a varchar(16)) character set cp932;
+ INSERT INTO t1 VALUES (0x8372835E),(0x8352835E);
+--- a/mysql-test/r/mysqlbinlog.result
++++ b/mysql-test/r/mysqlbinlog.result
+@@ -1,15 +1,17 @@
+ reset master;
++SET @save_binlog_size= @@global.max_binlog_size;
++SET @@global.max_binlog_size= 4096;
+ set timestamp=1000000000;
+ drop table if exists t1,t2,t3,t4,t5,t03,t04;
+ create table t1 (word varchar(20));
+ create table t2 (id int auto_increment not null primary key);
+ insert into t1 values ("abirvalg");
+ insert into t2 values ();
+-load data infile '../../std_data/words.dat' into table t1;
+-load data infile '../../std_data/words.dat' into table t1;
+-load data infile '../../std_data/words.dat' into table t1;
+-load data infile '../../std_data/words.dat' into table t1;
+-load data infile '../../std_data/words.dat' into table t1;
++load data infile '../../std_data/words3.dat' into table t1;
++load data infile '../../std_data/words3.dat' into table t1;
++load data infile '../../std_data/words3.dat' into table t1;
++load data infile '../../std_data/words3.dat' into table t1;
++load data infile '../../std_data/words3.dat' into table t1;
+ insert into t1 values ("Alas");
+ flush logs;
+ 
+@@ -255,6 +257,7 @@
+ ROLLBACK /* added by mysqlbinlog */;
+ /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+ drop table t1,t2;
++SET @@global.max_binlog_size= @save_binlog_size;
+ flush logs;
+ flush logs;
+ select * from t5  /* must be (1),(1) */;
+@@ -377,14 +380,14 @@
+ /*!*/;
+ SET TIMESTAMP=1000000000/*!*/;
+ SET @@session.collation_database=7/*!*/;
+-LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-a-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`)
++LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`)
+ /*!*/;
+ SET TIMESTAMP=1000000000/*!*/;
+ SET @@session.collation_database=DEFAULT/*!*/;
+-LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-b-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`)
++LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`)
+ /*!*/;
+ SET TIMESTAMP=1000000000/*!*/;
+-LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-c-0' INTO TABLE `t1` CHARACTER SET koi8r FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`)
++LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` CHARACTER SET koi8r FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`)
+ /*!*/;
+ SET TIMESTAMP=1000000000/*!*/;
+ drop table t1
+--- a/mysql-test/r/percona_server_variables_debug.result
++++ b/mysql-test/r/percona_server_variables_debug.result
+@@ -7,6 +7,7 @@
+ BACK_LOG
+ BASEDIR
+ BIG_TABLES
++BINLOG_ANNOTATE_ROWS_EVENTS
+ BINLOG_CACHE_SIZE
+ BINLOG_DIRECT_NON_TRANSACTIONAL_UPDATES
+ BINLOG_FORMAT
+@@ -273,6 +274,7 @@
+ RELAY_LOG_INFO_FILE
+ RELAY_LOG_PURGE
+ RELAY_LOG_SPACE_LIMIT
++REPLICATE_ANNOTATE_ROWS_EVENTS
+ REPORT_HOST
+ REPORT_PASSWORD
+ REPORT_PORT
+--- a/mysql-test/r/percona_server_variables_release.result
++++ b/mysql-test/r/percona_server_variables_release.result
+@@ -7,6 +7,7 @@
+ BACK_LOG
+ BASEDIR
+ BIG_TABLES
++BINLOG_ANNOTATE_ROWS_EVENTS
+ BINLOG_CACHE_SIZE
+ BINLOG_DIRECT_NON_TRANSACTIONAL_UPDATES
+ BINLOG_FORMAT
+@@ -270,6 +271,7 @@
+ RELAY_LOG_INFO_FILE
+ RELAY_LOG_PURGE
+ RELAY_LOG_SPACE_LIMIT
++REPLICATE_ANNOTATE_ROWS_EVENTS
+ REPORT_HOST
+ REPORT_PASSWORD
+ REPORT_PORT
+--- /dev/null
++++ b/mysql-test/std_data/words3.dat
+@@ -0,0 +1,66 @@
++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
+--- /dev/null
++++ b/mysql-test/suite/binlog/r/binlog_row_annotate.result
+@@ -0,0 +1,1219 @@
++#####################################################################################
++# The following Annotate_rows events should appear below:
++# - INSERT INTO test2.t2 VALUES (1), (2), (3)
++# - INSERT INTO test3.t3 VALUES (1), (2), (3)
++# - DELETE test1.t1, test2.t2 FROM <...>
++# - INSERT INTO test2.t2 VALUES (1), (2), (3)
++# - DELETE xtest1.xt1, test2.t2 FROM <...>
++#####################################################################################
++show binlog events in 'master-bin.000001' from <start_pos>;
++Log_name	Pos	Event_type	Server_id	End_log_pos	Info
++master-bin.000001	#	Query	1	#	DROP DATABASE IF EXISTS test1
++master-bin.000001	#	Query	1	#	DROP DATABASE IF EXISTS test2
++master-bin.000001	#	Query	1	#	DROP DATABASE IF EXISTS test3
++master-bin.000001	#	Query	1	#	CREATE DATABASE test1
++master-bin.000001	#	Query	1	#	CREATE DATABASE test2
++master-bin.000001	#	Query	1	#	CREATE DATABASE test3
++master-bin.000001	#	Query	1	#	BEGIN
++master-bin.000001	#	Table_map	1	#	table_id: # (test1.t1)
++master-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
++master-bin.000001	#	Query	1	#	COMMIT
++master-bin.000001	#	Query	1	#	BEGIN
++master-bin.000001	#	Annotate_rows	1	#	INSERT INTO test2.t2 VALUES (1), (2), (3)
++master-bin.000001	#	Table_map	1	#	table_id: # (test2.t2)
++master-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
++master-bin.000001	#	Query	1	#	COMMIT
++master-bin.000001	#	Query	1	#	BEGIN
++master-bin.000001	#	Annotate_rows	1	#	INSERT INTO test3.t3 VALUES (1), (2), (3)
++master-bin.000001	#	Table_map	1	#	table_id: # (test3.t3)
++master-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
++master-bin.000001	#	Query	1	#	COMMIT
++master-bin.000001	#	Query	1	#	BEGIN
++master-bin.000001	#	Annotate_rows	1	#	DELETE test1.t1, test2.t2
++FROM test1.t1 INNER JOIN test2.t2 INNER JOIN test3.t3
++WHERE test1.t1.a=test2.t2.a AND test2.t2.a=test3.t3.a
++master-bin.000001	#	Table_map	1	#	table_id: # (test1.t1)
++master-bin.000001	#	Table_map	1	#	table_id: # (test2.t2)
++master-bin.000001	#	Delete_rows	1	#	table_id: #
++master-bin.000001	#	Delete_rows	1	#	table_id: # flags: STMT_END_F
++master-bin.000001	#	Query	1	#	COMMIT
++master-bin.000001	#	Query	1	#	BEGIN
++master-bin.000001	#	Annotate_rows	1	#	INSERT INTO test2.v2 VALUES (1), (2), (3)
++master-bin.000001	#	Table_map	1	#	table_id: # (test2.t2)
++master-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
++master-bin.000001	#	Query	1	#	COMMIT
++master-bin.000001	#	Query	1	#	BEGIN
++master-bin.000001	#	Annotate_rows	1	#	DELETE xtest1.xt1, test2.t2
++FROM xtest1.xt1 INNER JOIN test2.t2 INNER JOIN test3.t3
++WHERE xtest1.xt1.a=test2.t2.a AND test2.t2.a=test3.t3.a
++master-bin.000001	#	Table_map	1	#	table_id: # (test2.t2)
++master-bin.000001	#	Delete_rows	1	#	table_id: # flags: STMT_END_F
++master-bin.000001	#	Query	1	#	COMMIT
++master-bin.000001	#	Rotate	1	#	master-bin.000002;pos=4
++#
++#####################################################################################
++# mysqlbinlog
++# The following Annotates should appear in this output:
++# - INSERT INTO test2.t2 VALUES (1), (2), (3)
++# - INSERT INTO test3.t3 VALUES (1), (2), (3)
++# - DELETE test1.t1, test2.t2 FROM <...> (with two subsequent Table maps)
++# - INSERT INTO test2.t2 VALUES (1), (2), (3)
++# - DELETE xtest1.xt1, test2.t2 FROM <...> (with one subsequent Table map)
++#####################################################################################
++/*!40019 SET @@session.max_insert_delayed_threads=0*/;
++/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
++DELIMITER /*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Start: binlog v 4, server v #.##.## created 010909  4:46:40 at startup
++ROLLBACK/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++SET @@session.pseudo_thread_id=#/*!*/;
++SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@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/*!*/;
++DROP DATABASE IF EXISTS test1
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++DROP DATABASE IF EXISTS test2
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++DROP DATABASE IF EXISTS test3
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++CREATE DATABASE test1
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++CREATE DATABASE test2
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++CREATE DATABASE test3
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test1`.`t1` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
++### INSERT INTO test1.t1
++### SET
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test1.t1
++### SET
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test1.t1
++### SET
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Annotate_rows:
++#Q> INSERT INTO test2.t2 VALUES (1), (2), (3)
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test2`.`t2` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
++### INSERT INTO test2.t2
++### SET
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test2.t2
++### SET
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test2.t2
++### SET
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Annotate_rows:
++#Q> INSERT INTO test3.t3 VALUES (1), (2), (3)
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test3`.`t3` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
++### INSERT INTO test3.t3
++### SET
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test3.t3
++### SET
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test3.t3
++### SET
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Annotate_rows:
++#Q> DELETE test1.t1, test2.t2
++#Q> FROM test1.t1 INNER JOIN test2.t2 INNER JOIN test3.t3
++#Q> WHERE test1.t1.a=test2.t2.a AND test2.t2.a=test3.t3
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test1`.`t1` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test2`.`t2` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Delete_rows: table id #
++#010909  4:46:40 server id #  end_log_pos # 	Delete_rows: table id # flags: STMT_END_F
++### DELETE FROM test1.t1
++### WHERE
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test1.t1
++### WHERE
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test1.t1
++### WHERE
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test2.t2
++### WHERE
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test2.t2
++### WHERE
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test2.t2
++### WHERE
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Annotate_rows:
++#Q> INSERT INTO test2.v2 VALUES (1), (2), (3)
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test2`.`t2` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
++### INSERT INTO test2.t2
++### SET
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test2.t2
++### SET
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test2.t2
++### SET
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Annotate_rows:
++#Q> DELETE xtest1.xt1, test2.t2
++#Q> FROM xtest1.xt1 INNER JOIN test2.t2 INNER JOIN test3.t3
++#Q> WHERE xtest1.xt1.a=test2.t2.a AND test2.t2.a=test3.t3
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test2`.`t2` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Delete_rows: table id # flags: STMT_END_F
++### DELETE FROM test2.t2
++### WHERE
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test2.t2
++### WHERE
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test2.t2
++### WHERE
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Rotate to master-bin.000002  pos: 4
++DELIMITER ;
++# End of log file
++ROLLBACK /* added by mysqlbinlog */;
++/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
++#
++#####################################################################################
++# mysqlbinlog --database=test1
++# The following Annotate should appear in this output:
++# - DELETE test1.t1, test2.t2 FROM <...>
++#####################################################################################
++/*!40019 SET @@session.max_insert_delayed_threads=0*/;
++/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
++DELIMITER /*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Start: binlog v 4, server v #.##.## created 010909  4:46:40 at startup
++ROLLBACK/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++SET @@session.pseudo_thread_id=#/*!*/;
++SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@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/*!*/;
++DROP DATABASE IF EXISTS test1
++/*!*/;
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++CREATE DATABASE test1
++/*!*/;
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test1`.`t1` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
++### INSERT INTO test1.t1
++### SET
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test1.t1
++### SET
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test1.t1
++### SET
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Annotate_rows:
++#Q> DELETE test1.t1, test2.t2
++#Q> FROM test1.t1 INNER JOIN test2.t2 INNER JOIN test3.t3
++#Q> WHERE test1.t1.a=test2.t2.a AND test2.t2.a=test3.t3
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test1`.`t1` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Delete_rows: table id #
++### DELETE FROM test1.t1
++### WHERE
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test1.t1
++### WHERE
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test1.t1
++### WHERE
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Rotate to master-bin.000002  pos: 4
++DELIMITER ;
++# End of log file
++ROLLBACK /* added by mysqlbinlog */;
++/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
++#
++#####################################################################################
++# mysqlbinlog --skip-annotate-rows-events
++# No Annotates should appear in this output
++#####################################################################################
++/*!40019 SET @@session.max_insert_delayed_threads=0*/;
++/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
++DELIMITER /*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Start: binlog v 4, server v #.##.## created 010909  4:46:40 at startup
++ROLLBACK/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++SET @@session.pseudo_thread_id=#/*!*/;
++SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@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/*!*/;
++DROP DATABASE IF EXISTS test1
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++DROP DATABASE IF EXISTS test2
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++DROP DATABASE IF EXISTS test3
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++CREATE DATABASE test1
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++CREATE DATABASE test2
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++CREATE DATABASE test3
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test1`.`t1` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
++### INSERT INTO test1.t1
++### SET
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test1.t1
++### SET
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test1.t1
++### SET
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test2`.`t2` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
++### INSERT INTO test2.t2
++### SET
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test2.t2
++### SET
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test2.t2
++### SET
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test3`.`t3` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
++### INSERT INTO test3.t3
++### SET
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test3.t3
++### SET
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test3.t3
++### SET
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test1`.`t1` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test2`.`t2` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Delete_rows: table id #
++#010909  4:46:40 server id #  end_log_pos # 	Delete_rows: table id # flags: STMT_END_F
++### DELETE FROM test1.t1
++### WHERE
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test1.t1
++### WHERE
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test1.t1
++### WHERE
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test2.t2
++### WHERE
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test2.t2
++### WHERE
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test2.t2
++### WHERE
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test2`.`t2` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
++### INSERT INTO test2.t2
++### SET
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test2.t2
++### SET
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test2.t2
++### SET
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test2`.`t2` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Delete_rows: table id # flags: STMT_END_F
++### DELETE FROM test2.t2
++### WHERE
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test2.t2
++### WHERE
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test2.t2
++### WHERE
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Rotate to master-bin.000002  pos: 4
++DELIMITER ;
++# End of log file
++ROLLBACK /* added by mysqlbinlog */;
++/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
++#
++#####################################################################################
++# mysqlbinlog --read-from-remote-server
++# The following Annotates should appear in this output:
++# - INSERT INTO test2.t2 VALUES (1), (2), (3)
++# - INSERT INTO test3.t3 VALUES (1), (2), (3)
++# - DELETE test1.t1, test2.t2 FROM <...> (with two subsequent Table maps)
++# - INSERT INTO test2.t2 VALUES (1), (2), (3)
++# - DELETE xtest1.xt1, test2.t2 FROM <...> (with one subsequent Table map)
++#####################################################################################
++/*!40019 SET @@session.max_insert_delayed_threads=0*/;
++/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
++DELIMITER /*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Start: binlog v 4, server v #.##.## created 010909  4:46:40 at startup
++ROLLBACK/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++SET @@session.pseudo_thread_id=#/*!*/;
++SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@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/*!*/;
++DROP DATABASE IF EXISTS test1
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++DROP DATABASE IF EXISTS test2
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++DROP DATABASE IF EXISTS test3
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++CREATE DATABASE test1
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++CREATE DATABASE test2
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++CREATE DATABASE test3
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test1`.`t1` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
++### INSERT INTO test1.t1
++### SET
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test1.t1
++### SET
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test1.t1
++### SET
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Annotate_rows:
++#Q> INSERT INTO test2.t2 VALUES (1), (2), (3)
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test2`.`t2` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
++### INSERT INTO test2.t2
++### SET
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test2.t2
++### SET
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test2.t2
++### SET
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Annotate_rows:
++#Q> INSERT INTO test3.t3 VALUES (1), (2), (3)
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test3`.`t3` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
++### INSERT INTO test3.t3
++### SET
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test3.t3
++### SET
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test3.t3
++### SET
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Annotate_rows:
++#Q> DELETE test1.t1, test2.t2
++#Q> FROM test1.t1 INNER JOIN test2.t2 INNER JOIN test3.t3
++#Q> WHERE test1.t1.a=test2.t2.a AND test2.t2.a=test3.t3
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test1`.`t1` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test2`.`t2` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Delete_rows: table id #
++#010909  4:46:40 server id #  end_log_pos # 	Delete_rows: table id # flags: STMT_END_F
++### DELETE FROM test1.t1
++### WHERE
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test1.t1
++### WHERE
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test1.t1
++### WHERE
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test2.t2
++### WHERE
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test2.t2
++### WHERE
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test2.t2
++### WHERE
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Annotate_rows:
++#Q> INSERT INTO test2.v2 VALUES (1), (2), (3)
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test2`.`t2` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
++### INSERT INTO test2.t2
++### SET
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test2.t2
++### SET
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test2.t2
++### SET
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Annotate_rows:
++#Q> DELETE xtest1.xt1, test2.t2
++#Q> FROM xtest1.xt1 INNER JOIN test2.t2 INNER JOIN test3.t3
++#Q> WHERE xtest1.xt1.a=test2.t2.a AND test2.t2.a=test3.t3
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test2`.`t2` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Delete_rows: table id # flags: STMT_END_F
++### DELETE FROM test2.t2
++### WHERE
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test2.t2
++### WHERE
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test2.t2
++### WHERE
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Rotate to master-bin.000002  pos: 4
++DELIMITER ;
++# End of log file
++ROLLBACK /* added by mysqlbinlog */;
++/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
++#
++#####################################################################################
++# mysqlbinlog --read-from-remote-server --database=test1
++# The following Annotate should appear in this output:
++# - DELETE test1.t1, test2.t2 FROM <...>
++#####################################################################################
++/*!40019 SET @@session.max_insert_delayed_threads=0*/;
++/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
++DELIMITER /*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Start: binlog v 4, server v #.##.## created 010909  4:46:40 at startup
++ROLLBACK/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++SET @@session.pseudo_thread_id=#/*!*/;
++SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@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/*!*/;
++DROP DATABASE IF EXISTS test1
++/*!*/;
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++CREATE DATABASE test1
++/*!*/;
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test1`.`t1` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
++### INSERT INTO test1.t1
++### SET
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test1.t1
++### SET
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test1.t1
++### SET
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Annotate_rows:
++#Q> DELETE test1.t1, test2.t2
++#Q> FROM test1.t1 INNER JOIN test2.t2 INNER JOIN test3.t3
++#Q> WHERE test1.t1.a=test2.t2.a AND test2.t2.a=test3.t3
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test1`.`t1` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Delete_rows: table id #
++### DELETE FROM test1.t1
++### WHERE
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test1.t1
++### WHERE
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test1.t1
++### WHERE
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Rotate to master-bin.000002  pos: 4
++DELIMITER ;
++# End of log file
++ROLLBACK /* added by mysqlbinlog */;
++/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
++#
++#####################################################################################
++# mysqlbinlog --read-from-remote-server --skip-annotate-rows-events
++# No Annotates should appear in this output
++#####################################################################################
++/*!40019 SET @@session.max_insert_delayed_threads=0*/;
++/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
++DELIMITER /*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Start: binlog v 4, server v #.##.## created 010909  4:46:40 at startup
++ROLLBACK/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++SET @@session.pseudo_thread_id=#/*!*/;
++SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@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/*!*/;
++DROP DATABASE IF EXISTS test1
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++DROP DATABASE IF EXISTS test2
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++DROP DATABASE IF EXISTS test3
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++CREATE DATABASE test1
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++CREATE DATABASE test2
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++CREATE DATABASE test3
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test1`.`t1` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
++### INSERT INTO test1.t1
++### SET
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test1.t1
++### SET
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test1.t1
++### SET
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test2`.`t2` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
++### INSERT INTO test2.t2
++### SET
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test2.t2
++### SET
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test2.t2
++### SET
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test3`.`t3` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
++### INSERT INTO test3.t3
++### SET
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test3.t3
++### SET
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test3.t3
++### SET
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test1`.`t1` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test2`.`t2` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Delete_rows: table id #
++#010909  4:46:40 server id #  end_log_pos # 	Delete_rows: table id # flags: STMT_END_F
++### DELETE FROM test1.t1
++### WHERE
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test1.t1
++### WHERE
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test1.t1
++### WHERE
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test2.t2
++### WHERE
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test2.t2
++### WHERE
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test2.t2
++### WHERE
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test2`.`t2` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
++### INSERT INTO test2.t2
++### SET
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test2.t2
++### SET
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### INSERT INTO test2.t2
++### SET
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++BEGIN
++/*!*/;
++# at #
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Table_map: `test2`.`t2` mapped to number #
++#010909  4:46:40 server id #  end_log_pos # 	Delete_rows: table id # flags: STMT_END_F
++### DELETE FROM test2.t2
++### WHERE
++###   @1=3 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test2.t2
++### WHERE
++###   @1=2 /* INT meta=0 nullable=1 is_null=0 */
++### DELETE FROM test2.t2
++### WHERE
++###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
++SET TIMESTAMP=1000000000/*!*/;
++COMMIT
++/*!*/;
++# at #
++#010909  4:46:40 server id #  end_log_pos # 	Rotate to master-bin.000002  pos: 4
++DELIMITER ;
++# End of log file
++ROLLBACK /* added by mysqlbinlog */;
++/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
+--- a/mysql-test/suite/binlog/r/binlog_stm_binlog.result
++++ b/mysql-test/suite/binlog/r/binlog_stm_binlog.result
+@@ -331,7 +331,7 @@
+ master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 243 )
+ master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 242 )
+ master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 241 )
+-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 240 )
++master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( <binlog_start> )
+ master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 239 )
+ master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 238 )
+ master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 237 )
+@@ -465,7 +465,7 @@
+ master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 109 )
+ master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 108 )
+ master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 107 )
+-master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( <binlog_start> )
++master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 106 )
+ master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 105 )
+ master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 104 )
+ master-bin.000001	#	Query	#	#	use `test`; insert into t1 values( 103 )
+--- a/mysql-test/suite/binlog/t/binlog_incident.test
++++ b/mysql-test/suite/binlog/t/binlog_incident.test
+@@ -4,6 +4,7 @@
+ 
+ source include/have_log_bin.inc;
+ source include/have_debug.inc;
++source include/binlog_start_pos.inc;
+ 
+ let $MYSQLD_DATADIR= `select @@datadir`;
+ RESET MASTER;
+@@ -20,7 +21,7 @@
+ DROP TABLE t1;
+ FLUSH LOGS;
+ 
+-exec $MYSQL_BINLOG --start-position=106 $MYSQLD_DATADIR/master-bin.000001 >$MYSQLTEST_VARDIR/tmp/binlog_incident-bug44442.sql;
++exec $MYSQL_BINLOG --start-position=$binlog_start_pos $MYSQLD_DATADIR/master-bin.000001 >$MYSQLTEST_VARDIR/tmp/binlog_incident-bug44442.sql;
+ --disable_query_log
+ eval SELECT cont LIKE '%RELOAD DATABASE; # Shall generate syntax error%' AS `Contain RELOAD DATABASE` FROM (SELECT load_file('$MYSQLTEST_VARDIR/tmp/binlog_incident-bug44442.sql') AS cont) AS tbl;
+ --enable_query_log
+--- a/mysql-test/suite/binlog/t/binlog_killed.test
++++ b/mysql-test/suite/binlog/t/binlog_killed.test
+@@ -1,5 +1,6 @@
+ -- source include/have_innodb.inc
+ -- source include/have_binlog_format_statement.inc
++-- source include/binlog_start_pos.inc
+ 
+ # You cannot use `KILL' with the Embedded MySQL Server library,
+ # because the embedded server merely runs inside the threads of the host
+@@ -51,7 +52,8 @@
+ let $rows= `select count(*) from t2  /* must be 2 or 0 */`;
+ 
+ let $MYSQLD_DATADIR= `select @@datadir`;
+---exec $MYSQL_BINLOG --force-if-open --start-position=134 $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog
++let $start_pos= `select @binlog_start_pos + 28`;
++--exec $MYSQL_BINLOG --force-if-open --start-position=$start_pos $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog
+ --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+ eval select
+ (@a:=load_file("$MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog"))
+--- a/mysql-test/suite/binlog/t/binlog_killed_simulate.test
++++ b/mysql-test/suite/binlog/t/binlog_killed_simulate.test
+@@ -1,5 +1,6 @@
+ -- source include/have_debug.inc
+ -- source include/have_binlog_format_statement.inc
++-- source include/binlog_start_pos.inc
+ #
+ # bug#27571 asynchronous setting mysql_$query()'s local error and 
+ #           Query_log_event::error_code
+@@ -24,7 +25,7 @@
+ #      for some constants like the offset of the first real event
+ #      that is different between severs versions.
+ let $MYSQLD_DATADIR= `select @@datadir`;
+---exec $MYSQL_BINLOG --force-if-open --start-position=106 $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog
++--exec $MYSQL_BINLOG --force-if-open --start-position=$binlog_start_pos $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog
+ --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+ eval select
+ (@a:=load_file("$MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
+--- /dev/null
++++ b/mysql-test/suite/binlog/t/binlog_row_annotate-master.opt
+@@ -0,0 +1 @@
++--timezone=GMT-3 --binlog-do-db=test1 --binlog-do-db=test2 --binlog-do-db=test3
+--- /dev/null
++++ b/mysql-test/suite/binlog/t/binlog_row_annotate.test
+@@ -0,0 +1,189 @@
++###############################################################################
++# WL47: Store in binlog text of statements that caused RBR events
++# new event:              ANNOTATE_ROWS_EVENT
++# new master option:      --binlog-annotate-rows-events
++# new mysqlbinlog option: --skip-annotate-rows-events
++#
++# Intended to test that:
++# *** If the --binlog-annotate-rows-events option is switched on on master
++#     then Annotate_rows events:
++#     - are generated;
++#     - are generated only once for "multi-table-maps" rbr queries;
++#     - are not generated when the corresponding queries are filtered away;
++#     - are generated when the corresponding queries are filtered away partialy
++#       (e.g. in case of multi-delete).
++# *** Annotate_rows events are printed by mysqlbinlog started without
++#     --skip-annotate-rows-events options both in remote and local cases.
++# *** Annotate_rows events are not printed by mysqlbinlog started with
++#     --skip-annotate-rows-events options both in remote and local cases.
++###############################################################################
++
++--source include/have_log_bin.inc
++--source include/have_binlog_format_row.inc
++--source include/binlog_start_pos.inc
++
++--disable_query_log
++
++# Fix timestamp to avoid varying results
++SET timestamp=1000000000;
++
++# Delete all existing binary logs
++RESET MASTER;
++
++--disable_warnings
++DROP DATABASE IF EXISTS test1;
++DROP DATABASE IF EXISTS test2;
++DROP DATABASE IF EXISTS test3;
++DROP DATABASE IF EXISTS xtest1;
++DROP DATABASE IF EXISTS xtest2;
++--enable_warnings
++
++CREATE DATABASE test1;
++CREATE TABLE test1.t1(a int);
++
++CREATE DATABASE test2;
++CREATE TABLE test2.t2(a int);
++CREATE VIEW  test2.v2 AS SELECT * FROM test2.t2;
++
++CREATE DATABASE test3;
++CREATE TABLE test3.t3(a int);
++
++CREATE DATABASE xtest1;
++CREATE TABLE xtest1.xt1(a int);
++
++CREATE DATABASE xtest2;
++CREATE TABLE xtest2.xt2(a int);
++
++# By default SESSION binlog_annotate_rows_events = OFF
++
++INSERT INTO test1.t1 VALUES (1), (2), (3);
++
++SET SESSION binlog_annotate_rows_events = ON;
++
++INSERT INTO test2.t2 VALUES (1), (2), (3);
++INSERT INTO test3.t3 VALUES (1), (2), (3);
++
++# This query generates two Table maps but the Annotate
++# event should appear only once before the first Table map
++DELETE test1.t1, test2.t2
++  FROM test1.t1 INNER JOIN test2.t2 INNER JOIN test3.t3
++  WHERE test1.t1.a=test2.t2.a AND test2.t2.a=test3.t3.a;
++
++# This event should be filtered out together with Annotate event
++INSERT INTO xtest1.xt1 VALUES (1), (2), (3);
++
++# This event should pass the filter
++INSERT INTO test2.v2 VALUES (1), (2), (3);
++
++# This event should pass the filter only for test2.t2 part
++DELETE xtest1.xt1, test2.t2
++  FROM xtest1.xt1 INNER JOIN test2.t2 INNER JOIN test3.t3
++  WHERE xtest1.xt1.a=test2.t2.a AND test2.t2.a=test3.t3.a;
++
++# These events should be filtered out together with Annotate events
++INSERT INTO xtest1.xt1 VALUES (1), (2), (3);
++INSERT INTO xtest2.xt2 VALUES (1), (2), (3);
++DELETE xtest1.xt1, xtest2.xt2
++  FROM xtest1.xt1 INNER JOIN xtest2.xt2 INNER JOIN test3.t3
++  WHERE xtest1.xt1.a=xtest2.xt2.a AND xtest2.xt2.a=test3.t3.a;
++
++FLUSH LOGS;
++--enable_query_log
++
++--echo #####################################################################################
++--echo # The following Annotate_rows events should appear below:
++--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3)
++--echo # - INSERT INTO test3.t3 VALUES (1), (2), (3)
++--echo # - DELETE test1.t1, test2.t2 FROM <...>
++--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3)
++--echo # - DELETE xtest1.xt1, test2.t2 FROM <...>
++--echo #####################################################################################
++
++let $start_pos= `select @binlog_start_pos`;
++--replace_column 2 # 5 #
++--replace_result $start_pos <start_pos>
++--replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\//
++--eval show binlog events in 'master-bin.000001' from $start_pos
++
++--echo #
++--echo #####################################################################################
++--echo # mysqlbinlog
++--echo # The following Annotates should appear in this output:
++--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3)
++--echo # - INSERT INTO test3.t3 VALUES (1), (2), (3)
++--echo # - DELETE test1.t1, test2.t2 FROM <...> (with two subsequent Table maps)
++--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3)
++--echo # - DELETE xtest1.xt1, test2.t2 FROM <...> (with one subsequent Table map)
++--echo #####################################################################################
++
++let $MYSQLD_DATADIR= `select @@datadir`;
++--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/
++--exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $MYSQLD_DATADIR/master-bin.000001
++
++--echo #
++--echo #####################################################################################
++--echo # mysqlbinlog --database=test1
++--echo # The following Annotate should appear in this output:
++--echo # - DELETE test1.t1, test2.t2 FROM <...>
++--echo #####################################################################################
++
++let $MYSQLD_DATADIR= `select @@datadir`;
++--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/
++--exec $MYSQL_BINLOG --base64-output=decode-rows --database=test1 -v -v $MYSQLD_DATADIR/master-bin.000001
++
++--echo #
++--echo #####################################################################################
++--echo # mysqlbinlog --skip-annotate-rows-events
++--echo # No Annotates should appear in this output
++--echo #####################################################################################
++
++let $MYSQLD_DATADIR= `select @@datadir`;
++--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/
++--exec $MYSQL_BINLOG --base64-output=decode-rows --skip-annotate-rows-events -v -v $MYSQLD_DATADIR/master-bin.000001
++
++--echo #
++--echo #####################################################################################
++--echo # mysqlbinlog --read-from-remote-server
++--echo # The following Annotates should appear in this output:
++--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3)
++--echo # - INSERT INTO test3.t3 VALUES (1), (2), (3)
++--echo # - DELETE test1.t1, test2.t2 FROM <...> (with two subsequent Table maps)
++--echo # - INSERT INTO test2.t2 VALUES (1), (2), (3)
++--echo # - DELETE xtest1.xt1, test2.t2 FROM <...> (with one subsequent Table map)
++--echo #####################################################################################
++
++let $MYSQLD_DATADIR= `select @@datadir`;
++--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/
++--exec $MYSQL_BINLOG --base64-output=decode-rows -v -v --read-from-remote-server --user=root --host=localhost --port=$MASTER_MYPORT master-bin.000001
++
++--echo #
++--echo #####################################################################################
++--echo # mysqlbinlog --read-from-remote-server --database=test1
++--echo # The following Annotate should appear in this output:
++--echo # - DELETE test1.t1, test2.t2 FROM <...>
++--echo #####################################################################################
++
++let $MYSQLD_DATADIR= `select @@datadir`;
++--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/
++--exec $MYSQL_BINLOG --base64-output=decode-rows --database=test1 -v -v --read-from-remote-server --user=root --host=localhost --port=$MASTER_MYPORT master-bin.000001
++
++--echo #
++--echo #####################################################################################
++--echo # mysqlbinlog --read-from-remote-server --skip-annotate-rows-events
++--echo # No Annotates should appear in this output
++--echo #####################################################################################
++
++let $MYSQLD_DATADIR= `select @@datadir`;
++--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/
++--exec $MYSQL_BINLOG --base64-output=decode-rows --skip-annotate-rows-events -v -v --read-from-remote-server --user=root --host=localhost --port=$MASTER_MYPORT master-bin.000001
++
++# Clean-up
++
++--disable_query_log
++DROP DATABASE test1;
++DROP DATABASE test2;
++DROP DATABASE test3;
++DROP DATABASE xtest1;
++DROP DATABASE xtest2;
++--enable_query_log
++
+--- /dev/null
++++ b/mysql-test/suite/rpl/r/percona_replicate_annotate_rows_events.result
+@@ -0,0 +1,16 @@
++include/master-slave.inc
++[connection master]
++DROP TABLE IF EXISTS t;
++CREATE TABLE t (a INT);
++INSERT INTO t VALUES(1);
++DROP TABLE t;
++select 738;
++738
++738
++select 738 = 738;
++738 = 738
++1
++select 738 = 738;
++738 = 738
++1
++include/rpl_end.inc
+--- /dev/null
++++ b/mysql-test/suite/rpl/r/rpl_row_annotate_do.result
+@@ -0,0 +1,141 @@
++include/master-slave.inc
++[connection master]
++########################################################################
++# TABLES ON MASTER
++########################################################################
++SELECT * FROM t1 ORDER BY a;
++a	b
++0	1
++SELECT * FROM t2 ORDER BY a;
++a	b
++SELECT * FROM t3 ORDER BY a;
++a	b
++1	1
++2	2
++3	3
++SELECT * FROM t5 ORDER BY a;
++a	b
++1	foo
++2	bar
++3	baz
++4	gås
++5	gås
++########################################################################
++# TABLES ON SLAVE: should be the same as on master
++########################################################################
++SELECT * FROM t1 ORDER BY a;
++a	b
++0	1
++SELECT * FROM t2 ORDER BY a;
++a	b
++SELECT * FROM t3 ORDER BY a;
++a	b
++1	1
++2	2
++3	3
++SELECT * FROM t5 ORDER BY a;
++a	b
++1	foo
++2	bar
++3	baz
++4	gås
++5	gås
++########################################################################
++# EVENTS ON SLAVE
++# The following Annotate_rows events should appear below:
++# - UPDATE t1 SET b = b + 1;
++# - REPLACE t1 VALUES (1,1), (2,2), (3,3);
++# - INSERT INTO t2 VALUES (1,1), (2,2), (3,3)
++# - INSERT INTO t3 VALUES (1,1), (2,2), (3,3)
++# - DELETE t1, t2 FROM <...>
++# - INSERT INTO t2 VALUES (1,1), (2,2), (3,3)
++# - DELETE xt1, t2 FROM <...>
++# - INSERT INTO t5(b) VALUES <...> (3 instances)
++########################################################################
++FLUSH LOGS;
++show binlog events in 'slave-bin.000001' from <start_pos>;
++Log_name	Pos	Event_type	Server_id	End_log_pos	Info
++slave-bin.000001	#	Query	1	#	DROP DATABASE IF EXISTS test1
++slave-bin.000001	#	Query	1	#	CREATE DATABASE test1
++slave-bin.000001	#	Query	1	#	use `test1`; CREATE TABLE t1(a int primary key, b int)
++slave-bin.000001	#	Query	1	#	use `test1`; CREATE TABLE t2(a int, b int)
++slave-bin.000001	#	Query	1	#	use `test1`; CREATE TABLE t3(a int, b int)
++slave-bin.000001	#	Query	1	#	use `test1`; CREATE TABLE t4(a int, b int)
++slave-bin.000001	#	Query	1	#	use `test1`; CREATE TABLE t5 (
++a INT PRIMARY KEY AUTO_INCREMENT,
++b VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_bin
++)
++slave-bin.000001	#	Query	1	#	BEGIN
++slave-bin.000001	#	Table_map	1	#	table_id: # (test1.t1)
++slave-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
++slave-bin.000001	#	Query	1	#	COMMIT
++slave-bin.000001	#	Query	1	#	BEGIN
++slave-bin.000001	#	Annotate_rows	1	#	UPDATE t1 SET b = b + 1
++slave-bin.000001	#	Table_map	1	#	table_id: # (test1.t1)
++slave-bin.000001	#	Update_rows	1	#	table_id: # flags: STMT_END_F
++slave-bin.000001	#	Query	1	#	COMMIT
++slave-bin.000001	#	Query	1	#	BEGIN
++slave-bin.000001	#	Annotate_rows	1	#	REPLACE t1 VALUES (1,1), (2,2), (3,3)
++slave-bin.000001	#	Table_map	1	#	table_id: # (test1.t1)
++slave-bin.000001	#	Update_rows	1	#	table_id: #
++slave-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
++slave-bin.000001	#	Query	1	#	COMMIT
++slave-bin.000001	#	Query	1	#	BEGIN
++slave-bin.000001	#	Annotate_rows	1	#	INSERT INTO t2 VALUES (1,1), (2,2), (3,3)
++slave-bin.000001	#	Table_map	1	#	table_id: # (test1.t2)
++slave-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
++slave-bin.000001	#	Query	1	#	COMMIT
++slave-bin.000001	#	Query	1	#	BEGIN
++slave-bin.000001	#	Annotate_rows	1	#	INSERT INTO t3 VALUES (1,1), (2,2), (3,3)
++slave-bin.000001	#	Table_map	1	#	table_id: # (test1.t3)
++slave-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
++slave-bin.000001	#	Query	1	#	COMMIT
++slave-bin.000001	#	Query	1	#	BEGIN
++slave-bin.000001	#	Annotate_rows	1	#	DELETE t1, t2 FROM t1 INNER JOIN t2 INNER JOIN t3 WHERE t1.a=t2.a AND t2.a=t3.a
++slave-bin.000001	#	Table_map	1	#	table_id: # (test1.t2)
++slave-bin.000001	#	Table_map	1	#	table_id: # (test1.t1)
++slave-bin.000001	#	Delete_rows	1	#	table_id: #
++slave-bin.000001	#	Delete_rows	1	#	table_id: # flags: STMT_END_F
++slave-bin.000001	#	Query	1	#	COMMIT
++slave-bin.000001	#	Query	1	#	BEGIN
++slave-bin.000001	#	Annotate_rows	1	#	INSERT INTO t2 VALUES (1,1), (2,2), (3,3)
++slave-bin.000001	#	Table_map	1	#	table_id: # (test1.t2)
++slave-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
++slave-bin.000001	#	Query	1	#	COMMIT
++slave-bin.000001	#	Query	1	#	BEGIN
++slave-bin.000001	#	Annotate_rows	1	#	DELETE xt1, t2 FROM xt1 INNER JOIN t2 INNER JOIN t3 WHERE xt1.a=t2.a AND t2.a=t3.a
++slave-bin.000001	#	Table_map	1	#	table_id: # (test1.t2)
++slave-bin.000001	#	Delete_rows	1	#	table_id: # flags: STMT_END_F
++slave-bin.000001	#	Query	1	#	COMMIT
++slave-bin.000001	#	Query	1	#	BEGIN
++slave-bin.000001	#	Annotate_rows	1	#	INSERT INTO t5(b) VALUES ('foo'), ('bar'), ('baz')
++slave-bin.000001	#	Table_map	1	#	table_id: # (test1.t5)
++slave-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
++slave-bin.000001	#	Query	1	#	COMMIT
++slave-bin.000001	#	Query	1	#	BEGIN
++slave-bin.000001	#	Annotate_rows	1	#	INSERT INTO t5(b) VALUES ('gås')
++slave-bin.000001	#	Table_map	1	#	table_id: # (test1.t5)
++slave-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
++slave-bin.000001	#	Query	1	#	COMMIT
++slave-bin.000001	#	Query	1	#	BEGIN
++slave-bin.000001	#	Annotate_rows	1	#	INSERT INTO t5(b) VALUES ('gÃ¥s')
++slave-bin.000001	#	Table_map	1	#	table_id: # (test1.t5)
++slave-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
++slave-bin.000001	#	Query	1	#	COMMIT
++slave-bin.000001	#	Rotate	2	#	slave-bin.000002;pos=4
++# 
++########################################################################
++# INSERTs DELAYED ON MASTERs
++########################################################################
++SET SESSION binlog_annotate_rows_events = ON;
++INSERT DELAYED INTO test1.t4 VALUES (1,1);
++FLUSH TABLES;
++SELECT * FROM test1.t4 ORDER BY a;
++a	b
++1	1
++########################################################################
++# ON SLAVE
++# No Annotate_rows events should appear below
++########################################################################
++FLUSH LOGS;
++include/rpl_end.inc
+--- /dev/null
++++ b/mysql-test/suite/rpl/r/rpl_row_annotate_dont.result
+@@ -0,0 +1,123 @@
++include/master-slave.inc
++[connection master]
++########################################################################
++# TABLES ON MASTER
++########################################################################
++SELECT * FROM t1 ORDER BY a;
++a	b
++0	1
++SELECT * FROM t2 ORDER BY a;
++a	b
++SELECT * FROM t3 ORDER BY a;
++a	b
++1	1
++2	2
++3	3
++SELECT * FROM t5 ORDER BY a;
++a	b
++1	foo
++2	bar
++3	baz
++4	gås
++5	gås
++########################################################################
++# TABLES ON SLAVE: should be the same as on master
++########################################################################
++SELECT * FROM t1 ORDER BY a;
++a	b
++0	1
++SELECT * FROM t2 ORDER BY a;
++a	b
++SELECT * FROM t3 ORDER BY a;
++a	b
++1	1
++2	2
++3	3
++SELECT * FROM t5 ORDER BY a;
++a	b
++1	foo
++2	bar
++3	baz
++4	gås
++5	gås
++########################################################################
++# EVENTS ON SLAVE
++# No Annotate_rows events should appear below
++########################################################################
++FLUSH LOGS;
++show binlog events in 'slave-bin.000001' from <start_pos>;
++Log_name	Pos	Event_type	Server_id	End_log_pos	Info
++slave-bin.000001	#	Query	1	#	DROP DATABASE IF EXISTS test1
++slave-bin.000001	#	Query	1	#	CREATE DATABASE test1
++slave-bin.000001	#	Query	1	#	use `test1`; CREATE TABLE t1(a int primary key, b int)
++slave-bin.000001	#	Query	1	#	use `test1`; CREATE TABLE t2(a int, b int)
++slave-bin.000001	#	Query	1	#	use `test1`; CREATE TABLE t3(a int, b int)
++slave-bin.000001	#	Query	1	#	use `test1`; CREATE TABLE t4(a int, b int)
++slave-bin.000001	#	Query	1	#	use `test1`; CREATE TABLE t5 (
++a INT PRIMARY KEY AUTO_INCREMENT,
++b VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_bin
++)
++slave-bin.000001	#	Query	1	#	BEGIN
++slave-bin.000001	#	Table_map	1	#	table_id: # (test1.t1)
++slave-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
++slave-bin.000001	#	Query	1	#	COMMIT
++slave-bin.000001	#	Query	1	#	BEGIN
++slave-bin.000001	#	Table_map	1	#	table_id: # (test1.t1)
++slave-bin.000001	#	Update_rows	1	#	table_id: # flags: STMT_END_F
++slave-bin.000001	#	Query	1	#	COMMIT
++slave-bin.000001	#	Query	1	#	BEGIN
++slave-bin.000001	#	Table_map	1	#	table_id: # (test1.t1)
++slave-bin.000001	#	Update_rows	1	#	table_id: #
++slave-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
++slave-bin.000001	#	Query	1	#	COMMIT
++slave-bin.000001	#	Query	1	#	BEGIN
++slave-bin.000001	#	Table_map	1	#	table_id: # (test1.t2)
++slave-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
++slave-bin.000001	#	Query	1	#	COMMIT
++slave-bin.000001	#	Query	1	#	BEGIN
++slave-bin.000001	#	Table_map	1	#	table_id: # (test1.t3)
++slave-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
++slave-bin.000001	#	Query	1	#	COMMIT
++slave-bin.000001	#	Query	1	#	BEGIN
++slave-bin.000001	#	Table_map	1	#	table_id: # (test1.t2)
++slave-bin.000001	#	Table_map	1	#	table_id: # (test1.t1)
++slave-bin.000001	#	Delete_rows	1	#	table_id: #
++slave-bin.000001	#	Delete_rows	1	#	table_id: # flags: STMT_END_F
++slave-bin.000001	#	Query	1	#	COMMIT
++slave-bin.000001	#	Query	1	#	BEGIN
++slave-bin.000001	#	Table_map	1	#	table_id: # (test1.t2)
++slave-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
++slave-bin.000001	#	Query	1	#	COMMIT
++slave-bin.000001	#	Query	1	#	BEGIN
++slave-bin.000001	#	Table_map	1	#	table_id: # (test1.t2)
++slave-bin.000001	#	Delete_rows	1	#	table_id: # flags: STMT_END_F
++slave-bin.000001	#	Query	1	#	COMMIT
++slave-bin.000001	#	Query	1	#	BEGIN
++slave-bin.000001	#	Table_map	1	#	table_id: # (test1.t5)
++slave-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
++slave-bin.000001	#	Query	1	#	COMMIT
++slave-bin.000001	#	Query	1	#	BEGIN
++slave-bin.000001	#	Table_map	1	#	table_id: # (test1.t5)
++slave-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
++slave-bin.000001	#	Query	1	#	COMMIT
++slave-bin.000001	#	Query	1	#	BEGIN
++slave-bin.000001	#	Table_map	1	#	table_id: # (test1.t5)
++slave-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
++slave-bin.000001	#	Query	1	#	COMMIT
++slave-bin.000001	#	Rotate	2	#	slave-bin.000002;pos=4
++# 
++########################################################################
++# INSERTs DELAYED ON MASTERs
++########################################################################
++SET SESSION binlog_annotate_rows_events = ON;
++INSERT DELAYED INTO test1.t4 VALUES (1,1);
++FLUSH TABLES;
++SELECT * FROM test1.t4 ORDER BY a;
++a	b
++1	1
++########################################################################
++# ON SLAVE
++# No Annotate_rows events should appear below
++########################################################################
++FLUSH LOGS;
++include/rpl_end.inc
+--- a/mysql-test/suite/rpl/r/rpl_row_conflicts.result
++++ b/mysql-test/suite/rpl/r/rpl_row_conflicts.result
+@@ -21,7 +21,7 @@
+ [on slave]
+ ---- Wait until slave stops with an error ----
+ include/wait_for_slave_sql_error.inc [errno=1062]
+-Last_SQL_Error = Could not execute Write_rows event on table test.t1; Duplicate entry '1' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log master-bin.000001, end_log_pos 346 (expected "duplicate key" error)
++Last_SQL_Error = Could not execute Write_rows event on table test.t1; Duplicate entry '1' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log master-bin.000001, end_log_pos 480 (expected "duplicate key" error)
+ call mtr.add_suppression("Slave SQL.*Duplicate entry .1. for key .PRIMARY.* Error_code: 1062");
+ SELECT * FROM t1;
+ a
+--- /dev/null
++++ b/mysql-test/suite/rpl/t/percona_replicate_annotate_rows_events-master.opt
+@@ -0,0 +1 @@
++--binlog_annotate_rows_events --replicate_annotate_rows_events
+--- /dev/null
++++ b/mysql-test/suite/rpl/t/percona_replicate_annotate_rows_events-slave.opt
+@@ -0,0 +1 @@
++--slave_net_timeout=1 --log_slave_updates=0 --binlog_annotate_rows_events --replicate_annotate_rows_events
+--- /dev/null
++++ b/mysql-test/suite/rpl/t/percona_replicate_annotate_rows_events.test
+@@ -0,0 +1,35 @@
++########################################################################
++# Bug #872754: Annotate rows events on slave doesnt' work without slave's binlog
++########################################################################
++
++--source include/master-slave.inc
++--source include/have_binlog_format_row.inc
++--source include/have_debug.inc
++
++connection master;
++--disable_warnings
++DROP TABLE IF EXISTS t;
++--enable_warnings
++
++CREATE TABLE t (a INT);
++INSERT INTO t VALUES(1);
++
++--sleep 2
++
++DROP TABLE t;
++
++# The following would hang with the bug not fixed
++--sync_slave_with_master
++
++connection master;
++--let $master_log_pos= query_get_value(SHOW MASTER STATUS, Position, 1)
++--eval select $master_log_pos
++
++connection slave;
++--let $read_master_log_pos= query_get_value(SHOW SLAVE STATUS, Read_Master_Log_Pos, 1)
++--eval select $master_log_pos = $read_master_log_pos
++
++--let $exec_master_log_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1)
++--eval select $master_log_pos = $exec_master_log_pos
++
++--source include/rpl_end.inc
+--- /dev/null
++++ b/mysql-test/suite/rpl/t/rpl_row_annotate_do-slave.opt
+@@ -0,0 +1 @@
++--log-slave-updates --replicate-annotate-rows-events --replicate-ignore-table=test1.xt1 --replicate-ignore-table=test1.xt2
+\ No newline at end of file
+--- /dev/null
++++ b/mysql-test/suite/rpl/t/rpl_row_annotate_do.test
+@@ -0,0 +1,16 @@
++###############################################################################
++# WL47: Store in binlog text of statements that caused RBR events
++# Wrapper for extra/rpl/rpl_row_annotate.test.
++# Intended to test that if the --replicate-annotate-rows-events option
++# is switched on on slave then Annotate_events:
++# - are reproduced on slave
++# - are reproduced only once for "multi-table-maps" rbr queries
++# - are not reproduced when the corresponding queries are filtered away
++#   on replication
++# - are reproduced when the corresponding queries are filtered away partialy
++#   (e.g. in case of multi-delete)
++# - are not generated on slave for queries that are not annotated on master.
++###############################################################################
++
++--source include/have_binlog_format_row.inc
++--source extra/rpl_tests/rpl_row_annotate.test
+--- /dev/null
++++ b/mysql-test/suite/rpl/t/rpl_row_annotate_dont-slave.opt
+@@ -0,0 +1 @@
++--log-slave-updates --replicate-ignore-table=test1.xt1 --replicate-ignore-table=test1.xt2
+\ No newline at end of file
+--- /dev/null
++++ b/mysql-test/suite/rpl/t/rpl_row_annotate_dont.test
+@@ -0,0 +1,9 @@
++###############################################################################
++# WL47: Store in binlog text of statements that caused RBR events
++# Wrapper for extra/rpl/rpl_row_annotate.test.
++# Intended to test that if the --replicate-annotate-rows-events option
++# is switched off on slave then Annotate_events are not reproduced.
++###############################################################################
++
++--source include/have_binlog_format_row.inc
++--source extra/rpl_tests/rpl_row_annotate.test
+--- a/mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test
++++ b/mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test
+@@ -1,7 +1,8 @@
+ # depends on the binlog output
+ -- source include/have_binlog_format_row.inc
++--source include/binlog_start_pos.inc
+ 
+-let $rename_event_pos= 897;
++let $rename_event_pos= `select @binlog_start_pos + 791`;
+ 
+ # Bug#18326: Do not lock table for writing during prepare of statement
+ # The use of the ps protocol causes extra table maps in the binlog, so
+--- a/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test
++++ b/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test
+@@ -162,15 +162,18 @@
+ 
+ remove_file $MYSQLTEST_VARDIR/tmp/master.sql;
+ 
++--source include/binlog_start_pos.inc
+ 
+ # this test for position option
+-# By setting this position to 416, we should only get the create of t3
++# By setting this position to start_binlog_pos + 310, we should only get the create of t3
++let $start_pos= `select @binlog_start_pos + 310`;
++let $stop_pos=  `select @binlog_start_pos + 463`;
+ --disable_query_log
+ select "--- Test 2 position test --" as "";
+ --enable_query_log
+ let $MYSQLD_DATADIR= `select @@datadir;`;
+ --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=416 --stop-position=569 $MYSQLD_DATADIR/master-bin.000001
++--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=$start_pos --stop-position=$stop_pos $MYSQLD_DATADIR/master-bin.000001
+ 
+ # These are tests for remote binlog.
+ # They should return the same as previous test.
+@@ -181,7 +184,7 @@
+ 
+ # This is broken now
+ --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --stop-position=569 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
++--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --stop-position=$stop_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
+ 
+ # This part is disabled due to bug #17654
+ 
+@@ -257,7 +260,7 @@
+ select "--- Test 5 LOAD DATA --" as "";
+ --enable_query_log
+ --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --stop-position=106 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
++--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --stop-position=$binlog_start_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
+ 
+ # Bug#7853 (mysqlbinlog does not accept input from stdin)
+ 
+@@ -265,14 +268,17 @@
+ select "--- Test 6 reading stdin --" as "";
+ --enable_query_log
+ let $MYSQLD_DATADIR= `select @@datadir;`;
++let $stop_pos= `select @binlog_start_pos + 463`;
+ --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+---exec $MYSQL_BINLOG --short-form --stop-position=569 - < $MYSQLD_DATADIR/master-bin.000001
++--exec $MYSQL_BINLOG --short-form --stop-position=$stop_pos - < $MYSQLD_DATADIR/master-bin.000001
+ 
+ --disable_query_log
+ select "--- Test 7 reading stdin w/position --" as "";
+ --enable_query_log
++let $start_pos= `select @binlog_start_pos + 310`;
++let $stop_pos= `select @binlog_start_pos + 463`;
+ --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+---exec $MYSQL_BINLOG --short-form --position=416 --stop-position=569 - < $MYSQLD_DATADIR/master-bin.000001
++--exec $MYSQL_BINLOG --short-form --position=$start_pos --stop-position=$stop_pos - < $MYSQLD_DATADIR/master-bin.000001
+ 
+ # Bug#16217 (mysql client did not know how not switch its internal charset)
+ --disable_query_log
+--- a/mysql-test/suite/rpl/t/rpl_stm_flsh_tbls.test
++++ b/mysql-test/suite/rpl/t/rpl_stm_flsh_tbls.test
+@@ -1,5 +1,6 @@
+ # depends on the binlog output
+ --source include/have_binlog_format_mixed_or_statement.inc
++--source include/binlog_start_pos.inc
+ 
+-let $rename_event_pos= 656;
++let $rename_event_pos= `select @binlog_start_pos + 550`;
+ -- source extra/rpl_tests/rpl_flsh_tbls.test
+--- a/mysql-test/t/ctype_cp932_binlog_stm.test
++++ b/mysql-test/t/ctype_cp932_binlog_stm.test
+@@ -28,16 +28,6 @@
+ 
+ --echo End of 5.0 tests
+ 
+-#
+-# #28436: Incorrect position in SHOW BINLOG EVENTS causes server coredump 
+-# Note: 364 is a magic position (found experimentally, depends on 
+-# the log's contents) that caused the server crash.
+-
+-call mtr.add_suppression("Error in Log_event::read_log_event\\\(\\\): 'Sanity check failed', data_len: 258, event_type: 49");
+-
+---error 1220
+-SHOW BINLOG EVENTS FROM 365;
+-
+ --echo Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment.
+ CREATE TABLE t1 (a varchar(16)) character set cp932;
+ INSERT INTO t1 VALUES (0x8372835E),(0x8352835E);
+--- a/mysql-test/t/mysqlbinlog-master.opt
++++ b/mysql-test/t/mysqlbinlog-master.opt
+@@ -1,2 +1 @@
+---max-binlog-size=4096
+ --force-restart
+--- a/mysql-test/t/mysqlbinlog.test
++++ b/mysql-test/t/mysqlbinlog.test
+@@ -3,10 +3,18 @@
+ -- source include/have_binlog_format_statement.inc
+ 
+ -- source include/have_log_bin.inc
++-- source include/binlog_start_pos.inc
+ 
+ # Deletes all the binary logs
+ reset master;
+ 
++# We need small binlog size to break the last LOAD DATA INFILE below so that
++# the corresponding Begin_load_query will be written to master-bin.000001
++# while the Execute_load_query will be written to master-bin.000002.
++
++SET @save_binlog_size= @@global.max_binlog_size;
++SET @@global.max_binlog_size= 4096;
++
+ # we need this for getting fixed timestamps inside of this test
+ set timestamp=1000000000;
+ 
+@@ -26,13 +34,15 @@
+ 
+ # test for load data and load data distributed among the several
+ # files (we need to fill up first binlog)
+-load data infile '../../std_data/words.dat' into table t1;
+-load data infile '../../std_data/words.dat' into table t1;
+-load data infile '../../std_data/words.dat' into table t1;
+-load data infile '../../std_data/words.dat' into table t1;
+-load data infile '../../std_data/words.dat' into table t1;
++load data infile '../../std_data/words3.dat' into table t1;
++load data infile '../../std_data/words3.dat' into table t1;
++load data infile '../../std_data/words3.dat' into table t1;
++load data infile '../../std_data/words3.dat' into table t1;
++load data infile '../../std_data/words3.dat' into table t1;
+ # simple query to show more in second binlog
+ insert into t1 values ("Alas");
++
++### Starting master-bin.000003
+ flush logs;
+ 
+ # delimiters are for easier debugging in future
+@@ -46,7 +56,7 @@
+ #
+ let $MYSQLD_DATADIR= `select @@datadir`;
+ --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+---replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
++--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/
+ --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLD_DATADIR/master-bin.000001
+ 
+ # this should not fail but shouldn't produce any working statements
+@@ -54,7 +64,7 @@
+ select "--- Broken LOAD DATA --" as "";
+ --enable_query_log
+ --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+---replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
++--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/
+ --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLD_DATADIR/master-bin.000002 2> /dev/null
+ 
+ # this should show almost nothing
+@@ -62,17 +72,17 @@
+ select "--- --database --" as "";
+ --enable_query_log
+ --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+---replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
++--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/
+ --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --database=nottest $MYSQLD_DATADIR/master-bin.000001 2> /dev/null
+ 
+ # this test for position option
+ --disable_query_log
+ select "--- --position --" as "";
+ --enable_query_log
++let $start_pos= `select @binlog_start_pos + 227`;
+ --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+---replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
+---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=332 $MYSQLD_DATADIR/master-bin.000002
+-
++--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/
++--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=$start_pos $MYSQLD_DATADIR/master-bin.000002
+ 
+ # These are tests for remote binlog.
+ # They should return the same as previous test.
+@@ -83,7 +93,7 @@
+ 
+ # This is broken now
+ --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+---replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
++--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/
+ --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
+ 
+ # This is broken too
+@@ -91,7 +101,7 @@
+ select "--- Broken LOAD DATA --" as "";
+ --enable_query_log
+ --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+---replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
++--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/
+ --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 2> /dev/null
+ 
+ # And this too ! (altough it is documented)
+@@ -99,34 +109,39 @@
+ select "--- --database --" as "";
+ --enable_query_log
+ --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+---replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
++--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/
+ --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --database=nottest master-bin.000001 2> /dev/null
+ 
+ # Strangely but this works
+ --disable_query_log
+ select "--- --position --" as "";
+ --enable_query_log
++let $start_pos= `select @binlog_start_pos + 227`;
+ --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+---replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
+---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --position=332 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
++--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/
++--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --position=$start_pos --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
+ 
+ # Bug#7853 mysqlbinlog does not accept input from stdin
+ --disable_query_log
+ select "--- reading stdin --" as "";
+ --enable_query_log
+ --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+---replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
++--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/
+ --exec $MYSQL_BINLOG --short-form - < $MYSQL_TEST_DIR/std_data/trunc_binlog.000001
+ 
+ --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+---replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
++--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/
+ --exec $MYSQL_BINLOG --short-form --position=79 - < $MYSQL_TEST_DIR/std_data/trunc_binlog.000001
+ drop table t1,t2;
+ 
++SET @@global.max_binlog_size= @save_binlog_size;
++
+ #
+ # Bug#14157 utf8 encoding in binlog without set character_set_client
+ #
++### Starting master-bin.000004
+ flush logs;
++
+ --write_file $MYSQLTEST_VARDIR/tmp/bug14157.sql
+ create table if not exists t5 (a int);
+ set names latin1;
+@@ -140,6 +155,8 @@
+ # resulted binlog, parly consisting of multi-byte utf8 chars,
+ # must be digestable for both client and server. In 4.1 the client
+ # should use default-character-set same as the server.
++
++### Starting master-bin.000005
+ flush logs;
+ --exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000004 | $MYSQL
+ select * from t5  /* must be (1),(1) */;
+@@ -150,6 +167,8 @@
+ # Check that a dump created by mysqlbinlog reproduces
+ # lc_time_names dependent values correctly
+ #
++
++### Starting master-bin.000006
+ flush logs;
+ create table t5 (c1 int, c2 varchar(128) character set latin1 not null);
+ insert into t5 values (1, date_format('2001-01-01','%W'));
+@@ -158,7 +177,10 @@
+ set lc_time_names=en_US;
+ insert into t5 values (3, date_format('2001-01-01','%W'));
+ select * from t5 order by c1;
++
++### Starting master-bin.000007
+ flush logs;
++
+ drop table t5;
+ --exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000006 | $MYSQL
+ select * from t5 order by c1;
+@@ -170,7 +192,10 @@
+ --disable_warnings
+ drop procedure if exists p1;
+ --enable_warnings
++
++### Starting master-bin.000008
+ flush logs;
++
+ delimiter //;
+ create procedure p1()
+ begin
+@@ -178,12 +203,15 @@
+ end;
+ //
+ delimiter ;//
++
++### Starting master-bin.000009
+ flush logs;
++
+ call p1();
+ drop procedure p1;
+ --error ER_SP_DOES_NOT_EXIST
+ call p1();
+---replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
++--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/
+ --exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000008
+ --exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000008 | $MYSQL
+ call p1();
+@@ -202,7 +230,9 @@
+ # (LOAD DATA INFILE need it)
+ #
+ 
++### Starting master-bin.000010
+ flush logs;
++
+ create table t1 (a varchar(64) character set utf8);
+ load data infile '../../std_data/loaddata6.dat' into table t1;
+ set character_set_database=koi8r;
+@@ -217,9 +247,12 @@
+ load data infile '../../std_data/loaddata6.dat' into table t1 character set koi8r;
+ select hex(a) from t1;
+ drop table t1;
++
++### Starting master-bin.000011
+ flush logs;
++
+ --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+---replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
++--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/
+ --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLD_DATADIR/master-bin.000010
+ 
+ #
+@@ -229,9 +262,14 @@
+ 
+ CREATE TABLE t1 (c1 CHAR(10));
+ # we need this for getting fixed timestamps inside of this test
++### Starting master-bin.000012
+ FLUSH LOGS;
++
+ INSERT INTO t1 VALUES ('0123456789');
++
++### Starting master-bin.000013
+ FLUSH LOGS;
++
+ DROP TABLE t1;
+ 
+ # We create a table, patch, and load the output into it
+@@ -257,11 +295,16 @@
+ #
+ # Bug#29928 incorrect connection_id() restoring from mysqlbinlog out
+ #
++### Starting master-bin.000014
+ FLUSH LOGS;
++
+ CREATE TABLE t1(a INT);
+ INSERT INTO t1 VALUES(connection_id());
+ let $a= `SELECT a FROM t1`;
++
++### Starting master-bin.000015
+ FLUSH LOGS;
++
+ let $outfile= $MYSQLTEST_VARDIR/tmp/bug29928.sql;
+ --exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000014 > $outfile
+ DROP TABLE t1;
+@@ -281,11 +324,12 @@
+ exec $MYSQL_BINLOG $MYSQL_TEST_DIR/std_data/corrupt-relay-bin.000624 > $MYSQLTEST_VARDIR/tmp/bug31793.sql;
+ --remove_file $MYSQLTEST_VARDIR/tmp/bug31793.sql
+ 
+-
+ #
+ # Test --disable-force-if-open and --force-if-open
+ #
++### Starting master-bin.000016
+ FLUSH LOGS;
++
+ --error 1
+ --exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000016 >/dev/null 2>/dev/null
+ --exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/master-bin.000016 >/dev/null 2>/dev/null
+@@ -300,9 +344,15 @@
+ SHOW GRANTS FOR untrusted@localhost;
+ USE mysqltest1;
+ CREATE TABLE t1 (a INT, b CHAR(64));
++
++### Starting master-bin.000017
+ flush logs;
++
+ INSERT INTO t1 VALUES (1,USER());
++
++### Starting master-bin.000018
+ flush logs;
++
+ echo mysqlbinlog var/log/master-bin.000017 > var/tmp/bug31611.sql;
+ exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000017 > $MYSQLTEST_VARDIR/tmp/bug31611.sql;
+ connect (unsecure,localhost,untrusted,,mysqltest1);
+@@ -326,14 +376,20 @@
+ connection default;
+ USE test;
+ SET BINLOG_FORMAT = STATEMENT;
++
++### Starting master-bin.000019
+ FLUSH LOGS;
++
+ CREATE TABLE t1 (a_real FLOAT, an_int INT, a_decimal DECIMAL(5,2), a_string CHAR(32));
+ SET @a_real = rand(20) * 1000;
+ SET @an_int = 1000;
+ SET @a_decimal = CAST(rand(19) * 999 AS DECIMAL(5,2));
+ SET @a_string = 'Just a test';
+ INSERT INTO t1 VALUES (@a_real, @an_int, @a_decimal, @a_string);
++
++### Starting master-bin.000020
+ FLUSH LOGS;
++
+ query_vertical SELECT * FROM t1;
+ DROP TABLE t1;
+ 
+@@ -357,6 +413,7 @@
+ 
+ RESET MASTER;
+ FLUSH LOGS;
++
+ --exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $binlog_file
+ --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+ eval SELECT
+--- a/mysql-test/t/mysqlbinlog2.test
++++ b/mysql-test/t/mysqlbinlog2.test
+@@ -3,7 +3,7 @@
+ 
+ # TODO: Need to look at making row based version once new binlog client is complete.
+ -- source include/have_binlog_format_mixed_or_statement.inc
+-
++-- source include/binlog_start_pos.inc
+ 
+ --disable_warnings
+ drop table if exists t1;
+@@ -50,15 +50,19 @@
+ --disable_query_log
+ select "--- start-position --" as "";
+ --enable_query_log
+---exec $MYSQL_BINLOG --short-form --start-position=608 $MYSQLD_DATADIR/master-bin.000001 
++let $start_pos= `select @binlog_start_pos + 502`;
++--exec $MYSQL_BINLOG --short-form --start-position=$start_pos $MYSQLD_DATADIR/master-bin.000001 
+ --disable_query_log
+ select "--- stop-position --" as "";
+ --enable_query_log
+---exec $MYSQL_BINLOG --short-form --stop-position=608 $MYSQLD_DATADIR/master-bin.000001 
++let $stop_pos= `select @binlog_start_pos + 502`;
++--exec $MYSQL_BINLOG --short-form --stop-position=$stop_pos $MYSQLD_DATADIR/master-bin.000001 
+ --disable_query_log
+ select "--- start and stop positions ---" as "";
+ --enable_query_log
+---exec $MYSQL_BINLOG --short-form --start-position=608 --stop-position 725 $MYSQLD_DATADIR/master-bin.000001 
++let $start_pos= `select @binlog_start_pos + 502`;
++let $stop_pos= `select @binlog_start_pos + 619`;
++--exec $MYSQL_BINLOG --short-form --start-position=$start_pos --stop-position $stop_pos $MYSQLD_DATADIR/master-bin.000001 
+ --disable_query_log
+ select "--- start-datetime --" as "";
+ --enable_query_log
+@@ -84,11 +88,13 @@
+ --disable_query_log
+ select "--- start-position --" as "";
+ --enable_query_log
+---exec $MYSQL_BINLOG --short-form --start-position=608 $MYSQLD_DATADIR/master-bin.000001 $MYSQLD_DATADIR/master-bin.000002
++let $start_pos= `select @binlog_start_pos + 502`;
++--exec $MYSQL_BINLOG --short-form --start-position=$start_pos $MYSQLD_DATADIR/master-bin.000001 $MYSQLD_DATADIR/master-bin.000002
+ --disable_query_log
+ select "--- stop-position --" as "";
+ --enable_query_log
+---exec $MYSQL_BINLOG --short-form --stop-position=134 $MYSQLD_DATADIR/master-bin.000001 $MYSQLD_DATADIR/master-bin.000002
++let $stop_pos= `select @binlog_start_pos + 28`;
++--exec $MYSQL_BINLOG --short-form --stop-position=$stop_pos $MYSQLD_DATADIR/master-bin.000001 $MYSQLD_DATADIR/master-bin.000002
+ --disable_query_log
+ select "--- start-datetime --" as "";
+ --enable_query_log
+@@ -111,15 +117,19 @@
+ --disable_query_log
+ select "--- start-position --" as "";
+ --enable_query_log
+---exec $MYSQL_BINLOG --short-form --start-position=608 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 
++let $start_pos= `select @binlog_start_pos + 502`;
++--exec $MYSQL_BINLOG --short-form --start-position=$start_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 
+ --disable_query_log
+ select "--- stop-position --" as "";
+ --enable_query_log
+---exec $MYSQL_BINLOG --short-form --stop-position=608 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 
++let $stop_pos= `select @binlog_start_pos + 502`;
++--exec $MYSQL_BINLOG --short-form --stop-position=$stop_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 
+ --disable_query_log
+ select "--- start and stop positions ---" as "";
+ --enable_query_log
+---exec $MYSQL_BINLOG --short-form --start-position=608 --stop-position 725 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
++let $start_pos= `select @binlog_start_pos + 502`;
++let $stop_pos= `select @binlog_start_pos + 619`;
++--exec $MYSQL_BINLOG --short-form --start-position=$start_pos --stop-position $stop_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
+ --disable_query_log
+ select "--- start-datetime --" as "";
+ --enable_query_log
+@@ -142,11 +152,13 @@
+ --disable_query_log
+ select "--- start-position --" as "";
+ --enable_query_log
+---exec $MYSQL_BINLOG --short-form --start-position=608 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001  master-bin.000002
++let $start_pos= `select @binlog_start_pos + 502`;
++--exec $MYSQL_BINLOG --short-form --start-position=$start_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001  master-bin.000002
+ --disable_query_log
+ select "--- stop-position --" as "";
+ --enable_query_log
+---exec $MYSQL_BINLOG --short-form --stop-position=134 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001  master-bin.000002
++let $stop_pos= `select @binlog_start_pos + 28`;
++--exec $MYSQL_BINLOG --short-form --stop-position=$stop_pos --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001  master-bin.000002
+ --disable_query_log
+ select "--- start-datetime --" as "";
+ --enable_query_log
 --- a/sql/handler.cc
 +++ b/sql/handler.cc
 @@ -4625,7 +4625,8 @@
@@ -258,12 +3062,12 @@
   */
  
 -int THD::binlog_write_table_map(TABLE *table, bool is_trans)
-+int THD::binlog_write_table_map(TABLE *table, bool is_trans,
-+                                my_bool *with_annotate)
++int THD::binlog_write_table_map(TABLE*   table, bool is_trans,
++                                my_bool* with_annotate)
  {
    int error;
    DBUG_ENTER("THD::binlog_write_table_map");
-@@ -4317,7 +4319,7 @@
+@@ -4317,7 +4320,7 @@
    if (is_trans && binlog_table_maps == 0)
      binlog_start_trans_and_stmt();
  
@@ -272,7 +3076,7 @@
      DBUG_RETURN(error);
  
    binlog_table_maps++;
-@@ -4447,10 +4449,12 @@
+@@ -4447,10 +4450,12 @@
  }
  
  /**
@@ -287,7 +3091,7 @@
  {
    THD *thd= event_info->thd;
    bool error= 1;
-@@ -4631,6 +4635,16 @@
+@@ -4631,6 +4636,16 @@
        }
      }
  
@@ -304,6 +3108,18 @@
      /*
         Write the SQL command
       */
+--- a/sql/log.h
++++ b/sql/log.h
+@@ -359,7 +359,8 @@
+   int new_file();
+ 
+   void reset_gathered_updates(THD *thd);
+-  bool write(Log_event* event_info); // binary log write
++  bool write(Log_event* event_info,
++             my_bool*   with_annotate= 0);       // binary log write
+   bool write(THD *thd, IO_CACHE *cache, Log_event *commit_event, bool incident);
+ 
+   bool write_incident(THD *thd, bool lock);
 --- a/sql/log_event.cc
 +++ b/sql/log_event.cc
 @@ -656,6 +656,7 @@
@@ -487,9 +3303,9 @@
 +  print_header(&pinfo->head_cache, pinfo, TRUE);
 +  my_b_printf(&pinfo->head_cache, "\tAnnotate_rows:\n");
 +
-+  char *pbeg;   // beginning of the next line
-+  char *pend;   // end of the next line
-+  uint cnt= 0;  // characters counter
++  char *pbeg;                                    // beginning of the next line
++  char *pend;                                    // end of the next line
++  uint  cnt= 0;                                  // characters counter
 +
 +  for (pbeg= m_query_txt; ; pbeg= pend)
 +  {
@@ -506,7 +3322,7 @@
 +    // find end of the next line
 +    for (pend= pbeg + 1;
 +         ++cnt <= m_query_len && *pend != '\r' && *pend != '\n';
-+         pend++) ;
++         pend++) {};
 +
 +    // print next line
 +    my_b_write(&pinfo->head_cache, (const uchar*) "#Q> ", 4);
@@ -632,18 +3448,20 @@
    @class Table_map_log_event
  
    In row-based mode, every row operation event is preceded by a
---- a/sql/log.h
-+++ b/sql/log.h
-@@ -359,7 +359,8 @@
-   int new_file();
- 
-   void reset_gathered_updates(THD *thd);
--  bool write(Log_event* event_info); // binary log write
-+  bool write(Log_event* event_info,
-+             my_bool *with_annotate= 0); // binary log write
-   bool write(THD *thd, IO_CACHE *cache, Log_event *commit_event, bool incident);
- 
-   bool write_incident(THD *thd, bool lock);
+--- a/sql/mysql_priv.h
++++ b/sql/mysql_priv.h
+@@ -615,7 +615,11 @@
+ /* BINLOG_DUMP options */
+ 
+ #define BINLOG_DUMP_NON_BLOCK   1
++#endif /* !MYSQL_CLIENT */
+ 
++#define BINLOG_SEND_ANNOTATE_ROWS_EVENT   2
++
++#ifndef MYSQL_CLIENT
+ /* sql_show.cc:show_log_files() */
+ #define SHOW_LOG_STATUS_FREE "FREE"
+ #define SHOW_LOG_STATUS_INUSE "IN USE"
 --- a/sql/mysqld.cc
 +++ b/sql/mysqld.cc
 @@ -504,6 +504,7 @@
@@ -682,20 +3500,6 @@
    {"binlog-do-db", OPT_BINLOG_DO_DB,
     "Tells the master it should log updates for the specified database, "
     "and exclude all others not explicitly mentioned.",
---- a/sql/mysql_priv.h
-+++ b/sql/mysql_priv.h
-@@ -615,7 +615,11 @@
- /* BINLOG_DUMP options */
- 
- #define BINLOG_DUMP_NON_BLOCK   1
-+#endif /* !MYSQL_CLIENT */
- 
-+#define BINLOG_SEND_ANNOTATE_ROWS_EVENT   2
-+
-+#ifndef MYSQL_CLIENT
- /* sql_show.cc:show_log_files() */
- #define SHOW_LOG_STATUS_FREE "FREE"
- #define SHOW_LOG_STATUS_INUSE "IN USE"
 --- a/sql/rpl_rli.cc
 +++ b/sql/rpl_rli.cc
 @@ -45,7 +45,8 @@
@@ -730,7 +3534,7 @@
 +  inline void set_annotate_event(Annotate_rows_log_event *event)
 +  {
 +    free_annotate_event();
-+    m_annotate_event= event;
++    m_annotate_event=                               event;
 +    sql_thd->variables.binlog_annotate_rows_events= 1;
 +  }
 +
@@ -755,7 +3559,7 @@
 +    {
 +      sql_thd->variables.binlog_annotate_rows_events= 0;
 +      delete m_annotate_event;
-+      m_annotate_event= 0;
++      m_annotate_event=                               0;
 +    }
 +  }
 +
@@ -773,7 +3577,7 @@
  static sys_var_const_os_str       sys_basedir(&vars, "basedir", mysql_home);
 +static sys_var_thd_bool
 +sys_binlog_annotate_rows_events(&vars, "binlog_annotate_rows_events",
-+                            &SV::binlog_annotate_rows_events);
++                                &SV::binlog_annotate_rows_events);
  static sys_var_long_ptr	sys_binlog_cache_size(&vars, "binlog_cache_size",
  					      &binlog_cache_size);
  static sys_var_thd_binlog_format sys_binlog_format(&vars, "binlog_format",
@@ -789,7 +3593,7 @@
    // TODO if big log files: Change next to int8store()
    int4store(buf, (ulong) mi->master_log_pos);
    int2store(buf + 4, binlog_flags);
-@@ -2311,17 +2314,41 @@
+@@ -2311,15 +2314,39 @@
      }
      exec_res= apply_event_and_update_pos(ev, thd, rli);
  
@@ -802,7 +3606,8 @@
 -    {
 -      DBUG_PRINT("info", ("Deleting the event after it has been executed"));
 -      delete ev;
-+    switch (ev->get_type_code()) {
++    switch (ev->get_type_code())
++    {
 +      case FORMAT_DESCRIPTION_EVENT:
 +        /*
 +          Format_description_log_event should not be deleted because it
@@ -836,11 +3641,8 @@
 +        break;
      }
  
-+
      /*
-       update_log_pos failed: this should not happen, so we don't
-       retry.
-@@ -2947,6 +2974,12 @@
+@@ -2947,6 +2973,12 @@
    thd->init_for_queries();
    thd->temporary_tables = rli->save_temporary_tables; // restore temp tables
    set_thd_in_use_temporary_tables(rli);   // (re)set sql_thd in use for saved temp tables
@@ -853,7 +3655,7 @@
    pthread_mutex_lock(&LOCK_thread_count);
    threads.append(thd);
    pthread_mutex_unlock(&LOCK_thread_count);
-@@ -3429,7 +3462,7 @@
+@@ -3429,7 +3461,7 @@
      If we get Load event, we need to pass a non-reusable buffer
      to read_log_event, so we do a trick
    */
@@ -862,7 +3664,7 @@
    {
      if (unlikely(!(tmp_buf=(char*)my_malloc(event_len+1,MYF(MY_WME)))))
      {
-@@ -3629,6 +3662,7 @@
+@@ -3629,6 +3661,7 @@
  {
    int error= 0;
    ulong inc_pos;
@@ -870,7 +3672,7 @@
    Relay_log_info *rli= &mi->rli;
    pthread_mutex_t *log_lock= rli->relay_log.get_log_lock();
    DBUG_ENTER("queue_event");
-@@ -3636,13 +3670,15 @@
+@@ -3636,13 +3669,16 @@
    LINT_INIT(inc_pos);
  
    if (mi->rli.relay_log.description_event_for_queue->binlog_version<4 &&
@@ -884,7 +3686,8 @@
 -  switch (buf[EVENT_TYPE_OFFSET]) {
 +  new_pos= uint4korr(buf+LOG_POS_OFFSET);
 +
-+  switch ((uchar)buf[EVENT_TYPE_OFFSET]) {
++  switch ((uchar)buf[EVENT_TYPE_OFFSET])
++  {
    case STOP_EVENT:
      /*
        We needn't write this event to the relay log. Indeed, it just indicates a
@@ -944,7 +3747,7 @@
        if (!have_fd_event)
        {
 -        int type = bufptr[EVENT_TYPE_OFFSET];
-+        int type = (uchar)bufptr[EVENT_TYPE_OFFSET];
++        int type= (uchar)bufptr[EVENT_TYPE_OFFSET];
          if (type == FORMAT_DESCRIPTION_EVENT || type == START_EVENT_V3)
            have_fd_event= TRUE;
          else
@@ -958,13 +3761,14 @@
    my_bool binlog_direct_non_trans_update;
    /*
      In slave thread we need to know in behalf of which
-@@ -1565,7 +1566,8 @@
+@@ -1565,7 +1566,9 @@
    */
    void binlog_start_trans_and_stmt();
    void binlog_set_stmt_begin();
 -  int binlog_write_table_map(TABLE *table, bool is_transactional);
-+  int binlog_write_table_map(TABLE *table, bool is_transactional,
-+                             my_bool *with_annotate= 0);
++  int binlog_write_table_map(TABLE*   table,
++                             bool     is_transactional,
++                             my_bool* with_annotate= 0);
    int binlog_write_row(TABLE* table, bool is_transactional,
                         MY_BITMAP const* cols, size_t colcnt,
                         const uchar *buf);
@@ -1018,7 +3822,7 @@
 -      }
 +        if (my_net_write(net, (uchar*) packet->ptr(), packet->length()))
 +        {
-+          errmsg = "Failed on my_net_write()";
++          errmsg=   "Failed on my_net_write()";
 +          my_errno= ER_UNKNOWN_ERROR;
 +          goto err;
 +        }
@@ -1049,14 +3853,14 @@
 +                        });
 +
 +        DBUG_PRINT("info", ("log event code %d",
-+			    (*packet)[LOG_EVENT_OFFSET+1] ));
++                            (*packet)[LOG_EVENT_OFFSET+1]));
 +        if ((uchar)(*packet)[LOG_EVENT_OFFSET+1] == LOAD_EVENT)
 +        {
 +          if (send_file(thd))
 +          {
-+	          errmsg = "failed in send_file()";
-+	          my_errno= ER_UNKNOWN_ERROR;
-+	          goto err;
++            errmsg=   "failed in send_file()";
++            my_errno= ER_UNKNOWN_ERROR;
++            goto err;
 +          }
 +        }
        }
@@ -1109,74 +3913,9 @@
                                                (uchar*) &opt_log_slave_updates);
 +static sys_var_const
 +sys_replicate_annotate_rows_events(&vars,
-+                                "replicate_annotate_rows_events",
-+                                OPT_GLOBAL, SHOW_MY_BOOL,
-+                                (uchar*) &opt_replicate_annotate_rows_events);
++                                   "replicate_annotate_rows_events",
++                                   OPT_GLOBAL, SHOW_MY_BOOL,
++                                   (uchar*) &opt_replicate_annotate_rows_events);
  static sys_var_const    sys_relay_log(&vars, "relay_log",
                                        OPT_GLOBAL, SHOW_CHAR_PTR,
                                        (uchar*) &opt_relay_logname);
---- /dev/null
-+++ b/mysql-test/suite/rpl/t/percona_replicate_annotate_rows_events-master.opt
-@@ -0,0 +1 @@
-+--binlog_annotate_rows_events --replicate_annotate_rows_events
---- /dev/null
-+++ b/mysql-test/suite/rpl/t/percona_replicate_annotate_rows_events-slave.opt
-@@ -0,0 +1 @@
-+--slave_net_timeout=1 --log_slave_updates=0 --binlog_annotate_rows_events --replicate_annotate_rows_events
---- /dev/null
-+++ b/mysql-test/suite/rpl/t/percona_replicate_annotate_rows_events.test
-@@ -0,0 +1,35 @@
-+########################################################################
-+# Bug #872754: Annotate rows events on slave doesnt' work without slave's binlog
-+########################################################################
-+
-+--source include/master-slave.inc
-+--source include/have_binlog_format_row.inc
-+--source include/have_debug.inc
-+
-+connection master;
-+--disable_warnings
-+DROP TABLE IF EXISTS t;
-+--enable_warnings
-+
-+CREATE TABLE t (a INT);
-+INSERT INTO t VALUES(1);
-+
-+--sleep 2
-+
-+DROP TABLE t;
-+
-+# The following would hang with the bug not fixed
-+--sync_slave_with_master
-+
-+connection master;
-+--let $master_log_pos= query_get_value(SHOW MASTER STATUS, Position, 1)
-+--eval select $master_log_pos
-+
-+connection slave;
-+--let $read_master_log_pos= query_get_value(SHOW SLAVE STATUS, Read_Master_Log_Pos, 1)
-+--eval select $master_log_pos = $read_master_log_pos
-+
-+--let $exec_master_log_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1)
-+--eval select $master_log_pos = $exec_master_log_pos
-+
-+--source include/rpl_end.inc
---- /dev/null
-+++ b/mysql-test/suite/rpl/r/percona_replicate_annotate_rows_events.result
-@@ -0,0 +1,16 @@
-+include/master-slave.inc
-+[connection master]
-+DROP TABLE IF EXISTS t;
-+CREATE TABLE t (a INT);
-+INSERT INTO t VALUES(1);
-+DROP TABLE t;
-+select 738;
-+738
-+738
-+select 738 = 738;
-+738 = 738
-+1
-+select 738 = 738;
-+738 = 738
-+1
-+include/rpl_end.inc

