Re: After Trigger assignment to NEW

From: "Owen Jacobson" <ojacobson(at)osl(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: After Trigger assignment to NEW
Date: 2006-02-24 18:58:25
Message-ID: 144D12D7DD4EC04F99241498BB4EEDCC23419A@nelson.osl.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Achilleus Mantzios wrote:

> O Tom Lane έγραψε στις Feb 24, 2006 :
>
> > By definition, an AFTER trigger is too late to change what was
> > stored. Use a BEFORE trigger.
>
> Too late if someone wants to store it.
> I wanna store the intented original values, thats why i use
> AFTER trigger.
> But i would like to alter what a final AFTER trigger would see.
>
> I'll elabarote a little.
>
> An update happens.
> The row is stored.
> An after trigger is fired that alters some NEW columns
> (nullifies them), aiming for a subsequent trigger
> to see the altered results .
>
> It should be something like a pointer to a HeapTuple, (right?),
> so that would be feasible i suppose.
>
> I would not even make a post if it was something that trivial.
>
> I hope you get my point.

Your real problem is that the "subsequent" trigger has behaviour you don't like. That's what you should be fixing. If dbmirror has no way to exclude specific tables from mirroring, take it up with them as a feature request, or patch dbmirror to work how you want it to.

AFTER triggers *must* receive the row that was actually inserted/updated/deleted. If they could receive a "modified" row that didn't reflect what was actually in the database, all sorts of useful trigger-based logging and replication patterns wouldn't work, and there's really no other way to implement them. See also Tom Lane's other message for further implications of being able to modify the rows seen by AFTER triggers.

I'd also be hesitant to write triggers that have to execute in a specific order.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Achilleus Mantzios 2006-02-24 19:47:51 Re: After Trigger assignment to NEW
Previous Message Daniel Hernandez 2006-02-24 18:10:30 Re: Missing fields on Query result.