Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux