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
Issue Links
- relates to
-
MDEV-33959 mysqldump of all databases cannot be loaded if a table uses a sequence from another schema
- Open