Bug #54242 ndb native default values break ndb_restore
Submitted: 4 Jun 2010 17:40 Modified: 1 Jul 2010 21:28
Reporter: Hartmut Holzgraefe Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:mysql-5.1-telco-7.1 OS:Any
Assigned to: Frazer Clement CPU Architecture:Any
Tags: mysql-cluster-7.1.4

[4 Jun 2010 17:40] Hartmut Holzgraefe
Description:
When using mysqldump to backup/restore schema information and ndb_restore for actual data rows only restoring to ndb-7.1.4 from an older version the restore fails on tables with default values. As pre-7.1.4 versions did not have default value support at all the table object comparison fails on the difference of no default vs. default

How to repeat:
- create table with default column values on mysql cluster < 7.1.4
- dump schema with "mysqldump --no-data ..."
- start cluster backup
...
- restore schema into 7.1.4 cluster using mysql command line client
- try to restore row data using "ndb_restore -r ..."

Suggested fix:
Ignore different column defaults in table structure comparison within ndb_restore, the backup should have explicit values for all columns anyway so the default value will never be used during restore (or does this clash with online add column?)
[4 Jun 2010 17:41] Hartmut Holzgraefe
See also bug #54178 and bug #53810
[7 Jun 2010 9:42] Hartmut Holzgraefe
See also bug #54279
[7 Jun 2010 16:51] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/110383

3573 Frazer Clement	2010-06-07
      Bug#54242 ndb native default values break ndb_restore
      
      Ndb-native support for default values allows column definitions in the Ndb 
      data nodes to include default value information.
      
      Currently that information must be constant.
      
      In MySQL, the TIMESTAMP type can have a 'default value' which is automatically
      set to the CURRENT_TIMESTAMP at INSERT or on row UPDATE time.  This cannot 
      currently be supported natively by the Ndb storage engine.
      Currently, the Ndb storage engine treats TIMESTAMP columns with DEFAULT CURRENT_TIMESTAMP
      as if they were DEFAULT 0.
      
      This patch returns the TIMESTAMP behaviour to be the same as it was before
      the native default support was added, except in the case where a constant
      TIMESTAMP default (e.g. 0 or 20100607174832) is set.
      
      The ndb_native_default_support testcase is enhanced to record the expected
      behaviour.
[8 Jun 2010 14:08] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/110504

3556 Frazer Clement	2010-06-08
      Bug#54242 ndb native default values break ndb_restore
      
      This patch enhances ndb_restore so that it :
       - Ignores differences in default values between DB and Backup table metadata
       - Provides more diagnostic information about schema differences being ignored
      
      The ndb_native_default_support testcase is enhanced to give some coverage of
      this behaviour.
[8 Jun 2010 14:08] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/110505

3555 Frazer Clement	2010-06-08
      Bug#54242 ndb native default values break ndb_restore
      
      Ndb-native support for default values allows column definitions in the Ndb 
      data nodes to include default value information.
      
      Currently that information must be constant.
      
      In MySQL, the TIMESTAMP type can have a 'default value' which is automatically
      set to the CURRENT_TIMESTAMP at INSERT or on row UPDATE time.  This cannot 
      currently be supported natively by the Ndb storage engine.
      Currently, the Ndb storage engine treats TIMESTAMP columns with DEFAULT CURRENT_TIMESTAMP
      as if they were DEFAULT 0.
      
      This patch returns the TIMESTAMP behaviour to be the same as it was before
      the native default support was added, except in the case where a constant
      TIMESTAMP default (e.g. 0 or 20100607174832) is set.
      
      The ndb_native_default_support testcase is enhanced to record the expected
      behaviour.
[8 Jun 2010 22:28] Bugs System
Pushed into 5.1.44-ndb-7.0.16 (revid:jonas@mysql.com-20100608221311-6rx8il9mnc7dcm0w) (version source revid:jonas@mysql.com-20100608221311-6rx8il9mnc7dcm0w) (merge vers: 5.1.44-ndb-7.0.16) (pib:16)
[18 Jun 2010 8:59] Frazer Clement
Pushed to 7.0.15a, 7.1.4a.
[1 Jul 2010 21:28] Jon Stephens
Documented bugfix in the NDB-7.0.15a and 7.1.4a changelogs as follows:

        When using mysqldump to back up and restore schema information
        while using ndb_restore for restoring only the data, restoring
        to MySQL Cluster NDB 7.1.4 from an older version failed on
        tables having columns with default values. This was because
        versions of MySQL Cluster prior to MySQL Cluster NDB 7.1.4 did
        not have native support for default values.

        In addition, the MySQL Server supports TIMESTAMP columns having
        dynamic default values, such as DEFAULT CURRENT_TIMESTAMP;
        however, the current implementation of NDB-native default values
        allows only for a constant default value, regardless of the 
        column's type.

        To fix these issues, the manner in which NDB treats TIMESTAMP
        columns is reverted to its pre-NDB-7.1.4 behavior (obtaining the
        default value from mysqld rather than NDB) except where a
        TIMESTAMP column uses a constant default, as in the case of a
        column declared as TIMESTAMP DEFAULT 0 or TIMESTAMP DEFAULT
        20100607174832.

Closed.