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

CREATE OR REPLACE fails to recreate same constraint name

    XMLWordPrintable

Details

    Description

      CREATE OR REPLACE failed with "Duplicate key on write or update" when it replace an empty table with the non-anonymous constraint name

      From comment
      Test fails due to a duplicate key on SYS_FOREIGN.NAME on the non-anonymous constraint name:

      Test:

      --source include/have_innodb.inc
       
      CREATE TABLE t(a INT PRIMARY KEY) ENGINE=InnoDB;
      CREATE OR REPLACE TABLE u(a INT PRIMARY KEY, CONSTRAINT c FOREIGN KEY d (a) REFERENCES t (a)) ENGINE=InnoDB;
      CREATE OR REPLACE TABLE u(a INT PRIMARY KEY, CONSTRAINT c FOREIGN KEY d (a) REFERENCES t (a)) ENGINE=InnoDB;
      DROP TABLE u, t;
      

      Actual result:

      At line 5: query 'CREATE OR REPLACE TABLE u(a INT PRIMARY KEY, CONSTRAINT c FOREIGN KEY d (a) REFERENCES t (a)) ENGINE=InnoDB' failed: ER_CANT_CREATE_TABLE (1005): Can't create table `test`.`u` (errno: 121 "Duplicate key on write or update")
      

      Expected result:
      No errors

      Attachments

        Issue Links

          Activity

            People

              midenok Aleksey Midenkov
              lstartseva Lena Startseva
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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