From: Date: November 3 2008 12:14pm Subject: bzr commit into mysql-5.1 branch (mats:2773) Bug#40360 List-Archive: http://lists.mysql.com/commits/57684 X-Bug: 40360 Message-Id: <20081103111457.3CD43469FF3@romeo> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit #At file:///home/bzr/bugs/b40360-5.1/ 2773 Mats Kindahl 2008-11-03 Bug #40360: Binlog related errors with binlog off When statement-based replication is used, and the transaction isolation level is READ-COMMITTED or stricter, InnoDB will print an error because statement-based replication might lead to inconsistency between master and slave databases. However, when the binary log is not engaged, this is not an issue and an error should not be printed. This patch makes thd_binlog_format() return BINLOG_FORMAT_ UNSPEC when the binary log is not engaged for the given thread. modified: mysql-test/r/innodb_mysql.result mysql-test/t/innodb_mysql.test sql/sql_class.cc per-file messages: mysql-test/t/innodb_mysql.test Adding test that no error message is printed from inside InnoDB when the binary log is turned off. === modified file 'mysql-test/r/innodb_mysql.result' --- a/mysql-test/r/innodb_mysql.result 2008-10-03 12:24:19 +0000 +++ b/mysql-test/r/innodb_mysql.result 2008-11-03 11:14:48 +0000 @@ -1668,3 +1668,16 @@ explain select a from t2 where a=b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index NULL a 10 NULL # Using where; Using index drop table t1, t2; +SET SESSION BINLOG_FORMAT=STATEMENT; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +SHOW VARIABLES LIKE 'log_bin'; +Variable_name Value +log_bin OFF +SELECT @@session.binlog_format; +@@session.binlog_format +STATEMENT +SELECT @@session.tx_isolation; +@@session.tx_isolation +READ-COMMITTED +CREATE TABLE t1 ( a INT ) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1); === modified file 'mysql-test/t/innodb_mysql.test' --- a/mysql-test/t/innodb_mysql.test 2008-05-07 05:58:21 +0000 +++ b/mysql-test/t/innodb_mysql.test 2008-11-03 11:14:48 +0000 @@ -29,3 +29,18 @@ insert into t2 select @a:=A.a+10*(B.a + explain select a from t2 where a=b; drop table t1, t2; +# +# Bug #40360: Binlog related errors with binlog off +# +# This bug is triggered when the binlog format is STATEMENT and the +# binary log is turned off. In this case, no error should be shown for +# the statement since there are no replication issues. + +SET SESSION BINLOG_FORMAT=STATEMENT; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +SHOW VARIABLES LIKE 'log_bin'; +SELECT @@session.binlog_format; +SELECT @@session.tx_isolation; +CREATE TABLE t1 ( a INT ) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1); + === modified file 'sql/sql_class.cc' --- a/sql/sql_class.cc 2008-10-21 12:18:38 +0000 +++ b/sql/sql_class.cc 2008-11-03 11:14:48 +0000 @@ -2852,7 +2852,10 @@ extern "C" int thd_non_transactional_upd extern "C" int thd_binlog_format(const MYSQL_THD thd) { - return (int) thd->variables.binlog_format; + if (mysql_bin_log.is_open() && (thd->options & OPTION_BIN_LOG)) + return (int) thd->variables.binlog_format; + else + return BINLOG_FORMAT_UNSPEC; } extern "C" void thd_mark_transaction_to_rollback(MYSQL_THD thd, bool all)