Re: TRIGGER BEFORE INSERT

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: Rafal Pietrak <rafal(at)zorro(dot)isa-geek(dot)com>, Alban Hertroys <alban(at)magproductions(dot)nl>, pgsql-general(at)postgresql(dot)org
Subject: Re: TRIGGER BEFORE INSERT
Date: 2007-01-11 19:27:51
Message-ID: 28753.1168543671@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Martijn van Oosterhout <kleptog(at)svana(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jonathan Hedstrom 2007-01-11 19:32:26 Re: ERROR: invalid memory alloc request size, and others
Previous Message Tom Lane 2007-01-11 19:24:58 Re: ORDER BY col is NULL in UNION causes error?