Re: CHECK Constraint Deferrable - Mailing list pgsql-hackers

From Tom Lane
Subject Re: CHECK Constraint Deferrable
Date
Msg-id 2147386.1696274710@sss.pgh.pa.us
Whole thread Raw
In response to Re: CHECK Constraint Deferrable  (Himanshu Upadhyaya <upadhyaya.himanshu@gmail.com>)
Responses Re: CHECK Constraint Deferrable
Re: CHECK Constraint Deferrable
Re: CHECK Constraint Deferrable
List pgsql-hackers
Himanshu Upadhyaya <upadhyaya.himanshu@gmail.com> writes:
> V3 patch attached.

Sorry for not weighing in on this before, but ... is this a feature
we want at all?  We are very clear in the existing docs that CHECK
conditions must be immutable [1], and that's not something we can
easily relax because if they are not then it's unclear when we need
to recheck them to ensure they stay satisfied.  But here we have a
feature whose only possible use is with constraints that *aren't*
immutable; else we might as well just check them immediately.
So that gives rise to a bunch of subtle questions about exactly what
properties a user-written constraint would need to have to guarantee
sane semantics given this implementation.  Can we define what those
properties are, or what the ensuing semantic guarantees are exactly?
Can we explain those things clearly enough that the average user would
have a shot at writing a valid deferred constraint?  Is a deferred
constraint having those properties likely to be actually useful?

I don't know the answers to these questions, but it troubles me a
lot that zero consideration appears to have been given to them.
I do not think we should put more effort into this patch unless
satisfactory answers are forthcoming.

            regards, tom lane

[1] See Note at the bottom of "5.4.1. Check Constraints" here:
https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-CHECK-CONSTRAINTS



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [DOCS] HOT - correct claim about indexes not referencing old line pointers
Next
From: Robert Haas
Date:
Subject: Re: Pre-proposal: unicode normalized text