PLpgSQL_function *plpgsql_curr_compile;
/* A context appropriate for short-term allocs during compilation */
-MemoryContext compile_tmp_cxt;
+MemoryContext plpgsql_compile_tmp_cxt;
/* ----------
* Hash table for compiled functions
* careful about pfree'ing their allocations, it is also wise to
* switch into a short-term context before calling into the
* backend. An appropriate context for performing short-term
- * allocations is the compile_tmp_cxt.
+ * allocations is the plpgsql_compile_tmp_cxt.
*
* NB: this code is not re-entrant. We assume that nothing we do here could
* result in the invocation of another plpgsql function.
ALLOCSET_DEFAULT_MINSIZE,
ALLOCSET_DEFAULT_INITSIZE,
ALLOCSET_DEFAULT_MAXSIZE);
- compile_tmp_cxt = MemoryContextSwitchTo(func_cxt);
+ plpgsql_compile_tmp_cxt = MemoryContextSwitchTo(func_cxt);
function->fn_signature = format_procedure(fcinfo->flinfo->fn_oid);
function->fn_oid = fcinfo->flinfo->fn_oid;
* argument types. In validation mode we won't be able to, so we
* arbitrarily assume we are dealing with integers.
*/
- MemoryContextSwitchTo(compile_tmp_cxt);
+ MemoryContextSwitchTo(plpgsql_compile_tmp_cxt);
numargs = get_func_arg_info(procTup,
&argtypes, &argnames, &argmodes);
plpgsql_check_syntax = false;
- MemoryContextSwitchTo(compile_tmp_cxt);
- compile_tmp_cxt = NULL;
+ MemoryContextSwitchTo(plpgsql_compile_tmp_cxt);
+ plpgsql_compile_tmp_cxt = NULL;
return function;
}
ALLOCSET_DEFAULT_MINSIZE,
ALLOCSET_DEFAULT_INITSIZE,
ALLOCSET_DEFAULT_MAXSIZE);
- compile_tmp_cxt = MemoryContextSwitchTo(func_cxt);
+ plpgsql_compile_tmp_cxt = MemoryContextSwitchTo(func_cxt);
function->fn_signature = pstrdup(func_name);
function->fn_is_trigger = PLPGSQL_NOT_TRIGGER;
plpgsql_check_syntax = false;
- MemoryContextSwitchTo(compile_tmp_cxt);
- compile_tmp_cxt = NULL;
+ MemoryContextSwitchTo(plpgsql_compile_tmp_cxt);
+ plpgsql_compile_tmp_cxt = NULL;
return function;
}
param = makeNode(Param);
param->paramkind = PARAM_EXTERN;
param->paramid = dno + 1;
- exec_get_datum_type_info(estate,
+ plpgsql_exec_get_datum_type_info(estate,
datum,
¶m->paramtype,
¶m->paramtypmod,
MemoryContext oldCxt;
/* Avoid memory leaks in the long-term function context */
- oldCxt = MemoryContextSwitchTo(compile_tmp_cxt);
+ oldCxt = MemoryContextSwitchTo(plpgsql_compile_tmp_cxt);
if (list_length(idents) == 2)
{
dtype = build_datatype(typetup,
attrStruct->atttypmod,
attrStruct->attcollation);
- MemoryContextSwitchTo(compile_tmp_cxt);
+ MemoryContextSwitchTo(plpgsql_compile_tmp_cxt);
done:
if (HeapTupleIsValid(classtup))
return NULL;
/* Avoid memory leaks in long-term function context */
- oldCxt = MemoryContextSwitchTo(compile_tmp_cxt);
+ oldCxt = MemoryContextSwitchTo(plpgsql_compile_tmp_cxt);
/* Look up relation name. Can't lock it - we might not have privileges. */
relvar = makeRangeVar(strVal(linitial(idents)),
datums_alloc = 128;
plpgsql_nDatums = 0;
/* This is short-lived, so needn't allocate in function's cxt */
- plpgsql_Datums = MemoryContextAlloc(compile_tmp_cxt,
+ plpgsql_Datums = MemoryContextAlloc(plpgsql_compile_tmp_cxt,
sizeof(PLpgSQL_datum *) * datums_alloc);
/* datums_last tracks what's been seen by plpgsql_add_initdatums() */
datums_last = 0;
/*
* Let the instrumentation plugin peek at this function
*/
- if (*plugin_ptr && (*plugin_ptr)->func_beg)
- ((*plugin_ptr)->func_beg) (&estate, func);
+ if (*plpgsql_plugin_ptr && (*plpgsql_plugin_ptr)->func_beg)
+ ((*plpgsql_plugin_ptr)->func_beg) (&estate, func);
/*
* Now call the toplevel block of statements
/*
* Let the instrumentation plugin peek at this function
*/
- if (*plugin_ptr && (*plugin_ptr)->func_end)
- ((*plugin_ptr)->func_end) (&estate, func);
+ if (*plpgsql_plugin_ptr && (*plpgsql_plugin_ptr)->func_end)
+ ((*plpgsql_plugin_ptr)->func_end) (&estate, func);
/* Clean up any leftover temporary memory */
plpgsql_destroy_econtext(&estate);
/*
* Let the instrumentation plugin peek at this function
*/
- if (*plugin_ptr && (*plugin_ptr)->func_beg)
- ((*plugin_ptr)->func_beg) (&estate, func);
+ if (*plpgsql_plugin_ptr && (*plpgsql_plugin_ptr)->func_beg)
+ ((*plpgsql_plugin_ptr)->func_beg) (&estate, func);
/*
* Now call the toplevel block of statements
/*
* Let the instrumentation plugin peek at this function
*/
- if (*plugin_ptr && (*plugin_ptr)->func_end)
- ((*plugin_ptr)->func_end) (&estate, func);
+ if (*plpgsql_plugin_ptr && (*plpgsql_plugin_ptr)->func_end)
+ ((*plpgsql_plugin_ptr)->func_end) (&estate, func);
/* Clean up any leftover temporary memory */
plpgsql_destroy_econtext(&estate);
/*
* Let the instrumentation plugin peek at this function
*/
- if (*plugin_ptr && (*plugin_ptr)->func_beg)
- ((*plugin_ptr)->func_beg) (&estate, func);
+ if (*plpgsql_plugin_ptr && (*plpgsql_plugin_ptr)->func_beg)
+ ((*plpgsql_plugin_ptr)->func_beg) (&estate, func);
/*
* Now call the toplevel block of statements
/*
* Let the instrumentation plugin peek at this function
*/
- if (*plugin_ptr && (*plugin_ptr)->func_end)
- ((*plugin_ptr)->func_end) (&estate, func);
+ if (*plpgsql_plugin_ptr && (*plpgsql_plugin_ptr)->func_end)
+ ((*plpgsql_plugin_ptr)->func_end) (&estate, func);
/* Clean up any leftover temporary memory */
plpgsql_destroy_econtext(&estate);
estate->err_stmt = stmt;
/* Let the plugin know that we are about to execute this statement */
- if (*plugin_ptr && (*plugin_ptr)->stmt_beg)
- ((*plugin_ptr)->stmt_beg) (estate, stmt);
+ if (*plpgsql_plugin_ptr && (*plpgsql_plugin_ptr)->stmt_beg)
+ ((*plpgsql_plugin_ptr)->stmt_beg) (estate, stmt);
CHECK_FOR_INTERRUPTS();
}
/* Let the plugin know that we have finished executing this statement */
- if (*plugin_ptr && (*plugin_ptr)->stmt_end)
- ((*plugin_ptr)->stmt_end) (estate, stmt);
+ if (*plpgsql_plugin_ptr && (*plpgsql_plugin_ptr)->stmt_end)
+ ((*plpgsql_plugin_ptr)->stmt_end) (estate, stmt);
estate->err_stmt = save_estmt;
loop_var_elem_type = InvalidOid;
}
else
- loop_var_elem_type = get_element_type(exec_get_datum_type(estate,
+ loop_var_elem_type = get_element_type(plpgsql_exec_get_datum_type(estate,
loop_var));
/*
* pointers so it can call back into PL/pgSQL for doing things like
* variable assignments and stack traces
*/
- if (*plugin_ptr)
+ if (*plpgsql_plugin_ptr)
{
- (*plugin_ptr)->error_callback = plpgsql_exec_error_callback;
- (*plugin_ptr)->assign_expr = exec_assign_expr;
+ (*plpgsql_plugin_ptr)->error_callback = plpgsql_exec_error_callback;
+ (*plpgsql_plugin_ptr)->assign_expr = exec_assign_expr;
- if ((*plugin_ptr)->func_setup)
- ((*plugin_ptr)->func_setup) (estate, func);
+ if ((*plpgsql_plugin_ptr)->func_setup)
+ ((*plpgsql_plugin_ptr)->func_setup) (estate, func);
}
}
}
/*
- * exec_get_datum_type Get datatype of a PLpgSQL_datum
+ * plpgsql_exec_get_datum_type Get datatype of a PLpgSQL_datum
*
* This is the same logic as in exec_eval_datum, except that it can handle
* some cases where exec_eval_datum has to fail; specifically, we may have
* happen only for a trigger's NEW/OLD records.)
*/
Oid
-exec_get_datum_type(PLpgSQL_execstate *estate,
+plpgsql_exec_get_datum_type(PLpgSQL_execstate *estate,
PLpgSQL_datum *datum)
{
Oid typeid;
}
/*
- * exec_get_datum_type_info Get datatype etc of a PLpgSQL_datum
+ * plpgsql_exec_get_datum_type_info Get datatype etc of a PLpgSQL_datum
*
- * An extended version of exec_get_datum_type, which also retrieves the
+ * An extended version of plpgsql_exec_get_datum_type, which also retrieves the
* typmod and collation of the datum.
*/
void
-exec_get_datum_type_info(PLpgSQL_execstate *estate,
+plpgsql_exec_get_datum_type_info(PLpgSQL_execstate *estate,
PLpgSQL_datum *datum,
Oid *typeid, int32 *typmod, Oid *collation)
{
syntax_errcontext.previous = error_context_stack;
error_context_stack = &syntax_errcontext;
- oldCxt = MemoryContextSwitchTo(compile_tmp_cxt);
+ oldCxt = MemoryContextSwitchTo(plpgsql_compile_tmp_cxt);
(void) raw_parser(stmt);
MemoryContextSwitchTo(oldCxt);
int plpgsql_extra_errors;
/* Hook for plugins */
-PLpgSQL_plugin **plugin_ptr = NULL;
+PLpgSQL_plugin **plpgsql_plugin_ptr = NULL;
static bool
RegisterSubXactCallback(plpgsql_subxact_cb, NULL);
/* Set up a rendezvous point with optional instrumentation plugin */
- plugin_ptr = (PLpgSQL_plugin **) find_rendezvous_variable("PLpgSQL_plugin");
+ plpgsql_plugin_ptr = (PLpgSQL_plugin **) find_rendezvous_variable("PLpgSQL_plugin");
inited = true;
}
extern char *plpgsql_error_funcname;
extern PLpgSQL_function *plpgsql_curr_compile;
-extern MemoryContext compile_tmp_cxt;
+extern MemoryContext plpgsql_compile_tmp_cxt;
-extern PLpgSQL_plugin **plugin_ptr;
+extern PLpgSQL_plugin **plpgsql_plugin_ptr;
/**********************************************************************
* Function declarations
extern void plpgsql_xact_cb(XactEvent event, void *arg);
extern void plpgsql_subxact_cb(SubXactEvent event, SubTransactionId mySubid,
SubTransactionId parentSubid, void *arg);
-extern Oid exec_get_datum_type(PLpgSQL_execstate *estate,
+extern Oid plpgsql_exec_get_datum_type(PLpgSQL_execstate *estate,
PLpgSQL_datum *datum);
-extern void exec_get_datum_type_info(PLpgSQL_execstate *estate,
+extern void plpgsql_exec_get_datum_type_info(PLpgSQL_execstate *estate,
PLpgSQL_datum *datum,
Oid *typeid, int32 *typmod, Oid *collation);