Re: Question on triggers and plpgsql

From: John DeSoi <desoi(at)pgedit(dot)com>
To: Sean Davis <sdavis2(at)mail(dot)nih(dot)gov>
Cc: Carlos Moreno <moreno(at)mochima(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Question on triggers and plpgsql
Date: 2005-04-08 14:13:02
Message-ID: 51899A9B-A838-11D9-9125-000A95B03262@pgedit.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2005-04-08 14:36:26 Re: Question on triggers and plpgsql
Previous Message Sean Davis 2005-04-08 13:41:57 Re: Question on triggers and plpgsql