Bug #70548 | timestamp column being set to current time | ||
---|---|---|---|
Submitted: | 7 Oct 2013 22:37 | Modified: | 8 Oct 2013 18:06 |
Reporter: | Don Cohen | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S2 (Serious) |
Version: | 5.5.9-log | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[7 Oct 2013 22:37]
Don Cohen
[8 Oct 2013 5:25]
MySQL Verification Team
I suppose this testcase demonstrates the same thing? ---- drop temporary table if exists t1; create temporary table t1(a int, b timestamp)engine=innodb; insert into t1(a) values (1); select * from t1; select sleep(2); update t1 set a=2; select * from t1; ----
[8 Oct 2013 5:26]
MySQL Verification Team
http://dev.mysql.com/doc/refman/5.5/en/timestamp-initialization.html
[8 Oct 2013 12:04]
MySQL Verification Team
Please see Shane's comments. Thanks.
[8 Oct 2013 16:47]
Don Cohen
yes, it does: mysql> create temporary table t1(a int, b timestamp)engine=innodb; insert into t1(a) values (1); select * from t1; Query OK, 0 rows affected (0.39 sec) mysql> Query OK, 1 row affected (0.05 sec) mysql> +------+---------------------+ | a | b | +------+---------------------+ | 1 | 2013-10-08 09:44:29 | +------+---------------------+ 1 row in set (0.02 sec) mysql> update t1 set a=2; select * from t1; Query OK, 1 row affected (0.06 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> +------+---------------------+ | a | b | +------+---------------------+ | 2 | 2013-10-08 09:45:17 | +------+---------------------+ 1 row in set (0.03 sec) mysql>
[8 Oct 2013 16:56]
Don Cohen
Ok, the url explains why it's auto updating given that the table definition says `collectiontime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP Now I want to know why that is the result of doing this: alter table samplecollection change column processtime processtime timestamp; It seems like a very bad default. I don't yet even see how to override it. I hope that's not what I get when I do create table ... ,col1 timestamp, ...
[8 Oct 2013 17:06]
Don Cohen
ok, I now see that is exactly what I get -- in other words don't use timestamp as the type unless you want that behavior... (which I never have wanted before) Now I get to look through all my earlier code for timestamp columns.
[8 Oct 2013 18:06]
Sveta Smirnova
Thank you for the feedback. Closed as "Not a Bug", because this is well-defined, described behavior.