Re: TRIGGER BEFORE INSERT - Mailing list pgsql-general

From Tom Lane
Subject Re: TRIGGER BEFORE INSERT
Date
Msg-id 28753.1168543671@sss.pgh.pa.us
Whole thread Raw
In response to Re: TRIGGER BEFORE INSERT  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
Martijn van Oosterhout <kleptog@svana.org> writes:
> On Thu, Jan 11, 2007 at 07:26:32PM +0100, Rafal Pietrak wrote:
>> So may be "SET CONSTRAINTS  .... DEFERRED " should be used somehow
>> differently? I've never had any use for that construct, may be I miss
>> something?

> Only at the beginning of a transaction and it only works on foreign
> keys marked deferrable.

No, you can do it mid-transaction.  I think the problem is the second
part: the FK constraint has to be marked deferrable, which is not the
default I believe.  Also, you could forget the SET CONSTRAINTS entirely
if you made the constraint INITIALLY DEFERRED ... then it'd always act
as a deferred check.

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: ORDER BY col is NULL in UNION causes error?
Next
From: Jonathan Hedstrom
Date:
Subject: Re: ERROR: invalid memory alloc request size, and others