Bug #1885 mysqldump does not dumps timestamp default
Submitted: 19 Nov 2003 1:55 Modified: 30 Jan 2004 8:28
Reporter: Marco Banfi Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0.15 OS:Windows (windows XP sp1)
Assigned to: Dmitry Lenev CPU Architecture:Any

[19 Nov 2003 1:55] Marco Banfi
Description:
when doing a dump with mysqldump --opt database >db.sql nothing is printed for timestamp fields default, but, creating a timestamp field a default could be specified. I use defaults as a work around to avoid E_FAIL while accessing timestamp fields (other than one) through MyODBC (3.51), without the default they are filled with '0', and ADO+odbc give orrible E_FAIL. :-(

How to repeat:
create database prova;
create table tavola (
            ts1 timestamp,
            ts2 timestamp default '20031225'
);

execute:
mysqldump --opt -u user prova >prova.sql
[19 Nov 2003 9:29] MySQL Verification Team
C:\mysql\bin>mysql -uroot prova
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 4.0.16-max-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create table tavola (
    ->             ts0 char(15) default "default value",
    ->             ts1 timestamp,
    ->             ts2 timestamp default '20031225'
    -> );
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

C:\mysql\bin>mysqldump --opt -uroot prova >prova.sql

C:\mysql\bin>type prova.sql
-- MySQL dump 9.09
--
-- Host: localhost    Database: prova
-- ------------------------------------------------------
-- Server version       4.0.16-max-nt

--
-- Table structure for table `tavola`
--

DROP TABLE IF EXISTS tavola;
CREATE TABLE tavola (
  ts0 char(15) default 'default value',
  ts1 timestamp(14) NOT NULL,
  ts2 timestamp(14) NOT NULL
) TYPE=MyISAM;

--
-- Dumping data for table `tavola`
--

/*!40000 ALTER TABLE tavola DISABLE KEYS */;
LOCK TABLES tavola WRITE;
UNLOCK TABLES;
/*!40000 ALTER TABLE tavola ENABLE KEYS */;
[9 Dec 2003 5:48] Ramil Kalimullin
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

Actually it's not a bug. Now one cannot set default value for timestamp fields.
[29 Jan 2004 6:46] Dmitry Lenev
Hello!

It was bad idea to prohibit setting of default values for TIMESTAMP fields (at least in stable tree). See also bug #2539 for example of user complaints about it.
So I've reopened this bug. Beg your pardon for all this mess.

Proper fix for this bug would be properly reflect default values in  
SHOW CREATE TABLE (which is used in mysqldump). 

Still I should note that default value for first timestamp column has no sense due to auto-update feature and so will be silently ignored in 4.0. This fact will be also properly reflected in SHOW CREATE TABLE.
[30 Jan 2004 8:28] Dmitry Lenev
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

ChangeSet 1.1683.6.1 2004/01/30 15:13:19 dlenev@mysql.com
  Fix for bugs #1885, #2464, #2539. Proper handling of default
  values for TIMESTAMP columns.