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

sequences used as default by other table not dumped in right order by mysqldump

    XMLWordPrintable

Details

    Description

      mysqldump treads sequences the same as other tables, dumping all of them in alphabetical order. A sequence may provide the default value for a column on another table though. So if the table name alphabetically comes before the sequence name, the tables CREATE statement will be in the dump output before the CREATE for the sequence table, and so the table creation will fail as it refers to a sequence not created yet.

      How to reproduce:

      • create sequence and table:

      CREATE SEQUENCE b;
      CREATE TABLE a (id INT PRIMARY KEY DEFAULT (NEXT VALUE FOR b));
      

      • dump database with mysqldump, then restore into an empty database
      • restore will fail when trying to create table `a`:

      ERROR 1146 (42S02) at line ...: Table 'test.b' doesn't exist

      Attachments

        Activity

          People

            sanja Oleksandr Byelkin
            hholzgra Hartmut Holzgraefe
            Votes:
            1 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

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