Re: subselect in CHECK constraint?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: subselect in CHECK constraint?
Дата
Msg-id 14071.968083196@sss.pgh.pa.us
обсуждение исходный текст
Ответ на subselect in CHECK constraint?  (Ian Turner <vectro@pipeline.com>)
Ответы Re: subselect in CHECK constraint?  (Ian Turner <vectro@pipeline.com>)
Список pgsql-general
Ian Turner <vectro@pipeline.com> 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

В списке pgsql-general по дате отправления:

Предыдущее
От: Travis Bauer
Дата:
Сообщение: Change to DatabaseMetaData.java for the jdbc2 driver (fwd)
Следующее
От: "Enrico Comini"
Дата:
Сообщение: JDBC