Re: Changes to not deferred FK in 8.0.3 to 7.4? - Mailing list pgsql-general

From Tom Lane
Subject Re: Changes to not deferred FK in 8.0.3 to 7.4?
Date
Msg-id 23276.1121780418@sss.pgh.pa.us
Whole thread Raw
In response to Re: Changes to not deferred FK in 8.0.3 to 7.4?  (Janning Vygen <vygen@gmx.de>)
Responses Re: Changes to not deferred FK in 8.0.3 to 7.4?
Re: Changes to not deferred FK in 8.0.3 to 7.4?
List pgsql-general
Janning Vygen <vygen@gmx.de> writes:
> On more related question:
> I updated pg_trigger and pg_constraint and changed all my FK:

> UPDATE pg_trigger
> SET
>   tgdeferrable = true,
>   tginitdeferred = true
> WHERE tgconstrname LIKE 'fk_%'
> ;

> UPDATE pg_constraint
> SET
>   condeferrable = true,
>   condeferred = true
> WHERE conname LIKE 'fk_%'
> ;

No, only the triggers that are for checks should be marked
deferrable/deferred.  These are the ones using functions
 RI_FKey_check_ins
 RI_FKey_check_upd
 RI_FKey_noaction_del
 RI_FKey_noaction_upd
You want the others nondeferrable because (a) that's the standard
behavior and (b) it'll ensure that the actions happen before the
checks are made.

            regards, tom lane

pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Slow first query
Next
From: "David Parker"
Date:
Subject: pg_dump and write locks