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

CHANGE COLUMN IF EXISTS does not work and throws wrong warning

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.0.2
    • Fix Version/s: 10.0.6
    • Component/s: None
    • Labels:
      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
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Show
              holyfoot Alexey Botchkov added a comment - http://lists.askmonty.org/pipermail/commits/2013-November/005662.html

                People

                • Assignee:
                  holyfoot Alexey Botchkov
                  Reporter:
                  elenst Elena Stepanova
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - Not Specified
                    Not Specified
                    Remaining:
                    Remaining Estimate - 0 minutes
                    0m
                    Logged:
                    Time Spent - 4 hours
                    4h