Re: [PATCH] Hooks at XactCommand level

Поиск
Список
Период
Сортировка
От Gilles Darold
Тема Re: [PATCH] Hooks at XactCommand level
Дата
Msg-id b727cc11-982a-e9c9-5321-e0e7fe45fa68@darold.net
обсуждение исходный текст
Ответ на Re: [PATCH] Hooks at XactCommand level  (Gilles Darold <gilles@darold.net>)
Ответы Re: [PATCH] Hooks at XactCommand level
Список pgsql-hackers
Hi,


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 [1] .


The patch compile and regressions tests with assert enabled passed
successfully.

There is no regression test for this feature but extension at [1] 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 [1])

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).


[1] https://github.com/darold/pg_statement_rollbackv2

--
Gilles Darold
http://www.darold.net/


Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Daniil Zakhlystov
Дата:
Сообщение: Re: libpq compression
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: [PATCH] Partial foreign key updates in referential integrity triggers