Re: Fwd: Start up question about triggers

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Fwd: Start up question about triggers
Date: 2006-06-23 17:48:08
Message-ID: 17077.1151084888@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Andrew Sullivan <ajs(at)crankycanuck(dot)ca> writes:
> On Fri, Jun 23, 2006 at 06:48:49PM +0300, Forums @ Existanze wrote:
>> Then there exist a TG_QUERY parameter that we could use to get the actual
>> query ran by a user, so if I ran the imaginary query

> Which "actual query"? By the time the trigger fires, the query might
> already have been rewritten, I think. No? I _think_ that even
> BEFORE triggers happen after the rewriter stage is called, but
> someone who has more clue will be able to correct me if I'm wrong.

Even if you could get hold of the user query text, it'd be a serious
mistake to imagine that it tells you everything you need to know about
the update. Aside from rule rewrites, previous BEFORE triggers could
have changed fields that are mentioned nowhere in the query. The only
safe way to determine what's going on is to compare the OLD and NEW
row values.

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Aaron Bono 2006-06-24 03:29:33 Re: Fwd: Start up question about triggers
Previous Message Andrew Sullivan 2006-06-23 17:35:04 Re: Fwd: Start up question about triggers