diff options
author | gkodinov/kgeorge@magare.gmz <> | 2007-06-28 16:07:55 +0300 |
---|---|---|
committer | gkodinov/kgeorge@magare.gmz <> | 2007-06-28 16:07:55 +0300 |
commit | 71aaf52a2f8da334fc0b95c01bdfa8a5e5f602cb (patch) | |
tree | a2bf9e1b332e76cb81626a4f4952dfcd1f7eed99 /sql/sql_update.cc | |
parent | 960f8c02c89a0ed54f4d7edbc0695161726a9576 (diff) | |
download | mariadb-git-71aaf52a2f8da334fc0b95c01bdfa8a5e5f602cb.tar.gz |
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.
Diffstat (limited to 'sql/sql_update.cc')
-rw-r--r-- | sql/sql_update.cc | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 693ba779e5d..ef1f46bfdd2 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -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> ¬_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> ¬_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, |