"Najib Abi Fadel" <nabifadel(at)usj(dot)edu(dot)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