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

CHANGE COLUMN IF EXISTS does not work and throws wrong warning

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.0.2
    • 10.0.6
    • None
    • None

    Description

      CHANGE COLUMN IF EXISTS does not change the existing column and throws a warning that the column does not exist:

      MariaDB [test]> create table t1 (a int);
      Query OK, 0 rows affected (0.20 sec)
       
      MariaDB [test]> alter table t1 change column a b bigint;
      Query OK, 0 rows affected (0.45 sec)               
      Records: 0  Duplicates: 0  Warnings: 0
       
      MariaDB [test]> drop table t1;
      Query OK, 0 rows affected (0.10 sec)
       
      MariaDB [test]> create table t1 (a int);
      Query OK, 0 rows affected (0.24 sec)
       
      MariaDB [test]> alter table t1 change column if exists a b bigint;
      Query OK, 0 rows affected, 1 warning (0.00 sec)
      Records: 0  Duplicates: 0  Warnings: 1
       
      MariaDB [test]> show warnings;
      +-------+------+----------------------------+
      | Level | Code | Message                    |
      +-------+------+----------------------------+
      | Note  | 1054 | Unknown column 'a' in 't1' |
      +-------+------+----------------------------+
      1 row in set (0.01 sec)
       
      MariaDB [test]> show create table t1;
      +-------+---------------------------------------------------------------------------------------+
      | Table | Create Table                                                                          |
      +-------+---------------------------------------------------------------------------------------+
      | t1    | CREATE TABLE `t1` (
        `a` int(11) DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
      +-------+---------------------------------------------------------------------------------------+
      1 row in set (0.00 sec)
       

      Without IF EXISTS clause it works all right:

      MariaDB [test]> alter table t1 change column a b bigint;
      Query OK, 0 rows affected (0.47 sec)               
      Records: 0  Duplicates: 0  Warnings: 0
       
      MariaDB [test]> show create table t1;
      +-------+------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                             |
      +-------+------------------------------------------------------------------------------------------+
      | t1    | CREATE TABLE `t1` (
        `b` bigint(20) DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
      +-------+------------------------------------------------------------------------------------------+
      1 row in set (0.01 sec)

      Test case:

      create table t1 (a int);
      alter table t1 change column if exists a b bigint;
      show warnings;
      show create table t1;

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

      Attachments

        Issue Links

          Activity

            People

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