1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Bug#29310: An InnoDB table was updated when the data wasn't actually changed.

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.


mysql-test/r/innodb_mysql.result:
  Added a test case for the bug#29310: An InnoDB table was updated when the data wasn't actually changed.
mysql-test/include/mix1.inc:
  Added a test case for the bug#29310: An InnoDB table was updated when the data wasn't actually changed.
sql/sql_update.cc:
  Bug#29310: An InnoDB table was updated when the data wasn't actually changed.
  Now the mysql_update function when an auto-updatable timestamp field is
  present marks write-only fields as to be read to force the table handler
  to retrieve them.
sql/sql_insert.cc:
  Bug#29310: An InnoDB table was updated when the data wasn't actually changed.
  Now the write_record function can compare records when fileds to be written is
  a subset of the fields to be read while updating a record.
This commit is contained in:
unknown
2007-07-08 18:13:04 +04:00
parent bc52d1d6e3
commit a68a457be8
4 changed files with 65 additions and 1 deletions

View File

@@ -231,6 +231,17 @@ int mysql_update(THD *thd,
if (cond_value == Item::COND_FALSE)
limit= 0; // Impossible WHERE
}
/*
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);
// Don't count on usage of 'only index' when calculating which key to use
table->covering_keys.clear_all();