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

When updating cascaded foreign keys, closing foreign key constraints is ignored and invalid.

    XMLWordPrintable

Details

    Description

      table1:

         CREATE TABLE users (
        id INT PRIMARY KEY,
        name VARCHAR(50)
      );
      

      table2

          CREATE TABLE orders (
        id INT PRIMARY KEY,
        user_id INT,
        order_date DATE,
        FOREIGN KEY (user_id) REFERENCES users(id)
      );
      

      Update:

       ALTER TABLE users  MODIFY COLUMN  `id` tinyint(11) unsigned NOT NULL auto_increment;
       ERROR 1833 (HY000): Cannot change column 'id': used in a foreign key constraint 'orders_ibfk_1' of table 'runzi.orders'
       
       
      MariaDB [runzi]> SET FOREIGN_KEY_CHECKS=0;
      Query OK, 0 rows affected (0.001 sec)
       
      MariaDB [runzi]> ALTER TABLE users  MODIFY COLUMN  `id` tinyint(11) unsigned NOT NULL auto_increment;
      ERROR 1833 (HY000): Cannot change column 'id': used in a foreign key constraint 'orders_ibfk_1' of table 'runzi.orders'
      MariaDB [runzi]>
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Runzi Runzi
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.