summaryrefslogtreecommitdiff
path: root/sql/sql_insert.cc
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2005-06-06 20:41:52 +0300
committerunknown <monty@mysql.com>2005-06-06 20:41:52 +0300
commit9595c788f9857d0e712f6659d3a0d85300aa0f7b (patch)
tree17b738558f52110891f2e7512fe70f70ae16ea5e /sql/sql_insert.cc
parenta0682cac4763061d34e4659da8a27866624e6f5b (diff)
downloadmariadb-git-9595c788f9857d0e712f6659d3a0d85300aa0f7b.tar.gz
Ensure that we reset auto-increment cache if we have to do an UPDATE becasue of REPLACE
This fixes bug #11080: Multi-row REPLACE fails on a duplicate key error mysql-test/r/auto_increment.result: New tests for auto-increment and replace mysql-test/r/innodb.result: New tests for auto-increment and replace mysql-test/t/auto_increment.test: New tests for auto-increment and replace mysql-test/t/innodb.test: New tests for auto-increment and replace mysys/my_alloc.c: More comments
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r--sql/sql_insert.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index dbecfe1489e..6fb871cbc9d 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -916,6 +916,12 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
if (res == VIEW_CHECK_ERROR)
goto before_trg_err;
+ if (thd->clear_next_insert_id)
+ {
+ /* Reset auto-increment cacheing if we do an update */
+ thd->clear_next_insert_id= 0;
+ thd->next_insert_id= 0;
+ }
if ((error=table->file->update_row(table->record[1],table->record[0])))
{
if ((error == HA_ERR_FOUND_DUPP_KEY) && info->ignore)
@@ -949,6 +955,12 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
table->triggers->process_triggers(thd, TRG_EVENT_UPDATE,
TRG_ACTION_BEFORE, TRUE))
goto before_trg_err;
+ if (thd->clear_next_insert_id)
+ {
+ /* Reset auto-increment cacheing if we do an update */
+ thd->clear_next_insert_id= 0;
+ thd->next_insert_id= 0;
+ }
if ((error=table->file->update_row(table->record[1],
table->record[0])))
goto err;