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

ALTER TABLE .. ADD UNIQUE INDEX IF NOT EXISTS causes syntax error

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 10.0.2
    • Fix Version/s: 10.0.6
    • Component/s: None
    • Labels:
      None

      Description

      Test case:

      create table t1 (i int);
      alter table t1 add unique index if not exists idx(i);

      Output:

      MariaDB [test]> create table t1 (i int);
      Query OK, 0 rows affected (0.32 sec)
       
      MariaDB [test]> alter table t1 add unique index if not exists idx(i);
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'if not exists idx(i)' at line 1

      Apparently this variation somehow slipped from the syntax changes. This one works:

      MariaDB [test]> create unique index if not exists idx2 on t1 (i);
      Query OK, 0 rows affected (0.42 sec)
      Records: 0  Duplicates: 0  Warnings: 0

      This of course works too:

      MariaDB [test]> alter table t1 add unique index idx1(i);
      Query OK, 0 rows affected (0.33 sec)
      Records: 0  Duplicates: 0  Warnings: 0

      And other modifiers work (with corresponding data types):

      MariaDB [test]> alter table t2 add fulltext index if not exists idx(b);
      Query OK, 0 rows affected (0.23 sec)               
      Records: 0  Duplicates: 0  Warnings: 0
       
      MariaDB [test]> alter table t2 add spatial index if not exists idx2(a);
      Query OK, 0 rows affected (0.19 sec)               
      Records: 0  Duplicates: 0  Warnings: 0

      revision-id: bar@mariadb.org-20130424142022-u4xhikvoqggze9b0
      revno: 3745
      branch-nick: 10.0

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              holyfoot Alexey Botchkov
              Reporter:
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.