summaryrefslogtreecommitdiff
path: root/src/pl/plpython/plpy_main.c
diff options
context:
space:
mode:
authorAndres Freund2022-03-08 02:30:28 +0000
committerAndres Freund2022-03-08 02:30:28 +0000
commit9b7e24a2cb37fb52af13219f625cd719e364a346 (patch)
treec35fe718f0a8d8723631b5759a47e37bfb6f7fbf /src/pl/plpython/plpy_main.c
parentdb23464715f4792298c639153dda7bfd9ad9d602 (diff)
plpython: Code cleanup related to removal of Python 2 support.
Since 19252e8ec93 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 <[email protected]> Reviewed-By: Tom Lane <[email protected]> Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/pl/plpython/plpy_main.c')
-rw-r--r--src/pl/plpython/plpy_main.c59
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)
{