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

ADD PRIMARY KEY IF NOT EXISTS on composite key

    XMLWordPrintable

Details

    Description

      I try to alter table to add a composite primary key with "if not exists clause" to a table. One of these column is already in a composite unique index with an other column.

      I get warning code 1061 "Multiple primary key defined".
      But without "IF NOT EXISTS", it works fine.

      This is my example :

      CREATE TABLE `HORIZON` (
      	`ID` BIGINT(20) NOT NULL,
      	`RANK` MEDIUMINT(4) NOT NULL,
      	`CHECK_POINT` BIGINT(20) NOT NULL,
      	UNIQUE INDEX `HORIZON_UIDX01` (`ID`, `RANK`)
      ) COLLATE='utf8_general_ci' ENGINE=InnoDB ;
       
      ALTER TABLE `HORIZON` ADD PRIMARY KEY IF NOT EXISTS (`ID`, `CHECK_POINT`); /* warning code 1061 */
      ALTER TABLE `HORIZON` ADD PRIMARY KEY (`ID`, `CHECK_POINT`); /* works fine */
      

      Attachments

        Issue Links

          Activity

            People

              holyfoot Alexey Botchkov
              antoine.lange Antoine Lange
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.