Re: Trigger loop question - Mailing list pgsql-general

From Gregory Wood
Subject Re: Trigger loop question
Date
Msg-id 4056705B.7010001@ewebengine.com
Whole thread Raw
In response to Re: Trigger loop question  (Mike Nolan <nolan@gw.tssi.com>)
Responses Re: Trigger loop question
List pgsql-general
Mike Nolan wrote:

> However, if I update table 'B' and the 2nd trigger fires, that trigger
> will still see the OLD value if does a query on table 'A', since I
> think transaction atomic rules require that any updated values aren't
> made available to the outside world (including other triggers) until the
> transaction is complete.

I could be mistaken here, but... I don't believe that is the case. The
transaction can see what's going on inside of itself. Everything outside
of the transaction typically won't see what is inside the transaction,
until it is committed anyway.

> I tested this, and the 2nd trigger still sees the original value of
> the field from the first table, which I think is the proper result.

I think this has more to do with whether the first trigger was fired
BEFORE or AFTER the UPDATE. If the first trigger is fired BEFORE the
UPDATE, then the second trigger (fired on the UPDATE) will not see the
AFTER values of the first trigger. If you fire the first trigger as
AFTER, I bet you'll see the changes.

Greg

pgsql-general by date:

Previous
From: Andreas
Date:
Subject: Re: Postmaster won't run as service on Cygwin
Next
From: Andreas
Date:
Subject: Re: Postmaster won't run as service on Cygwin