Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-7778

impossible create copy of table, if table contain default value for timestamp field

    XMLWordPrintable

Details

    Description

      MariaDB has wonderful feature which allows easy create copy of any table.

      create table `new_name` select * from `old_table`

      But I found that this is not worked if `old_table` contain default value for timestamp field.

      CREATE TABLE `table1` (
        `f1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

      0 row(s) affected

      CREATE TABLE `table2` (
        `f2` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8

      0 row(s) affected

      create table `table1copy` select * from `table1` limit 0;

      Error Code: 1067
      Invalid default value for 'f1'

      create table `table2copy` select * from `table2` limit 0;

      0 row(s) affected

      show create table table2copy

      CREATE TABLE `table2copy` (
        `f2` timestamp NULL DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              mikhail Mikhail Gavrilov
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0d
                  0d
                  Logged:
                  Time Spent - 40m
                  40m

                  Git Integration

                    Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.