Bug #20490 Can't create a TIMESTAMP that defaults to CURRENT_TIMESTAMP
Submitted: 15 Jun 2006 21:12 Modified: 12 Sep 2006 12:14
Reporter: Adam Sealey Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Query Browser Severity:S2 (Serious)
Version:1.1.20 OS:Windows (Windows XP)
Assigned to: Michael G. Zinner CPU Architecture:Any
Tags: Object Editors

[15 Jun 2006 21:12] Adam Sealey
Description:
When trying to add a column of type TIMESTAMP, the sql that is generated for the DEFAULT value is incorrect

How to repeat:
Create a table, then add a column of type TIMESTAMP.  In the Default Value field, enter CURRENT_TIMESTAMP.  The SQL generated is 

ALTER TABLE `WFG-UM`.`Patron_Info` MODIFY COLUMN `timestamp` TIMESTAMP NOT NULL DEFAULT 'CURRENT_TIMESTAMP' COMMENT 'Date and Time that this information was gathered';

When executed, the application throws 
MySQL Error Number 1067
Invalid default value for 'timestamp'.

Additionally, after making the alteration manually, the default value is shown correctly, but the NOTNULL column is unchecked, when in reality the column is not checked

Suggested fix:
Remove the single quotes from the default value when generating timestamp default values that are based on functions.

Example that seems to work fine:
ALTER TABLE `WFG-UM`.`Patron_Info` MODIFY COLUMN `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Date and Time that this information was gathered';
[16 Jun 2006 17:38] MySQL Verification Team
Thank you for the bug report.