List:Internals« Previous MessageNext Message »
From:Mats Kindahl Date:February 14 2005 5:39pm
Subject:bk commit into 4.0 tree (mats:1.2060) BUG#8412
View as plain text  
Below is the list of changes that have just been committed into a local
4.0 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
  1.2060 05/02/14 18:39:33 mats@stripped +3 -0
  Bug#8412: For replication to work correctly, the prologue and 
  epilogue to an SQL statement should not have an error code even
  when the SQL statement itself has an error code.

  sql/log.cc
    1.161 05/02/14 18:39:32 mats@stripped +14 -1
    Setting error code to 0 for SQL statement prologue and epilogue.

  mysql-test/t/rpl_insert_id.test
    1.7 05/02/14 18:39:32 mats@stripped +16 -0
    Adding test to ensure that slave handles error statement gracefully.

  mysql-test/r/rpl_insert_id.result
    1.7 05/02/14 18:39:31 mats@stripped +5 -0
    Adding test to ensure that slave handles error statement gracefully.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	mats
# Host:	romeo.kindahl.net
# Root:	/home/bk/b8412-mysql-4.0

--- 1.160/sql/log.cc	2004-12-07 12:08:17 +01:00
+++ 1.161/sql/log.cc	2005-02-14 18:39:32 +01:00
@@ -1182,6 +1182,7 @@
 	p= strmov(strmov(buf, "SET CHARACTER SET "),
 		  thd->variables.convert_set->name);
 	Query_log_event e(thd, buf, (ulong) (p - buf), 0);
+	e.error_code = 0;	// This statement cannot fail (see [1]).
 	e.set_log_pos(this);
 	if (e.write(file))
 	  goto err;
@@ -1199,12 +1200,22 @@
       {
 	Query_log_event e(thd, "SET FOREIGN_KEY_CHECKS=0", 24, 0);
 	e.set_log_pos(this);
+	e.error_code = 0;	// This statement cannot fail (see [1]).
 	if (e.write(file))
 	  goto err;
       }
     }
 
-    /* Write the SQL command */
+    /* 
+       Write the SQL command 
+       
+       [1] If this statement has an error code, the slave is required to fail
+           with the same error code or stop. The preamble and epilogue should
+           *not* have this error code since the execution of those is
+           guaranteed *not* to produce any error code. This would therefore
+           stop the slave even if the execution of the real statement can be
+           handled gracefully by the slave.
+     */
 
     event_info->set_log_pos(this);
     if (event_info->write(file))
@@ -1218,6 +1229,7 @@
       {
         Query_log_event e(thd, "SET FOREIGN_KEY_CHECKS=1", 24, 0);
         e.set_log_pos(this);
+	e.error_code = 0;	// This statement cannot fail (see [1]).
         if (e.write(file))
           goto err;
       }
@@ -1226,6 +1238,7 @@
       {
 	Query_log_event e(thd, "SET CHARACTER SET DEFAULT", 25, 0);
 	e.set_log_pos(this);
+	e.error_code = 0;	// This statement cannot fail (see [1]).
 	if (e.write(file))
 	  goto err;
       }

--- 1.6/mysql-test/r/rpl_insert_id.result	2004-02-02 00:40:37 +01:00
+++ 1.7/mysql-test/r/rpl_insert_id.result	2005-02-14 18:39:31 +01:00
@@ -69,3 +69,8 @@
 9	13
 drop table t1;
 drop table t2;
+SET TIMESTAMP=1000000000;
+CREATE TABLE t1 ( a INT UNIQUE );
+SET FOREIGN_KEY_CHECKS=0;
+INSERT INTO t1 VALUES (1),(1);
+Duplicate entry '1' for key 1

--- 1.6/mysql-test/t/rpl_insert_id.test	2004-02-02 00:41:05 +01:00
+++ 1.7/mysql-test/t/rpl_insert_id.test	2005-02-14 18:39:32 +01:00
@@ -62,3 +62,19 @@
 save_master_pos;
 connection slave;
 sync_with_master;
+
+#
+# Bug#8412: Error codes reported in binary log for CHARACTER SET,
+#           FOREIGN_KEY_CHECKS
+#
+connection master;
+SET TIMESTAMP=1000000000;
+CREATE TABLE t1 ( a INT UNIQUE );
+SET FOREIGN_KEY_CHECKS=0;
+--error 1062
+INSERT INTO t1 VALUES (1),(1);
+sync_slave_with_master;
+
+
+
+
Thread
bk commit into 4.0 tree (mats:1.2060) BUG#8412Mats Kindahl14 Feb