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

IF EXISTS clause does not work for RENAME COLUMN and RENAME INDEX

    XMLWordPrintable

Details

    Description

      In MDEV-16290, ALTER TABLE .. RENAME COLUMN was implemented. I think it should follow standard conventions and support IF EXISTS clause, as other column operations do:

      10.5 a4ab54d7

      MariaDB [test]> create table t (a int);
      Query OK, 0 rows affected (0.214 sec)
       
      MariaDB [test]> alter table t change column if exists a b int;
      Query OK, 0 rows affected (0.044 sec)
      Records: 0  Duplicates: 0  Warnings: 0
       
      MariaDB [test]> alter table t modify column if exists b char(8);
      Query OK, 0 rows affected (0.292 sec)              
      Records: 0  Duplicates: 0  Warnings: 0
       
      MariaDB [test]> alter table t add column if not exists a int;
      Query OK, 0 rows affected (0.040 sec)
      Records: 0  Duplicates: 0  Warnings: 0
       
      MariaDB [test]> alter table t drop column if exists a;
      Query OK, 0 rows affected (0.089 sec)
      Records: 0  Duplicates: 0  Warnings: 0
      

      MariaDB [test]> alter table t rename column if exists b to c;
      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 exists b to c' at line 1
      

      Same for RENAME INDEX implemented in MDEV-7318.

      Attachments

        Issue Links

          Activity

            People

              midenok Aleksey Midenkov
              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.