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

Failed to INSERT a proper value when no FOREIGN KEY violation

    XMLWordPrintable

Details

    Description

      Run the following statements, in which the last INSERT statement should succeed, since there is no FOREIGN KEY violation. But an error is retuned.

      CREATE TABLE t0 (c2 FLOAT8, PRIMARY KEY (c2));
      CREATE TABLE t1 (c1 FLOAT8 UNIQUE, FOREIGN KEY (c1) REFERENCES t0(c2) ON UPDATE CASCADE);
      ALTER TABLE t0 RENAME AS t2, ALGORITHM COPY;
      INSERT INTO t2 (c2) VALUES (1);
      INSERT INTO t1 (c1) VALUES (1); -- actual: failed, expected: succeed
      

      I got the following error message, which seems incorrect, since there is no table with name t0.

      ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `t1_ibfk_1` FOREIGN KEY (`c1`) REFERENCES `t0` (`c2`) ON UPDATE CASCADE)
      

      Attachments

        Issue Links

          Activity

            People

              thiru Thirunarayanan Balathandayuthapani
              John Jove John Jove
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.