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

Versioned REPLACE succeeds with ON DELETE RESTRICT constraint

    XMLWordPrintable

Details

    Description

      The following test succeeds, but shouldn't:

      --source include/have_innodb.inc
       
      CREATE TABLE t0 (pk integer primary key) WITH SYSTEM VERSIONING ENGINE=innodb ;
      CREATE TABLE t1 (pk integer primary key REFERENCES t0(pk) 
                                ON DELETE RESTRICT ON UPDATE CASCADE)  ENGINE=innodb ;
      CREATE TABLE t2 (pk integer)  ENGINE=innodb ;
       
      INSERT INTO t0 (pk) VALUES (1) ;
      INSERT INTO t1 (pk) VALUES (1) ;
      INSERT INTO t2 (pk) VALUES (1) ;
      # ALTER TABLE t1 ADD FOREIGN KEY (pk)  ;
      # FLUSH TABLES;
      --error ER_ROW_IS_REFERENCED_2
      DELETE FROM t0;
       
      --echo # Succeeds!
      REPLACE t0 values (1);
       
      SELECT * FROM t0 INTO OUTFILE 'load_table1_innodb_int_autoinc';
      --echo # Also succeeds!
      LOAD DATA INFILE 'load_table1_innodb_int_autoinc' REPLACE INTO TABLE t0;
       
      DELETE t0, t2 FROM t0 join t2;
      select pk as `empty!` from t0;
       
       
      DROP TABLE t1, t0, t2;
      

      Here, the referential constraint forbids deleting. However, it succeeds for operations that do deletion, other than single-table delete

      The expected behavior is: REPLACE, multi-DELETE and LOAD DATA...REPLACE fail with ER_ROW_IS_REFERENCED_2.

      Attachments

        Issue Links

          Activity

            People

              midenok Aleksey Midenkov
              nikitamalyavin Nikita Malyavin
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.