mirror of
https://github.com/postgres/postgres.git
synced 2025-10-21 02:52:47 +03:00
plpython: Code cleanup related to removal of Python 2 support.
Since 19252e8ec9
we reject Python 2 during build configuration. Now that the
dust on the buildfarm has settled, remove Python 2 specific code, including
the "Python 2/3 porting layer".
The code to detect conflicts between plpython using Python 2 and 3 is not
removed, in case somebody creates an out-of-tree version adding back support
for Python 2.
Reviewed-By: Peter Eisentraut <peter@eisentraut.org>
Reviewed-By: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/20211031184548.g4sxfe47n2kyi55r@alap3.anarazel.de
This commit is contained in:
@@ -28,27 +28,13 @@
|
||||
* exported functions
|
||||
*/
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
/* Use separate names to reduce confusion */
|
||||
#define plpython_validator plpython3_validator
|
||||
#define plpython_call_handler plpython3_call_handler
|
||||
#define plpython_inline_handler plpython3_inline_handler
|
||||
#endif
|
||||
|
||||
extern void _PG_init(void);
|
||||
|
||||
PG_MODULE_MAGIC;
|
||||
|
||||
PG_FUNCTION_INFO_V1(plpython_validator);
|
||||
PG_FUNCTION_INFO_V1(plpython_call_handler);
|
||||
PG_FUNCTION_INFO_V1(plpython_inline_handler);
|
||||
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
/* Define aliases plpython2_call_handler etc */
|
||||
PG_FUNCTION_INFO_V1(plpython2_validator);
|
||||
PG_FUNCTION_INFO_V1(plpython2_call_handler);
|
||||
PG_FUNCTION_INFO_V1(plpython2_inline_handler);
|
||||
#endif
|
||||
PG_FUNCTION_INFO_V1(plpython3_validator);
|
||||
PG_FUNCTION_INFO_V1(plpython3_call_handler);
|
||||
PG_FUNCTION_INFO_V1(plpython3_inline_handler);
|
||||
|
||||
|
||||
static bool PLy_procedure_is_trigger(Form_pg_proc procStruct);
|
||||
@@ -82,6 +68,10 @@ _PG_init(void)
|
||||
* the actual failure for later, so that operations like pg_restore can
|
||||
* load more than one plpython library so long as they don't try to do
|
||||
* anything much with the language.
|
||||
*
|
||||
* While we only support Python 3 these days, somebody might create an
|
||||
* out-of-tree version adding back support for Python 2. Conflicts with
|
||||
* such an extension should be detected.
|
||||
*/
|
||||
bitmask_ptr = (int **) find_rendezvous_variable("plpython_version_bitmask");
|
||||
if (!(*bitmask_ptr)) /* am I the first? */
|
||||
@@ -125,13 +115,9 @@ PLy_initialize(void)
|
||||
if (inited)
|
||||
return;
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
PyImport_AppendInittab("plpy", PyInit_plpy);
|
||||
#endif
|
||||
Py_Initialize();
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
PyImport_ImportModule("plpy");
|
||||
#endif
|
||||
PLy_init_interp();
|
||||
PLy_init_plpy();
|
||||
if (PyErr_Occurred())
|
||||
@@ -171,7 +157,7 @@ PLy_init_interp(void)
|
||||
}
|
||||
|
||||
Datum
|
||||
plpython_validator(PG_FUNCTION_ARGS)
|
||||
plpython3_validator(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid funcoid = PG_GETARG_OID(0);
|
||||
HeapTuple tuple;
|
||||
@@ -203,17 +189,8 @@ plpython_validator(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
Datum
|
||||
plpython2_validator(PG_FUNCTION_ARGS)
|
||||
{
|
||||
/* call plpython validator with our fcinfo so it gets our oid */
|
||||
return plpython_validator(fcinfo);
|
||||
}
|
||||
#endif /* PY_MAJOR_VERSION < 3 */
|
||||
|
||||
Datum
|
||||
plpython_call_handler(PG_FUNCTION_ARGS)
|
||||
plpython3_call_handler(PG_FUNCTION_ARGS)
|
||||
{
|
||||
bool nonatomic;
|
||||
Datum retval;
|
||||
@@ -284,16 +261,8 @@ plpython_call_handler(PG_FUNCTION_ARGS)
|
||||
return retval;
|
||||
}
|
||||
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
Datum
|
||||
plpython2_call_handler(PG_FUNCTION_ARGS)
|
||||
{
|
||||
return plpython_call_handler(fcinfo);
|
||||
}
|
||||
#endif /* PY_MAJOR_VERSION < 3 */
|
||||
|
||||
Datum
|
||||
plpython_inline_handler(PG_FUNCTION_ARGS)
|
||||
plpython3_inline_handler(PG_FUNCTION_ARGS)
|
||||
{
|
||||
LOCAL_FCINFO(fake_fcinfo, 0);
|
||||
InlineCodeBlock *codeblock = (InlineCodeBlock *) DatumGetPointer(PG_GETARG_DATUM(0));
|
||||
@@ -368,14 +337,6 @@ plpython_inline_handler(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
Datum
|
||||
plpython2_inline_handler(PG_FUNCTION_ARGS)
|
||||
{
|
||||
return plpython_inline_handler(fcinfo);
|
||||
}
|
||||
#endif /* PY_MAJOR_VERSION < 3 */
|
||||
|
||||
static bool
|
||||
PLy_procedure_is_trigger(Form_pg_proc procStruct)
|
||||
{
|
||||
|
Reference in New Issue
Block a user