1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +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.
This commit is contained in:
gkodinov/kgeorge@magare.gmz
2007-06-28 16:07:55 +03:00
parent 960f8c02c8
commit 71aaf52a2f
7 changed files with 79 additions and 26 deletions

View File

@@ -548,9 +548,12 @@ int mysql_update(THD *thd,
error= table->file->ha_update_row(table->record[1],
table->record[0]);
}
if (!error)
if (!error || error == HA_ERR_RECORD_IS_THE_SAME)
{
updated++;
if (error != HA_ERR_RECORD_IS_THE_SAME)
updated++;
else
error= 0;
thd->no_trans_update.stmt= !transactional_table;
if (table->triggers &&
@@ -1524,7 +1527,8 @@ bool multi_update::send_data(List<Item> &not_used_values)
main_table->file->extra(HA_EXTRA_PREPARE_FOR_UPDATE);
}
if ((error=table->file->ha_update_row(table->record[1],
table->record[0])))
table->record[0])) &&
error != HA_ERR_RECORD_IS_THE_SAME)
{
updated--;
if (!ignore ||
@@ -1542,6 +1546,11 @@ bool multi_update::send_data(List<Item> &not_used_values)
}
else
{
if (error == HA_ERR_RECORD_IS_THE_SAME)
{
error= 0;
updated--;
}
/* non-transactional or transactional table got modified */
/* either multi_update class' flag is raised in its branch */
if (table->file->has_transactions())
@@ -1768,13 +1777,17 @@ int multi_update::do_updates(bool from_send_error)
goto err;
}
if ((local_error=table->file->ha_update_row(table->record[1],
table->record[0])))
table->record[0])) &&
local_error != HA_ERR_RECORD_IS_THE_SAME)
{
if (!ignore ||
table->file->is_fatal_error(local_error, HA_CHECK_DUP_KEY))
goto err;
}
updated++;
if (local_error != HA_ERR_RECORD_IS_THE_SAME)
updated++;
else
local_error= 0;
if (table->triggers &&
table->triggers->process_triggers(thd, TRG_EVENT_UPDATE,