From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #6123: DELETE fails if before trigger causes another trigger to UPDATE
Date: Tue, 19 Jul 2011 16:45:16 -0500
Message-ID: <4E25B49C020000250003F51D@gw.wicourts.gov> (raw)
In-Reply-To: <5769.1311111047@sss.pgh.pa.us>
References: <201107191831.p6JIVdxu055846@wwwmaster.postgresql.org>
<201107191831.p6JIVdxu055846@wwwmaster.postgresql.org>
<5769.1311111047@sss.pgh.pa.us>
Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
>> [ circular trigger relationships ]
>
>> I expect the DELETE from a to delete related b record(s) and then
>> succeed. Instead the UPDATE in b_del_trig causes delete of a to
>> silently fail.
>
> 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.
At the point where heap_delete finds that the tuple has expired, I
think it should follow the ctid chain as long as xmax is from the
same top-level transaction, and then decide if it has something to
do. Normally, that would be zero iterations, so I doubt the
performance impact is huge.
I'm willing to mess with that logic if there's a chance that it will
be accepted. I may *need* to even if it won't, to allow our
migration to native PostgreSQL triggers to succeed -- we've been
trying to work around it for the last few days, but the places where
it's popping up are becoming increasingly hard to accommodate that
way.
-Kevin
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: Kevin.Grittner@wicourts.gov, tgl@sss.pgh.pa.us
Subject: Re: BUG #6123: DELETE fails if before trigger causes another trigger to UPDATE
In-Reply-To: <4E25B49C020000250003F51D@gw.wicourts.gov>
References: <201107191831.p6JIVdxu055846@wwwmaster.postgresql.org> <5769.1311111047@sss.pgh.pa.us> <4E25B49C020000250003F51D@gw.wicourts.gov>
* 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