mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 13:02:28 +01:00
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)
This commit is contained in:
parent
ac76e6db6a
commit
8a3c1ae851
1 changed files with 17 additions and 0 deletions
|
@ -3221,6 +3221,23 @@ no_commit:
|
|||
}
|
||||
}
|
||||
|
||||
/* 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);
|
||||
|
|
Loading…
Reference in a new issue