diff options
Diffstat (limited to 'src/pl/plpython/plpy_main.c')
-rw-r--r-- | src/pl/plpython/plpy_main.c | 59 |
1 files changed, 10 insertions, 49 deletions
diff --git a/src/pl/plpython/plpy_main.c b/src/pl/plpython/plpy_main.c index 3eedaa80da7..0bce1064951 100644 --- a/src/pl/plpython/plpy_main.c +++ b/src/pl/plpython/plpy_main.c @@ -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) { |