[MDEV-32876] Allow stored functions in CHECK constraints Created: 2023-11-25  Updated: 2023-11-25

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

Type: Task Priority: Major
Reporter: Federico Razzoli Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: check_constraints, stored_procedures


 Description   

We should be able to use stored functions in CHECK constraints:

CREATE OR REPLACE TABLE t (
    email VARCHAR(100) NOT NULL CHECK (is_email(email))
);

PostgreSQL and SQL Server allow this. I didn't check other DBMSs.

PostgreSQL assumes that the function logic never changes. If you replace the function with a new version, it won't notice if CHECK constraints fail. I think that this is a reasonable limitation.

Since MariaDB has a [NOT] DETERMINISTIC clause, it would also be reasonable to only allow DETERMINISTIC functions in CHECK constraints.


Generated at Thu Feb 08 10:34:41 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.