Re: Sequence of SQL command execution involving triggers and stored procedures. - Mailing list pgsql-sql

From Tom Lane
Subject Re: Sequence of SQL command execution involving triggers and stored procedures.
Date
Msg-id 4960.1095525561@sss.pgh.pa.us
Whole thread Raw
In response to Sequence of SQL command execution involving triggers and stored procedures.  ("Omkar Rath" <orath@cisco.com>)
List pgsql-sql
"Omkar Rath" <orath@cisco.com> writes:
> Say there is a stored procedure i.e FUNCTION sp_foo(...) which has say,
> SQL commands (any of SELECT,INSERT,UPDATE,DELETE) in its body, say S1
> followed by S2 then S3.... Furthermore, execution of statement S2
> results in trigger functions getting invoked (that contain yet other SQL
> statements).
>
> By the time, the trigger functions execute (as a result of S2), S3 has
> already executed.

In existing PG releases, AFTER triggers are always fired at the
completion of the whole interactive command (ie, the outer SELECT that
called sp_foo).

There are changes in 8.0 to fire them at the end of the specific query
that triggered them, which I believe will do what you want.
        regards, tom lane


pgsql-sql by date:

Previous
From: Greg Stark
Date:
Subject: Re: 1-byte integers
Next
From: Christopher Browne
Date:
Subject: Re: How to check postgres running or not ?