Triggers on transaction?

From: Jordan Gigov <coladict(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Triggers on transaction?
Date: 2015-05-27 10:39:21
Message-ID: CA+nBocCxTd64U8pteO172VfEZfSavu31oqZK2GzwGf05k7G_6A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

Perhaps in 9.6 this part of syntax for trigger creation can be changed from:

[ FOR [ EACH ] { ROW | STATEMENT } ]

to:

[ FOR [ EACH ] { ROW | STATEMENT | TRANSACTION } ]

I looked though the code get an idea of how difficult it would be to
implement and I think I might be able to do it, at least for functions
without parameters. My idea for functions with parameters is to have them
constrained to each one only accepting arrays of the type of element that
is passed. Meaning if the column type is integer[], the function must take
integer[][] in that parameter. From then on it's a matter of choice whether
they'll be passed at original order or reverse and whether the trigger
execution will be moved back or not.

Should I bother trying or will such a feature not be accepted into a final
release, even if it's working?

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marko Tiikkaja 2015-05-27 10:42:29 Re: Triggers on transaction?
Previous Message Guillaume Lelarge 2015-05-27 10:02:41 Re: about lob(idea)