Re: Compressing the AFTER TRIGGER queue

From: Jim Nasby <jim(at)nasby(dot)net>
To: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: "Robert Haas" <robertmhaas(at)gmail(dot)com>, "Simon Riggs" <simon(at)2ndquadrant(dot)com>, "Dean Rasheed" <dean(dot)a(dot)rasheed(at)gmail(dot)com>, "PostgreSQL Hackers" <pgsql-hackers(at)postgresql(dot)org>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Compressing the AFTER TRIGGER queue
Date: 2011-08-15 20:07:03
Message-ID: BD669E03-7295-46D2-8DF7-F7A927EB7B4E@nasby.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Aug 4, 2011, at 8:40 AM, Kevin Grittner wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>> On Wed, Aug 3, 2011 at 6:05 PM, Jim Nasby <jim(at)nasby(dot)net> wrote:
>>> Not sure how much this relates to this discussion, but I have
>>> often wished we had AFTER FOR EACH STATEMENT triggers that
>>> provided OLD and NEW recordsets you could make use of. Sometimes
>>> it's very valuably to be able to look at *all* the rows that
>>> changed in a transaction in one shot.
>>
>> Yeah, that would be awesome. I think some of our competitors
>> provide exactly that feature...
>
> If I remember correctly, MS SQL Server and Sybase ASE provide
> INSERTED and DELETED relations in triggers instead of NEW and OLD
> records. In a FOR EACH ROW trigger the relation contains only one
> row.
>
> This is related to the thread on BEFORE triggers, in that these
> products require that you UPDATE the row in the base table to modify
> it (normally by joining to the INSERTED relation), making the latest
> values available to other trigger code, and providing a clear
> distinction between the values coming in to the trigger and the
> latest values in the database.

Yeah, that sounds like how DB2 does it (though the relations were by default named NEW and OLD).

If there is agreement that having a NEW recordset that contains all the new records (or new values on updates) and an OLD recordset that contains all the old records, are there any other API issues that need to be resolved? How would this actually be implemented?
--
Jim C. Nasby, Database Architect jim(at)nasby(dot)net
512.569.9461 (cell) http://jim.nasby.net

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-08-15 20:31:35 Re: Should we have an optional limit on the recursion depth of recursive CTEs?
Previous Message Peter Geoghegan 2011-08-15 19:49:41 Should we have an optional limit on the recursion depth of recursive CTEs?