Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Not a Bug
-
10.6.12, 10.10.3
-
Using your docker image
Description
Hi
I have following code snippet, where I use a foreign key in a check constraint. This code was working with version 10.10.2, but does not anymore with 10.10.3. I checked and it still works with the latest 10.3.38.
DROP TABLE IF EXISTS `feedback`; |
|
CREATE TABLE IF NOT EXISTS `feedback` ( |
`id` INT NOT NULL AUTO_INCREMENT, |
PRIMARY KEY (`id`)); |
|
DROP TABLE IF EXISTS `message`; |
|
CREATE TABLE IF NOT EXISTS `message` ( |
`id` INT NOT NULL AUTO_INCREMENT, |
`feedback_id` INT, |
`value` INT, |
PRIMARY KEY (`id`), |
CONSTRAINT `fk_message_feedback` |
FOREIGN KEY (`feedback_id`) |
REFERENCES `feedback` (`id`) |
ON UPDATE CASCADE, |
CONSTRAINT `failing_constraint` |
CHECK ((`value` >= 10 AND `feedback_id` IS NOT NULL) |
OR (`value` <= 10 AND `feedback_id` IS NULL))); |
I get the error code 1901:
Error Code: 1901. Function or expression 'feedback_id' cannot be used in the CHECK clause of `failing_constraint`
|
Now my question is, if you have introduced a bug in your latest release or if that code snippet is something that should not be working, but was working so far unintentionally. I did not find an exact documentation if a foreign key should not be used in a check constraint.
Attachments
Issue Links
- duplicates
-
MDEV-22880 Honor constraints on UPDATE CASCADE
- Open
- is caused by
-
MDEV-22602 WITHOUT OVERLAPS constraint is ignored when update is performed via foreign key cascade
- Closed
- relates to
-
MDEV-30674 Implement CHECK constraints validation on cascading updates
- Closed
-
MDEV-31322 FKs with 'ON UPDATE CASCADE' can be set in some contexts but not others
- Closed
-
MDEV-31769 Adding a check constraint in "create table" doesn't work if it uses a foreign key with "update cascade"
- Closed