MCPcopy Create free account
hub / github.com/apache/cloudberry / PLy_initialize

Function PLy_initialize

src/pl/plpython/plpy_main.c:116–157  ·  view source on GitHub ↗

* Perform one-time setup of PL/Python, after checking for a conflict * with other versions of Python. */

Source from the content-addressed store, hash-verified

114 * with other versions of Python.
115 */
116static void
117PLy_initialize(void)
118{
119 static bool inited = false;
120
121 /*
122 * Check for multiple Python libraries before actively doing anything with
123 * libpython. This must be repeated on each entry to PL/Python, in case a
124 * conflicting library got loaded since we last looked.
125 *
126 * It is attractive to weaken this error from FATAL to ERROR, but there
127 * would be corner cases, so it seems best to be conservative.
128 */
129 if (*plpython_version_bitmask_ptr != (1 << PY_MAJOR_VERSION))
130 ereport(FATAL,
131 (errmsg("multiple Python libraries are present in session"),
132 errdetail("Only one Python major version can be used in one session.")));
133
134 /* The rest should only be done once per session */
135 if (inited)
136 return;
137
138#if PY_MAJOR_VERSION >= 3
139 PyImport_AppendInittab("plpy", PyInit_plpy);
140#endif
141 Py_Initialize();
142#if PY_MAJOR_VERSION >= 3
143 PyImport_ImportModule("plpy");
144#endif
145 PLy_init_interp();
146 PLy_init_plpy();
147 if (PyErr_Occurred())
148 PLy_elog(FATAL, "untrapped error in initialization");
149
150 init_procedure_caches();
151
152 explicit_subtransactions = NIL;
153
154 PLy_execution_contexts = NULL;
155
156 inited = true;
157}
158
159/*
160 * For GPDB Use:

Callers 3

plpython_validatorFunction · 0.85
plpython_call_handlerFunction · 0.85
plpython_inline_handlerFunction · 0.85

Calls 5

PLy_init_interpFunction · 0.85
PLy_init_plpyFunction · 0.85
init_procedure_cachesFunction · 0.85
errmsgFunction · 0.50
errdetailFunction · 0.50

Tested by

no test coverage detected