Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.11, 11.4, 11.8, 12.3, 13.0, 13.1
-
None
-
Can result in unexpected behaviour
Description
DELETE ... FOR PORTION OF on a bitemporal FK parent raises ER_ROW_IS_REFERENCED_2, even though the referenced ID is still valid through the remaining portions
CREATE TABLE parent (id INT,s DATE, e DATE, PERIOD FOR appTIME(s, e), UNIQUE (id, appTIME WITHOUT OVERLAPS)) ENGINE=InnoDB WITH SYSTEM VERSIONING; |
CREATE TABLE child (cid INT PRIMARY KEY,parent_id INT,FOREIGN KEY(parent_id) REFERENCES parent (id)) ENGINE=InnoDB; |
INSERT INTO parent (id, s, e) VALUES (1, '2000-01-01', '2099-01-01'); |
INSERT INTO child (cid, parent_id) VALUES (1, 1); |
DELETE FROM parent FOR PORTION OF appTIME FROM '2010-01-01' TO '2020-01-01' WHERE id=1; |
CLI Output
10.11.19-dbg>create table parent ( id int,s date, e date, period for apptime(s, e), unique(id, apptime without overlaps)) engine=innodb with system versioning; |
Query OK, 0 rows affected (0.015 sec) |
 |
10.11.19-dbg>create table child (cid int primary key,parent_id int,foreign key (parent_id) references parent(id)) engine=innodb; |
Query OK, 0 rows affected (0.011 sec) |
 |
10.11.19-dbg>insert into parent (id, s, e) values (1, '2000-01-01', '2099-01-01'); |
Query OK, 1 row affected (0.002 sec)
|
 |
10.11.19-dbg>insert into child (cid, parent_id) values (1, 1); |
Query OK, 1 row affected (0.001 sec)
|
 |
10.11.19-dbg>delete from parent for portion of apptime from '2010-01-01' to '2020-01-01' where id = 1; |
ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`)) |
10.11.19-dbg>
|