MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Jonathan Perkin Date:June 12 2008 11:36am
Subject:bk commit into 6.0 tree (jperkin:1.2627) BUG#37221
View as plain text  
Below is the list of changes that have just been committed into a local
6.0 repository of jperkin.  When jperkin 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-06-12 13:36:39+02:00, jperkin@stripped +6 -0
  Merge -r2694..2696 from mysql-6.0-falcon bzr tree.  Original comments:
  ------------------------------------------------------------
  revno: 2696
  committer: Mats Kindahl <mats@stripped>
  branch nick: b37221-mysql-6.0-falcon
  timestamp: Tue 2008-06-10 14:39:13 +0200
  message:
    BUG#37221: SET AUTOCOMMIT=1 does not commit binary log
  
    Adding comment to Falcon regression test for the bug.
  ------------------------------------------------------------
  revno: 2695
  committer: Mats Kindahl <mats@stripped>
  branch nick: b37221-mysql-6.0-falcon
  timestamp: Mon 2008-06-09 21:32:42 +0200
  message:
    Bug #37221: SET AUTOCOMMIT=1 does not commit binary log
  
    When setting AUTOCOMMIT=1 after starting a transaction, the binary log
    did not commit the outstanding transaction. The reason was that the binary
    log commit function saw the values of the new settings, deciding that there
    were nothing to commit.
  
    Fixed the problem by moving the implicit commit to before the thread option
    flags were changed, so that the binary log sees the old values of the flags
    instead of the values they will take after the statement.

  mysql-test/extra/binlog_tests/implicit.test@stripped, 2008-06-12 13:31:46+02:00, jperkin@stripped +28 -0
    BitKeeper file /data0/mysqldev/my/build-200804161538-6.0.5-alpha/mysql-6.0-release/mysql-test/extra/binlog_tests/implicit.test

  mysql-test/extra/binlog_tests/implicit.test@stripped, 2008-06-12 13:31:46+02:00, jperkin@stripped +0 -0

  mysql-test/suite/binlog/r/binlog_implicit_commit.result@stripped, 2008-06-12 13:32:12+02:00, jperkin@stripped +345 -0
    BitKeeper file /data0/mysqldev/my/build-200804161538-6.0.5-alpha/mysql-6.0-release/mysql-test/suite/binlog/r/binlog_implicit_commit.result

  mysql-test/suite/binlog/r/binlog_implicit_commit.result@stripped, 2008-06-12 13:32:12+02:00, jperkin@stripped +0 -0

  mysql-test/suite/binlog/t/binlog_implicit_commit.test@stripped, 2008-06-12 13:32:12+02:00, jperkin@stripped +63 -0
    BitKeeper file /data0/mysqldev/my/build-200804161538-6.0.5-alpha/mysql-6.0-release/mysql-test/suite/binlog/t/binlog_implicit_commit.test

  mysql-test/suite/binlog/t/binlog_implicit_commit.test@stripped, 2008-06-12 13:32:12+02:00, jperkin@stripped +0 -0

  mysql-test/suite/falcon/r/rpl_falcon_bug_37221.result@stripped, 2008-06-12 13:32:12+02:00, jperkin@stripped +38 -0
    BitKeeper file /data0/mysqldev/my/build-200804161538-6.0.5-alpha/mysql-6.0-release/mysql-test/suite/falcon/r/rpl_falcon_bug_37221.result

  mysql-test/suite/falcon/r/rpl_falcon_bug_37221.result@stripped, 2008-06-12 13:32:12+02:00, jperkin@stripped +0 -0

  mysql-test/suite/falcon/t/rpl_falcon_bug_37221.test@stripped, 2008-06-12 13:32:12+02:00, jperkin@stripped +53 -0
    BitKeeper file /data0/mysqldev/my/build-200804161538-6.0.5-alpha/mysql-6.0-release/mysql-test/suite/falcon/t/rpl_falcon_bug_37221.test

  mysql-test/suite/falcon/t/rpl_falcon_bug_37221.test@stripped, 2008-06-12 13:32:12+02:00, jperkin@stripped +0 -0

  sql/set_var.cc@stripped, 2008-06-12 13:32:17+02:00, jperkin@stripped +9 -2
    Merge from mysql-6.0-falcon bzr tree -r2695..2697

diff -Nrup a/mysql-test/extra/binlog_tests/implicit.test b/mysql-test/extra/binlog_tests/implicit.test
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/mysql-test/extra/binlog_tests/implicit.test	2008-06-12 13:31:46 +02:00
@@ -0,0 +1,28 @@
+# First part: outside a transaction
+RESET MASTER;
+eval $prepare;
+
+INSERT INTO t1 VALUES (1);
+source include/show_binlog_events.inc;
+eval $statement;
+source include/show_binlog_events.inc;
+if (`select '$cleanup' != ''`) {
+  eval $cleanup;
+}
+
+# Second part: inside a transaction
+RESET MASTER;
+eval $prepare;
+BEGIN;
+INSERT INTO t1 VALUES (2);
+source include/show_binlog_events.inc;
+eval $statement;
+source include/show_binlog_events.inc;
+INSERT INTO t1 VALUES (3);
+source include/show_binlog_events.inc;
+COMMIT;
+source include/show_binlog_events.inc;
+if (`select '$cleanup' != ''`) {
+  eval $cleanup;
+}
+
diff -Nrup a/mysql-test/suite/binlog/r/binlog_implicit_commit.result b/mysql-test/suite/binlog/r/binlog_implicit_commit.result
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/mysql-test/suite/binlog/r/binlog_implicit_commit.result	2008-06-12 13:32:12 +02:00
@@ -0,0 +1,345 @@
+CREATE TABLE t1 (id INT) ENGINE = InnoDB;
+SET BINLOG_FORMAT = STATEMENT;
+RESET MASTER;
+SET AUTOCOMMIT = 0;
+INSERT INTO t1 VALUES (1);
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+SET AUTOCOMMIT = 1;
+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	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+COMMIT;
+RESET MASTER;
+SET AUTOCOMMIT = 0;
+BEGIN;
+INSERT INTO t1 VALUES (2);
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+SET AUTOCOMMIT = 1;
+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	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (2)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+INSERT INTO t1 VALUES (3);
+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	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (2)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (3)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+COMMIT;
+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	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (2)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (3)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+COMMIT;
+RESET MASTER;
+SET AUTOCOMMIT = 1;
+INSERT INTO t1 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`; BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+SET AUTOCOMMIT = 1;
+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	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+COMMIT;
+RESET MASTER;
+SET AUTOCOMMIT = 1;
+BEGIN;
+INSERT INTO t1 VALUES (2);
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+SET AUTOCOMMIT = 1;
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+INSERT INTO t1 VALUES (3);
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+COMMIT;
+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	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (3)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+COMMIT;
+RESET MASTER;
+SET AUTOCOMMIT = 0;
+INSERT INTO t1 VALUES (1);
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+SET AUTOCOMMIT = 0;
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+COMMIT;
+RESET MASTER;
+SET AUTOCOMMIT = 0;
+BEGIN;
+INSERT INTO t1 VALUES (2);
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+SET AUTOCOMMIT = 0;
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+INSERT INTO t1 VALUES (3);
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+COMMIT;
+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	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (3)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+COMMIT;
+RESET MASTER;
+SET AUTOCOMMIT = 1;
+INSERT INTO t1 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`; BEGIN
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+SET AUTOCOMMIT = 0;
+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	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (1)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+COMMIT;
+RESET MASTER;
+SET AUTOCOMMIT = 1;
+BEGIN;
+INSERT INTO t1 VALUES (2);
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+SET AUTOCOMMIT = 0;
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+INSERT INTO t1 VALUES (3);
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+COMMIT;
+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	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (2)
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (3)
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+COMMIT;
+SET BINLOG_FORMAT = ROW;
+RESET MASTER;
+SET AUTOCOMMIT = 0;
+INSERT INTO t1 VALUES (1);
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+SET AUTOCOMMIT = 1;
+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	#	Xid	#	#	COMMIT /* XID */
+COMMIT;
+RESET MASTER;
+SET AUTOCOMMIT = 0;
+BEGIN;
+INSERT INTO t1 VALUES (2);
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+SET AUTOCOMMIT = 1;
+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	#	Xid	#	#	COMMIT /* XID */
+INSERT INTO t1 VALUES (3);
+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	#	Xid	#	#	COMMIT /* XID */
+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	#	Xid	#	#	COMMIT /* XID */
+COMMIT;
+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	#	Xid	#	#	COMMIT /* XID */
+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	#	Xid	#	#	COMMIT /* XID */
+COMMIT;
+RESET MASTER;
+SET AUTOCOMMIT = 1;
+INSERT INTO t1 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`; BEGIN
+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 */
+SET AUTOCOMMIT = 1;
+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	#	Xid	#	#	COMMIT /* XID */
+COMMIT;
+RESET MASTER;
+SET AUTOCOMMIT = 1;
+BEGIN;
+INSERT INTO t1 VALUES (2);
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+SET AUTOCOMMIT = 1;
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+INSERT INTO t1 VALUES (3);
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+COMMIT;
+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	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+COMMIT;
+RESET MASTER;
+SET AUTOCOMMIT = 0;
+INSERT INTO t1 VALUES (1);
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+SET AUTOCOMMIT = 0;
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+COMMIT;
+RESET MASTER;
+SET AUTOCOMMIT = 0;
+BEGIN;
+INSERT INTO t1 VALUES (2);
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+SET AUTOCOMMIT = 0;
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+INSERT INTO t1 VALUES (3);
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+COMMIT;
+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	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+COMMIT;
+RESET MASTER;
+SET AUTOCOMMIT = 1;
+INSERT INTO t1 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`; BEGIN
+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 */
+SET AUTOCOMMIT = 0;
+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	#	Xid	#	#	COMMIT /* XID */
+COMMIT;
+RESET MASTER;
+SET AUTOCOMMIT = 1;
+BEGIN;
+INSERT INTO t1 VALUES (2);
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+SET AUTOCOMMIT = 0;
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+INSERT INTO t1 VALUES (3);
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+COMMIT;
+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	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+COMMIT;
+RESET MASTER;
+SET AUTOCOMMIT = 0;
+INSERT INTO t1 VALUES (1);
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+LOCK TABLES t1 WRITE;
+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	#	Xid	#	#	COMMIT /* XID */
+INSERT INTO t1 VALUES (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.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Xid	#	#	COMMIT /* XID */
+UNLOCK TABLES;
+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	#	Xid	#	#	COMMIT /* XID */
+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	#	Xid	#	#	COMMIT /* XID */
+COMMIT;
+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	#	Xid	#	#	COMMIT /* XID */
+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	#	Xid	#	#	COMMIT /* XID */
+DROP TABLE t1;
diff -Nrup a/mysql-test/suite/binlog/t/binlog_implicit_commit.test b/mysql-test/suite/binlog/t/binlog_implicit_commit.test
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/mysql-test/suite/binlog/t/binlog_implicit_commit.test	2008-06-12 13:32:12 +02:00
@@ -0,0 +1,63 @@
+# The purpose of this test is to test that setting autocommit does a
+# commit of outstanding transactions and nothing is left pending in
+# the transaction cache.
+
+source include/have_log_bin.inc;
+source include/have_innodb.inc;
+
+# We need a transactional engine, so let's use InnoDB
+CREATE TABLE t1 (id INT) ENGINE = InnoDB;
+
+# Testing SET AUTOCOMMIT
+SET BINLOG_FORMAT = STATEMENT;
+
+let $cleanup = COMMIT;
+
+let $prepare = SET AUTOCOMMIT = 0;
+let $statement = SET AUTOCOMMIT = 1;
+source extra/binlog_tests/implicit.test;
+
+let $prepare = SET AUTOCOMMIT = 1;
+let $statement = SET AUTOCOMMIT = 1;
+source extra/binlog_tests/implicit.test;
+
+let $prepare = SET AUTOCOMMIT = 0;
+let $statement = SET AUTOCOMMIT = 0;
+source extra/binlog_tests/implicit.test;
+
+let $prepare = SET AUTOCOMMIT = 1;
+let $statement = SET AUTOCOMMIT = 0;
+source extra/binlog_tests/implicit.test;
+
+SET BINLOG_FORMAT = ROW;
+let $prepare = SET AUTOCOMMIT = 0;
+let $statement = SET AUTOCOMMIT = 1;
+source extra/binlog_tests/implicit.test;
+
+let $prepare = SET AUTOCOMMIT = 1;
+let $statement = SET AUTOCOMMIT = 1;
+source extra/binlog_tests/implicit.test;
+
+let $prepare = SET AUTOCOMMIT = 0;
+let $statement = SET AUTOCOMMIT = 0;
+source extra/binlog_tests/implicit.test;
+
+let $prepare = SET AUTOCOMMIT = 1;
+let $statement = SET AUTOCOMMIT = 0;
+source extra/binlog_tests/implicit.test;
+
+RESET MASTER;
+SET AUTOCOMMIT = 0;
+INSERT INTO t1 VALUES (1);
+source include/show_binlog_events.inc;
+LOCK TABLES t1 WRITE;
+source include/show_binlog_events.inc;
+INSERT INTO t1 VALUES (2);
+source include/show_binlog_events.inc;
+UNLOCK TABLES;
+source include/show_binlog_events.inc;
+COMMIT;
+source include/show_binlog_events.inc;
+
+# Cleaning up
+DROP TABLE t1;
diff -Nrup a/mysql-test/suite/falcon/r/rpl_falcon_bug_37221.result b/mysql-test/suite/falcon/r/rpl_falcon_bug_37221.result
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/mysql-test/suite/falcon/r/rpl_falcon_bug_37221.result	2008-06-12 13:32:12 +02:00
@@ -0,0 +1,38 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+[master]
+SET BINLOG_FORMAT = 'ROW';
+CREATE TABLE IF NOT EXISTS t1 (id INT) ENGINE = Falcon;
+SET AUTOCOMMIT=0;
+INSERT INTO t1 VALUES (1);
+SET AUTOCOMMIT=1;
+SELECT * FROM t1;
+id
+1
+[slave]
+SELECT * FROM t1;
+id
+1
+[master]
+BEGIN;
+INSERT INTO t1 VALUES (2);
+SET AUTOCOMMIT=1;
+[slave]
+SELECT * FROM t1 /* Should not contain 2 */;
+id
+1
+[master]
+INSERT INTO t1 VALUES (3);
+COMMIT;
+[slave]
+SELECT * FROM t1 /* Should contain 2 and 3 */;
+id
+1
+2
+3
+[master]
+DROP TABLE t1;
diff -Nrup a/mysql-test/suite/falcon/t/rpl_falcon_bug_37221.test b/mysql-test/suite/falcon/t/rpl_falcon_bug_37221.test
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/mysql-test/suite/falcon/t/rpl_falcon_bug_37221.test	2008-06-12 13:32:12 +02:00
@@ -0,0 +1,53 @@
+# BUG#37221: SET AUTOCOMMIT=1 does not commit binary log
+
+# Regression test to ensure that the bug does not re-appear. The test
+# is using the Falcon engine, but the problem is a generic case. See
+# binlog_implicit_commit.test for a more elaborate test.
+
+source include/master-slave.inc;
+
+--echo [master]
+connection master;
+SET BINLOG_FORMAT = 'ROW';
+
+CREATE TABLE IF NOT EXISTS t1 (id INT) ENGINE = Falcon;
+
+# When switching to AUTOCOMMIT=1, there is an implicit commit if we
+# are outside a real transaction.
+
+SET AUTOCOMMIT=0;
+INSERT INTO t1 VALUES (1);
+SET AUTOCOMMIT=1;
+SELECT * FROM t1;
+--echo [slave]
+sync_slave_with_master;
+SELECT * FROM t1;
+
+# When inside a transaction, AUTOCOMMIT=1 should not commit the
+# transaction. This is hard to test for sure (since delays might cause
+# the transaction to not propagate fast enough), but it will not cause
+# any false negatives (just false positives).
+
+--echo [master]
+connection master;
+BEGIN;
+INSERT INTO t1 VALUES (2);
+SET AUTOCOMMIT=1;
+
+--echo [slave]
+connection slave;
+SELECT * FROM t1 /* Should not contain 2 */;
+
+--echo [master]
+connection master;
+INSERT INTO t1 VALUES (3);
+COMMIT;
+
+--echo [slave]
+sync_slave_with_master;
+SELECT * FROM t1 /* Should contain 2 and 3 */;
+
+--echo [master]
+connection master;
+DROP TABLE t1;
+sync_slave_with_master;
diff -Nrup a/sql/set_var.cc b/sql/set_var.cc
--- a/sql/set_var.cc	2008-04-01 15:44:53 +02:00
+++ b/sql/set_var.cc	2008-06-12 13:32:17 +02:00
@@ -2931,6 +2931,15 @@ static bool set_option_autocommit(THD *t
 
   ulonglong org_options= thd->options;
 
+  /*
+    If we are setting AUTOCOMMIT=1 and it was not already 1, then we
+    need to commit any outstanding transactions.
+   */
+  if (var->save_result.ulong_value != 0 &&
+      (thd->options & OPTION_NOT_AUTOCOMMIT) &&
+      ha_commit(thd))
+    return 1;
+
   if (var->save_result.ulong_value != 0)
     thd->options&= ~((sys_var_thd_bit*) var->var)->bit_flag;
   else
@@ -2944,8 +2953,6 @@ static bool set_option_autocommit(THD *t
       thd->options&= ~(ulonglong) (OPTION_BEGIN | OPTION_KEEP_LOG);
       thd->transaction.all.modified_non_trans_table= FALSE;
       thd->server_status|= SERVER_STATUS_AUTOCOMMIT;
-      if (ha_commit(thd))
-	return 1;
     }
     else
     {
Thread
bk commit into 6.0 tree (jperkin:1.2627) BUG#37221Jonathan Perkin12 Jun