summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <Li-Bing.Song@sun.com>2009-09-10 18:05:53 +0800
committerunknown <Li-Bing.Song@sun.com>2009-09-10 18:05:53 +0800
commite436b8866be640b2160f0b756f85559437cff67d (patch)
tree538e6a864b103b7e754288ccbccc74d3911e8fd3 /sql
parent104d9ce76a68fd3da2f9217514a4c61454802c1d (diff)
downloadmariadb-git-e436b8866be640b2160f0b756f85559437cff67d.tar.gz
BUG#45999 Row based replication fails when auto_increment field = 0
In RBR, There is an inconsistency between slaves and master. When INSERT statement which includes an auto_increment field is executed, Store engine of master will check the value of the auto_increment field. It will generate a sequence number and then replace the value, if its value is NULL or empty. if the field's value is 0, the store engine will do like encountering the NULL values unless NO_AUTO_VALUE_ON_ZERO is set into SQL_MODE. In contrast, if the field's value is 0, Store engine of slave always generates a new sequence number whether or not NO_AUTO_VALUE_ON_ZERO is set into SQL_MODE. SQL MODE of slave sql thread is always consistency with master's. Another variable is related to this bug. If generateing a sequence number is decided by the values of table->auto_increment_field_not_null and SQL_MODE(if includes MODE_NO_AUTO_VALUE_ON_ZERO) The table->auto_increment_is_not_null is FALSE, which causes this bug to appear. ..
Diffstat (limited to 'sql')
-rw-r--r--sql/log_event.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 0cda724b698..08fe3aba8ed 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -8312,6 +8312,16 @@ Write_rows_log_event::do_before_row_operations(const Slave_reporting_capability
/* Honor next number column if present */
m_table->next_number_field= m_table->found_next_number_field;
+ /*
+ * Fixed Bug#45999, In RBR, Store engine of Slave auto-generates new
+ * sequence numbers for auto_increment fields if the values of them are 0.
+ * If generateing a sequence number is decided by the values of
+ * table->auto_increment_field_not_null and SQL_MODE(if includes
+ * MODE_NO_AUTO_VALUE_ON_ZERO) in update_auto_increment function.
+ * SQL_MODE of slave sql thread is always consistency with master's.
+ * In RBR, auto_increment fields never are NULL.
+ */
+ m_table->auto_increment_field_not_null= TRUE;
return error;
}
@@ -8321,6 +8331,7 @@ Write_rows_log_event::do_after_row_operations(const Slave_reporting_capability *
{
int local_error= 0;
m_table->next_number_field=0;
+ m_table->auto_increment_field_not_null= FALSE;
if (bit_is_set(slave_exec_mode, SLAVE_EXEC_MODE_IDEMPOTENT) == 1 ||
m_table->s->db_type()->db_type == DB_TYPE_NDBCLUSTER)
{