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
Ответ на
Список
Дерево обсуждения
Purpose of DEFERRABLE _and_ INITIALLY DEFERRED foreign key constraint checking? Ron <ronljohnsonjr@gmail.com>
Re: Purpose of DEFERRABLE _and_ INITIALLY DEFERRED foreign key constraint checking? Adrian Klaver <adrian.klaver@aklaver.com>
Re: Purpose of DEFERRABLE _and_ INITIALLY DEFERRED foreign key constraint checking? Ron <ronljohnsonjr@gmail.com>
Re: Purpose of DEFERRABLE _and_ INITIALLY DEFERRED foreign key constraint checking? Adrian Klaver <adrian.klaver@aklaver.com>
Re: Purpose of DEFERRABLE _and_ INITIALLY DEFERRED foreign key constraint checking? Julien Rouhaud <rjuju123@gmail.com>
Re: Purpose of DEFERRABLE _and_ INITIALLY DEFERRED foreign key constraint checking? Jan Wieck <jan@wi3ck.info>
Re: Purpose of DEFERRABLE _and_ INITIALLY DEFERRED foreign key constraint checking? Francisco Olarte <folarte@peoplecall.com>
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 по дате отправления