Re: Purpose of DEFERRABLE _and_ INITIALLY DEFERRED foreign key constraint checking?

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: Purpose of DEFERRABLE _and_ INITIALLY DEFERRED foreign key constraint checking?
Дата
Msg-id 05b30f5d-ae4e-edb1-7691-8ef0d867617f@aklaver.com
обсуждение исходный текст
Ответ на Re: Purpose of DEFERRABLE _and_ INITIALLY DEFERRED foreign key constraint checking?  (Ron <ronljohnsonjr@gmail.com>)
Список pgsql-general
On 8/3/22 18:13, Ron wrote:
> On 8/3/22 20:02, Adrian Klaver wrote:
>> On 8/3/22 17:30, Ron wrote:
>>> AWS RDS Postgresql 12.10

> 
> And https://www.postgresql.org/docs/12/sql-set-constraints.html seems to 
> say that SET CONSTRAINTS can make DEFERRABLE FKs temporarily not 
> deferrable.
> 
> What's the point?

The way I think of it is:

1) CONSTRAINTS are something that is supposed to constrain an action.

2) Setting DEFERRABLE is a cheat code to push 1) out to the end of a 
transaction by using INITIALLY DEFERRED.

3) If the constraint was created/altered to DEFERRABLE INITIALLY 
DEFERRED the SET CONSTRAINTS IMMEDIATE unsets the cheat code in a given 
transaction. Maybe for most cases you want the check done at the end  of 
the transaction, but in a specific case you need that check to happen 
before another statement occurs prior to the end of the transaction.


-- 
Adrian Klaver
adrian.klaver@aklaver.com



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

Предыдущее
От: Thomas Guyot
Дата:
Сообщение: Re: Is Client connections via ca.crt only possible?
Следующее
От: Sacheen Birhade
Дата:
Сообщение: How to choose new master from slaves.?