distal-attribute
distal-attribute
distal-attribute
distal-attribute

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

User, date Message
Written by arucard
3 months ago
Category: General
12 posts since Wed, 22 Aug 12
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
Written by ansgar
3 months ago
4960 posts since Fri, 07 Apr 06
Yes, can confirm that.
Written by arucard
3 months ago
12 posts since Wed, 22 Aug 12
Should I report it somewhere else or here is it ok?

Regards
Michal
Written by ansgar
3 months ago
4960 posts since Fri, 07 Apr 06
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.
Written by ansgar
3 months ago
4960 posts since Fri, 07 Apr 06
Fixed in r4777. Please test yourself.
Written by arucard
3 months ago
12 posts since Wed, 22 Aug 12
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.