Re: functions allowed in CHECK constraints

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: functions allowed in CHECK constraints
Дата
Msg-id CAKFQuwY6=rJ0J+b9b4VQ=JkJUTdv95N9bmUE9MZojzdetJM3Ow@mail.gmail.com
обсуждение исходный текст
Ответ на functions allowed in CHECK constraints  (Achilleas Mantzios <itdev@itdevel.internal.net>)
Ответы Re: functions allowed in CHECK constraints  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
On Fri, Feb 9, 2018 at 1:37 AM, Achilleas Mantzios <itdev@itdevel.internal.net> wrote:

So, what's the point in forbidding the use of subselects if one can use functions? And OTOH if effectively doing so is bad for some reason, why let it happen with a function?

Short answer, the system treats the function as a black-box and doesn't know that you've used it to circumvent its prohibition on subselects.  The prohibition still is in place though.  If you use a function you are expected to ensure you do not violate any of the restrictions yourself.

The reason it is bad is because the query is only run at row insertion time - and if the external data that the subquery references changes the check constraint can become invalidated.  If that happens at minimum a dump/restore will fail.

David J.

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

Предыдущее
От: Achilleas Mantzios
Дата:
Сообщение: Re: functions allowed in CHECK constraints
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: functions allowed in CHECK constraints