Permalink
Browse files

Fix some more command trigger remainings in PL support internals.

  • Loading branch information...
1 parent 16bc698 commit c4d551e1e6696b74ee7e844fbc58c0a619739481 @dimitri committed Jun 20, 2012
@@ -235,11 +235,11 @@ static void set_interp_require(bool trusted);
static Datum plperl_func_handler(PG_FUNCTION_ARGS);
static Datum plperl_trigger_handler(PG_FUNCTION_ARGS);
-static void plperl_command_trigger_handler(PG_FUNCTION_ARGS);
+static void plperl_event_trigger_handler(PG_FUNCTION_ARGS);
static plperl_proc_desc *compile_plperl_function(Oid fn_oid,
bool is_dml_trigger,
- bool is_cmd_trigger);
+ bool is_event_trigger);
static SV *plperl_hash_from_tuple(HeapTuple tuple, TupleDesc tupdesc);
static SV *plperl_hash_from_datum(Datum attr);
@@ -1573,7 +1573,7 @@ plperl_trigger_build_args(FunctionCallInfo fcinfo)
/* Set up the arguments for a command trigger call. */
static SV *
-plperl_command_trigger_build_args(FunctionCallInfo fcinfo)
+plperl_event_trigger_build_args(FunctionCallInfo fcinfo)
{
EventTriggerData *tdata;
char *objectid;
@@ -1702,7 +1702,7 @@ plperl_call_handler(PG_FUNCTION_ARGS)
if (CALLED_AS_TRIGGER(fcinfo))
retval = PointerGetDatum(plperl_trigger_handler(fcinfo));
else if (CALLED_AS_EVENT_TRIGGER(fcinfo))
- plperl_command_trigger_handler(fcinfo);
+ plperl_event_trigger_handler(fcinfo);
else
retval = plperl_func_handler(fcinfo);
}
@@ -1829,7 +1829,7 @@ plperl_validator(PG_FUNCTION_ARGS)
Oid *argtypes;
char **argnames;
char *argmodes;
- bool is_dml_trigger = false, is_cmd_trigger = false;
+ bool is_dml_trigger = false, is_event_trigger = false;
int i;
/* Get the new function's pg_proc entry */
@@ -1849,7 +1849,7 @@ plperl_validator(PG_FUNCTION_ARGS)
(proc->prorettype == OPAQUEOID && proc->pronargs == 0))
is_dml_trigger = true;
else if (proc->prorettype == EVTTRIGGEROID)
- is_cmd_trigger = true;
+ is_event_trigger = true;
else if (proc->prorettype != RECORDOID &&
proc->prorettype != VOIDOID)
ereport(ERROR,
@@ -1876,7 +1876,7 @@ plperl_validator(PG_FUNCTION_ARGS)
/* Postpone body checks if !check_function_bodies */
if (check_function_bodies)
{
- (void) compile_plperl_function(funcoid, is_dml_trigger, is_cmd_trigger);
+ (void) compile_plperl_function(funcoid, is_dml_trigger, is_event_trigger);
}
/* the result of a validator is ignored */
@@ -2148,7 +2148,7 @@ plperl_call_perl_trigger_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo,
static void
-plperl_call_perl_command_trigger_func(plperl_proc_desc *desc,
+plperl_call_perl_event_trigger_func(plperl_proc_desc *desc,
FunctionCallInfo fcinfo,
SV *td)
{
@@ -2432,7 +2432,7 @@ plperl_trigger_handler(PG_FUNCTION_ARGS)
static void
-plperl_command_trigger_handler(PG_FUNCTION_ARGS)
+plperl_event_trigger_handler(PG_FUNCTION_ARGS)
{
plperl_proc_desc *prodesc;
SV *svTD;
@@ -2461,8 +2461,8 @@ plperl_command_trigger_handler(PG_FUNCTION_ARGS)
activate_interpreter(prodesc->interp);
- svTD = plperl_command_trigger_build_args(fcinfo);
- plperl_call_perl_command_trigger_func(prodesc, fcinfo, svTD);
+ svTD = plperl_event_trigger_build_args(fcinfo);
+ plperl_call_perl_event_trigger_func(prodesc, fcinfo, svTD);
if (SPI_finish() != SPI_OK_FINISH)
elog(ERROR, "SPI_finish() failed");
@@ -2515,7 +2515,7 @@ validate_plperl_function(plperl_proc_ptr *proc_ptr, HeapTuple procTup)
static plperl_proc_desc *
-compile_plperl_function(Oid fn_oid, bool is_dml_trigger, bool is_cmd_trigger)
+compile_plperl_function(Oid fn_oid, bool is_dml_trigger, bool is_event_trigger)
{
HeapTuple procTup;
Form_pg_proc procStruct;
@@ -2617,7 +2617,7 @@ compile_plperl_function(Oid fn_oid, bool is_dml_trigger, bool is_cmd_trigger)
* Get the required information for input conversion of the
* return value.
************************************************************/
- if (!is_dml_trigger && !is_cmd_trigger)
+ if (!is_dml_trigger && !is_event_trigger)
{
typeTup =
SearchSysCache1(TYPEOID,
@@ -2675,7 +2675,7 @@ compile_plperl_function(Oid fn_oid, bool is_dml_trigger, bool is_cmd_trigger)
* Get the required information for output conversion
* of all procedure arguments
************************************************************/
- if (!is_dml_trigger && !is_cmd_trigger)
+ if (!is_dml_trigger && !is_event_trigger)
{
prodesc->nargs = procStruct->pronargs;
for (i = 0; i < prodesc->nargs; i++)
@@ -264,7 +264,7 @@ do_compile(FunctionCallInfo fcinfo,
{
Form_pg_proc procStruct = (Form_pg_proc) GETSTRUCT(procTup);
bool is_dml_trigger = CALLED_AS_TRIGGER(fcinfo);
- bool is_cmd_trigger = CALLED_AS_EVENT_TRIGGER(fcinfo);
+ bool is_event_trigger = CALLED_AS_EVENT_TRIGGER(fcinfo);
Datum prosrcdatum;
bool isnull;
char *proc_source;
@@ -353,8 +353,8 @@ do_compile(FunctionCallInfo fcinfo,
if (is_dml_trigger)
function->fn_is_trigger = PLPGSQL_DML_TRIGGER;
- else if (is_cmd_trigger)
- function->fn_is_trigger = PLPGSQL_CMD_TRIGGER;
+ else if (is_event_trigger)
+ function->fn_is_trigger = PLPGSQL_EVENT_TRIGGER;
else
function->fn_is_trigger = PLPGSQL_NOT_TRIGGER;
@@ -679,7 +679,7 @@ do_compile(FunctionCallInfo fcinfo,
break;
- case PLPGSQL_CMD_TRIGGER:
+ case PLPGSQL_EVENT_TRIGGER:
function->fn_rettype = VOIDOID;
function->fn_retbyval = false;
function->fn_retistuple = true;
@@ -773,8 +773,8 @@ plpgsql_exec_trigger(PLpgSQL_function *func,
return rettup;
}
-void plpgsql_exec_command_trigger(PLpgSQL_function *func,
- EventTriggerData *trigdata)
+void plpgsql_exec_event_trigger(PLpgSQL_function *func,
+ EventTriggerData *trigdata)
{
PLpgSQL_execstate estate;
ErrorContextCallback plerrcontext;
@@ -119,8 +119,8 @@ plpgsql_call_handler(PG_FUNCTION_ARGS)
retval = PointerGetDatum(plpgsql_exec_trigger(func,
(TriggerData *) fcinfo->context));
else if (CALLED_AS_EVENT_TRIGGER(fcinfo))
- plpgsql_exec_command_trigger(func,
- (EventTriggerData *) fcinfo->context);
+ plpgsql_exec_event_trigger(func,
+ (EventTriggerData *) fcinfo->context);
else
retval = plpgsql_exec_function(func, fcinfo);
}
@@ -228,7 +228,7 @@ plpgsql_validator(PG_FUNCTION_ARGS)
char **argnames;
char *argmodes;
bool is_dml_trigger = false;
- bool is_cmd_trigger = false;
+ bool is_event_trigger = false;
int i;
/* Get the new function's pg_proc entry */
@@ -248,7 +248,7 @@ plpgsql_validator(PG_FUNCTION_ARGS)
(proc->prorettype == OPAQUEOID && proc->pronargs == 0))
is_dml_trigger = true;
else if (proc->prorettype == EVTTRIGGEROID)
- is_cmd_trigger = true;
+ is_event_trigger = true;
else if (proc->prorettype != RECORDOID &&
proc->prorettype != VOIDOID &&
!IsPolymorphicType(proc->prorettype))
@@ -303,7 +303,7 @@ plpgsql_validator(PG_FUNCTION_ARGS)
trigdata.type = T_TriggerData;
fake_fcinfo.context = (Node *) &trigdata;
}
- else if (is_cmd_trigger)
+ else if (is_event_trigger)
{
EventTriggerData trigdata;
MemSet(&trigdata, 0, sizeof(trigdata));
@@ -679,7 +679,7 @@ typedef struct PLpgSQL_func_hashkey
typedef enum PLpgSQL_trigtype
{
PLPGSQL_DML_TRIGGER,
- PLPGSQL_CMD_TRIGGER,
+ PLPGSQL_EVENT_TRIGGER,
PLPGSQL_NOT_TRIGGER
} PLpgSQL_trigtype;
@@ -932,7 +932,7 @@ extern Datum plpgsql_exec_function(PLpgSQL_function *func,
FunctionCallInfo fcinfo);
extern HeapTuple plpgsql_exec_trigger(PLpgSQL_function *func,
TriggerData *trigdata);
-extern void plpgsql_exec_command_trigger(PLpgSQL_function *func,
+extern void plpgsql_exec_event_trigger(PLpgSQL_function *func,
EventTriggerData *trigdata);
extern void plpgsql_xact_cb(XactEvent event, void *arg);
extern void plpgsql_subxact_cb(SubXactEvent event, SubTransactionId mySubid,
@@ -335,7 +335,7 @@ PLy_exec_trigger(FunctionCallInfo fcinfo, PLyProcedure *proc)
/* command trigger handler
*/
void
-PLy_exec_command_trigger(FunctionCallInfo fcinfo, PLyProcedure *proc)
+PLy_exec_event_trigger(FunctionCallInfo fcinfo, PLyProcedure *proc)
{
PyObject *volatile pltdata = NULL;
EventTriggerData *tdata;
@@ -9,6 +9,6 @@
extern Datum PLy_exec_function(FunctionCallInfo fcinfo, PLyProcedure *proc);
extern HeapTuple PLy_exec_trigger(FunctionCallInfo fcinfo, PLyProcedure *proc);
-extern void PLy_exec_command_trigger(FunctionCallInfo fcinfo, PLyProcedure *proc);
+extern void PLy_exec_event_trigger(FunctionCallInfo fcinfo, PLyProcedure *proc);
#endif /* PLPY_EXEC_H */
@@ -64,7 +64,7 @@ PG_FUNCTION_INFO_V1(plpython2_inline_handler);
static bool PLy_procedure_is_trigger(Form_pg_proc procStruct);
-static bool PLy_procedure_is_command_trigger(Form_pg_proc procStruct);
+static bool PLy_procedure_is_event_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);
@@ -158,7 +158,7 @@ plpython_validator(PG_FUNCTION_ARGS)
Oid funcoid = PG_GETARG_OID(0);
HeapTuple tuple;
Form_pg_proc procStruct;
- bool is_dml_trigger, is_cmd_trigger;
+ bool is_dml_trigger, is_event_trigger;
if (!check_function_bodies)
{
@@ -172,11 +172,11 @@ plpython_validator(PG_FUNCTION_ARGS)
procStruct = (Form_pg_proc) GETSTRUCT(tuple);
is_dml_trigger = PLy_procedure_is_trigger(procStruct);
- is_cmd_trigger = PLy_procedure_is_command_trigger(procStruct);
+ is_event_trigger = PLy_procedure_is_event_trigger(procStruct);
ReleaseSysCache(tuple);
- PLy_procedure_get(funcoid, is_dml_trigger, is_cmd_trigger);
+ PLy_procedure_get(funcoid, is_dml_trigger, is_event_trigger);
PG_RETURN_VOID();
}
@@ -232,7 +232,7 @@ plpython_call_handler(PG_FUNCTION_ARGS)
{
proc = PLy_procedure_get(fcinfo->flinfo->fn_oid, false, true);
exec_ctx->curr_proc = proc;
- PLy_exec_command_trigger(fcinfo, proc);
+ PLy_exec_event_trigger(fcinfo, proc);
}
else
{
@@ -347,7 +347,7 @@ PLy_procedure_is_trigger(Form_pg_proc procStruct)
procStruct->pronargs == 0));
}
-static bool PLy_procedure_is_command_trigger(Form_pg_proc procStruct)
+static bool PLy_procedure_is_event_trigger(Form_pg_proc procStruct)
{
return (procStruct->prorettype == EVTTRIGGEROID);
}
@@ -26,7 +26,7 @@ static HTAB *PLy_procedure_cache = NULL;
static HTAB *PLy_trigger_cache = NULL;
static PLyProcedure *PLy_procedure_create(HeapTuple procTup, Oid fn_oid,
- bool is_dml_trigger, bool is_cmd_trigger);
+ bool is_dml_trigger, bool is_event_trigger);
static bool PLy_procedure_argument_valid(PLyTypeInfo *arg);
static bool PLy_procedure_valid(PLyProcedure *proc, HeapTuple procTup);
static char *PLy_procedure_munge_source(const char *name, const char *src);
@@ -74,7 +74,7 @@ PLy_procedure_name(PLyProcedure *proc)
* function calls.
*/
PLyProcedure *
-PLy_procedure_get(Oid fn_oid, bool is_dml_trigger, bool is_cmd_trigger)
+PLy_procedure_get(Oid fn_oid, bool is_dml_trigger, bool is_event_trigger)
{
HeapTuple procTup;
PLyProcedureEntry *volatile entry;
@@ -85,7 +85,7 @@ PLy_procedure_get(Oid fn_oid, bool is_dml_trigger, bool is_cmd_trigger)
elog(ERROR, "cache lookup failed for function %u", fn_oid);
/* Look for the function in the corresponding cache */
- if (is_dml_trigger || is_cmd_trigger)
+ if (is_dml_trigger || is_event_trigger)
entry = hash_search(PLy_trigger_cache,
&fn_oid, HASH_ENTER, &found);
else
@@ -98,22 +98,22 @@ PLy_procedure_get(Oid fn_oid, bool is_dml_trigger, bool is_cmd_trigger)
{
/* Haven't found it, create a new cache entry */
entry->proc = PLy_procedure_create(procTup, fn_oid,
- is_dml_trigger, is_cmd_trigger);
+ is_dml_trigger, is_event_trigger);
}
else if (!PLy_procedure_valid(entry->proc, procTup))
{
/* Found it, but it's invalid, free and reuse the cache entry */
PLy_procedure_delete(entry->proc);
PLy_free(entry->proc);
entry->proc = PLy_procedure_create(procTup, fn_oid,
- is_dml_trigger, is_cmd_trigger);
+ is_dml_trigger, is_event_trigger);
}
/* Found it and it's valid, it's fine to use it */
}
PG_CATCH();
{
/* Do not leave an uninitialised entry in the cache */
- if (is_dml_trigger || is_cmd_trigger)
+ if (is_dml_trigger || is_event_trigger)
hash_search(PLy_trigger_cache,
&fn_oid, HASH_REMOVE, NULL);
else
@@ -133,7 +133,7 @@ PLy_procedure_get(Oid fn_oid, bool is_dml_trigger, bool is_cmd_trigger)
*/
static PLyProcedure *
PLy_procedure_create(HeapTuple procTup, Oid fn_oid,
- bool is_dml_trigger, bool is_cmd_trigger)
+ bool is_dml_trigger, bool is_event_trigger)
{
char procName[NAMEDATALEN + 256];
Form_pg_proc procStruct;
@@ -177,7 +177,7 @@ PLy_procedure_create(HeapTuple procTup, Oid fn_oid,
* get information required for output conversion of the return value,
* but only if this isn't a trigger.
*/
- if (!is_dml_trigger && !is_cmd_trigger)
+ if (!is_dml_trigger && !is_event_trigger)
{
HeapTuple rvTypeTup;
Form_pg_type rvTypeStruct;
@@ -42,7 +42,7 @@ typedef struct PLyProcedureEntry
/* PLyProcedure manipulation */
extern char *PLy_procedure_name(PLyProcedure *proc);
extern PLyProcedure *PLy_procedure_get(Oid fn_oid,
- bool is_dml_trigger, bool is_cmd_trigger);
+ bool is_dml_trigger, bool is_event_trigger);
extern void PLy_procedure_compile(PLyProcedure *proc, const char *src);
extern void PLy_procedure_delete(PLyProcedure *proc);

0 comments on commit c4d551e

Please sign in to comment.