List:Commits« Previous MessageNext Message »
From:Guangbao Ni Date:February 18 2009 12:48pm
Subject:bzr commit into mysql-5.1-bugteam branch (gni:2805) Bug#41980
View as plain text  
#At file:///home/ngb/mysql/bzr/bugteam-5.1-bug41980/

 2805 Guangbao Ni	2009-02-18
      BUG#41980 SBL, INSERT .. SELECT .. LIMIT = ERROR, even when @@SQL_LOG_BIN is 0 !
      
      Don't judge whether the binary logging function is turned on, 
      directly issue the unsafe warning/error message when sql_mode=statement.
      
      Fixed with adding a condition which judge if the logging function is turned on.
added:
  mysql-test/suite/rpl/r/rpl_unsafe_error_msg.result
  mysql-test/suite/rpl/t/rpl_unsafe_error_msg.test
modified:
  sql/sql_class.cc

per-file messages:
  mysql-test/suite/rpl/r/rpl_unsafe_error_msg.result
    Test case result for unsafe warning/error message
  mysql-test/suite/rpl/t/rpl_unsafe_error_msg.test
    Test case for unsafe message warning/error
  sql/sql_class.cc
    Add a condition (sql_bin_log=on) for if statement
    in order to prevent from issuing the warning/error message
    when binary logging function is turned off.
=== added file 'mysql-test/suite/rpl/r/rpl_unsafe_error_msg.result'
--- a/mysql-test/suite/rpl/r/rpl_unsafe_error_msg.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_unsafe_error_msg.result	2009-02-18 12:46:49 +0000
@@ -0,0 +1,15 @@
+drop table if exists t1, t2;
+create table t1(i int primary key);
+create table t2(i int primary key);
+"Should issue message Statement is not safe to log in statement format."
+insert into t1 select * from t2 limit 1;
+Warnings:
+Warning	1592	Statement is not safe to log in statement format.
+set @@SQL_MODE=STRICT_ALL_TABLES;
+set @@SQL_LOG_BIN=0;
+"Should NOT have any warning message issued in the following statements"
+insert into t1 select * from t2 limit 1;
+set @@SQL_MODE=STRICT_ALL_TABLES;
+insert into t1 select * from t2 limit 1;
+drop table t1, t2;
+"End of tests"

=== added file 'mysql-test/suite/rpl/t/rpl_unsafe_error_msg.test'
--- a/mysql-test/suite/rpl/t/rpl_unsafe_error_msg.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_unsafe_error_msg.test	2009-02-18 12:46:49 +0000
@@ -0,0 +1,36 @@
+#
+#For bug#41980, SBL, INSERT .. SELECT .. LIMIT = ERROR, even when @@SQL_LOG_BIN is 0 
+#               Binary logging is turn off.
+#               warning/error shoulde be issued 
+#               when the statement is not safe for statement-based replication
+#
+
+# Requires statement logging
+-- source include/have_binlog_format_statement.inc
+
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+create table t1(i int primary key);
+create table t2(i int primary key);
+
+#The following statement should issue warning message
+--echo "Should issue message Statement is not safe to log in statement format."
+insert into t1 select * from t2 limit 1;
+
+set @@SQL_MODE=STRICT_ALL_TABLES;
+#The following statement should issue error message
+# The following statement make mysqld crash, so it commeted out before bug#42640 is fixed
+#insert into t1 select * from t2 limit 1;
+
+set @@SQL_LOG_BIN=0;
+--echo "Should NOT have any warning message issued in the following statements"
+#The following statement should NOT issue warning/error message
+insert into t1 select * from t2 limit 1;
+
+set @@SQL_MODE=STRICT_ALL_TABLES;
+insert into t1 select * from t2 limit 1;
+
+#clean up
+drop table t1, t2;
+--echo "End of tests"

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2009-02-13 16:20:56 +0000
+++ b/sql/sql_class.cc	2009-02-18 12:46:49 +0000
@@ -3662,7 +3662,8 @@ int THD::binlog_query(THD::enum_binlog_q
     If we are in statement mode and trying to log an unsafe statement,
     we should print a warning.
   */
-  if (lex->is_stmt_unsafe() &&
+  if ((options & OPTION_BIN_LOG) &&
+      lex->is_stmt_unsafe() &&
       variables.binlog_format == BINLOG_FORMAT_STMT)
   {
     push_warning(this, MYSQL_ERROR::WARN_LEVEL_WARN,

Thread
bzr commit into mysql-5.1-bugteam branch (gni:2805) Bug#41980Guangbao Ni18 Feb