Details
-
Task
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
None
-
None
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.