Re: BUG #6632: "before delete" triggers that delete rows from the same table can invalidate constraints

From: Ignas Mikalajunas <ignas(at)pow(dot)lt>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6632: "before delete" triggers that delete rows from the same table can invalidate constraints
Date: 2012-05-07 15:09:40
Message-ID: CAKMRbDa50YaSs_qcGVY7jX=dhL2BETMMCsCUHPPo672ObaO4pQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, May 7, 2012 at 6:06 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> ignas(at)pow(dot)lt writes:
>> [ you can sabotage foreign key constraints with triggers ]
>
> This is not a bug, it's a "don't do that" issue.  The only way to
> prevent it would be to not fire triggers during FK operations, or
> to somehow restrict what triggers are allowed to do, and either of
> those cures would be worse than the disease.
>
> In general, it's bad design to use a BEFORE trigger to propagate changes
> to other rows; you should do that in AFTER triggers.  See the
> documentation.
>
>                        regards, tom lane

I see, thank you very much for the explanation.

Ignas

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Heikki Linnakangas 2012-05-07 15:37:27 Re: BUG #6629: Creating a gist index fails with "too many LWLocks taken"
Previous Message Tom Lane 2012-05-07 15:06:10 Re: BUG #6632: "before delete" triggers that delete rows from the same table can invalidate constraints