diff options
author | unknown <evgen@moonbone.local> | 2007-06-12 01:41:23 +0400 |
---|---|---|
committer | unknown <evgen@moonbone.local> | 2007-06-12 01:41:23 +0400 |
commit | ccf393b67a9bcf52db91806f49c940ccd08545cc (patch) | |
tree | d6397e6bc275da4f6312afe4726409c25b52ca8d /sql/sql_insert.cc | |
parent | 59d139eb293e1bcf72cf544e2b8dbe9216ee7acb (diff) | |
download | mariadb-git-ccf393b67a9bcf52db91806f49c940ccd08545cc.tar.gz |
Bug#28904: INSERT .. ON DUPLICATE was silently updating rows when it shouldn't.
When the INSERT .. ON DUPLICATE KEY UPDATE has to update a matched row but
the new data is the same as in the record then it returns as if
no rows were inserted or updated. Nevertheless the row is silently
updated. This leads to a situation when zero updated rows are reported
in the case when data has actually been changed.
Now the write_record function updates a row only if new data differs from
that in the record.
sql/sql_insert.cc:
Bug#28904: INSERT .. ON DUPLICATE was silently updating rows when it shouldn't.
Now the write_record function updates a row only if new data differs from
that in the record.
mysql-test/r/insert_update.result:
Added a test case for the bug#28904: INSERT .. ON DUPLICATE was silently
updating rows when it shouldn't.
mysql-test/t/insert_update.test:
Added a test case for the bug#28904: INSERT .. ON DUPLICATE was silently
updating rows when it shouldn't.
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r-- | sql/sql_insert.cc | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index f3ed3ebab24..228fc8860ae 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1404,23 +1404,18 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) goto before_trg_err; table->file->restore_auto_increment(); - if ((error=table->file->update_row(table->record[1],table->record[0]))) + if ((table->file->table_flags() & HA_PARTIAL_COLUMN_READ) || + compare_record(table, thd->query_id)) { - if ((error == HA_ERR_FOUND_DUPP_KEY) && info->ignore) + if ((error=table->file->update_row(table->record[1],table->record[0]))) { - goto ok_or_after_trg_err; + if ((error == HA_ERR_FOUND_DUPP_KEY) && info->ignore) + { + goto ok_or_after_trg_err; + } + goto err; } - goto err; - } - - if (table->next_number_field) - table->file->adjust_next_insert_id_after_explicit_value( - table->next_number_field->val_int()); - info->touched++; - if ((table->file->table_flags() & HA_PARTIAL_COLUMN_READ) || - compare_record(table, thd->query_id)) - { info->updated++; trg_error= (table->triggers && table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, @@ -1429,6 +1424,11 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) info->copied++; } + if (table->next_number_field) + table->file->adjust_next_insert_id_after_explicit_value( + table->next_number_field->val_int()); + info->touched++; + goto ok_or_after_trg_err; } else /* DUP_REPLACE */ |