Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
10.5
-
None
Description
create or replace table t1 (f1 int, f2 date, f3 date, key(f1,f3,f2)) engine=InnoDB; |
create or replace table t2 (a int, s date, e date, period for p(s,e), primary key(a, p without overlaps), foreign key(a,e,s) references t1(f1,f3,f2) on delete cascade on update cascade) engine=InnoDB; |
insert into t1 values (1,'2020-01-01','2021-01-01'),(2,'2020-06-01','2020-07-01'); |
insert into t2 values (1,'2020-01-01','2021-01-01'),(2,'2020-06-01','2020-07-01'); |
|
update t1 set f1 = 2 where f1 = 1; |
select * from t2; |
10.5 69077dea25 |
MariaDB [test]> update t1 set f1 = 2 where f1 = 1; |
Query OK, 1 row affected (0.024 sec)
|
Rows matched: 1 Changed: 1 Warnings: 0 |
|
MariaDB [test]> select * from t2; |
+---+------------+------------+ |
| a | s | e |
|
+---+------------+------------+ |
| 2 | 2020-06-01 | 2020-07-01 |
|
| 2 | 2020-01-01 | 2021-01-01 |
|
+---+------------+------------+ |
2 rows in set (0.001 sec) |
So, now we have a non-unique key with an overlap.
Traditional PK would prevent the update by throwing ER_FOREIGN_DUPLICATE_KEY_WITH_CHILD_INFO.
Attachments
Issue Links
- causes
-
MDEV-30606 Foreign key cannot be used in the check constraint
- Closed
- relates to
-
MDEV-19402 Invoke triggers for foreign key cascade actions
- Closed
-
MDEV-30674 Implement CHECK constraints validation on cascading updates
- Closed
-
MDEV-16417 Store Foreign Key metadata outside of InnoDB
- In Review
-
MDEV-18114 Foreign Key Constraint actions don't affect Virtual Column
- Closed
-
MDEV-22880 Honor constraints on UPDATE CASCADE
- Open