1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +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.


sql/sql_class.h:
  Fixed bug #27954.
  Added commentary for THD::clear_next_insert_id variable.
sql/handler.cc:
  Fixed bug #27954.
  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.
mysql-test/t/insert_update.test:
  Added test case for bug #27954.
mysql-test/r/insert_update.result:
  Added test case for bug #27954.
This commit is contained in:
unknown
2007-05-08 00:24:25 +05:00
parent 5352b41d29
commit 35659a285d
4 changed files with 50 additions and 0 deletions

View File

@@ -1431,6 +1431,10 @@ public:
*/
bool insert_id_used;
/*
clear_next_insert_id is set if engine was called at least once
for this statement to generate auto_increment value.
*/
bool clear_next_insert_id;
/* for IS NULL => = last_insert_id() fix in remove_eq_conds() */
bool substitute_null_with_insert_id;