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

From Tom Lane
Subject Re: bug or not? Trigger preventing delete causes circumvention of FK
Date
Msg-id 5965.1134094667@sss.pgh.pa.us
Whole thread Raw
In response to bug or not? Trigger preventing delete causes circumvention of FK  (Luca Pireddu <luca@cs.ualberta.ca>)
List pgsql-general
Luca Pireddu <luca@cs.ualberta.ca> writes:
> 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.

[ shrug... ] So don't do that.  Triggers can break FK constraints in any
number of ways beside this one (eg, changing the data in the record).
If we tried to prevent that I think we'd either waste a lot of cycles or
cripple the trigger feature ... quite possibly both.

            regards, tom lane

pgsql-general by date:

Previous
From: Luca Pireddu
Date:
Subject: bug or not? Trigger preventing delete causes circumvention of FK
Next
From: Kathy Lo
Date:
Subject: Re: memory leak under heavy load?