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

MODIFY COLUMN no longer possible with Foreign Key Constraints

    XMLWordPrintable

Details

    Description

      Starting with MariaDB version 10.11.5 modifying the column type of a foreign key in the referenced table leads to an error. Consider the following example:

      MariaDB [(none)]> DROP DATABASE IF EXISTS playground;
      MariaDB [(none)]> CREATE DATABASE playground;
      MariaDB [(none)]> USE playground;

      MariaDB [playground]> CREATE TABLE table1 (my_id VARCHAR(20), PRIMARY KEY (my_id));
      MariaDB [playground]> CREATE TABLE table2 (your_id VARCHAR(20), FOREIGN KEY (your_id) REFERENCES table1(my_id));

      MariaDB [playground]> ALTER TABLE table1 MODIFY my_id VARCHAR(25);
      ERROR 1833 (HY000): Cannot change column 'my_id': used in a foreign key constraint 'playground/table2_ibfk_1' of table 'playground/table2'

      This used to work with MariaDB 10.11.4 without the error. It also works in MySQL 5.7.
      Is this an intended change to protect the foreign key relation? This impacts our existing database migration scripts, which no longer work as before.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              KrZipfel KrZipfel
              Votes:
              1 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.