Re: Trigger before delete does fire before, but delete doesn't not happen - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Trigger before delete does fire before, but delete doesn't not happen
Date
Msg-id 779447495.987121228163527348.JavaMail.root@sz0030a.emeryville.ca.mail.comcast.net
Whole thread Raw
Responses Re: Trigger before delete does fire before, but delete doesn't not happen
List pgsql-general
----- "Tom Lane" <tgl@sss.pgh.pa.us> wrote:

> Adrian Klaver <aklaver@comcast.net> writes:
> > The problem as far as I can tell is tuple visibility.
>
> Sort of: the triggers on commandeligne fire (and update the commande
> row)
> at completion of the DELETE command inside p_commande_bd.  This means
> that by the time control returns from that trigger, the tuple version
> that was targeted for deletion is already dead, so there's nothing to
> do.  It doesn't chain up to the newer version of the row.
>

Thanks for the explanation. Just so I am clear,the act of updating the row in p_commandeligne_ad creates a new tuple
forthe row with id of 1. This means the original statement "delete from commande where id=1" runs against a version of
therow that no longer exists and becomes a no-op statement. This happens because the trigger was run as BEFORE and
changedthe row from under the original statement. 


>             regards, tom lane


Adrian Klaver
aklaver@comcast.net


pgsql-general by date:

Previous
From: "Scott Marlowe"
Date:
Subject: Re: Monty on MySQL 5.1: "Oops, we did it again"
Next
From: Andrew Sullivan
Date:
Subject: Re: Monty on MySQL 5.1: "Oops, we did it again"