1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00
This bug affects multi-row INSERT ... ON DUPLICATE into table
with PRIMARY KEY of AUTO_INCREMENT field and some additional UNIQUE indices.
If the first row in multi-row INSERT contains duplicated values of UNIQUE
indices, then following rows of multi-row INSERT (with either duplicated or
unique key field values) may me applied to _arbitrary_ records of table as
updates.
This bug was introduced in 5.0. Related code was widely rewritten in 5.1, and
5.1 is already free of this problem. 4.1 was not affected too.

When updating the row during INSERT ON DUPLICATE KEY UPDATE, we called
restore_auto_increment(), which set next_insert_id back to 0, but we
forgot to set clear_next_insert_id back to 0.
restore_auto_increment() function has been fixed.
This commit is contained in:
gshchepa/uchum@gleb.loc
2007-05-08 00:24:25 +05:00
parent 2cf753a1e8
commit eb1f21f8b6
4 changed files with 50 additions and 0 deletions

View File

@ -1685,7 +1685,14 @@ void handler::restore_auto_increment()
{
THD *thd= table->in_use;
if (thd->next_insert_id)
{
thd->next_insert_id= thd->prev_insert_id;
if (thd->next_insert_id == 0)
{
/* we didn't generate a value, engine will be called again */
thd->clear_next_insert_id= 0;
}
}
}