[MDEV-4436] CHANGE COLUMN IF EXISTS does not work and throws wrong warning Created: 2013-04-25  Updated: 2013-11-11  Resolved: 2013-11-11

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.0.2
Fix Version/s: 10.0.6

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Alexey Botchkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-318 IF (NOT) EXIST clauses for ALTER TABL... Closed

 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



 Comments   
Comment by Alexey Botchkov [ 2013-11-11 ]

http://lists.askmonty.org/pipermail/commits/2013-November/005662.html

Generated at Thu Feb 08 06:56:24 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.