Re: how do you get there from here? - Mailing list pgsql-general

From Alban Hertroys
Subject Re: how do you get there from here?
Date
Msg-id 51E9F96F-CD48-47D6-AF98-183B2E8770BF@solfertje.student.utwente.nl
Whole thread Raw
In response to Re: how do you get there from here?  ("Michael P. Soulier" <michael_soulier@mitel.com>)
Responses Re: how do you get there from here?  ("Michael P. Soulier" <michael_soulier@mitel.com>)
List pgsql-general
On May 13, 2009, at 8:48 PM, Michael P. Soulier wrote:

> Can someone suggest a better way that doesn't hit this "pending
> trigger"
> issue while in a transaction?


IIRC you had an initially deferred foreign key constraint? Do you
absolutely need that to be initially deferred, or deferrable even?
Because that's what's causing your problem, not the foreign key
constraint itself.

If that FK does need to be initially deferred, as a workaround you can
temporarily disable the foreign key while doing your updates. Easiest
is to drop the constraint, do your updates and recreate the
constraint, at which point the database will verify that the related
records match the constraint. Of course this opens a risk where a
record gets inserted that doesn't match your FK constraint which will
cause recreation to error out and your transaction to rollback.

Alban Hertroys

--
If you can't see the forest for the trees,
cut the trees and you'll see there is no forest.


!DSPAM:737,4a0d321a10092082955122!



pgsql-general by date:

Previous
From: Raymond O'Donnell
Date:
Subject: Re: Where is pg_dump?
Next
From: Tom Lane
Date:
Subject: Re: drop table but file still exists