Ian Turner <[EMAIL PROTECTED]> writes:
> I'm guessing this means I can't do subselects in CHECK statements.

Right.  Pushing the SELECT into a SQL or PLPGSQL function that's called
by the constraint is a good workaround, ie

        CHECK (testconstraint(a, b))

where FUNCTION testconstraint(a int, b int) RETURNS bool does all the
heavy lifting.  If you use plpgsql there should be a performance
advantage too --- the query plan for the function will be cached for
re-use across calls, which is not true for the text of CHECK conditions.

                        regards, tom lane

Reply via email to