[MDEV-26097] Constraints: support deferred constraints Created: 2021-07-06  Updated: 2024-01-18

Status: Open
Project: MariaDB Server
Component/s: Server
Fix Version/s: None

Type: Task Priority: Major
Reporter: Nilnandan Joshi Assignee: Ralf Gebhardt
Resolution: Unresolved Votes: 0
Labels: Compatibility

Issue Links:
Duplicate
is duplicated by MDEV-26096 Make the Unique index ONLY evaluate i... Stalled
Relates
relates to MDEV-22361 Cross-engine foreign keys support Open

 Description   

I would be nice if deferred constraints will be supported by MariaDB
Upstream : https://bugs.mysql.com/bug.php?id=7529



 Comments   
Comment by Marko Mäkelä [ 2022-01-25 ]

When it comes to FOREIGN KEY constraints, I think that we may first need MDEV-22361. Implementing deferred constraint checks inside InnoDB only would not seem too useful, because that code is not compatible with other features (MySQL Bug #11472 Triggers not executed following foreign key updates/deletes).

I have a vague idea how to implement deferred constraints: Before COMMIT or XA PREPARE, traverse the log of changed rows that might violate some constraints, and perform the checks. Inside InnoDB, we actually already have such a log: the undo log of the transaction. But InnoDB itself does not know anything about CHECK constraints, and it would probably be expensive to iterate each undo log record if violations are rare.

It could be better to maintain a shorter ‘deferred check’ list that would be appended to during the execution of the transaction whenever some constraint is failing during the initial row operation. The storage engine would simply say ‘this operation needs to be checked and may lead to rollback’ and allow the ‘transient violation’.

Generated at Thu Feb 08 09:42:43 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.