Bug #67914 Timestamp auto update column not updated on each update statement
| Submitted: | 16 Dec 2012 10:36 | Modified: | 18 Jan 2013 15:07 |
|---|---|---|---|
| Reporter: | Mohammad Lahlouh | Email Updates: | |
| Status: | No Feedback | Impact on me: | |
| Category: | MySQL Server | Severity: | S2 (Serious) |
| Version: | 5.5.20 | OS: | Linux (ubuntu) |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | auto-update, current_timestamp, timestamp | ||
[16 Dec 2012 10:36]
Mohammad Lahlouh
[18 Dec 2012 15:07]
Sveta Smirnova
Thank you for the report. > But sometime i update the record to set record_posted_date = now(), and i expected to auto update mv_ts column to current_timestamp, but mv_ts keep 0000-00-00 without any changes. Do you mean you created mv_ts after you have some data in table? I tried to repeat it with minimal test case, but could not: create table t1( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `record_posted_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`), KEY `rec_posted_dt_idx` (`record_posted_date`) ); insert into t1(record_posted_date) values (now()); insert into t1(record_posted_date) select record_posted_date from t1; insert into t1(record_posted_date) select record_posted_date from t1; insert into t1(record_posted_date) select record_posted_date from t1; alter table t1 add column `mv_ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; alter table t1 add key(mv_ts); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `record_posted_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `mv_ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `rec_posted_dt_idx` (`record_posted_date`), KEY `mv_ts` (`mv_ts`) ) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=latin1 select * from t1; id record_posted_date mv_ts 1 2012-12-18 18:02:55 0000-00-00 00:00:00 2 2012-12-18 18:02:55 0000-00-00 00:00:00 3 2012-12-18 18:02:55 0000-00-00 00:00:00 4 2012-12-18 18:02:55 0000-00-00 00:00:00 5 2012-12-18 18:02:55 0000-00-00 00:00:00 6 2012-12-18 18:02:55 0000-00-00 00:00:00 7 2012-12-18 18:02:55 0000-00-00 00:00:00 8 2012-12-18 18:02:55 0000-00-00 00:00:00 update t1 set record_posted_date = now() where id = 5; select * from t1; id record_posted_date mv_ts 1 2012-12-18 18:02:55 0000-00-00 00:00:00 2 2012-12-18 18:02:55 0000-00-00 00:00:00 3 2012-12-18 18:02:55 0000-00-00 00:00:00 4 2012-12-18 18:02:55 0000-00-00 00:00:00 5 2012-12-18 18:02:58 2012-12-18 18:02:58 6 2012-12-18 18:02:55 0000-00-00 00:00:00 7 2012-12-18 18:02:55 0000-00-00 00:00:00 8 2012-12-18 18:02:55 0000-00-00 00:00:00 Please check this test case and inform if I got your scenario right: this is what you are doing.
[19 Jan 2013 1:00]
Bugs System
No feedback was provided for this bug for over a month, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open".
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.