Re: bug or not? Trigger preventing delete causes circumvention of FK

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Luca Pireddu <luca(at)cs(dot)ualberta(dot)ca>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: bug or not? Trigger preventing delete causes circumvention of FK
Date: 2005-12-09 02:17:47
Message-ID: 5965.1134094667@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Luca Pireddu <luca(at)cs(dot)ualberta(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kathy Lo 2005-12-09 04:15:44 Re: memory leak under heavy load?
Previous Message Luca Pireddu 2005-12-09 02:12:25 bug or not? Trigger preventing delete causes circumvention of FK