Re: After each row trigger NOT seeing data changes?

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Karl Nack <karlnack(at)futurityinc(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: After each row trigger NOT seeing data changes?
Date: 2010-02-25 22:24:47
Message-ID: 201002252224.o1PMOlC10423@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane wrote:
> Karl Nack <karlnack(at)futurityinc(dot)com> writes:
> > I notice the row count does not reflect the newly-inserted row, which
> > suggests that the trigger is not seeing changes made to the table. This
> > seems to be exactly opposite of what's in the manual:
> > http://www.postgresql.org/docs/8.3/interactive/trigger-datachanges.html
> > http://www.postgresql.org/docs/8.3/interactive/trigger-example.html
>
> The reason is that you've declared the function STABLE, which causes it
> to use the calling query's starting snapshot. So it cannot see any
> in-progress changes of the calling query. Declare it VOLATILE (or
> let it default to that) and it will act as you expect.
>
> I'm not sure if the cited portions of the manual ought to contain notes
> about this or not. It seems a bit off-topic for them, but if other
> people have been bit by this, then maybe ... comments anyone?

I have applied the attached documentation patch to subtly mention this
issue.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
PG East: http://www.enterprisedb.com/community/nav-pg-east-2010.do
+ If your life is a hard drive, Christ can be your backup. +

Attachment Content-Type Size
/rtmp/diff text/x-diff 1.5 KB

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2010-02-25 23:21:58 Re: trouble with to_char('L')
Previous Message Scott Marlowe 2010-02-25 20:13:05 Re: Tool for determining field usage of database tables