1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-34756 Validation of new foreign key skipped if innodb_alter_copy_bulk=ON

- During copy algorithm, InnoDB should disable bulk insert
operation if the table has foreign key relation and foreign key
check is enabled.
This commit is contained in:
Thirunarayanan Balathandayuthapani
2024-08-21 18:58:20 +05:30
parent 70afc62750
commit 22b48bb393
3 changed files with 59 additions and 1 deletions

View File

@ -42,3 +42,28 @@ INSERT INTO t1 SELECT seq, seq * 2 FROM seq_3_to_65536;
# Alter should use temporary file for sorting
ALTER TABLE t1 ADD INDEX(f2);
DROP TABLE t1;
--echo #
--echo # MDEV-34756 Validation of new foreign key skipped
--echo # if innodb_alter_copy_bulk=ON
--echo #
CREATE TABLE t1(f1 INT NOT NULL PRIMARY KEY,
f2 INT NOT NULL)ENGINE=InnoDB;
CREATE TABLE t2(f1 INT NOT NULL PRIMARY KEY,
f2 INT NOT NULL)ENGINE=InnoDB;
--enable_info
ALTER TABLE t2 ADD CONSTRAINT FOREIGN KEY(f1) REFERENCES t1(f1);
--disable_info
INSERT INTO t1 VALUES (1, 1);
INSERT INTO t2 VALUES (1, 2);
--replace_regex /#sql-alter-[0-9a-f-]*/#sql-alter/
--error ER_NO_REFERENCED_ROW_2
ALTER TABLE t2 ADD CONSTRAINT FOREIGN KEY(f2) REFERENCES t1(f1);
INSERT INTO t1 VALUES(3, 1);
--enable_info
SET STATEMENT foreign_key_checks=0 FOR
ALTER TABLE t2 ADD CONSTRAINT FOREIGN KEY(f2) REFERENCES t1(f1);
ALTER TABLE t1 FORCE;
ALTER TABLE t2 FORCE;
--disable_info
DROP TABLE t2, t1;