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

ALTER TABLE CHANGE COLUMN c1 c1 bigint NOT NULL - generates error if table uses SYSTEM VERSIONING

Details

    Description

      If you issue an ALTER TABLE to make a column that is a foreign key NOT NULL you get the following error:

      Cannot change column 'c1': used in a foreign key constraint 'p2c_ibfk_1'
      

      In prior versions of MariaDB this was allowed and did not generate an error. Further, if you issue an ALTER TABLE to make a column that is a foreign key NULLable you do NOT get any error message.

      Attachments

        Issue Links

          Activity

            rdyas Robert Dyas created issue -
            rdyas Robert Dyas made changes -
            Field Original Value New Value
            Summary ALTER TABLE CHANGE COLUMN c1 c1 bigint NOT NULL - generates error ALTER TABLE CHANGE COLUMN c1 c1 bigint NOT NULL - generates error if table uses SYSTEM VERSIONING
            rdyas Robert Dyas made changes -
            Component/s System versioning [ 14303 ]
            alice Alice Sherepa added a comment -

            Thanks for the report! Reproducible with Innodb on MariaDB 10.3

            --source include/have_innodb.inc
            SET @@system_versioning_alter_history = 1;
             
            create table t1 (a int not null, key(a))engine=innodb with system versioning;
            create table t2 (b int, foreign key(b) references t1(a))engine=innodb with system versioning;
            alter table t2 modify column b int default null;
            drop table t2,t1;
             
            create table t1 (a int, key(a))engine=innodb with system versioning;
            create table t2 (b int, foreign key(b) references t1(a))engine=innodb with system versioning;
            alter table t2 modify column b int not null;
            drop table t2,t1;
             
            mysqltest: At line 17: query 'alter table t2 modify column b int not null' failed: 1832: Cannot change column 'b': used in a foreign key constraint 't2_ibfk_1'
            

            alice Alice Sherepa added a comment - Thanks for the report! Reproducible with Innodb on MariaDB 10.3 --source include/have_innodb.inc SET @@system_versioning_alter_history = 1;   create table t1 (a int not null, key(a))engine=innodb with system versioning; create table t2 (b int, foreign key(b) references t1(a))engine=innodb with system versioning; alter table t2 modify column b int default null; drop table t2,t1;   create table t1 (a int, key(a))engine=innodb with system versioning; create table t2 (b int, foreign key(b) references t1(a))engine=innodb with system versioning; alter table t2 modify column b int not null; drop table t2,t1;   mysqltest: At line 17: query 'alter table t2 modify column b int not null' failed: 1832: Cannot change column 'b': used in a foreign key constraint 't2_ibfk_1'
            alice Alice Sherepa made changes -
            Affects Version/s 10.3 [ 22126 ]
            alice Alice Sherepa made changes -
            Fix Version/s 10.3 [ 22126 ]
            alice Alice Sherepa made changes -
            Comment [ Thanks for the report! Reproducible with Innodb on MariaDB 10.3
            {noformat}
            --source include/have_innodb.inc
            SET @@system_versioning_alter_history = 1;

            create table t1 (a int not null, key(a))engine=innodb with system versioning;
            create table t2 (b int, foreign key(b) references t1(a))engine=innodb with system versioning;
            alter table t2 modify column b int default null;
            drop table t2,t1;

            create table t1 (a int, key(a))engine=innodb with system versioning;
            create table t2 (b int, foreign key(b) references t1(a))engine=innodb with system versioning;
            alter table t2 modify column b int not null;
            drop table t2,t1;

            mysqltest: At line 17: query 'alter table t2 modify column b int not null' failed: 1832: Cannot change column 'b': used in a foreign key constraint 't2_ibfk_1'
            {noformat} ]
            alice Alice Sherepa made changes -
            Assignee Marko Mäkelä [ marko ]
            midenok Aleksey Midenkov made changes -
            Assignee Marko Mäkelä [ marko ] Aleksey Midenok [ midenok ]
            midenok Aleksey Midenkov made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            midenok Aleksey Midenkov made changes -
            Assignee Aleksey Midenok [ midenok ] Eugene Kosov [ kevg ]
            Status In Progress [ 3 ] In Review [ 10002 ]
            kevg Eugene Kosov (Inactive) made changes -
            Assignee Eugene Kosov [ kevg ] Aleksey Midenok [ midenok ]
            midenok Aleksey Midenkov made changes -
            Status In Review [ 10002 ] Stalled [ 10000 ]
            midenok Aleksey Midenkov made changes -
            midenok Aleksey Midenkov made changes -
            Status Stalled [ 10000 ] In Progress [ 3 ]
            midenok Aleksey Midenkov made changes -
            Status In Progress [ 3 ] Stalled [ 10000 ]
            midenok Aleksey Midenkov made changes -
            Status Stalled [ 10000 ] In Progress [ 3 ]
            midenok Aleksey Midenkov made changes -
            Assignee Aleksey Midenok [ midenok ] Marko Mäkelä [ marko ]
            Status In Progress [ 3 ] In Review [ 10002 ]

            I think that the tests need a little more work.

            marko Marko Mäkelä added a comment - I think that the tests need a little more work.
            marko Marko Mäkelä made changes -
            Assignee Marko Mäkelä [ marko ] Aleksey Midenok [ midenok ]
            Status In Review [ 10002 ] Stalled [ 10000 ]
            marko Marko Mäkelä made changes -
            issue.field.resolutiondate 2018-11-01 14:46:03.0 2018-11-01 14:46:03.645
            marko Marko Mäkelä made changes -
            Fix Version/s 10.3.11 [ 23141 ]
            Fix Version/s 10.3 [ 22126 ]
            Resolution Fixed [ 1 ]
            Status Stalled [ 10000 ] Closed [ 6 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 89037 ] MariaDB v4 [ 154840 ]

            People

              midenok Aleksey Midenkov
              rdyas Robert Dyas
              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.