Re: Fwd: [NOVICE] Trigger and Recursive Relation ? - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Fwd: [NOVICE] Trigger and Recursive Relation ?
Date
Msg-id 20877.1154555244@sss.pgh.pa.us
Whole thread Raw
In response to Re: Fwd: [NOVICE] Trigger and Recursive Relation ?  ("Nikolay Samokhvalov" <samokhvalov@gmail.com>)
List pgsql-bugs
"Nikolay Samokhvalov" <samokhvalov@gmail.com> writes:
> I don't understand how this can be called "not bug"... Please, help me
> understand it :-)

The situation is that the DELETE arrives at a row after the trigger has
already UPDATEd that row.  You could make a reasonable case for throwing
an error in this situation, but what we choose to do is assume that the
trigger's action is correct.  The row version that the DELETE would have
acted on no longer "exists", so I don't really see that this violates the
spec (bearing in mind that the spec doesn't know what MVCC is).

I think the subtext of your complaint is that you'd like the DELETE to
be applied to the updated row, but that doesn't hold any more water than
what we do now.  Consider the opposite case where the outer query is an
UPDATE and the trigger DELETEs a row that the outer query will reach
later --- it certainly isn't going to make sense to un-delete the row
so we can update it.  The only sensible choices here are to throw an
error or do nothing.

            regards, tom lane

pgsql-bugs by date:

Previous
From: "Nikolay Samokhvalov"
Date:
Subject: Re: Fwd: [NOVICE] Trigger and Recursive Relation ?
Next
From: Brian Hurt
Date:
Subject: Re: BUG #2561: Manual is wrong: You can't grant a group to