1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Fix bug #10886 - INSERT ... SELECT ... ON DUPLICATE KEY UPDATE produces bad results

Temporary field wasn't restored to default values after ON DUPLICATE KEY
 UPDATE event, which results in wrong data being inserted in new record.
This commit is contained in:
evgen@moonbone.local
2005-06-21 22:24:58 +04:00
parent 362a45fd34
commit dc381ea960
3 changed files with 33 additions and 4 deletions

View File

@ -1625,11 +1625,22 @@ bool select_insert::send_data(List<Item> &values)
store_values(values);
error=thd->net.report_error || write_record(table,&info);
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
if (!error && table->next_number_field) // Clear for next record
if (!error)
{
table->next_number_field->reset();
if (! last_insert_id && thd->insert_id_used)
last_insert_id=thd->insert_id();
/*
Restore fields of the record since it is possible that they were
changed by ON DUPLICATE KEY UPDATE clause.
*/
if (info.handle_duplicates == DUP_UPDATE)
restore_record(table, default_values);
if (table->next_number_field) // Clear for next record
{
table->next_number_field->reset();
if (! last_insert_id && thd->insert_id_used)
last_insert_id=thd->insert_id();
}
}
DBUG_RETURN(error);
}