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

ALTER TABLE that renames columns and CHECK constraints

Details

    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;
      

      Attachments

        Issue Links

          Activity

            zzzeek Mike Bayer added a comment -

            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'

            zzzeek Mike Bayer added a comment - 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'

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

            monty Michael Widenius added a comment - Fixed by adding Item::rename_fields_processor and use this to rename fields in virtual columns, check constraint and default values

            People

              monty Michael Widenius
              serg Sergei Golubchik
              Votes:
              0 Vote for this issue
              Watchers:
              5 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.