mirror of
https://github.com/MariaDB/server.git
synced 2025-07-08 17:02:21 +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:
@ -951,4 +951,32 @@ NULL
|
||||
1
|
||||
Two
|
||||
drop tables t1;
|
||||
create table t1(f1 varchar(5) unique, f2 timestamp NOT NULL DEFAULT
|
||||
CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
|
||||
insert into t1(f1) values(1);
|
||||
select @a:=f2 from t1;
|
||||
@a:=f2
|
||||
#
|
||||
update t1 set f1=1;
|
||||
select @b:=f2 from t1;
|
||||
@b:=f2
|
||||
#
|
||||
select if(@a=@b,"ok","wrong");
|
||||
if(@a=@b,"ok","wrong")
|
||||
ok
|
||||
insert into t1(f1) values (1) on duplicate key update f1="1";
|
||||
select @b:=f2 from t1;
|
||||
@b:=f2
|
||||
#
|
||||
select if(@a=@b,"ok","wrong");
|
||||
if(@a=@b,"ok","wrong")
|
||||
ok
|
||||
insert into t1(f1) select f1 from t1 on duplicate key update f1="1";
|
||||
select @b:=f2 from t1;
|
||||
@b:=f2
|
||||
#
|
||||
select if(@a=@b,"ok","wrong");
|
||||
if(@a=@b,"ok","wrong")
|
||||
ok
|
||||
drop table t1;
|
||||
End of 5.1 tests
|
||||
|
Reference in New Issue
Block a user