List:Commits« Previous MessageNext Message »
From:He Zhenxing Date:January 14 2009 8:27am
Subject:bzr commit into mysql-5.1-bugteam branch (zhenxing.he:2747) Bug#41986
View as plain text  
#At file:///media/sdb2/hezx/work/mysql/bzrwork/b41986/5.1-bugteam/

 2747 He Zhenxing	2009-01-14
      BUG#41986 Replication slave does not pick up proper AUTO_INCREMENT value for Innodb tables
      
      The next number (AUTO_INCREMENT) field of the table for write
      rows events are not initialized, and cause some engines (innodb)
      not correctly update the tables's auto_increment value.
      
      This patch fixed this problem by honor next number fields if present.
modified:
  mysql-test/extra/rpl_tests/rpl_auto_increment.test
  mysql-test/suite/rpl/r/rpl_auto_increment.result
  sql/log_event.cc

per-file messages:
  mysql-test/extra/rpl_tests/rpl_auto_increment.test
    Add test code for BUG#41986
  mysql-test/suite/rpl/r/rpl_auto_increment.result
    update test result file for BUG#41986
  sql/log_event.cc
    set next_number_field before writing rows, and reset next_number_field after finished writing rows
=== modified file 'mysql-test/extra/rpl_tests/rpl_auto_increment.test'
--- a/mysql-test/extra/rpl_tests/rpl_auto_increment.test	2007-06-06 17:57:07 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_auto_increment.test	2009-01-14 08:27:32 +0000
@@ -145,6 +145,23 @@ select * from t3 order by a;
 connection master;
 
 drop table t1,t2,t3;
+sync_slave_with_master;
+
+#
+# BUG#41986 Replication slave does not pick up proper AUTO_INCREMENT value for Innodb tables
+#
+connection master;
+set auto_increment_increment=1;
+set auto_increment_offset=1;
+CREATE TABLE t1 (id MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=innodb;
+INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
+show create table t1;
+
+sync_slave_with_master;
+show create table t1;
+
+connection master;
+drop table t1;
 
 # End cleanup
 sync_slave_with_master;

=== modified file 'mysql-test/suite/rpl/r/rpl_auto_increment.result'
--- a/mysql-test/suite/rpl/r/rpl_auto_increment.result	2007-06-27 12:28:02 +0000
+++ b/mysql-test/suite/rpl/r/rpl_auto_increment.result	2009-01-14 08:27:32 +0000
@@ -227,3 +227,20 @@ select * from t3 order by a;
 a
 127
 drop table t1,t2,t3;
+set auto_increment_increment=1;
+set auto_increment_offset=1;
+CREATE TABLE t1 (id MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=innodb;
+INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `id` mediumint(9) NOT NULL AUTO_INCREMENT,
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `id` mediumint(9) NOT NULL AUTO_INCREMENT,
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
+drop table t1;

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2009-01-05 16:10:20 +0000
+++ b/sql/log_event.cc	2009-01-14 08:27:32 +0000
@@ -8091,6 +8091,9 @@ Write_rows_log_event::do_before_row_oper
     analyze if explicit data is provided for slave's TIMESTAMP columns).
   */
   m_table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
+  
+  /* Honor next number column if present */
+  m_table->next_number_field= m_table->found_next_number_field;
   return error;
 }
 
@@ -8099,6 +8102,7 @@ Write_rows_log_event::do_after_row_opera
                                               int error)
 {
   int local_error= 0;
+  m_table->next_number_field=0;
   if (bit_is_set(slave_exec_mode, SLAVE_EXEC_MODE_IDEMPOTENT) == 1 ||
       m_table->s->db_type()->db_type == DB_TYPE_NDBCLUSTER)
   {

Thread
bzr commit into mysql-5.1-bugteam branch (zhenxing.he:2747) Bug#41986He Zhenxing14 Jan