mirror of
https://github.com/postgres/postgres.git
synced 2025-10-21 02:52:47 +03:00
PL/Python: Add event trigger support
Allow event triggers to be written in PL/Python. It provides a TD dictionary with some information about the event trigger. Author: Euler Taveira <euler@eulerto.com> Co-authored-by: Dimitri Fontaine <dimitri@2ndQuadrant.fr> Reviewed-by: Pavel Stehule <pavel.stehule@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/03f03515-2068-4f5b-b357-8fb540883c38%40app.fastmail.com
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "access/htup_details.h"
|
||||
#include "catalog/pg_proc.h"
|
||||
#include "catalog/pg_type.h"
|
||||
#include "commands/event_trigger.h"
|
||||
#include "commands/trigger.h"
|
||||
#include "executor/spi.h"
|
||||
#include "miscadmin.h"
|
||||
@@ -240,6 +241,13 @@ plpython3_call_handler(PG_FUNCTION_ARGS)
|
||||
trv = PLy_exec_trigger(fcinfo, proc);
|
||||
retval = PointerGetDatum(trv);
|
||||
}
|
||||
else if (CALLED_AS_EVENT_TRIGGER(fcinfo))
|
||||
{
|
||||
proc = PLy_procedure_get(funcoid, InvalidOid, PLPY_EVENT_TRIGGER);
|
||||
exec_ctx->curr_proc = proc;
|
||||
PLy_exec_event_trigger(fcinfo, proc);
|
||||
retval = (Datum) 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
proc = PLy_procedure_get(funcoid, InvalidOid, PLPY_NOT_TRIGGER);
|
||||
@@ -346,6 +354,9 @@ PLy_procedure_is_trigger(Form_pg_proc procStruct)
|
||||
case TRIGGEROID:
|
||||
ret = PLPY_TRIGGER;
|
||||
break;
|
||||
case EVENT_TRIGGEROID:
|
||||
ret = PLPY_EVENT_TRIGGER;
|
||||
break;
|
||||
default:
|
||||
ret = PLPY_NOT_TRIGGER;
|
||||
break;
|
||||
|
Reference in New Issue
Block a user