mirror of
https://github.com/postgres/postgres.git
synced 2025-10-21 02:52:47 +03:00
PL/Python: Refactor for event trigger support
Change is_trigger type from boolean to enum. That's a preparation for adding event trigger support. 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:
@@ -38,7 +38,7 @@ PG_FUNCTION_INFO_V1(plpython3_call_handler);
|
||||
PG_FUNCTION_INFO_V1(plpython3_inline_handler);
|
||||
|
||||
|
||||
static bool PLy_procedure_is_trigger(Form_pg_proc procStruct);
|
||||
static PLyTrigType PLy_procedure_is_trigger(Form_pg_proc procStruct);
|
||||
static void plpython_error_callback(void *arg);
|
||||
static void plpython_inline_error_callback(void *arg);
|
||||
static void PLy_init_interp(void);
|
||||
@@ -163,7 +163,7 @@ plpython3_validator(PG_FUNCTION_ARGS)
|
||||
Oid funcoid = PG_GETARG_OID(0);
|
||||
HeapTuple tuple;
|
||||
Form_pg_proc procStruct;
|
||||
bool is_trigger;
|
||||
PLyTrigType is_trigger;
|
||||
|
||||
if (!CheckFunctionValidatorAccess(fcinfo->flinfo->fn_oid, funcoid))
|
||||
PG_RETURN_VOID();
|
||||
@@ -235,14 +235,14 @@ plpython3_call_handler(PG_FUNCTION_ARGS)
|
||||
Relation tgrel = ((TriggerData *) fcinfo->context)->tg_relation;
|
||||
HeapTuple trv;
|
||||
|
||||
proc = PLy_procedure_get(funcoid, RelationGetRelid(tgrel), true);
|
||||
proc = PLy_procedure_get(funcoid, RelationGetRelid(tgrel), PLPY_TRIGGER);
|
||||
exec_ctx->curr_proc = proc;
|
||||
trv = PLy_exec_trigger(fcinfo, proc);
|
||||
retval = PointerGetDatum(trv);
|
||||
}
|
||||
else
|
||||
{
|
||||
proc = PLy_procedure_get(funcoid, InvalidOid, false);
|
||||
proc = PLy_procedure_get(funcoid, InvalidOid, PLPY_NOT_TRIGGER);
|
||||
exec_ctx->curr_proc = proc;
|
||||
retval = PLy_exec_function(fcinfo, proc);
|
||||
}
|
||||
@@ -336,10 +336,22 @@ plpython3_inline_handler(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
static bool
|
||||
static PLyTrigType
|
||||
PLy_procedure_is_trigger(Form_pg_proc procStruct)
|
||||
{
|
||||
return (procStruct->prorettype == TRIGGEROID);
|
||||
PLyTrigType ret;
|
||||
|
||||
switch (procStruct->prorettype)
|
||||
{
|
||||
case TRIGGEROID:
|
||||
ret = PLPY_TRIGGER;
|
||||
break;
|
||||
default:
|
||||
ret = PLPY_NOT_TRIGGER;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
|
Reference in New Issue
Block a user