[Bug] MySQL - Timestamp column with DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP

arucard's profile image arucard posted 10 years ago in General Permalink
Hi, I've found this strange behaviour and I think it's a bug.

First, I use MySQL from version 5.1. up to 5.6 and HeidiSQL revision 4775. Also found this behaviour couple revisions back.

To replicate behaviour, create sandbox database and test table like this:

CREATE DATABASE `sandbox`;
USE `sandbox`;
CREATE TABLE `test_timestamp_update` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'id',
`title` VARCHAR(50) NULL DEFAULT NULL COMMENT 'title' COLLATE 'utf8_czech_ci',
`dt_upd` TIMESTAMP NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT 'title' COLLATE 'utf8_czech_ci',
PRIMARY KEY (`id`)
)
COMMENT='Test timestamp update'
COLLATE='utf8_czech_ci'
ENGINE=InnoDB;


Now, navigate to this new table and first look at column description and then CREATE code. At both screens, there is no ON UPDATE CURRENT_TIMESTAMP and even given COMMENT.

But, run this SQL:

SHOW CREATE TABLE `sandbox`.`test_timestamp_update`;


There is UPDATE part and COMMENT too. I think HeidiSQL just somehow trim this information because if I do this, UPDATE timestamp works:

INSERT INTO `sandbox`.`test_timestamp_update` (`title`) VALUES ('test title');
SELECT * FROM `sandbox`.`test_timestamp_update`;
UPDATE `sandbox`.`test_timestamp_update` SET `title` = 'test title updated' WHERE `id` = 1;
SELECT * FROM `sandbox`.`test_timestamp_update`;



It's not critical, but I've found this being little bit annoying. :)
Can anyone else confirm this?


Regards
Michal
ansgar's profile image ansgar posted 10 years ago Permalink
Yes, can confirm that.
arucard's profile image arucard posted 10 years ago Permalink
Should I report it somewhere else or here is it ok?

Regards
Michal
ansgar's profile image ansgar posted 10 years ago Permalink
Sigh... there is a issue tracker, but anyway - people report bugs here and there, and even send me callstacks per private mail. Latter one is a no-go, but everything "public" on the net does it.
Code modification/commit a2c76e7 from ansgar.becker, 10 years ago, revision 8.3.0.4777
Detect DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP in column definitions. See http://www.heidisql.com/forum.php?t=15768
ansgar's profile image ansgar posted 10 years ago Permalink
Fixed in r4777. Please test yourself.
arucard's profile image arucard posted 10 years ago Permalink
I confirm that it is fixed.
Thank you, ansgar.

P.S.: Next time I will use issue tracker.

Please login to leave a reply, or register at first.