From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
---|---|
To: | Glyn Astill <glynastill(at)yahoo(dot)co(dot)uk>, Andreas Joseph Krogh <andreas(at)visena(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Triggers on transaction? |
Date: | 2015-05-27 16:54:45 |
Message-ID: | 5565F6D5.9060301@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 05/27/2015 09:40 AM, Glyn Astill wrote:
>> From: Andreas Joseph Krogh <andreas(at)visena(dot)com>
>> To: pgsql-hackers(at)postgresql(dot)org
>> Sent: Wednesday, 27 May 2015, 13:55
>> Subject: Re: [HACKERS] Triggers on transaction?
>>
>>
>> På onsdag 27. mai 2015 kl. 12:42:29, skrev Marko Tiikkaja <marko(at)joh(dot)to>:
>> On 5/27/15 12:39 PM, Jordan Gigov wrote:
>>>> I found myself in need of triggers that are run only once per transaction,
>>>> rather than per row or statement within the transaction. Meaning it will
>>>> always be deferred and never called twice for the same transaction.
>>> What's the use case?
>>
>> I've often needed this for stuff like:
>>
>> UPDATE some_table SET col = 'foo' where id = 1;
>> UPDATE some_table SET col = 'bar' where id = 1;
>>
>> I want the "on-tx"-trigger to only run once, and on the last update of "col" so that it sees 'bar'.
>>
>
>
> I often have similar requirements, and usually end up having to track what's already been updated with a trigger or similar then finally do the work in a deferred trigger. I'd have thought something more like FOR EACH { ROW | STATEMENT } PER TRANSACTION would be more fitting.
>
>
It's come up before. You can read some history here:
<http://postgresql.nabble.com/pre-commit-triggers-td5778575.html>
It seems clear there is some sort of unmet need here.
cheers
andrew
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2015-05-27 17:41:27 | Re: Can we add syntax for references auto create index or not. |
Previous Message | Robert Haas | 2015-05-27 16:52:52 | Re: [COMMITTERS] pgsql: Add pg_audit, an auditing extension |