diff options
author | Georgi Kodinov <joro@sun.com> | 2010-04-28 15:55:54 +0300 |
---|---|---|
committer | Georgi Kodinov <joro@sun.com> | 2010-04-28 15:55:54 +0300 |
commit | 4d0e9957acdddf7a07e095ef2e8f53a2cb99b24b (patch) | |
tree | 41ec718dfcd507a7c17133735e455579a9db766f /sql/sql_update.cc | |
parent | 7b46404b14220f15532acefca57d3db2d7a2106e (diff) | |
download | mariadb-git-4d0e9957acdddf7a07e095ef2e8f53a2cb99b24b.tar.gz |
Bug #47453: InnoDB incorrectly changes TIMESTAMP columns when JOINed
during an UPDATE
Extended the fix for bug 29310 to multi-table update:
When a table is being updated it has two set of fields - fields required for
checks of conditions and fields to be updated. A storage engine is allowed
not to retrieve columns marked for update. Due to this fact records can't
be compared to see whether the data has been changed or not. This makes the
server always update records independently of data change.
Now when an auto-updatable timestamp field is present and server sees that
a table handle isn't going to retrieve write-only fields then all of such
fields are marked as to be read to force the handler to retrieve them.
Diffstat (limited to 'sql/sql_update.cc')
-rw-r--r-- | sql/sql_update.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 63af275cef3..d8141deba63 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -1379,6 +1379,16 @@ int multi_update::prepare(List<Item> ¬_used_values, { table->read_set= &table->def_read_set; bitmap_union(table->read_set, &table->tmp_set); + /* + If a timestamp field settable on UPDATE is present then to avoid wrong + update force the table handler to retrieve write-only fields to be able + to compare records and detect data change. + */ + if (table->file->ha_table_flags() & HA_PARTIAL_COLUMN_READ && + table->timestamp_field && + (table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_UPDATE || + table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_BOTH)) + bitmap_union(table->read_set, table->write_set); } } |