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

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

                Dates

                Created:
                Updated:
                Resolved: