|From:||Gilles Darold <gilles(at)darold(dot)net>|
|To:||Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Nicolas CHAHWEKILIAN <leptitstagiaire(at)gmail(dot)com>|
|Subject:||Re: [PATCH] Hooks at XactCommand level|
|Views:||Raw Message | Whole Thread | Download mbox | Resend email|
I have renamed the patch and the title of this proposal registered in
the commitfest "Xact/SubXact event callback at command start" to reflect
the last changes that do not include new hooks anymore.
Here is the new description corresponding to the current patch.
This patch allow to execute user-defined code for the start of any
command through a xact registered callback. It introduce two new events
in XactEvent and SubXactEvent enum called respectively
XACT_EVENT_COMMAND_START and SUBXACT_EVENT_COMMAND_START. The callback
is not called if a transaction is not started.
The objective of this new callback is to be able to call user-defined
code before any new statement is executed. For example it can call a
rollback to savepoint if there was an error in the previous transaction
statement, which allow to implements Rollback at Statement Level at
server side using a PostgreSQL extension, see  .
The patch compile and regressions tests with assert enabled passed
There is no regression test for this feature but extension at  has
been used for validation of the new callback.
The patch adds insignificant overhead by looking at an existing callback
definition but clearly it is the responsibility to the developer to
evaluate the performances impact of its user-defined code for this
callback as it will be called before each statement. Here is a very
simple test using pgbench -c 20 -j 8 -T 30
tps = 669.930274 (without user-defined code)
tps = 640.718361 (with user-defined code from extension )
the overhead for this extension is around 4.5% which I think is not so
bad good for such feature (internally it adds calls to RELEASE +
SAVEPOINT before each write statement execution and in case of error a
ROLLBACK TO savepoint).
|Next Message||Peter Eisentraut||2021-07-14 13:51:33||Re: [PATCH] Partial foreign key updates in referential integrity triggers|
|Previous Message||Daniil Zakhlystov||2021-07-14 13:01:00||Re: libpq compression|