Bug #45669 | Column default value not reflected in SHOW CREATE output | ||
---|---|---|---|
Submitted: | 23 Jun 2009 8:09 | Modified: | 19 Jun 2013 18:17 |
Reporter: | Rafal Somla | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: DDL | Severity: | S3 (Non-critical) |
Version: | 4.1, 5.0, 5,1, 5.4, 6.0 bzr | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[23 Jun 2009 8:09]
Rafal Somla
[23 Jun 2009 8:33]
Rafal Somla
A test script illustrating problem with restored views. See differences between footprint.pre and footprint.post after running it. CREATE DATABASE db1; USE db1; CREATE TABLE t2 ( c0 TIMESTAMP ); ALTER TABLE t2 ALTER COLUMN c0 SET DEFAULT '20071222140633'; CREATE VIEW v2 AS SELECT * FROM t2; --error 0,1 --remove_file check_objects.sql --write_file check_objects.sql USE information_schema; SELECT * FROM columns WHERE table_schema LIKE 'db%'; EOF --exec $MYSQL --vertical <check_objects.sql >footprint.pre BACKUP DATABASE db1 TO 'db1.bak'; DROP DATABASE db1; RESTORE FROM 'db1.bak'; --exec $MYSQL --vertical <check_objects.sql >footprint.post --diff_files footprint.pre footprint.post DROP DATABASE db1; --exit
[23 Jun 2009 8:36]
Sveta Smirnova
Thank you for the report. Verified as described.
[23 Jun 2009 11:35]
Peter Laursen
I seems to be a problem with a specific ALTER syntax. Here it seems that there are no issue: CREATE DATABASE db1; USE db1; CREATE TABLE t2 ( c0 TIMESTAMP ); ALTER TABLE `db1`.`t2` CHANGE `c0` `c0` TIMESTAMP DEFAULT '20071222140633' NOT NULL; SHOW CREATE TABLE t2; /* CREATE TABLE `t2` ( `c0` timestamp NOT NULL DEFAULT '2007-12-22 14:06:33' ) ENGINE=InnoDB DEFAULT CHARSET=utf8 */ (but ON UPDATE will then disappear of course unless specified) BTW: I am almost sure that Baron Schwartz reported the same or a similar issue around 1 year ago.
[23 Jun 2009 11:43]
Peter Laursen
And doesn't it affect 'mysqldump' and similar backups (if DROP TABLE+CREATE TABLE is in the script)? Data will of course be backed up and restored, but new data entered after restore will be affected. I think this is more than 'S3'!
[23 Jun 2009 18:16]
MySQL Verification Team
Baron reported similar bug #33887
[24 Jun 2009 11:00]
Peter Laursen
It looks like an issue specific for TIMESTAMP type (and possibly other *timetypes*). with VARCHAR: CREATE DATABASE db1; USE db1; CREATE TABLE t2 ( c0 VARCHAR(50) ); ALTER TABLE t2 ALTER COLUMN c0 SET DEFAULT '20071222140633'; SHOW CREATE TABLE t2; /* CREATE TABLE `t2` ( `c0` varchar(50) DEFAULT '20071222140633' ) ENGINE=InnoDB DEFAULT CHARSET=utf8 */ ALTER TABLE t2 ALTER COLUMN c0 SET DEFAULT '20091222140633'; SHOW CREATE TABLE t2; /* CREATE TABLE `t2` ( `c0` varchar(50) DEFAULT '20091222140633' ) ENGINE=InnoDB DEFAULT CHARSET=utf8 */
[12 Dec 2011 19:48]
Sveta Smirnova
Bug #63476 was marked as duplicate of this one.
[19 Jun 2013 18:17]
Paul DuBois
Noted in 5.7.2 changelog. If ALTER TABLE was used to set the default value for a TIMESTAMP or DATETIME column that had CURRENT_TIMESTAMP as its default when it was created, the new default was not shown by SHOW CREATE TABLE.