Re: bug or not? Trigger preventing delete causes circumvention

From: Luca Pireddu <luca(at)cs(dot)ualberta(dot)ca>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: bug or not? Trigger preventing delete causes circumvention
Date: 2005-12-09 16:49:55
Message-ID: 200512090949.55632.luca@cs.ualberta.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2005-12-09 16:57:27 Re: PgSQL 8.1.0 Solaris w/ Sun's cc
Previous Message Andrew J. Kopciuch 2005-12-09 16:35:44 Re: tsearch2: How to use different configurations for two columns?