Re: After each row trigger NOT seeing data changes?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Karl Nack <karlnack(at)futurityinc(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: After each row trigger NOT seeing data changes?
Date: 2009-05-21 20:36:22
Message-ID: 14635.1242938182@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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?

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Raymond O'Donnell 2009-05-21 20:39:58 Re: After each row trigger NOT seeing data changes?
Previous Message Rodrigo Gonzalez 2009-05-21 20:31:55 Re: After each row trigger NOT seeing data changes?