Commit e4b83507 authored by unknown's avatar unknown

ha_innodb.cc:

  Update the InnoDB internal auto-inc counter in ::write_row() if the statement is a REPLACE that fails in a duplicate key error: REPLACE will handle duplicate key error, and the insert will eventually succeed; note that we did NOT change InnoDB's behavior in an UPDATE, because updating the auto-inc counter in an UPDATE would require a bigger patch (Bug #11005)


sql/ha_innodb.cc:
  Update the InnoDB internal auto-inc counter in ::write_row() if the statement is a REPLACE that fails in a duplicate key error: REPLACE will handle duplicate key error, and the insert will eventually succeed; note that we did NOT change InnoDB's behavior in an UPDATE, because updating the auto-inc counter in an UPDATE would require a bigger patch (Bug #11005)
parent 2ce5fb13
......@@ -3221,6 +3221,23 @@ ha_innobase::write_row(
}
}
/* A REPLACE command and LOAD DATA INFILE REPLACE handle a duplicate
key error themselves, and we must update the autoinc counter if we are
performing those statements. */
if (error == DB_DUPLICATE_KEY && auto_inc_used
&& (user_thd->lex->sql_command == SQLCOM_REPLACE
|| user_thd->lex->sql_command == SQLCOM_REPLACE_SELECT
|| (user_thd->lex->sql_command == SQLCOM_LOAD
&& user_thd->lex->duplicates == DUP_REPLACE))) {
auto_inc = table->next_number_field->val_int();
if (auto_inc != 0) {
dict_table_autoinc_update(prebuilt->table, auto_inc);
}
}
innodb_srv_conc_exit_innodb(prebuilt->trx);
error = convert_error_code_to_mysql(error, user_thd);
......
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