Re: Using SUBSELECT in CHECK expressions - Mailing list pgsql-general

From Tom Lane
Subject Re: Using SUBSELECT in CHECK expressions
Date
Msg-id 25124.1067981198@sss.pgh.pa.us
Whole thread Raw
In response to Using SUBSELECT in CHECK expressions  ("Najib Abi Fadel" <nabifadel@usj.edu.lb>)
Responses Re: Using SUBSELECT in CHECK expressions
List pgsql-general
"Najib Abi Fadel" <nabifadel@usj.edu.lb> writes:
> Is postgres going to support in a future release the use of SUBSELECT in a =
> CHECK expression ??

Not very likely.  To my mind, such a constraint would imply rechecking
whenever the table(s) read by the sub-SELECT change, not only when a
row of the constrained table changes.  I don't know any reasonably
efficient implementation of that behavior.  We might figure out how to
do it eventually, but don't hold your breath.

If you are satisfied with only a one-directional constraint (apply the
check just when the constrained table is modified), you can have it today.
Just put the SELECT into a function that's called by the CHECK
expression.

            regards, tom lane

pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Foreign Key to Inherited table
Next
From: Stephan Szabo
Date:
Subject: Re: Using SUBSELECT in CHECK expressions