mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Bug #29157: UPDATE, changed rows incorrect
Sometimes the number of really updated rows (with changed column values) cannot be determined at the server level alone (e.g. if the storage engine does not return enough column values to verify that). So the only dependable way in such cases is to let the storage engine return that information if possible. Fixed the bug at server level by providing a way for the storage engine to return information about wether it actually updated the row or the old and the new column values are the same. It can do that by returning HA_ERR_RECORD_IS_THE_SAME in ha_update_row(). Note that each storage engine may choose not to try to return this status code, so this behaviour remains storage engine specific. include/my_base.h: Bug #29157: handle the row not updated special return value sql/log_event.cc: Bug #29157: handle the row not updated special return value sql/sp.cc: Bug #29157: handle the row not updated special return value sql/sql_acl.cc: Bug #29157: handle the row not updated special return value sql/sql_insert.cc: Bug #29157: handle the row not updated special return value sql/sql_servers.cc: Bug #29157: handle the row not updated special return value sql/sql_update.cc: Bug #29157: handle the row not updated special return value
This commit is contained in:
@@ -1423,7 +1423,8 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
|
||||
compare_record(table))
|
||||
{
|
||||
if ((error=table->file->ha_update_row(table->record[1],
|
||||
table->record[0])))
|
||||
table->record[0])) &&
|
||||
error != HA_ERR_RECORD_IS_THE_SAME)
|
||||
{
|
||||
if (info->ignore &&
|
||||
!table->file->is_fatal_error(error, HA_CHECK_DUP_KEY))
|
||||
@@ -1433,7 +1434,10 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
|
||||
goto err;
|
||||
}
|
||||
|
||||
info->updated++;
|
||||
if (error != HA_ERR_RECORD_IS_THE_SAME)
|
||||
info->updated++;
|
||||
else
|
||||
error= 0;
|
||||
/*
|
||||
If ON DUP KEY UPDATE updates a row instead of inserting one, it's
|
||||
like a regular UPDATE statement: it should not affect the value of a
|
||||
@@ -1481,9 +1485,13 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
|
||||
(!table->triggers || !table->triggers->has_delete_triggers()))
|
||||
{
|
||||
if ((error=table->file->ha_update_row(table->record[1],
|
||||
table->record[0])))
|
||||
table->record[0])) &&
|
||||
error != HA_ERR_RECORD_IS_THE_SAME)
|
||||
goto err;
|
||||
info->deleted++;
|
||||
if (error != HA_ERR_RECORD_IS_THE_SAME)
|
||||
info->deleted++;
|
||||
else
|
||||
error= 0;
|
||||
thd->record_first_successful_insert_id_in_cur_stmt(table->file->insert_id_for_cur_row);
|
||||
/*
|
||||
Since we pretend that we have done insert we should call
|
||||
|
Reference in New Issue
Block a user