Re: Question on triggers and plpgsql - Mailing list pgsql-sql

From John DeSoi
Subject Re: Question on triggers and plpgsql
Date
Msg-id 51899A9B-A838-11D9-9125-000A95B03262@pgedit.com
Whole thread Raw
In response to Re: Question on triggers and plpgsql  (Sean Davis <sdavis2@mail.nih.gov>)
List pgsql-sql
On Apr 8, 2005, at 9:41 AM, Sean Davis wrote:

> Just one detail, but in the form of a question. In the original 
> posting, I think the trigger was doing the logging for something 
> happening on a table as a before insert or update--I may be wrong on 
> that detail.  I would think of doing such actions AFTER the 
> update/insert.  In the world of transaction-safe operations, is there 
> ANY danger in doing the logging as a BEFORE trigger rather than an 
> AFTER trigger?


Good point. I think both will work in this case and it would depend on 
the application if it makes a difference. You definitely want an AFTER 
trigger if you need to see the final state of the row before making 
changes. In this case the assignment of the column does not depend on 
any other factors so it would not seem to matter. But I agree from a 
semantics point of view, an AFTER trigger might be a little better for 
this.

John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL



pgsql-sql by date:

Previous
From: Sean Davis
Date:
Subject: Re: Question on triggers and plpgsql
Next
From: Tom Lane
Date:
Subject: Re: Question on triggers and plpgsql