Re: bug or not? Trigger preventing delete causes circumvention - Mailing list pgsql-general

From Luca Pireddu
Subject Re: bug or not? Trigger preventing delete causes circumvention
Date
Msg-id 200512090949.55632.luca@cs.ualberta.ca
Whole thread Raw
In response to Re: bug or not? Trigger preventing delete causes circumvention  (Jan Wieck <JanWieck@Yahoo.com>)
List pgsql-general
On Friday 09 December 2005 09:22, Jan Wieck wrote:
> On 12/8/2005 9:12 PM, Luca Pireddu wrote:
> > I wrote a trigger function with the intent of preventing the deletion of
> > a parent record when a referencing record would not allow it.  However,
> > the result is that the referencing record stays, but the referenced one
> > is gone, so that my foreign key constraint is not respected.  The
> > behaviour can be replicated with the following:
>
> You did something else than intended. You prevented deletion of the
> referencing (dependent) record. That is where you defined the trigger,
> and that is what renders the foreign key constraints DELETE operation
> from dependent into a NOP.
>
> I guess that counts more as a pilot error.
>
>
> Jan
>

Thanks for the clarification.  I was working under the assumption that
preventing the deletion would cause an error to be raised by the FK check.
On a related note, I can achieve my intended behaviour by raising an
exception in the trigger, rather than returning null.

Luca

pgsql-general by date:

Previous
From: "Andrew J. Kopciuch"
Date:
Subject: Re: tsearch2: How to use different configurations for two columns?
Next
From: Peter Eisentraut
Date:
Subject: Re: PgSQL 8.1.0 Solaris w/ Sun's cc