List:Commits« Previous MessageNext Message »
From:Mats Kindahl Date:March 28 2008 11:30am
Subject:bk commit into 5.1 tree (mats:1.2559) BUG#29020
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of mats.  When mats does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2008-03-28 12:30:28+01:00, mats@mats-laptop.(none) +33 -0
  BUG#29020 (Event results not correctly replicated to slave in RBR):
  
  The bug allow multiple executing transactions working with non-transactional
  to interfere with each others by interleaving the events of different trans-
  actions.
  
  Bug is fixed by writing non-transactional events to the transaction cache and
  flushing the cache to the binary log at statement commit. To mimic the behavior
  of normal statement-based replication, we flush the transaction cache in row-
  based mode when there is no committed statements in the transaction cache,
  which means we are committing the first one. This means that it will be written
  to the binary log as a "mini-transaction" with just the rows for the statement.
  
  Note that the changes here does not take effect when building the server with
  HAVE_TRANSACTIONS set to false, but it is not clear if this was possible before
  this patch either.
  
  In addition, the code now always generate a BEGIN/COMMIT pair for transactions
  (or BEGIN/ROLLBACK pair in the case of non-transactional changes in a statement
  that was rolled back).

  mysql-test/extra/rpl_tests/rpl_row_delayed_ins.test@stripped, 2008-03-28 12:30:22+01:00, mats@mats-laptop.(none) +0 -1
    Removing SHOW BINLOG EVENTS causing test to be non-deterministic.

  mysql-test/r/ctype_cp932_binlog_row.result@stripped, 2008-03-28 12:30:22+01:00, mats@mats-laptop.(none) +2 -0
    Result change.

  mysql-test/suite/binlog/r/binlog_base64_flag.result@stripped, 2008-03-28 12:30:22+01:00, mats@mats-laptop.(none) +1 -0
    Result change.

  mysql-test/suite/binlog/r/binlog_multi_engine.result@stripped, 2008-03-28 12:30:22+01:00, mats@mats-laptop.(none) +2 -0
    Result file change.

  mysql-test/suite/binlog/r/binlog_row_binlog.result@stripped, 2008-03-28 12:30:22+01:00, mats@mats-laptop.(none) +27 -3
    Result file change.

  mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result@stripped, 2008-03-28 12:30:23+01:00, mats@mats-laptop.(none) +13 -0
    Result file change.

  mysql-test/suite/binlog/r/binlog_row_insert_select.result@stripped, 2008-03-28 12:30:23+01:00, mats@mats-laptop.(none) +2 -0
    Result file change.

  mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result@stripped, 2008-03-28 12:30:23+01:00, mats@mats-laptop.(none) +35 -3
    Result file change.

  mysql-test/suite/binlog/r/binlog_stm_binlog.result@stripped, 2008-03-28 12:30:23+01:00, mats@mats-laptop.(none) +6 -0
    Result file change.

  mysql-test/suite/binlog/t/binlog_base64_flag.test@stripped, 2008-03-28 12:30:23+01:00, mats@mats-laptop.(none) +3 -0
    Removing table that will be used in test to prevent failing if preceeding
    tests forgot to drop the table.

  mysql-test/suite/rpl/r/rpl_rbr_to_sbr.result@stripped, 2008-03-28 12:30:23+01:00, mats@mats-laptop.(none) +6 -2
    Result file change.

  mysql-test/suite/rpl/r/rpl_row_basic_11bugs.result@stripped, 2008-03-28 12:30:23+01:00, mats@mats-laptop.(none) +6 -2
    Result file change.

  mysql-test/suite/rpl/r/rpl_row_create_table.result@stripped, 2008-03-28 12:30:23+01:00, mats@mats-laptop.(none) +53 -46
    Result file change.

  mysql-test/suite/rpl/r/rpl_row_delayed_ins.result@stripped, 2008-03-28 12:30:24+01:00, mats@mats-laptop.(none) +0 -10
    Result file change.

  mysql-test/suite/rpl/r/rpl_row_flsh_tbls.result@stripped, 2008-03-28 12:30:24+01:00, mats@mats-laptop.(none) +2 -2
    Result file change.

  mysql-test/suite/rpl/r/rpl_row_inexist_tbl.result@stripped, 2008-03-28 12:30:24+01:00, mats@mats-laptop.(none) +2 -2
    Result file change.

  mysql-test/suite/rpl/r/rpl_row_log.result@stripped, 2008-03-28 12:30:24+01:00, mats@mats-laptop.(none) +26 -8
    Result file change.

  mysql-test/suite/rpl/r/rpl_row_log_innodb.result@stripped, 2008-03-28 12:30:24+01:00, mats@mats-laptop.(none) +2 -0
    Result file change.

  mysql-test/suite/rpl/r/rpl_row_until.result@stripped, 2008-03-28 12:30:24+01:00, mats@mats-laptop.(none) +10 -10
    Result file change.

  mysql-test/suite/rpl/r/rpl_slave_skip.result@stripped, 2008-03-28 12:30:24+01:00, mats@mats-laptop.(none) +10 -4
    Result file change.

  mysql-test/suite/rpl/r/rpl_switch_stm_row_mixed.result@stripped, 2008-03-28 12:30:24+01:00, mats@mats-laptop.(none) +100 -330
    Result file change.

  mysql-test/suite/rpl/r/rpl_truncate_2myisam.result@stripped, 2008-03-28 12:30:24+01:00, mats@mats-laptop.(none) +6 -0
    Result file change.

  mysql-test/suite/rpl/t/rpl_row_create_table.test@stripped, 2008-03-28 12:30:25+01:00, mats@mats-laptop.(none) +3 -3
    Binlog position change.

  mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test@stripped, 2008-03-28 12:30:25+01:00, mats@mats-laptop.(none) +1 -1
    Binlog position change.

  mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test@stripped, 2008-03-28 12:30:25+01:00, mats@mats-laptop.(none) +11 -6
    Binlog position change. Added stop position to mysqlbinlog argments to prevent
    extreneous output.

  mysql-test/suite/rpl/t/rpl_row_until.test@stripped, 2008-03-28 12:30:25+01:00, mats@mats-laptop.(none) +1 -1
    Binlog position change.

  mysql-test/suite/rpl/t/rpl_slave_skip.test@stripped, 2008-03-28 12:30:25+01:00, mats@mats-laptop.(none) +1 -1
    Binlog position change.

  mysql-test/suite/rpl/t/rpl_switch_stm_row_mixed.test@stripped, 2008-03-28 12:30:25+01:00, mats@mats-laptop.(none) +1 -1
    Removing extreneous SHOW BINLOG EVENTS causing test to be non-deterministic.

  mysql-test/suite/rpl_ndb/r/rpl_ndb_log.result@stripped, 2008-03-28 12:30:25+01:00, mats@mats-laptop.(none) +2 -0
    Result change.

  sql/log.cc@stripped, 2008-03-28 12:30:25+01:00, mats@mats-laptop.(none) +131 -50
    Adding variable at_least_one_stmt to denote that there is at least one
    statement committed to the transaction cache (but there might be more).
    
    Removing duplicate checks from binlog_end_trans(). The transaction cache
    should always be committed or rolled back when this function is called.
    
    Correcting conditions for binlog_rollback() and binlog_commit() and removing
    the previous "invisible commit" in favor of always using explicit commits
    in the binary log.

  sql/log_event.cc@stripped, 2008-03-28 12:30:26+01:00, mats@mats-laptop.(none) +1 -16
    Marking table map event to be cached. Removing Muted_query_log_event from code.

  sql/log_event.h@stripped, 2008-03-28 12:30:26+01:00, mats@mats-laptop.(none) +0 -25
    Removing unused class Muted_query_log_event.

  sql/sql_insert.cc@stripped, 2008-03-28 12:30:26+01:00, mats@mats-laptop.(none) +6 -6
    Adding missing call to ha_autocommit_or_rollback() for delayed thread. Marking
    CREATE-SELECT statements as transactional, since they don't need to be logged.

diff -Nrup a/mysql-test/extra/rpl_tests/rpl_row_delayed_ins.test b/mysql-test/extra/rpl_tests/rpl_row_delayed_ins.test
--- a/mysql-test/extra/rpl_tests/rpl_row_delayed_ins.test	2007-03-30 10:26:59 +02:00
+++ b/mysql-test/extra/rpl_tests/rpl_row_delayed_ins.test	2008-03-28 12:30:22 +01:00
@@ -15,7 +15,6 @@ SELECT * FROM t1 ORDER BY a;
 sync_slave_with_master;
 
 connection master;
-source include/show_binlog_events.inc;
 sync_slave_with_master;
 SELECT * FROM t1 ORDER BY a;
 connection master;
diff -Nrup a/mysql-test/r/ctype_cp932_binlog_row.result b/mysql-test/r/ctype_cp932_binlog_row.result
--- a/mysql-test/r/ctype_cp932_binlog_row.result	2007-03-30 10:27:01 +02:00
+++ b/mysql-test/r/ctype_cp932_binlog_row.result	2008-03-28 12:30:22 +01:00
@@ -9,8 +9,10 @@ EXECUTE stmt1 USING @var1;
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1(f1 blob)
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 SELECT HEX(f1) FROM t1;
 HEX(f1)
 8300
diff -Nrup a/mysql-test/suite/binlog/r/binlog_base64_flag.result b/mysql-test/suite/binlog/r/binlog_base64_flag.result
--- a/mysql-test/suite/binlog/r/binlog_base64_flag.result	2008-02-08 18:16:56 +01:00
+++ b/mysql-test/suite/binlog/r/binlog_base64_flag.result	2008-03-28 12:30:22 +01:00
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS t1;
 ==== Test BUG#32407 ====
 select * from t1;
 a
diff -Nrup a/mysql-test/suite/binlog/r/binlog_multi_engine.result b/mysql-test/suite/binlog/r/binlog_multi_engine.result
--- a/mysql-test/suite/binlog/r/binlog_multi_engine.result	2008-02-28 22:50:05 +01:00
+++ b/mysql-test/suite/binlog/r/binlog_multi_engine.result	2008-03-28 12:30:22 +01:00
@@ -78,8 +78,10 @@ UPDATE t1n, t1b SET e = 2, b = 3 WHERE f
 ERROR HY000: Binary logging not possible. Message: Row-based format required for this statement, but not allowed by this combination of engines
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1m)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1n)
 master-bin.000001	#	Table_map	#	#	table_id: # (mysql.ndb_apply_status)
diff -Nrup a/mysql-test/suite/binlog/r/binlog_row_binlog.result b/mysql-test/suite/binlog/r/binlog_row_binlog.result
--- a/mysql-test/suite/binlog/r/binlog_row_binlog.result	2008-02-08 16:55:01 +01:00
+++ b/mysql-test/suite/binlog/r/binlog_row_binlog.result	2008-03-28 12:30:22 +01:00
@@ -1085,9 +1085,11 @@ show binlog events from 0;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	4	Format_desc	1	106	Server version, Binlog ver: 4
 master-bin.000001	106	Query	1	227	use `test`; create table t1 (a bigint unsigned, b bigint(20) unsigned)
-master-bin.000001	227	Table_map	1	269	table_id: # (test.t1)
-master-bin.000001	269	Write_rows	1	315	table_id: # flags: STMT_END_F
-master-bin.000001	315	Query	1	391	use `test`; drop table t1
+master-bin.000001	227	Query	1	295	use `test`; BEGIN
+master-bin.000001	295	Table_map	1	337	table_id: # (test.t1)
+master-bin.000001	337	Write_rows	1	383	table_id: # flags: STMT_END_F
+master-bin.000001	383	Query	1	452	use `test`; COMMIT
+master-bin.000001	452	Query	1	528	use `test`; drop table t1
 End of 5.0 tests
 reset master;
 create table t1 (id tinyint auto_increment primary key);
@@ -1111,8 +1113,10 @@ use test;
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; create table t1 (id tinyint auto_increment primary key)
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 master-bin.000001	#	Query	#	#	use `test`; drop table t1
 master-bin.000001	#	Query	#	#	use `test`; create table t1 (a int)
 master-bin.000001	#	Query	#	#	use `test`; BEGIN
@@ -1123,12 +1127,18 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE IF NOT EXISTS `t3` (
   `a` int(11) DEFAULT NULL
 )
+master-bin.000001	#	Query	#	#	use `mysql`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysql.user)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysql`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysql`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysql.user)
 master-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysql`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysql`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysql.user)
 master-bin.000001	#	Delete_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysql`; COMMIT
 drop table t1,t2,t3,tt1;
 create table t1 (a int not null auto_increment, primary key (a)) engine=myisam;
 set @@session.auto_increment_increment=1, @@session.auto_increment_offset=1;
@@ -1138,8 +1148,10 @@ insert delayed into t1 values (300);
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; create table t1 (id tinyint auto_increment primary key)
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 master-bin.000001	#	Query	#	#	use `test`; drop table t1
 master-bin.000001	#	Query	#	#	use `test`; create table t1 (a int)
 master-bin.000001	#	Query	#	#	use `test`; BEGIN
@@ -1150,20 +1162,32 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE IF NOT EXISTS `t3` (
   `a` int(11) DEFAULT NULL
 )
+master-bin.000001	#	Query	#	#	use `mysql`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysql.user)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysql`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysql`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysql.user)
 master-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysql`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysql`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysql.user)
 master-bin.000001	#	Delete_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysql`; COMMIT
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE `t1`,`t2`,`t3` /* generated by server */
 master-bin.000001	#	Query	#	#	use `test`; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 insert delayed into t1 values (null),(null),(null),(null);
 insert delayed into t1 values (null),(null),(400),(null);
 11 == 11
diff -Nrup a/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result b/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result
--- a/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result	2007-06-27 14:27:31 +02:00
+++ b/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result	2008-03-28 12:30:23 +01:00
@@ -5,13 +5,26 @@ reset master;
 insert into t2 values (@v);
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 flush logs;
 /*!40019 SET @@session.max_insert_delayed_threads=0*/;
 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
 DELIMITER /*!*/;
 ROLLBACK/*!*/;
+use test/*!*/;
+SET TIMESTAMP=10000/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/;
+SET @@session.sql_mode=0/*!*/;
+/*!\C latin1 *//*!*/;
+SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/;
+BEGIN
+/*!*/;
+SET TIMESTAMP=10000/*!*/;
+COMMIT
+/*!*/;
 DELIMITER ;
 # End of log file
 ROLLBACK /* added by mysqlbinlog */;
diff -Nrup a/mysql-test/suite/binlog/r/binlog_row_insert_select.result b/mysql-test/suite/binlog/r/binlog_row_insert_select.result
--- a/mysql-test/suite/binlog/r/binlog_row_insert_select.result	2007-06-27 14:27:24 +02:00
+++ b/mysql-test/suite/binlog/r/binlog_row_insert_select.result	2008-03-28 12:30:23 +01:00
@@ -8,8 +8,10 @@ insert into t1 select * from t2;
 ERROR 23000: Duplicate entry '2' for key 'a'
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; ROLLBACK
 select * from t1;
 a
 1
diff -Nrup a/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result b/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result
--- a/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result	2008-03-05 13:59:21 +01:00
+++ b/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result	2008-03-28 12:30:23 +01:00
@@ -117,8 +117,10 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 delete from t1;
 delete from t2;
 reset master;
@@ -131,8 +133,10 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 insert into t1 values(11);
 commit;
 show binlog events from <binlog_start>;
@@ -141,8 +145,10 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
@@ -272,14 +278,20 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 master-bin.000001	#	Query	#	#	use `test`; drop table t1,t2
 master-bin.000001	#	Query	#	#	use `test`; create table t0 (n int)
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t0)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t0)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 master-bin.000001	#	Query	#	#	use `test`; create table t2 (n int) engine=innodb
 do release_lock("lock1");
 drop table t0,t2;
@@ -362,38 +374,52 @@ a	b
 DROP TABLE t1,t2;
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE if exists t2
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE IF EXISTS t2
 master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t2 (a int, b int, primary key (a)) engine=innodb
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Query	#	#	use `test`; TRUNCATE table t2
 master-bin.000001	#	Xid	#	#	COMMIT /* XID */
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Query	#	#	use `test`; BEGIN
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Query	#	#	use `test`; COMMIT
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE t2
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Query	#	#	use `test`; TRUNCATE table t2
 master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE `t1` /* generated by server */
 reset master;
 create table t1 (a int) engine=innodb;
@@ -489,9 +515,11 @@ insert into t2 values (bug27417(2));
 ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; ROLLBACK
 /* only (!) with fixes for #23333 will show there is the query */;
 select count(*) from t1 /* must be 3 */;
 count(*)
@@ -506,9 +534,11 @@ count(*)
 2
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 /* the query must be in regardless of #23333 */;
 select count(*) from t1 /* must be 5 */;
 count(*)
@@ -564,11 +594,13 @@ update t3 set b=b+bug27417(1);
 ERROR 23000: Duplicate entry '4' for key 'b'
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t3)
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: #
 master-bin.000001	#	Update_rows	#	#	table_id: #
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; ROLLBACK
 /* the output must denote there is the query */;
 select count(*) from t1 /* must be 2 */;
 count(*)
diff -Nrup a/mysql-test/suite/binlog/r/binlog_stm_binlog.result b/mysql-test/suite/binlog/r/binlog_stm_binlog.result
--- a/mysql-test/suite/binlog/r/binlog_stm_binlog.result	2008-02-08 13:47:22 +01:00
+++ b/mysql-test/suite/binlog/r/binlog_stm_binlog.result	2008-03-28 12:30:23 +01:00
@@ -648,12 +648,18 @@ master-bin.000001	#	Query	#	#	use `mysql
 master-bin.000001	#	Query	#	#	use `mysql`; DELETE FROM user WHERE host='localhost' AND user='@#@'
 master-bin.000001	#	Query	#	#	use `test`; drop table t1,t2,t3,tt1
 master-bin.000001	#	Query	#	#	use `test`; create table t1 (a int not null auto_increment, primary key (a)) engine=myisam
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 insert delayed into t1 values (null),(null),(null),(null);
 insert delayed into t1 values (null),(null),(400),(null);
 11 == 11
diff -Nrup a/mysql-test/suite/binlog/t/binlog_base64_flag.test b/mysql-test/suite/binlog/t/binlog_base64_flag.test
--- a/mysql-test/suite/binlog/t/binlog_base64_flag.test	2008-02-09 19:43:31 +01:00
+++ b/mysql-test/suite/binlog/t/binlog_base64_flag.test	2008-03-28 12:30:23 +01:00
@@ -9,6 +9,9 @@
 # BINLOG statement does not work in embedded mode.
 source include/not_embedded.inc;
 
+disable_warnings;
+DROP TABLE IF EXISTS t1;
+enable_warnings;
 
 # Test to show BUG#32407.  This reads a binlog created with the
 # mysql-5.1-telco-6.1 tree, specifically at the tag
diff -Nrup a/mysql-test/suite/rpl/r/rpl_rbr_to_sbr.result b/mysql-test/suite/rpl/r/rpl_rbr_to_sbr.result
--- a/mysql-test/suite/rpl/r/rpl_rbr_to_sbr.result	2007-08-21 14:32:26 +02:00
+++ b/mysql-test/suite/rpl/r/rpl_rbr_to_sbr.result	2008-03-28 12:30:23 +01:00
@@ -18,8 +18,10 @@ Log_name	Pos	Event_type	Server_id	End_lo
 master-bin.000001	#	Format_desc	1	#	Server ver: VERSION, Binlog ver: 4
 master-bin.000001	#	Query	1	#	use `test`; CREATE TABLE t1 (a INT, b LONG)
 master-bin.000001	#	Query	1	#	use `test`; INSERT INTO t1 VALUES (1,1), (2,2)
+master-bin.000001	#	Query	1	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	1	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	1	#	use `test`; COMMIT
 **** On Slave ****
 SHOW SLAVE STATUS;
 Slave_IO_State	#
@@ -28,7 +30,7 @@ Master_User	root
 Master_Port	MASTER_PORT
 Connect_Retry	1
 Master_Log_File	master-bin.000001
-Read_Master_Log_Pos	457
+Read_Master_Log_Pos	594
 Relay_Log_File	#
 Relay_Log_Pos	#
 Relay_Master_Log_File	master-bin.000001
@@ -43,7 +45,7 @@ Replicate_Wild_Ignore_Table	
 Last_Errno	0
 Last_Error	
 Skip_Counter	0
-Exec_Master_Log_Pos	457
+Exec_Master_Log_Pos	594
 Relay_Log_Space	#
 Until_Condition	None
 Until_Log_File	
@@ -66,6 +68,8 @@ slave-bin.000001	#	Format_desc	2	#	Serve
 slave-bin.000001	#	Query	2	#	use `test`; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9
 slave-bin.000001	#	Query	1	#	use `test`; CREATE TABLE t1 (a INT, b LONG)
 slave-bin.000001	#	Query	1	#	use `test`; INSERT INTO t1 VALUES (1,1), (2,2)
+slave-bin.000001	#	Query	1	#	use `test`; BEGIN
 slave-bin.000001	#	Table_map	1	#	table_id: # (test.t1)
 slave-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	1	#	use `test`; COMMIT
 DROP TABLE IF EXISTS t1;
diff -Nrup a/mysql-test/suite/rpl/r/rpl_row_basic_11bugs.result b/mysql-test/suite/rpl/r/rpl_row_basic_11bugs.result
--- a/mysql-test/suite/rpl/r/rpl_row_basic_11bugs.result	2007-12-12 11:14:49 +01:00
+++ b/mysql-test/suite/rpl/r/rpl_row_basic_11bugs.result	2008-03-28 12:30:23 +01:00
@@ -27,8 +27,10 @@ INSERT INTO t2 VALUES (3,3), (4,4);
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT, b INT)
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 **** On Slave ****
 SHOW DATABASES;
 Database
@@ -56,8 +58,10 @@ SHOW BINLOG EVENTS;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	4	Format_desc	1	106	Server ver: SERVER_VERSION, Binlog ver: 4
 master-bin.000001	106	Query	1	192	use `test`; CREATE TABLE t1 (a INT)
-master-bin.000001	192	Table_map	1	233	table_id: # (test.t1)
-master-bin.000001	233	Write_rows	1	272	table_id: # flags: STMT_END_F
+master-bin.000001	192	Query	1	260	use `test`; BEGIN
+master-bin.000001	260	Table_map	1	301	table_id: # (test.t1)
+master-bin.000001	301	Write_rows	1	340	table_id: # flags: STMT_END_F
+master-bin.000001	340	Query	1	409	use `test`; COMMIT
 DROP TABLE t1;
 ================ Test for BUG#17620 ================
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
diff -Nrup a/mysql-test/suite/rpl/r/rpl_row_create_table.result b/mysql-test/suite/rpl/r/rpl_row_create_table.result
--- a/mysql-test/suite/rpl/r/rpl_row_create_table.result	2007-12-14 14:40:43 +01:00
+++ b/mysql-test/suite/rpl/r/rpl_row_create_table.result	2008-03-28 12:30:23 +01:00
@@ -140,8 +140,10 @@ a	b
 SHOW BINLOG EVENTS FROM 1374;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 #	1374	Query	#	1474	use `test`; CREATE TABLE t7 (a INT, b INT UNIQUE)
-#	1474	Table_map	#	1516	table_id: # (test.t7)
-#	1516	Write_rows	#	1572	table_id: # flags: STMT_END_F
+#	1474	Query	#	1542	use `test`; BEGIN
+#	1542	Table_map	#	1584	table_id: # (test.t7)
+#	1584	Write_rows	#	1640	table_id: # flags: STMT_END_F
+#	1640	Query	#	1711	use `test`; ROLLBACK
 SELECT * FROM t7 ORDER BY a,b;
 a	b
 1	2
@@ -154,10 +156,12 @@ INSERT INTO t7 SELECT a,b FROM tt4;
 ROLLBACK;
 Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
-SHOW BINLOG EVENTS FROM 1572;
+SHOW BINLOG EVENTS FROM 1711;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-#	1572	Table_map	#	1614	table_id: # (test.t7)
-#	1614	Write_rows	#	1670	table_id: # flags: STMT_END_F
+#	1711	Query	#	1779	use `test`; BEGIN
+#	1779	Table_map	#	1821	table_id: # (test.t7)
+#	1821	Write_rows	#	1877	table_id: # flags: STMT_END_F
+#	1877	Query	#	1946	use `test`; COMMIT
 SELECT * FROM t7 ORDER BY a,b;
 a	b
 1	2
@@ -192,10 +196,10 @@ Create Table	CREATE TABLE `t9` (
   `a` int(11) DEFAULT NULL,
   `b` int(11) DEFAULT NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
-SHOW BINLOG EVENTS FROM 1670;
+SHOW BINLOG EVENTS FROM 1946;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-#	1670	Query	#	1756	use `test`; CREATE TABLE t8 LIKE t4
-#	1756	Query	#	1895	use `test`; CREATE TABLE `t9` (
+#	1946	Query	#	2032	use `test`; CREATE TABLE t8 LIKE t4
+#	2032	Query	#	2171	use `test`; CREATE TABLE `t9` (
   `a` int(11) DEFAULT NULL,
   `b` int(11) DEFAULT NULL
 )
@@ -276,31 +280,35 @@ SHOW BINLOG EVENTS;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 #	4	Format_desc	#	106	Server ver: #, Binlog ver: #
 #	106	Query	#	192	use `test`; CREATE TABLE t1 (a INT)
-#	192	Table_map	#	233	table_id: # (test.t1)
-#	233	Write_rows	#	277	table_id: # flags: STMT_END_F
-#	277	Query	#	345	use `test`; BEGIN
-#	345	Query	#	470	use `test`; CREATE TABLE `t2` (
+#	192	Query	#	260	use `test`; BEGIN
+#	260	Table_map	#	301	table_id: # (test.t1)
+#	301	Write_rows	#	345	table_id: # flags: STMT_END_F
+#	345	Query	#	414	use `test`; COMMIT
+#	414	Query	#	482	use `test`; BEGIN
+#	482	Query	#	607	use `test`; CREATE TABLE `t2` (
   `a` int(11) DEFAULT NULL
 ) ENGINE=InnoDB
-#	470	Table_map	#	511	table_id: # (test.t2)
-#	511	Write_rows	#	555	table_id: # flags: STMT_END_F
-#	555	Xid	#	582	COMMIT /* XID */
-#	582	Query	#	650	use `test`; BEGIN
-#	650	Query	#	775	use `test`; CREATE TABLE `t3` (
+#	607	Table_map	#	648	table_id: # (test.t2)
+#	648	Write_rows	#	692	table_id: # flags: STMT_END_F
+#	692	Xid	#	719	COMMIT /* XID */
+#	719	Query	#	787	use `test`; BEGIN
+#	787	Query	#	912	use `test`; CREATE TABLE `t3` (
   `a` int(11) DEFAULT NULL
 ) ENGINE=InnoDB
-#	775	Table_map	#	816	table_id: # (test.t3)
-#	816	Write_rows	#	860	table_id: # flags: STMT_END_F
-#	860	Xid	#	887	COMMIT /* XID */
-#	887	Query	#	955	use `test`; BEGIN
-#	955	Query	#	1080	use `test`; CREATE TABLE `t4` (
+#	912	Table_map	#	953	table_id: # (test.t3)
+#	953	Write_rows	#	997	table_id: # flags: STMT_END_F
+#	997	Xid	#	1024	COMMIT /* XID */
+#	1024	Query	#	1092	use `test`; BEGIN
+#	1092	Query	#	1217	use `test`; CREATE TABLE `t4` (
   `a` int(11) DEFAULT NULL
 ) ENGINE=InnoDB
-#	1080	Table_map	#	1121	table_id: # (test.t4)
-#	1121	Write_rows	#	1165	table_id: # flags: STMT_END_F
-#	1165	Xid	#	1192	COMMIT /* XID */
-#	1192	Table_map	#	1233	table_id: # (test.t1)
-#	1233	Write_rows	#	1277	table_id: # flags: STMT_END_F
+#	1217	Table_map	#	1258	table_id: # (test.t4)
+#	1258	Write_rows	#	1302	table_id: # flags: STMT_END_F
+#	1302	Xid	#	1329	COMMIT /* XID */
+#	1329	Query	#	1397	use `test`; BEGIN
+#	1397	Table_map	#	1438	table_id: # (test.t1)
+#	1438	Write_rows	#	1482	table_id: # flags: STMT_END_F
+#	1482	Query	#	1551	use `test`; COMMIT
 SHOW TABLES;
 Tables_in_test
 t1
@@ -367,15 +375,17 @@ SHOW BINLOG EVENTS;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 #	4	Format_desc	#	106	Server ver: #, Binlog ver: #
 #	106	Query	#	192	use `test`; CREATE TABLE t1 (a INT)
-#	192	Table_map	#	233	table_id: # (test.t1)
-#	233	Write_rows	#	277	table_id: # flags: STMT_END_F
-#	277	Query	#	377	use `test`; CREATE TABLE t2 (a INT) ENGINE=INNODB
-#	377	Query	#	445	use `test`; BEGIN
-#	445	Table_map	#	486	table_id: # (test.t2)
-#	486	Write_rows	#	530	table_id: # flags: STMT_END_F
-#	530	Table_map	#	571	table_id: # (test.t2)
-#	571	Write_rows	#	610	table_id: # flags: STMT_END_F
-#	610	Xid	#	637	COMMIT /* XID */
+#	192	Query	#	260	use `test`; BEGIN
+#	260	Table_map	#	301	table_id: # (test.t1)
+#	301	Write_rows	#	345	table_id: # flags: STMT_END_F
+#	345	Query	#	414	use `test`; COMMIT
+#	414	Query	#	514	use `test`; CREATE TABLE t2 (a INT) ENGINE=INNODB
+#	514	Query	#	582	use `test`; BEGIN
+#	582	Table_map	#	623	table_id: # (test.t2)
+#	623	Write_rows	#	667	table_id: # flags: STMT_END_F
+#	667	Table_map	#	708	table_id: # (test.t2)
+#	708	Write_rows	#	747	table_id: # flags: STMT_END_F
+#	747	Xid	#	774	COMMIT /* XID */
 SELECT * FROM t2 ORDER BY a;
 a
 1
@@ -396,17 +406,14 @@ Warnings:
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
 SELECT * FROM t2 ORDER BY a;
 a
-SHOW BINLOG EVENTS FROM 637;
+SHOW BINLOG EVENTS FROM 949;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-#	637	Query	#	705	use `test`; BEGIN
-#	705	Query	#	785	use `test`; TRUNCATE TABLE t2
-#	785	Xid	#	812	COMMIT /* XID */
-#	812	Query	#	880	use `test`; BEGIN
-#	880	Table_map	#	921	table_id: # (test.t2)
-#	921	Write_rows	#	965	table_id: # flags: STMT_END_F
-#	965	Table_map	#	1006	table_id: # (test.t2)
-#	1006	Write_rows	#	1045	table_id: # flags: STMT_END_F
-#	1045	Query	#	1116	use `test`; ROLLBACK
+#	949	Query	#	1017	use `test`; BEGIN
+#	1017	Table_map	#	1058	table_id: # (test.t2)
+#	1058	Write_rows	#	1102	table_id: # flags: STMT_END_F
+#	1102	Table_map	#	1143	table_id: # (test.t2)
+#	1143	Write_rows	#	1182	table_id: # flags: STMT_END_F
+#	1182	Query	#	1253	use `test`; ROLLBACK
 SELECT * FROM t2 ORDER BY a;
 a
 DROP TABLE t1,t2;
diff -Nrup a/mysql-test/suite/rpl/r/rpl_row_delayed_ins.result b/mysql-test/suite/rpl/r/rpl_row_delayed_ins.result
--- a/mysql-test/suite/rpl/r/rpl_row_delayed_ins.result	2007-06-27 14:27:32 +02:00
+++ b/mysql-test/suite/rpl/r/rpl_row_delayed_ins.result	2008-03-28 12:30:24 +01:00
@@ -14,16 +14,6 @@ a
 1
 2
 3
-show binlog events from <binlog_start>;
-Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	#	Query	#	#	use `test`; create table t1(a int not null primary key) engine=myisam
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	use `test`; flush tables
 SELECT * FROM t1 ORDER BY a;
 a
 1
diff -Nrup a/mysql-test/suite/rpl/r/rpl_row_flsh_tbls.result b/mysql-test/suite/rpl/r/rpl_row_flsh_tbls.result
--- a/mysql-test/suite/rpl/r/rpl_row_flsh_tbls.result	2007-08-21 14:32:26 +02:00
+++ b/mysql-test/suite/rpl/r/rpl_row_flsh_tbls.result	2008-03-28 12:30:24 +01:00
@@ -12,13 +12,13 @@ create table t4 (a int);
 insert into t4 select * from t3;
 rename table t1 to t5, t2 to t1;
 flush no_write_to_binlog tables;
-SHOW BINLOG EVENTS FROM 623 ;
+SHOW BINLOG EVENTS FROM 897 ;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	1	#	use `test`; rename table t1 to t5, t2 to t1
 select * from t3;
 a
 flush tables;
-SHOW BINLOG EVENTS FROM 623 ;
+SHOW BINLOG EVENTS FROM 897 ;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	1	#	use `test`; rename table t1 to t5, t2 to t1
 master-bin.000001	#	Query	1	#	use `test`; flush tables
diff -Nrup a/mysql-test/suite/rpl/r/rpl_row_inexist_tbl.result b/mysql-test/suite/rpl/r/rpl_row_inexist_tbl.result
--- a/mysql-test/suite/rpl/r/rpl_row_inexist_tbl.result	2007-08-21 14:32:26 +02:00
+++ b/mysql-test/suite/rpl/r/rpl_row_inexist_tbl.result	2008-03-28 12:30:24 +01:00
@@ -24,7 +24,7 @@ Master_User	root
 Master_Port	MASTER_PORT
 Connect_Retry	1
 Master_Log_File	master-bin.000001
-Read_Master_Log_Pos	605
+Read_Master_Log_Pos	1153
 Relay_Log_File	#
 Relay_Log_Pos	#
 Relay_Master_Log_File	master-bin.000001
@@ -39,7 +39,7 @@ Replicate_Wild_Ignore_Table	
 Last_Errno	1146
 Last_Error	Error 'Table 'test.t1' doesn't exist' on opening table `test`.`t1`
 Skip_Counter	0
-Exec_Master_Log_Pos	530
+Exec_Master_Log_Pos	941
 Relay_Log_Space	#
 Until_Condition	None
 Until_Log_File	
diff -Nrup a/mysql-test/suite/rpl/r/rpl_row_log.result b/mysql-test/suite/rpl/r/rpl_row_log.result
--- a/mysql-test/suite/rpl/r/rpl_row_log.result	2007-08-21 14:32:52 +02:00
+++ b/mysql-test/suite/rpl/r/rpl_row_log.result	2008-03-28 12:30:24 +01:00
@@ -20,22 +20,26 @@ show binlog events;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Format_desc	1	#	Server ver: VERSION, Binlog ver: 4
 master-bin.000001	#	Query	1	#	use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM
+master-bin.000001	#	Query	1	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	1	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	1	#	use `test`; COMMIT
 master-bin.000001	#	Query	1	#	use `test`; drop table t1
 master-bin.000001	#	Query	1	#	use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM
+master-bin.000001	#	Query	1	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	1	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	1	#	use `test`; COMMIT
 show binlog events from 106 limit 1;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	1	#	use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM
 show binlog events from 106 limit 2;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	1	#	use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM
-master-bin.000001	#	Table_map	1	#	table_id: # (test.t1)
+master-bin.000001	#	Query	1	#	use `test`; BEGIN
 show binlog events from 106 limit 2,1;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Table_map	1	#	table_id: # (test.t1)
 flush logs;
 create table t3 (a int)ENGINE=MyISAM;
 select * from t1 order by 1 asc;
@@ -192,47 +196,59 @@ insert into t2 values (1);
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 master-bin.000001	#	Query	#	#	use `test`; drop table t1
 master-bin.000001	#	Query	#	#	use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 master-bin.000001	#	Rotate	#	#	master-bin.000002;pos=4
 show binlog events in 'master-bin.000002';
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000002	#	Format_desc	1	#	Server ver: VERSION, Binlog ver: 4
 master-bin.000002	#	Query	1	#	use `test`; create table t3 (a int)ENGINE=MyISAM
 master-bin.000002	#	Query	1	#	use `test`; create table t2 (n int)ENGINE=MyISAM
+master-bin.000002	#	Query	1	#	use `test`; BEGIN
 master-bin.000002	#	Table_map	1	#	table_id: # (test.t2)
 master-bin.000002	#	Write_rows	1	#	table_id: # flags: STMT_END_F
+master-bin.000002	#	Query	1	#	use `test`; COMMIT
 show binary logs;
 Log_name	File_size
-master-bin.000001	1266
-master-bin.000002	379
+master-bin.000001	1540
+master-bin.000002	516
 start slave;
 show binary logs;
 Log_name	File_size
-slave-bin.000001	1364
-slave-bin.000002	280
+slave-bin.000001	1638
+slave-bin.000002	417
 show binlog events in 'slave-bin.000001' from 4;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 slave-bin.000001	#	Format_desc	2	#	Server ver: VERSION, Binlog ver: 4
 slave-bin.000001	#	Query	1	#	use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM
+slave-bin.000001	#	Query	1	#	use `test`; BEGIN
 slave-bin.000001	#	Table_map	1	#	table_id: # (test.t1)
 slave-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	1	#	use `test`; COMMIT
 slave-bin.000001	#	Query	1	#	use `test`; drop table t1
 slave-bin.000001	#	Query	1	#	use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM
+slave-bin.000001	#	Query	1	#	use `test`; BEGIN
 slave-bin.000001	#	Table_map	1	#	table_id: # (test.t1)
 slave-bin.000001	#	Write_rows	1	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	1	#	use `test`; COMMIT
 slave-bin.000001	#	Query	1	#	use `test`; create table t3 (a int)ENGINE=MyISAM
 slave-bin.000001	#	Rotate	2	#	slave-bin.000002;pos=4
 show binlog events in 'slave-bin.000002' from 4;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 slave-bin.000002	#	Format_desc	2	#	Server ver: VERSION, Binlog ver: 4
 slave-bin.000002	#	Query	1	#	use `test`; create table t2 (n int)ENGINE=MyISAM
+slave-bin.000002	#	Query	1	#	use `test`; BEGIN
 slave-bin.000002	#	Table_map	1	#	table_id: # (test.t2)
 slave-bin.000002	#	Write_rows	1	#	table_id: # flags: STMT_END_F
+slave-bin.000002	#	Query	1	#	use `test`; COMMIT
 SHOW SLAVE STATUS;
 Slave_IO_State	#
 Master_Host	127.0.0.1
@@ -240,7 +256,7 @@ Master_User	root
 Master_Port	MASTER_PORT
 Connect_Retry	1
 Master_Log_File	master-bin.000002
-Read_Master_Log_Pos	379
+Read_Master_Log_Pos	516
 Relay_Log_File	#
 Relay_Log_Pos	#
 Relay_Master_Log_File	master-bin.000002
@@ -255,7 +271,7 @@ Replicate_Wild_Ignore_Table	
 Last_Errno	0
 Last_Error	
 Skip_Counter	0
-Exec_Master_Log_Pos	379
+Exec_Master_Log_Pos	516
 Relay_Log_Space	#
 Until_Condition	None
 Until_Log_File	
@@ -284,8 +300,10 @@ set insert_id=5;
 insert into t1 values (NULL, last_insert_id()), (NULL, last_insert_id());
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 select * from t1;
 a	b
 1	1
diff -Nrup a/mysql-test/suite/rpl/r/rpl_row_log_innodb.result b/mysql-test/suite/rpl/r/rpl_row_log_innodb.result
--- a/mysql-test/suite/rpl/r/rpl_row_log_innodb.result	2007-12-14 14:40:43 +01:00
+++ b/mysql-test/suite/rpl/r/rpl_row_log_innodb.result	2008-03-28 12:30:24 +01:00
@@ -300,8 +300,10 @@ set insert_id=5;
 insert into t1 values (NULL, last_insert_id()), (NULL, last_insert_id());
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 select * from t1;
 a	b
 1	1
diff -Nrup a/mysql-test/suite/rpl/r/rpl_row_until.result b/mysql-test/suite/rpl/r/rpl_row_until.result
--- a/mysql-test/suite/rpl/r/rpl_row_until.result	2007-08-21 14:33:00 +02:00
+++ b/mysql-test/suite/rpl/r/rpl_row_until.result	2008-03-28 12:30:24 +01:00
@@ -26,7 +26,7 @@ Master_User	root
 Master_Port	MASTER_PORT
 Connect_Retry	1
 Master_Log_File	master-bin.000001
-Read_Master_Log_Pos	750
+Read_Master_Log_Pos	1161
 Relay_Log_File	#
 Relay_Log_Pos	#
 Relay_Master_Log_File	master-bin.000001
@@ -41,7 +41,7 @@ Replicate_Wild_Ignore_Table	
 Last_Errno	0
 Last_Error	
 Skip_Counter	0
-Exec_Master_Log_Pos	317
+Exec_Master_Log_Pos	454
 Relay_Log_Space	#
 Until_Condition	Master
 Until_Log_File	master-bin.000001
@@ -72,7 +72,7 @@ Master_User	root
 Master_Port	MASTER_PORT
 Connect_Retry	1
 Master_Log_File	master-bin.000001
-Read_Master_Log_Pos	750
+Read_Master_Log_Pos	1161
 Relay_Log_File	#
 Relay_Log_Pos	#
 Relay_Master_Log_File	master-bin.000001
@@ -87,7 +87,7 @@ Replicate_Wild_Ignore_Table	
 Last_Errno	0
 Last_Error	
 Skip_Counter	0
-Exec_Master_Log_Pos	317
+Exec_Master_Log_Pos	454
 Relay_Log_Space	#
 Until_Condition	Master
 Until_Log_File	master-no-such-bin.000001
@@ -104,7 +104,7 @@ Last_IO_Errno	#
 Last_IO_Error	#
 Last_SQL_Errno	0
 Last_SQL_Error	
-start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=728;
+start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=1014;
 select * from t2;
 n
 1
@@ -116,7 +116,7 @@ Master_User	root
 Master_Port	MASTER_PORT
 Connect_Retry	1
 Master_Log_File	master-bin.000001
-Read_Master_Log_Pos	750
+Read_Master_Log_Pos	1161
 Relay_Log_File	#
 Relay_Log_Pos	#
 Relay_Master_Log_File	master-bin.000001
@@ -131,11 +131,11 @@ Replicate_Wild_Ignore_Table	
 Last_Errno	0
 Last_Error	
 Skip_Counter	0
-Exec_Master_Log_Pos	594
+Exec_Master_Log_Pos	868
 Relay_Log_Space	#
 Until_Condition	Relay
 Until_Log_File	slave-relay-bin.000004
-Until_Log_Pos	728
+Until_Log_Pos	1014
 Master_SSL_Allowed	No
 Master_SSL_CA_File	
 Master_SSL_CA_Path	
@@ -158,7 +158,7 @@ Master_User	root
 Master_Port	MASTER_PORT
 Connect_Retry	1
 Master_Log_File	master-bin.000001
-Read_Master_Log_Pos	750
+Read_Master_Log_Pos	1161
 Relay_Log_File	#
 Relay_Log_Pos	#
 Relay_Master_Log_File	master-bin.000001
@@ -173,7 +173,7 @@ Replicate_Wild_Ignore_Table	
 Last_Errno	0
 Last_Error	
 Skip_Counter	0
-Exec_Master_Log_Pos	750
+Exec_Master_Log_Pos	1161
 Relay_Log_Space	#
 Until_Condition	Master
 Until_Log_File	master-bin.000001
diff -Nrup a/mysql-test/suite/rpl/r/rpl_slave_skip.result b/mysql-test/suite/rpl/r/rpl_slave_skip.result
--- a/mysql-test/suite/rpl/r/rpl_slave_skip.result	2007-10-19 14:18:30 +02:00
+++ b/mysql-test/suite/rpl/r/rpl_slave_skip.result	2008-03-28 12:30:24 +01:00
@@ -17,14 +17,20 @@ show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT, b INT)
 master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t2 (c INT, d INT)
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
 master-bin.000001	#	Update_rows	#	#	table_id: #
 master-bin.000001	#	Update_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 SELECT * FROM t1;
 a	b
 1	1
@@ -36,7 +42,7 @@ c	d
 2	16
 3	54
 **** On Slave ****
-START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=484;
+START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=762;
 SHOW SLAVE STATUS;
 Slave_IO_State	#
 Master_Host	127.0.0.1
@@ -44,7 +50,7 @@ Master_User	root
 Master_Port	MASTER_PORT
 Connect_Retry	1
 Master_Log_File	master-bin.000001
-Read_Master_Log_Pos	722
+Read_Master_Log_Pos	1133
 Relay_Log_File	#
 Relay_Log_Pos	#
 Relay_Master_Log_File	master-bin.000001
@@ -59,11 +65,11 @@ Replicate_Wild_Ignore_Table	
 Last_Errno	0
 Last_Error	
 Skip_Counter	0
-Exec_Master_Log_Pos	488
+Exec_Master_Log_Pos	762
 Relay_Log_Space	#
 Until_Condition	Master
 Until_Log_File	master-bin.000001
-Until_Log_Pos	484
+Until_Log_Pos	762
 Master_SSL_Allowed	No
 Master_SSL_CA_File	
 Master_SSL_CA_Path	
diff -Nrup a/mysql-test/suite/rpl/r/rpl_switch_stm_row_mixed.result b/mysql-test/suite/rpl/r/rpl_switch_stm_row_mixed.result
--- a/mysql-test/suite/rpl/r/rpl_switch_stm_row_mixed.result	2007-12-14 14:40:43 +01:00
+++ b/mysql-test/suite/rpl/r/rpl_switch_stm_row_mixed.result	2008-03-28 12:30:24 +01:00
@@ -430,20 +430,34 @@ Log_name	Pos	Event_type	Server_id	End_lo
 master-bin.000001	#	Query	#	#	drop database if exists mysqltest1
 master-bin.000001	#	Query	#	#	create database mysqltest1
 master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE TABLE t1 (a varchar(100))
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
 master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 values("work_8_")
 master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 select 'emergency_7_'
 master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 values("work_9_")
@@ -457,19 +471,29 @@ master-bin.000001	#	Query	#	#	use `mysql
 master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 values("for_15_")
 master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 select "yesterday_16_"
 master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 values("work_18_")
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
 master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 select 'emergency_17_'
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
 master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 select "yesterday_21_"
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
 master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 select 'emergency_17_'
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
 master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 select "yesterday_24_"
 master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE TABLE `t2` (
@@ -493,9 +517,11 @@ master-bin.000001	#	Table_map	#	#	table_
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
 master-bin.000001	#	Query	#	#	use `mysqltest1`; create table t5 select * from t1 where 3 in (select 1 union select 2 union select curdate() union select 3)
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t5)
 master-bin.000001	#	Write_rows	#	#	table_id: #
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
 master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`root`@`localhost` procedure foo()
 begin
 insert into t1 values("work_25_");
@@ -522,26 +548,44 @@ begin
 insert into t1 values(concat("work_250_",x));
 insert into t1 select "yesterday_270_";
 end
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
 master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 values(concat("work_250_", NAME_CONST('x',_latin1'hello')))
 master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 select "yesterday_270_"
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
 master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 values(concat("work_250_", NAME_CONST('x',_latin1'world')))
 master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 select "yesterday_270_"
 master-bin.000001	#	Query	#	#	use `mysqltest1`; drop function foo3
@@ -551,402 +595,94 @@ insert into t1 values("foo3_32_");
 call foo();
 return 100;
 end
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: #
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: #
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: #
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
 master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function foo4() returns bigint unsigned
 begin
 insert into t2 select foo3();
 return 100;
 end
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: #
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: #
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: #
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
 master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function foo5() returns bigint unsigned
 begin
 insert into t2 select UUID();
 return 100;
 end
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function foo6(x varchar(100)) returns bigint unsigned
-begin
-insert into t2 select x;
-return 100;
-end
-master-bin.000001	#	Query	#	#	use `mysqltest1`; SELECT `mysqltest1`.`foo6`(_latin1'foo6_1_')
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select uuid()
-master-bin.000001	#	Query	#	#	use `mysqltest1`; create table t11 (data varchar(255))
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t11)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t11 select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysqltest1' and TABLE_NAME IN ('v1','t11')
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t11 select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysqltest1' and TABLE_NAME IN ('v1','t11')
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t11 select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysqltest1' and TABLE_NAME IN ('v1','t11')
-master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`root`@`localhost` trigger t11_bi before insert on t11 for each row
-begin
-set NEW.data = concat(NEW.data,UUID());
-end
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t11)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	use `mysqltest1`; create table t20 select * from t1
-master-bin.000001	#	Query	#	#	use `mysqltest1`; create table t21 select * from t2
-master-bin.000001	#	Query	#	#	use `mysqltest1`; create table t22 select * from t3
-master-bin.000001	#	Query	#	#	use `mysqltest1`; drop table t1,t2,t3
-master-bin.000001	#	Query	#	#	use `mysqltest1`; create table t1 (a int primary key auto_increment, b varchar(100))
-master-bin.000001	#	Query	#	#	use `mysqltest1`; create table t2 (a int primary key auto_increment, b varchar(100))
-master-bin.000001	#	Query	#	#	use `mysqltest1`; create table t3 (b varchar(100))
-master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function f (x varchar(100)) returns int deterministic
-begin
-insert into t1 values(null,x);
-insert into t2 values(null,x);
-return 1;
-end
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: #
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: #
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Intvar	#	#	INSERT_ID=3
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 values(null,"try_44_")
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: #
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	use `mysqltest1`; create table t12 select * from t1
-master-bin.000001	#	Query	#	#	use `mysqltest1`; drop table t1
-master-bin.000001	#	Query	#	#	use `mysqltest1`; create table t1 (a int, b varchar(100), key(a))
-master-bin.000001	#	Intvar	#	#	INSERT_ID=4
-master-bin.000001	#	Query	#	#	use `mysqltest1`; SELECT `mysqltest1`.`f`(_latin1'try_45_')
-master-bin.000001	#	Query	#	#	use `mysqltest1`; create table t13 select * from t1
-master-bin.000001	#	Query	#	#	use `mysqltest1`; drop table t1
-master-bin.000001	#	Query	#	#	use `mysqltest1`; create table t1 (a int primary key auto_increment, b varchar(100))
-master-bin.000001	#	Query	#	#	use `mysqltest1`; drop function f
-master-bin.000001	#	Query	#	#	use `mysqltest1`; create table t14 (unique (a)) select * from t2
-master-bin.000001	#	Query	#	#	use `mysqltest1`; truncate table t2
-master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function f1 (x varchar(100)) returns int deterministic
-begin
-insert into t1 values(null,x);
-return 1;
-end
-master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function f2 (x varchar(100)) returns int deterministic
-begin
-insert into t2 values(null,x);
-return 1;
-end
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Write_rows	#	#	table_id: #
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Write_rows	#	#	table_id: #
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t3)
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Write_rows	#	#	table_id: #
-master-bin.000001	#	Write_rows	#	#	table_id: #
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	use `mysqltest1`; drop function f2
-master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function f2 (x varchar(100)) returns int deterministic
-begin
-declare y int;
-insert into t1 values(null,x);
-set y = (select count(*) from t2);
-return y;
-end
-master-bin.000001	#	Intvar	#	#	INSERT_ID=4
-master-bin.000001	#	Query	#	#	use `mysqltest1`; SELECT `mysqltest1`.`f1`(_latin1'try_53_')
-master-bin.000001	#	Intvar	#	#	INSERT_ID=5
-master-bin.000001	#	Query	#	#	use `mysqltest1`; SELECT `mysqltest1`.`f2`(_latin1'try_54_')
-master-bin.000001	#	Query	#	#	use `mysqltest1`; drop function f2
-master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`root`@`localhost` trigger t1_bi before insert on t1 for each row
-begin
-insert into t2 values(null,"try_55_");
-end
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Write_rows	#	#	table_id: #
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	use `mysqltest1`; alter table t1 modify a int, drop primary key
-master-bin.000001	#	Intvar	#	#	INSERT_ID=5
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 values(null,"try_57_")
-master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE TABLE `t16` (
-  `UUID()` varchar(36) CHARACTER SET utf8 NOT NULL DEFAULT ''
-)
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t16)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t16)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t16 values("try_66_")
-master-bin.000001	#	Query	#	#	use `mysqltest1`; DROP TABLE IF EXISTS t11
-master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE TABLE t11 (song VARCHAR(255))
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t11)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	use `mysqltest1`; INSERT INTO t11 VALUES('Careful With That Axe, Eugene')
-master-bin.000001	#	Query	#	#	use `mysqltest1`; DROP TABLE IF EXISTS t12
-master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE TABLE t12 (data LONG)
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t12)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`root`@`localhost` FUNCTION my_user()
-RETURNS CHAR(64)
-BEGIN
-DECLARE user CHAR(64);
-SELECT USER() INTO user;
-RETURN user;
-END
-master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`root`@`localhost` FUNCTION my_current_user()
-RETURNS CHAR(64)
-BEGIN
-DECLARE user CHAR(64);
-SELECT CURRENT_USER() INTO user;
-RETURN user;
-END
-master-bin.000001	#	Query	#	#	use `mysqltest1`; DROP TABLE IF EXISTS t13
-master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE TABLE t13 (data CHAR(64))
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t13)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t13)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t13)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t13)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-show binlog events from <binlog_start>;
-Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	#	Query	#	#	drop database if exists mysqltest1
-master-bin.000001	#	Query	#	#	create database mysqltest1
-master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE TABLE t1 (a varchar(100))
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 values("work_8_")
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 select 'emergency_7_'
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 values("work_9_")
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 select 'emergency_7_'
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 values("for_10_")
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 select "yesterday_11_"
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 values("work_13_")
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 select 'emergency_12_'
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 values("work_14_")
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 select 'emergency_12_'
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 values("for_15_")
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 select "yesterday_16_"
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 values("work_18_")
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 select 'emergency_17_'
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 select "yesterday_21_"
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 select 'emergency_17_'
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 select "yesterday_24_"
 master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
-master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE TABLE `t2` (
-  `rpad(UUID(),100,' ')` varchar(100) CHARACTER SET utf8 NOT NULL DEFAULT ''
-)
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
 master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
-master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE TABLE `t3` (
-  `1` varbinary(108) NOT NULL DEFAULT ''
-)
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t3)
+master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
 master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
-master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE TABLE `t4` (
-  `a` varchar(100) DEFAULT NULL
-)
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t4)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
-master-bin.000001	#	Query	#	#	use `mysqltest1`; create table t5 select * from t1 where 3 in (select 1 union select 2 union select curdate() union select 3)
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t5)
-master-bin.000001	#	Write_rows	#	#	table_id: #
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`root`@`localhost` procedure foo()
-begin
-insert into t1 values("work_25_");
-insert into t1 values(concat("for_26_",UUID()));
-insert into t1 select "yesterday_27_";
-end
-master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`root`@`localhost` procedure foo2()
-begin
-insert into t1 values(concat("emergency_28_",UUID()));
-insert into t1 values("work_29_");
-insert into t1 values(concat("for_30_",UUID()));
-set session binlog_format=row; # accepted for stored procs
-insert into t1 values("more work_31_");
-set session binlog_format=mixed;
-end
-master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function foo3() returns bigint unsigned
-begin
-set session binlog_format=row; # rejected for stored funcs
-insert into t1 values("alarm");
-return 100;
-end
-master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`root`@`localhost` procedure foo4(x varchar(100))
-begin
-insert into t1 values(concat("work_250_",x));
-insert into t1 select "yesterday_270_";
-end
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 values(concat("work_250_", NAME_CONST('x',_latin1'hello')))
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 select "yesterday_270_"
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 values(concat("work_250_", NAME_CONST('x',_latin1'world')))
-master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 select "yesterday_270_"
-master-bin.000001	#	Query	#	#	use `mysqltest1`; drop function foo3
-master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function foo3() returns bigint unsigned
-begin
-insert into t1 values("foo3_32_");
-call foo();
-return 100;
-end
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: #
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: #
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: #
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function foo4() returns bigint unsigned
-begin
-insert into t2 select foo3();
-return 100;
-end
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: #
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: #
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
-master-bin.000001	#	Write_rows	#	#	table_id: #
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function foo5() returns bigint unsigned
-begin
-insert into t2 select UUID();
-return 100;
-end
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
-master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
-master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
 master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function foo6(x varchar(100)) returns bigint unsigned
 begin
 insert into t2 select x;
 return 100;
 end
 master-bin.000001	#	Query	#	#	use `mysqltest1`; SELECT `mysqltest1`.`foo6`(_latin1'foo6_1_')
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
 master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select uuid()
 master-bin.000001	#	Query	#	#	use `mysqltest1`; create table t11 (data varchar(255))
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t11)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
 master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t11 select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysqltest1' and TABLE_NAME IN ('v1','t11')
 master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t11 select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysqltest1' and TABLE_NAME IN ('v1','t11')
 master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t11 select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysqltest1' and TABLE_NAME IN ('v1','t11')
@@ -954,8 +690,11 @@ master-bin.000001	#	Query	#	#	use `mysql
 begin
 set NEW.data = concat(NEW.data,UUID());
 end
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t11)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
@@ -966,6 +705,7 @@ master-bin.000001	#	Table_map	#	#	table_
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
 master-bin.000001	#	Query	#	#	use `mysqltest1`; create table t20 select * from t1
 master-bin.000001	#	Query	#	#	use `mysqltest1`; create table t21 select * from t2
 master-bin.000001	#	Query	#	#	use `mysqltest1`; create table t22 select * from t3
@@ -979,20 +719,26 @@ insert into t1 values(null,x);
 insert into t2 values(null,x);
 return 1;
 end
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: #
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: #
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
 master-bin.000001	#	Intvar	#	#	INSERT_ID=3
 master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 values(null,"try_44_")
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: #
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
 master-bin.000001	#	Query	#	#	use `mysqltest1`; create table t12 select * from t1
 master-bin.000001	#	Query	#	#	use `mysqltest1`; drop table t1
 master-bin.000001	#	Query	#	#	use `mysqltest1`; create table t1 (a int, b varchar(100), key(a))
@@ -1014,20 +760,26 @@ begin
 insert into t2 values(null,x);
 return 1;
 end
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
 master-bin.000001	#	Write_rows	#	#	table_id: #
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
 master-bin.000001	#	Write_rows	#	#	table_id: #
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t3)
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
 master-bin.000001	#	Write_rows	#	#	table_id: #
 master-bin.000001	#	Write_rows	#	#	table_id: #
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
 master-bin.000001	#	Query	#	#	use `mysqltest1`; drop function f2
 master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function f2 (x varchar(100)) returns int deterministic
 begin
@@ -1045,30 +797,40 @@ master-bin.000001	#	Query	#	#	use `mysql
 begin
 insert into t2 values(null,"try_55_");
 end
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t1)
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t2)
 master-bin.000001	#	Write_rows	#	#	table_id: #
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
 master-bin.000001	#	Query	#	#	use `mysqltest1`; alter table t1 modify a int, drop primary key
 master-bin.000001	#	Intvar	#	#	INSERT_ID=5
 master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t1 values(null,"try_57_")
 master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE TABLE `t16` (
   `UUID()` varchar(36) CHARACTER SET utf8 NOT NULL DEFAULT ''
 )
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t16)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t16)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
 master-bin.000001	#	Query	#	#	use `mysqltest1`; insert into t16 values("try_66_")
 master-bin.000001	#	Query	#	#	use `mysqltest1`; DROP TABLE IF EXISTS t11
 master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE TABLE t11 (song VARCHAR(255))
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t11)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
 master-bin.000001	#	Query	#	#	use `mysqltest1`; INSERT INTO t11 VALUES('Careful With That Axe, Eugene')
 master-bin.000001	#	Query	#	#	use `mysqltest1`; DROP TABLE IF EXISTS t12
 master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE TABLE t12 (data LONG)
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t12)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
 master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE DEFINER=`root`@`localhost` FUNCTION my_user()
 RETURNS CHAR(64)
 BEGIN
@@ -1085,13 +847,21 @@ RETURN user;
 END
 master-bin.000001	#	Query	#	#	use `mysqltest1`; DROP TABLE IF EXISTS t13
 master-bin.000001	#	Query	#	#	use `mysqltest1`; CREATE TABLE t13 (data CHAR(64))
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t13)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t13)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t13)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
+master-bin.000001	#	Query	#	#	use `mysqltest1`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (mysqltest1.t13)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `mysqltest1`; COMMIT
 drop database mysqltest1;
 set global binlog_format =@my_binlog_format;
diff -Nrup a/mysql-test/suite/rpl/r/rpl_truncate_2myisam.result b/mysql-test/suite/rpl/r/rpl_truncate_2myisam.result
--- a/mysql-test/suite/rpl/r/rpl_truncate_2myisam.result	2007-11-02 13:00:35 +01:00
+++ b/mysql-test/suite/rpl/r/rpl_truncate_2myisam.result	2008-03-28 12:30:24 +01:00
@@ -114,8 +114,10 @@ show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE IF EXISTS t1
 master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 master-bin.000001	#	Query	#	#	use `test`; TRUNCATE TABLE t1
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE t1
 RESET MASTER;
@@ -230,9 +232,13 @@ show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE IF EXISTS t1
 master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Delete_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 master-bin.000001	#	Query	#	#	use `test`; DROP TABLE t1
 RESET MASTER;
diff -Nrup a/mysql-test/suite/rpl/t/rpl_row_create_table.test b/mysql-test/suite/rpl/t/rpl_row_create_table.test
--- a/mysql-test/suite/rpl/t/rpl_row_create_table.test	2007-12-14 14:40:43 +01:00
+++ b/mysql-test/suite/rpl/t/rpl_row_create_table.test	2008-03-28 12:30:25 +01:00
@@ -94,7 +94,7 @@ INSERT INTO t7 SELECT a,b FROM tt4;
 ROLLBACK;
 --replace_column 1 # 4 #
 --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
-SHOW BINLOG EVENTS FROM 1572;
+SHOW BINLOG EVENTS FROM 1711;
 SELECT * FROM t7 ORDER BY a,b;
 sync_slave_with_master;
 SELECT * FROM t7 ORDER BY a,b;
@@ -110,7 +110,7 @@ CREATE TEMPORARY TABLE tt7 SELECT 1;
 --query_vertical SHOW CREATE TABLE t9
 --replace_column 1 # 4 #
 --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
-SHOW BINLOG EVENTS FROM 1670;
+SHOW BINLOG EVENTS FROM 1946;
 sync_slave_with_master;
 --echo **** On Slave ****
 --query_vertical SHOW CREATE TABLE t8
@@ -227,7 +227,7 @@ ROLLBACK;
 SELECT * FROM t2 ORDER BY a;
 --replace_column 1 # 4 #
 --replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/
-SHOW BINLOG EVENTS FROM 637;
+SHOW BINLOG EVENTS FROM 949;
 sync_slave_with_master;
 SELECT * FROM t2 ORDER BY a;
 
diff -Nrup a/mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test b/mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test
--- a/mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test	2007-08-21 14:32:26 +02:00
+++ b/mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test	2008-03-28 12:30:25 +01:00
@@ -1,7 +1,7 @@
 # depends on the binlog output
 -- source include/have_binlog_format_row.inc
 
-let $rename_event_pos= 623;
+let $rename_event_pos= 897;
 
 # 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
diff -Nrup a/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test b/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test
--- a/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test	2007-10-11 18:17:56 +02:00
+++ b/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test	2008-03-28 12:30:25 +01:00
@@ -164,12 +164,12 @@ connection master;
 
 
 # this test for position option
-# By setting this position to 413, we should only get the create of t3
+# By setting this position to 416, we should only get the create of t3
 --disable_query_log
 select "--- Test 2 position test --" as "";
 --enable_query_log
 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=416 $MYSQLTEST_VARDIR/log/master-bin.000001
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=416 --stop-position=569 $MYSQLTEST_VARDIR/log/master-bin.000001
 
 # These are tests for remote binlog.
 # They should return the same as previous test.
@@ -180,7 +180,7 @@ select "--- Test 3 First Remote test --"
 
 # This is broken now
 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
---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
+--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
 
 # This part is disabled due to bug #17654
 
@@ -246,12 +246,17 @@ connection master;
 --exec rm $MYSQLTEST_VARDIR/tmp/remote.sql
 ################### End Bug 17654 ######################
 
+# What is the point of this test? It seems entirely pointless. It
+# might make sense for statement-based replication, but for row-based
+# replication the LOAD DATA INFILE is printed just as empty
+# transactions. /Matz
+
 # LOAD DATA
 --disable_query_log
 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/ --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=106 --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)
 
@@ -259,13 +264,13 @@ select "--- Test 5 LOAD DATA --" as "";
 select "--- Test 6 reading stdin --" as "";
 --enable_query_log
 --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form - < $MYSQLTEST_VARDIR/log/master-bin.000001
+--exec $MYSQL_BINLOG --short-form --stop-position=569 - < $MYSQLTEST_VARDIR/log/master-bin.000001
 
 --disable_query_log
 select "--- Test 7 reading stdin w/position --" as "";
 --enable_query_log
 --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form --position=416 - < $MYSQLTEST_VARDIR/log/master-bin.000001
+--exec $MYSQL_BINLOG --short-form --position=416 --stop-position=569 - < $MYSQLTEST_VARDIR/log/master-bin.000001
 
 # Bug#16217 (mysql client did not know how not switch its internal charset)
 --disable_query_log
diff -Nrup a/mysql-test/suite/rpl/t/rpl_row_until.test b/mysql-test/suite/rpl/t/rpl_row_until.test
--- a/mysql-test/suite/rpl/t/rpl_row_until.test	2007-10-26 16:11:18 +02:00
+++ b/mysql-test/suite/rpl/t/rpl_row_until.test	2008-03-28 12:30:25 +01:00
@@ -42,7 +42,7 @@ select * from t1;
 source include/show_slave_status.inc;
 
 # try replicate all up to and not including the second insert to t2;
-start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=728;
+start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=1014;
 --source include/wait_for_slave_sql_to_stop.inc
 select * from t2;
 source include/show_slave_status.inc;
diff -Nrup a/mysql-test/suite/rpl/t/rpl_slave_skip.test b/mysql-test/suite/rpl/t/rpl_slave_skip.test
--- a/mysql-test/suite/rpl/t/rpl_slave_skip.test	2007-10-19 14:18:30 +02:00
+++ b/mysql-test/suite/rpl/t/rpl_slave_skip.test	2008-03-28 12:30:25 +01:00
@@ -26,7 +26,7 @@ save_master_pos;
 connection slave;
 
 # Stop when reaching the the first table map event.
-START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=484;
+START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=762;
 wait_for_slave_to_stop;
 --replace_result $MASTER_MYPORT MASTER_PORT
 --replace_column 1 # 8 # 9 # 23 # 33 # 35 # 36 #
diff -Nrup a/mysql-test/suite/rpl/t/rpl_switch_stm_row_mixed.test b/mysql-test/suite/rpl/t/rpl_switch_stm_row_mixed.test
--- a/mysql-test/suite/rpl/t/rpl_switch_stm_row_mixed.test	2007-12-06 16:26:59 +01:00
+++ b/mysql-test/suite/rpl/t/rpl_switch_stm_row_mixed.test	2008-03-28 12:30:25 +01:00
@@ -526,6 +526,7 @@ sync_slave_with_master;
 # 
 
 connection master;
+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1); 
 
 # Just to get something that is non-trivial, albeit still simple, we
 # stuff the result of USER() and CURRENT_USER() into a variable.
@@ -571,7 +572,6 @@ sync_slave_with_master;
 diff_files $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_master.sql $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_slave.sql;
 
 connection master;
-source include/show_binlog_events.inc;
 
 # Now test that mysqlbinlog works fine on a binlog generated by the
 # mixed mode
diff -Nrup a/mysql-test/suite/rpl_ndb/r/rpl_ndb_log.result b/mysql-test/suite/rpl_ndb/r/rpl_ndb_log.result
--- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_log.result	2007-08-21 14:33:04 +02:00
+++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_log.result	2008-03-28 12:30:25 +01:00
@@ -316,8 +316,10 @@ set insert_id=5;
 insert into t1 values (NULL, last_insert_id()), (NULL, last_insert_id());
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
 master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
 master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
 select * from t1;
 a	b
 1	1
diff -Nrup a/sql/log.cc b/sql/log.cc
--- a/sql/log.cc	2008-03-05 09:44:37 +01:00
+++ b/sql/log.cc	2008-03-28 12:30:25 +01:00
@@ -52,8 +52,6 @@ LOGGER logger;
 MYSQL_BIN_LOG mysql_bin_log;
 ulong sync_binlog_counter= 0;
 
-static Muted_query_log_event invisible_commit;
-
 static bool test_if_number(const char *str,
 			   long *res, bool allow_wildcards);
 static int binlog_init(void *p);
@@ -155,7 +153,7 @@ private:
 class binlog_trx_data {
 public:
   binlog_trx_data()
-    : m_pending(0), before_stmt_pos(MY_OFF_T_UNDEF)
+    : m_pending(0), before_stmt_pos(MY_OFF_T_UNDEF), at_least_one_stmt(0)
   {
     trans_log.end_of_file= max_binlog_cache_size;
   }
@@ -188,6 +186,16 @@ public:
     reinit_io_cache(&trans_log, WRITE_CACHE, pos, 0, 0);
     if (pos < before_stmt_pos)
       before_stmt_pos= MY_OFF_T_UNDEF;
+
+    /*
+      The only valid positions that can be truncated to are at the
+      beginning of a statement. We are relying on this fact to be able
+      to set the at_least_one_stmt flag correctly. In other word, if
+      we are truncating to the beginning of the transaction cache,
+      there will be no statements in the cache, otherwhise, we will
+      have at least one statement in the transaction cache.
+     */
+    at_least_one_stmt= (pos > 0);
   }
 
   /*
@@ -213,6 +221,12 @@ public:
 
   IO_CACHE trans_log;                         // The transaction cache
 
+  /**
+    Boolean that is true if there is at least one statement in the
+    transaction cache.
+  */
+  bool at_least_one_stmt;
+
 private:
   /*
     Pending binrows event. This event is the event where the rows are
@@ -1373,26 +1387,20 @@ binlog_end_trans(THD *thd, binlog_trx_da
       inside a stored function.
      */
     thd->binlog_flush_pending_rows_event(TRUE);
+
+    error= mysql_bin_log.write(thd, &trx_data->trans_log, end_ev);
+    trx_data->reset();
+
     /*
-      We write the transaction cache to the binary log if either we're
-      committing the entire transaction, or if we are doing an
-      autocommit outside a transaction.
-     */
-    if (all || !(thd->options & (OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT)))
+      We need to step the table map version after writing the
+      transaction cache to disk.
+    */
+    mysql_bin_log.update_table_map_version();
+    statistic_increment(binlog_cache_use, &LOCK_status);
+    if (trans_log->disk_writes != 0)
     {
-      error= mysql_bin_log.write(thd, &trx_data->trans_log, end_ev);
-      trx_data->reset();
-      /*
-        We need to step the table map version after writing the
-        transaction cache to disk.
-      */
-      mysql_bin_log.update_table_map_version();
-      statistic_increment(binlog_cache_use, &LOCK_status);
-      if (trans_log->disk_writes != 0)
-      {
-        statistic_increment(binlog_cache_disk_use, &LOCK_status);
-        trans_log->disk_writes= 0;
-      }
+      statistic_increment(binlog_cache_disk_use, &LOCK_status);
+      trans_log->disk_writes= 0;
     }
   }
   else
@@ -1431,6 +1439,8 @@ static int binlog_prepare(handlerton *ht
   return 0;
 }
 
+#define YESNO(X) ((X) ? "yes" : "no")
+
 /**
   This function is called once after each statement.
 
@@ -1439,10 +1449,8 @@ static int binlog_prepare(handlerton *ht
 
   @param hton  The binlog handlerton.
   @param thd   The client thread that executes the transaction.
-  @param all   true if this is the last statement before a COMMIT
-               statement; false if either this is a statement in a
-               transaction but not the last, or if this is a statement
-               not inside a BEGIN block and autocommit is on.
+  @param all   This is @c true if this is a real transaction commit, and
+               @false otherwise.
 
   @see handlerton::commit
 */
@@ -1458,26 +1466,86 @@ static int binlog_commit(handlerton *hto
     trx_data->reset();
     DBUG_RETURN(0);
   }
+
   /*
-    Write commit event if at least one of the following holds:
-     - the user sends an explicit COMMIT; or
-     - the autocommit flag is on, and we are not inside a BEGIN.
-    However, if the user has not sent an explicit COMMIT, and we are
-    either inside a BEGIN or run with autocommit off, then this is not
-    the end of a transaction and we should not write a commit event.
+    Decision table for committing a transaction. The top part, the
+    *conditions* represent different cases that can occur, and hte
+    bottom part, the *actions*, represent what should be done in that
+    particular case.
+
+    Real transaction        'all' was true
+
+    Statement in cache      There were at least one statement in the
+                            transaction cache
+
+    In transaction          We are inside a transaction
+
+    Stmt modified non-trans The statement being committed modified a
+                            non-transactional table
+
+    All modified non-trans  Some statement before this one in the
+                            transaction modified a non-transactional
+                            table
+
+
+    =============================  = = = = = = = = = = = = = = = =
+    Real transaction               N N N N N N N N N N N N N N N N
+    Statement in cache             N N N N N N N N Y Y Y Y Y Y Y Y
+    In transaction                 N N N N Y Y Y Y N N N N Y Y Y Y
+    Stmt modified non-trans        N N Y Y N N Y Y N N Y Y N N Y Y
+    All modified non-trans         N Y N Y N Y N Y N Y N Y N Y N Y
+
+    Action: (C)ommit/(A)ccumulate  C C - C A C - C - - - - A A - A
+    =============================  = = = = = = = = = = = = = = = =
+
+
+    =============================  = = = = = = = = = = = = = = = =
+    Real transaction               Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y
+    Statement in cache             N N N N N N N N Y Y Y Y Y Y Y Y
+    In transaction                 N N N N Y Y Y Y N N N N Y Y Y Y
+    Stmt modified non-trans        N N Y Y N N Y Y N N Y Y N N Y Y
+    All modified non-trans         N Y N Y N Y N Y N Y N Y N Y N Y
+
+    (C)ommit/(A)ccumulate/(-)      - - - - C C - C - - - - C C - C
+    =============================  = = = = = = = = = = = = = = = =
+
+    In other words, we commit the transaction if and only if both of
+    the following are true:
+     - We are not in a transaction and committing a statement
+
+     - We are in a transaction and one (or more) of the following are
+       true:
+
+       - A full transaction is committed
+
+         OR
+
+       - A non-transactional statement is committed and there is
+         no statement cached
+
+    Otherwise, we accumulate the statement
   */
-  if (all || !(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
+  ulonglong const in_transaction=
+    thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN);
+  DBUG_PRINT("debug",
+             ("all: %d, empty: %s, in_transaction: %s, all.modified_non_trans_table: %s, stmt.modified_non_trans_table: %s",
+              all,
+              YESNO(trx_data->empty()),
+              YESNO(in_transaction),
+              YESNO(thd->transaction.all.modified_non_trans_table),
+              YESNO(thd->transaction.stmt.modified_non_trans_table)));
+  if (in_transaction &&
+      (all ||
+       (!trx_data->at_least_one_stmt &&
+        thd->transaction.stmt.modified_non_trans_table)) ||
+      !in_transaction && !all)
   {
     Query_log_event qev(thd, STRING_WITH_LEN("COMMIT"), TRUE, FALSE);
     qev.error_code= 0; // see comment in MYSQL_LOG::write(THD, IO_CACHE)
     int error= binlog_end_trans(thd, trx_data, &qev, all);
     DBUG_RETURN(error);
   }
-  else
-  {
-    int error= binlog_end_trans(thd, trx_data, &invisible_commit, all);
-    DBUG_RETURN(error);
-  }
+  DBUG_RETURN(0);
 }
 
 /**
@@ -1490,10 +1558,8 @@ static int binlog_commit(handlerton *hto
 
   @param hton  The binlog handlerton.
   @param thd   The client thread that executes the transaction.
-  @param all   true if this is the last statement before a COMMIT
-               statement; false if either this is a statement in a
-               transaction but not the last, or if this is a statement
-               not inside a BEGIN block and autocommit is on.
+  @param all   This is @c true if this is a real transaction rollback, and
+               @false otherwise.
 
   @see handlerton::rollback
 */
@@ -1509,21 +1575,36 @@ static int binlog_rollback(handlerton *h
     DBUG_RETURN(0);
   }
 
-  /*
-    Update the binary log with a BEGIN/ROLLBACK block if we have
-    cached some queries and we updated some non-transactional
-    table. Such cases should be rare (updating a
-    non-transactional table inside a transaction...)
-  */
-  if (unlikely(thd->transaction.all.modified_non_trans_table || 
-               (thd->options & OPTION_KEEP_LOG)))
+  DBUG_PRINT("debug", ("all: %s, all.modified_non_trans_table: %s, stmt.modified_non_trans_table: %s",
+                       YESNO(all),
+                       YESNO(thd->transaction.all.modified_non_trans_table),
+                       YESNO(thd->transaction.stmt.modified_non_trans_table)));
+  if (all && thd->transaction.all.modified_non_trans_table ||
+      !all && thd->transaction.stmt.modified_non_trans_table ||
+      (thd->options & OPTION_KEEP_LOG))
   {
+    /*
+      We write the transaction cache with a rollback last if we have
+      modified any non-transactional table. We do this even if we are
+      committing a single statement that has modified a
+      non-transactional table since it can have modified a
+      transactional table in that statement as well, which needs to be
+      rolled back on the slave.
+    */
     Query_log_event qev(thd, STRING_WITH_LEN("ROLLBACK"), TRUE, FALSE);
     qev.error_code= 0; // see comment in MYSQL_LOG::write(THD, IO_CACHE)
     error= binlog_end_trans(thd, trx_data, &qev, all);
   }
-  else
+  else if (all && !thd->transaction.all.modified_non_trans_table ||
+           !all && !thd->transaction.stmt.modified_non_trans_table)
+  {
+    /*
+      If we have modified only transactional tables, we can truncate
+      the transaction cache without writing anything to the binary
+      log.
+     */
     error= binlog_end_trans(thd, trx_data, 0, all);
+  }
   DBUG_RETURN(error);
 }
 
diff -Nrup a/sql/log_event.cc b/sql/log_event.cc
--- a/sql/log_event.cc	2008-02-28 18:55:42 +01:00
+++ b/sql/log_event.cc	2008-03-28 12:30:26 +01:00
@@ -2603,21 +2603,6 @@ Query_log_event::do_shall_skip(Relay_log
 
 
 /**************************************************************************
-	Muted_query_log_event methods
-**************************************************************************/
-
-#ifndef MYSQL_CLIENT
-/*
-  Muted_query_log_event::Muted_query_log_event()
-*/
-Muted_query_log_event::Muted_query_log_event()
-  :Query_log_event()
-{
-}
-#endif
-
-
-/**************************************************************************
 	Start_log_event_v3 methods
 **************************************************************************/
 
@@ -7054,7 +7039,7 @@ int Table_map_log_event::save_field_meta
 #if !defined(MYSQL_CLIENT)
 Table_map_log_event::Table_map_log_event(THD *thd, TABLE *tbl, ulong tid,
                                          bool is_transactional, uint16 flags)
-  : Log_event(thd, 0, is_transactional),
+  : Log_event(thd, 0, true),
     m_table(tbl),
     m_dbnam(tbl->s->db.str),
     m_dblen(m_dbnam ? tbl->s->db.length : 0),
diff -Nrup a/sql/log_event.h b/sql/log_event.h
--- a/sql/log_event.h	2008-02-20 14:52:20 +01:00
+++ b/sql/log_event.h	2008-03-28 12:30:26 +01:00
@@ -1614,31 +1614,6 @@ public:        /* !!! Public in this pat
 };
 
 
-/**
-  @class Muted_query_log_event
-
-  Pretends to log SQL queries, but doesn't actually do so.  This is
-  used internally only and never written to any binlog.
-
-  @section Muted_query_log_event_binary_format Binary Format
-
-  This log event is not stored, and thus the binary format is 0 bytes
-  long.  Note that not even the Common-Header is stored.
-*/
-class Muted_query_log_event: public Query_log_event
-{
-public:
-#ifndef MYSQL_CLIENT
-  Muted_query_log_event();
-
-  bool write(IO_CACHE* file) { return(false); };
-  virtual bool write_post_header_for_derived(IO_CACHE* file) { return FALSE; }
-#else
-  Muted_query_log_event() {}
-#endif
-};
-
-
 #ifdef HAVE_REPLICATION
 
 /**
diff -Nrup a/sql/sql_insert.cc b/sql/sql_insert.cc
--- a/sql/sql_insert.cc	2008-02-19 13:45:16 +01:00
+++ b/sql/sql_insert.cc	2008-03-28 12:30:26 +01:00
@@ -2426,6 +2426,7 @@ pthread_handler_t handle_delayed_insert(
       */
       di->table->file->ha_release_auto_increment();
       mysql_unlock_tables(thd, lock);
+      ha_autocommit_or_rollback(thd, 0);
       di->group_count=0;
       pthread_mutex_lock(&di->mutex);
     }
@@ -3677,13 +3678,10 @@ void select_create::abort()
   DBUG_ENTER("select_create::abort");
 
   /*
-   Disable binlog, because we "roll back" partial inserts in ::abort
-   by removing the table, even for non-transactional tables.
-  */
-  tmp_disable_binlog(thd);
-  /*
     In select_insert::abort() we roll back the statement, including
-    truncating the transaction cache of the binary log.
+    truncating the transaction cache of the binary log. To do this, we
+    pretend that the statement is transactional, even though it might
+    be the case that it was not.
 
     We roll back the statement prior to deleting the table and prior
     to releasing the lock on the table, since there might be potential
@@ -3694,7 +3692,9 @@ void select_create::abort()
     of the table succeeded or not, since we need to reset the binary
     log state.
   */
+  tmp_disable_binlog(thd);
   select_insert::abort();
+  thd->transaction.stmt.modified_non_trans_table= FALSE;
   reenable_binlog(thd);
 
 
Thread
bk commit into 5.1 tree (mats:1.2559) BUG#29020Mats Kindahl28 Mar