Description:
I experience that one the first TIMESTAMP in a table definition an "ON UPDATE CURRENT_TIMESTAMP" takes effect *implicitly*. There is no such clause in table definition!
For TIMESTAMP *not first* in a table definition an no such implicit "ON UPDATE CURRENT_TIMESTAMP" happens.
How to repeat:
CREATE TABLE `timestamptable1` (
`TextField` varchar(20) NOT NULL,
`LastUpdate` timestamp NOT NULL,
`DateCreated` timestamp
) ENGINE=InnoDB;
CREATE TABLE `timestamptable2` (
`TextField` varchar(20) NOT NULL,
`DateCreated` timestamp,
`LastUpdate` timestamp NOT NULL
) ENGINE=InnoDB;
insert into timestamptable1 set TextField="Original Text", Datecreated = CURRENT_TIMESTAMP;
insert into timestamptable2 set TextField="Original Text", Datecreated = CURRENT_TIMESTAMP;
select * from timestamptable1;
/*
TextField LastUpdate DateCreated
------------- ------------------- -------------------
Original Text 2008-10-18 10:15:02 2008-10-18 10:15:02
*/
select * from timestamptable2;
/*
TextField DateCreated LastUpdate
------------- ------------------- -------------------
Original Text 2008-10-18 10:15:54 0000-00-00 00:00:00
*/
update timestamptable1 set TextField="Revised Text";
update timestamptable2 set TextField="Revised Text";
select * from timestamptable1;
/*
TextField LastUpdate DateCreated
------------ ------------------- -------------------
Revised Text 2008-10-18 10:19:10 2008-10-18 10:15:02
*/
select * from timestamptable2;
/*
TextField DateCreated LastUpdate
------------ ------------------- -------------------
Revised Text 2008-10-18 10:19:14 0000-00-00 00:00:00
*/
Suggested fix:
To mee this looks like TIMESTAMP behaviour of 3.x and 4.0.
Is it intentional and documented like this? To me this looks like a regression in code!