97 static bool inited =
false;
109 (
errmsg(
"multiple Python libraries are present in session"),
110 errdetail(
"Only one Python major version can be used in one session.")));
118 PyImport_ImportModule(
"plpy");
121 if (PyErr_Occurred())
140 static PyObject *PLy_interp_safe_globals = NULL;
143 mainmod = PyImport_AddModule(
"__main__");
144 if (mainmod == NULL || PyErr_Occurred())
148 PLy_interp_safe_globals = PyDict_New();
149 if (PLy_interp_safe_globals == NULL)
177 elog(
ERROR,
"cache lookup failed for function %u", funcoid);
200 nonatomic = fcinfo->context &&
216 Oid funcoid = fcinfo->flinfo->fn_oid;
226 plerrcontext.
arg = exec_ctx;
277 MemSet(&flinfo, 0,
sizeof(flinfo));
278 fake_fcinfo->flinfo = &flinfo;
284 "__plpython_inline_block",
310 plerrcontext.
arg = exec_ctx;
339 return (procStruct->prorettype == TRIGGEROID);
368 elog(
ERROR,
"no Python function is currently executing");
380 if (
context->scratch_ctx == NULL)
383 "PL/Python scratch context",
410 elog(
ERROR,
"no Python function is currently executing");
#define MemSet(start, val, len)
void ** find_rendezvous_variable(const char *varName)
int errdetail(const char *fmt,...)
ErrorContextCallback * error_context_stack
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
bool CheckFunctionValidatorAccess(Oid validatorOid, Oid functionOid)
#define SizeForFunctionCallInfo(nargs)
#define PG_GETARG_DATUM(n)
#define LOCAL_FCINFO(name, nargs)
bool check_function_bodies
#define HeapTupleIsValid(tuple)
MemoryContext TopTransactionContext
void pfree(void *pointer)
MemoryContext TopMemoryContext
MemoryContext CurrentMemoryContext
void * MemoryContextAlloc(MemoryContext context, Size size)
char * MemoryContextStrdup(MemoryContext context, const char *string)
void MemoryContextDelete(MemoryContext context)
MemoryContext PortalContext
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
void pg_bindtextdomain(const char *domain)
#define IsA(nodeptr, _type_)
#define castNode(_type_, nodeptr)
FormData_pg_proc * Form_pg_proc
Datum PLy_exec_function(FunctionCallInfo fcinfo, PLyProcedure *proc)
HeapTuple PLy_exec_trigger(FunctionCallInfo fcinfo, PLyProcedure *proc)
static int plpython_version_bitmask
Datum plpython3_validator(PG_FUNCTION_ARGS)
PyObject * PLy_interp_globals
static int * plpython_version_bitmask_ptr
static void PLy_initialize(void)
PG_FUNCTION_INFO_V1(plpython3_validator)
static void plpython_inline_error_callback(void *arg)
static PLyExecutionContext * PLy_execution_contexts
Datum plpython3_inline_handler(PG_FUNCTION_ARGS)
static bool PLy_procedure_is_trigger(Form_pg_proc procStruct)
PLyExecutionContext * PLy_current_execution_context(void)
static void plpython_error_callback(void *arg)
MemoryContext PLy_get_scratch_context(PLyExecutionContext *context)
static PLyExecutionContext * PLy_push_execution_context(bool atomic_context)
static void PLy_pop_execution_context(void)
static void PLy_init_interp(void)
Datum plpython3_call_handler(PG_FUNCTION_ARGS)
PyMODINIT_FUNC PyInit_plpy(void)
void init_procedure_caches(void)
char * PLy_procedure_name(PLyProcedure *proc)
PLyProcedure * PLy_procedure_get(Oid fn_oid, Oid fn_rel, bool is_trigger)
void PLy_procedure_compile(PLyProcedure *proc, const char *src)
void PLy_procedure_delete(PLyProcedure *proc)
List * explicit_subtransactions
static Datum PointerGetDatum(const void *X)
static Datum ObjectIdGetDatum(Oid X)
static Pointer DatumGetPointer(Datum X)
#define RelationGetRelid(relation)
int SPI_connect_ext(int options)
#define SPI_OPT_NONATOMIC
struct ErrorContextCallback * previous
void(* callback)(void *arg)
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
#define CALLED_AS_TRIGGER(fcinfo)