Re: Trigger loop question

From: Gregory Wood <gwood(at)ewebengine(dot)com>
To: Mike Nolan <nolan(at)gw(dot)tssi(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql general list <pgsql-general(at)postgresql(dot)org>
Subject: Re: Trigger loop question
Date: 2004-03-16 03:11:23
Message-ID: 4056705B.7010001@ewebengine.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andreas 2004-03-16 03:53:07 Re: Postmaster won't run as service on Cygwin
Previous Message Andreas 2004-03-16 03:09:22 Re: Postmaster won't run as service on Cygwin