Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Duplicate
-
10.11.4
-
None
Description
This used to work correctly, but at some point it broke.
create table a ( |
id int, |
primary key (id) |
);
|
|
-- This works, because update is "restrict"
|
create table b1 ( |
a_id int, |
foreign key (a_id) references a(id) on update restrict, |
check (a_id > 7) |
);
|
|
-- This works, because we are altering the table, even though update is "cascade"
|
create table b2 ( |
a_id int, |
foreign key (a_id) references a(id) on update cascade |
);
|
alter table b2 add check (a_id > 7); |
|
-- But "update cascade" doesn't work in the table create
|
create table b3 ( |
a_id int, |
foreign key (a_id) references a(id) on update cascade, |
check (a_id > 7) |
);
|
-- Error in query (1901): Function or expression 'a_id' cannot be used in the CHECK clause of `CONSTRAINT_1` |
Attachments
Issue Links
- duplicates
-
MDEV-31322 FKs with 'ON UPDATE CASCADE' can be set in some contexts but not others
-
- Closed
-
- relates to
-
MDEV-12302 Execute triggers for foreign key updates/deletes
-
- Confirmed
-
-
MDEV-30606 Foreign key cannot be used in the check constraint
-
- Closed
-
Please check the
MDEV-30606comment - about the error, that it was an intentional change.So the current problem is about ALTER, that it still allows to add the constraint and it is the same issue as
MDEV-31322