ha_innodb.cc:

Manually ported this bug fix from 4.0: 
 Fix InnoDB bug #6287: if one uses INSERT IGNORE to insert several rows at a time, and the first inserts are ignored because of a duplicate key collision, then InnoDB in a replication slave assigns AUTO_INCREMENT values 1 bigger than in the master
parent a69ddb03
...@@ -2390,8 +2390,9 @@ ha_innobase::write_row( ...@@ -2390,8 +2390,9 @@ ha_innobase::write_row(
same SQL statement! */ same SQL statement! */
if (auto_inc == 0 && user_thd->next_insert_id != 0) { if (auto_inc == 0 && user_thd->next_insert_id != 0) {
auto_inc = user_thd->next_insert_id;
auto_inc_counter_for_this_stat = auto_inc; auto_inc_counter_for_this_stat
= user_thd->next_insert_id;
} }
if (auto_inc == 0 && auto_inc_counter_for_this_stat) { if (auto_inc == 0 && auto_inc_counter_for_this_stat) {
...@@ -2399,14 +2400,14 @@ ha_innobase::write_row( ...@@ -2399,14 +2400,14 @@ ha_innobase::write_row(
this SQL statement with SET INSERT_ID. We must this SQL statement with SET INSERT_ID. We must
assign sequential values from the counter. */ assign sequential values from the counter. */
auto_inc_counter_for_this_stat++;
incremented_auto_inc_for_stat = TRUE;
auto_inc = auto_inc_counter_for_this_stat; auto_inc = auto_inc_counter_for_this_stat;
/* We give MySQL a new value to place in the /* We give MySQL a new value to place in the
auto-inc column */ auto-inc column */
user_thd->next_insert_id = auto_inc; user_thd->next_insert_id = auto_inc;
auto_inc_counter_for_this_stat++;
incremented_auto_inc_for_stat = TRUE;
} }
if (auto_inc != 0) { if (auto_inc != 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment