/* *CheckformultiplePythonlibrariesbeforeactivelydoinganythingwith *libpython.ThismustberepeatedoneachentrytoPL/Python,incasea *conflictinglibrarygotloadedsincewelastlooked. * *ItisattractivetoweakenthiserrorfromFATALtoERROR,butthere *wouldbecornercases,soitseemsbesttobeconservative.
*/ if (*plpython_version_bitmask_ptr != (1 << PY_MAJOR_VERSION))
ereport(FATAL,
(errmsg("multiple Python libraries are present in session"),
errdetail("Only one Python major version can be used in one session.")));
/* The rest should only be done once per session */ if (inited) return;
PyImport_AppendInittab("plpy", PyInit_plpy);
Py_Initialize();
PyImport_ImportModule("plpy");
PLy_init_interp();
PLy_init_plpy(); if (PyErr_Occurred())
PLy_elog(FATAL, "untrapped error in initialization");
mainmod = PyImport_AddModule("__main__"); if (mainmod == NULL || PyErr_Occurred())
PLy_elog(ERROR, "could not import \"__main__\" module");
Py_INCREF(mainmod);
PLy_interp_globals = PyModule_GetDict(mainmod);
PLy_interp_safe_globals = PyDict_New(); if (PLy_interp_safe_globals == NULL)
PLy_elog(ERROR, NULL);
PyDict_SetItemString(PLy_interp_globals, "GD", PLy_interp_safe_globals);
Py_DECREF(mainmod); if (PLy_interp_globals == NULL || PyErr_Occurred())
PLy_elog(ERROR, "could not initialize globals");
}
Datum
plpython3_validator(PG_FUNCTION_ARGS)
{
Oid funcoid = PG_GETARG_OID(0);
HeapTuple tuple;
Form_pg_proc procStruct; bool is_trigger;
if (!CheckFunctionValidatorAccess(fcinfo->flinfo->fn_oid, funcoid))
PG_RETURN_VOID();
if (!check_function_bodies)
PG_RETURN_VOID();
/* Do this only after making sure we need to do something */
PLy_initialize();
/* Get the new function's pg_proc entry */
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcoid)); if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", funcoid);
procStruct = (Form_pg_proc) GETSTRUCT(tuple);
PLyExecutionContext *
PLy_current_execution_context(void)
{ if (PLy_execution_contexts == NULL)
elog(ERROR, "no Python function is currently executing");
if (context == NULL)
elog(ERROR, "no Python function is currently executing");
PLy_execution_contexts = context->next;
if (context->scratch_ctx)
MemoryContextDelete(context->scratch_ctx);
pfree(context);
}
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.21Bemerkung:
(vorverarbeitet am 2026-09-28)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.