diff options
author | unknown <gshchepa/uchum@gleb.loc> | 2007-05-08 00:24:25 +0500 |
---|---|---|
committer | unknown <gshchepa/uchum@gleb.loc> | 2007-05-08 00:24:25 +0500 |
commit | 35659a285d3bf1c18798cd2819c18d3d6fca8e55 (patch) | |
tree | 87b2e5da90d760cfa0520e274d66d96828f5bef1 /sql/handler.cc | |
parent | 5352b41d29bf3a0ca37d64acfa61527a4944812d (diff) | |
download | mariadb-git-35659a285d3bf1c18798cd2819c18d3d6fca8e55.tar.gz |
Fixed bug #27954.
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.
Diffstat (limited to 'sql/handler.cc')
-rw-r--r-- | sql/handler.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index c6c31593a5f..867ac7ff778 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -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; + } + } } |