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

alter table - failing to ADD KEY IF NOT EXISTS when existing dropping the same index name earlier in the alter table

    XMLWordPrintable

Details

    Description

      > CREATE TABLE b (`transaction_id` int(11) NOT NULL DEFAULT '0', KEY `transaction_id` (`transaction_id`));
      Query OK, 0 rows affected (0.01 sec)
       
      > alter table b DROP KEY transaction_id, ADD UNIQUE KEY IF NOT EXISTS (transaction_id);
      Query OK, 0 rows affected, 1 warning (0.00 sec)
      Records: 0  Duplicates: 0  Warnings: 1
       
      > show create table b;
      +-------+-----------------------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                                              |
      +-------+-----------------------------------------------------------------------------------------------------------+
      | b     | CREATE TABLE `b` (
        `transaction_id` int(11) NOT NULL DEFAULT '0'
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
      +-------+-----------------------------------------------------------------------------------------------------------+

      expected results: A table with a unique key.

      holyfoot says in MDEV-8212 that the IF EXISTS applies to what is there BEFORE the query. This is obviously how its implemented. What the expected behaviour reading the SQL statement?

      Attachments

        Issue Links

          Activity

            People

              danblack Daniel Black
              danblack Daniel Black
              Votes:
              1 Vote for this issue
              Watchers:
              7 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.