From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #6123: DELETE fails if before trigger causes another trigger to UPDATE
Date: Tue, 19 Jul 2011 18:10:41 -0400
Message-ID: <11540.1311113441@sss.pgh.pa.us> (raw)
In-Reply-To: <4E25B49C020000250003F51D@gw.wicourts.gov>
References: <201107191831.p6JIVdxu055846@wwwmaster.postgresql.org>
<201107191831.p6JIVdxu055846@wwwmaster.postgresql.org>
<5769.1311111047@sss.pgh.pa.us>
<4E25B49C020000250003F51D@gw.wicourts.gov>
"Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> The update causes the already-selected target row version of the
>> DELETE to be obsoleted, so heap_delete finds it has nothing to do.
>> I'm disinclined to mess with that logic.
> It's pretty astonishing behavior for application programmers. It's
> not unusual for triggers on detail from one table to maintain a
> status, count, or sum in a higher level table. When a DELETE from
> the higher level table causes deletes at the lower level, the lower
> level trigger really doesn't have any way to know that. I think
> this should be considered a bug.
I think you have no idea how large a can of worms you're opening.
To point out just one problem, if heap_delete restarts itself and tries
to delete some other row version than it started with, should the ON
DELETE triggers be fired again? If not, why not? If they are, what
prevents an infinite loop?
IMO, application code that causes this to happen is impossibly fragile
and needs to be rewritten to not do it.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, Kevin.Grittner@wicourts.gov
Subject: Re: BUG #6123: DELETE fails if before trigger causes another trigger to UPDATE
In-Reply-To: <11540.1311113441@sss.pgh.pa.us>
References: <201107191831.p6JIVdxu055846@wwwmaster.postgresql.org> <5769.1311111047@sss.pgh.pa.us> <4E25B49C020000250003F51D@gw.wicourts.gov> <11540.1311113441@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox