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

modification of the column fails to check foreign key constraint

    XMLWordPrintable

Details

    Description

      Testcase with 2 tables

      create table tab1 (
          t1id int unsigned not null auto_increment,
          t1val varchar(30) not null,
          constraint pkt1 primary key (t1id)
      );
      create table tab2 (
          t2id int unsigned not null auto_increment,
          t1id int unsigned,
          t2tval datetime,
          t2nval int,
          constraint pkt2 primary key (t2id)
      );
      alter table tab2 add index FkIdxt2t1id (t1id), add constraint Fkt2t1id foreign key (t1id) references tab1 (t1id);
      

      Altering columns in one statement failes

      alter table tab2 modify t1id int unsigned not null, modify t2tval timestamp(3), modify t2nval bigint;

      Cannot change column 't1id': used in a foreign key constraint 'Fkt2t1id'
      

      alter not null in seperate statement works, also 2 modify data types

      alter table tab2 modify t1id int unsigned not null;
      alter table tab2 modify t2tval timestamp(3), modify t2nval bigint;

      Attachments

        1. test_fail.sql
          0.5 kB
          Stefan van Hasselt
        2. test_fix.sql
          0.5 kB
          Stefan van Hasselt

        Issue Links

          Activity

            People

              thiru Thirunarayanan Balathandayuthapani
              svh Stefan van Hasselt
              Votes:
              1 Vote for this issue
              Watchers:
              8 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.