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

Don't allow multiple table CONSTRAINTs with the same name.

    XMLWordPrintable

Details

    Description

      MariaDB [test]> create table tfk (id INT, c1 INT, c2 INT NOT NULL, CONSTRAINT sid FOREIGN KEY (`c1`) REFERENCES tpk (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT sid check (c2>15));
      Query OK, 0 rows affected (0.23 sec)
       
      MariaDB [test]> show create table tfk;
      +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                                                                                                                                                                                                                                                   |
      +-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
      | tfk   | CREATE TABLE `tfk` (
        `id` int(11) DEFAULT NULL,
        `c1` int(11) DEFAULT NULL,
        `c2` int(11) NOT NULL,
        KEY `sid` (`c1`),
        CONSTRAINT `sid` FOREIGN KEY (`c1`) REFERENCES `tpk` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
        CONSTRAINT `sid` CHECK (`c2` > 15)
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
      +-------+-------------------------------------------------------------------------------------------
      

      So two constraints with the same name 'sid' were created.

      Attachments

        Activity

          People

            holyfoot Alexey Botchkov
            holyfoot Alexey Botchkov
            Votes:
            0 Vote for this issue
            Watchers:
            5 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.