[MDEV-13508] ALTER TABLE that renames columns and CHECK constraints Created: 2017-08-12  Updated: 2020-06-13  Resolved: 2018-02-10

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table
Affects Version/s: 10.2
Fix Version/s: 10.2.13

Type: Bug Priority: Critical
Reporter: Sergei Golubchik Assignee: Michael Widenius
Resolution: Fixed Votes: 0
Labels: suse

Issue Links:
Duplicate
is duplicated by MDEV-16161 Syntax error reserverd keyword Closed
Relates
relates to MDEV-11114 Cannot drop column referenced by CHEC... Closed
relates to MDEV-22881 Unexpected errors, corrupt output, Va... Closed

 Description   

If a column is renamed, CHECK constraint isn't changed to use the new column name. But UNIQUE constraint is.

create table t1 (a int, b int, check(a>b));
alter table t1 change column a b int, change column b a int;
show create table t1;

Compare with

create table t1 (a int, b int, unique(a,b));
alter table t1 change column a b int, change column b a int;
show create table t1;



 Comments   
Comment by Mike Bayer [ 2017-11-17 ]

note also as in MDEV-11114 this prevents the column from being renamed in most cases:

MariaDB [test]> create table t1 (a int, check (a in (0, 1)));
Query OK, 0 rows affected (0.03 sec)

MariaDB [test]> alter table t1 change column a b int;
ERROR 1054 (42S22): Unknown column 'a' in 'CHECK'

Comment by Michael Widenius [ 2018-02-10 ]

Fixed by adding Item::rename_fields_processor and use this to rename fields in
virtual columns, check constraint and default values

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