From f8598518aa027fa4766be287a0fba549dcf11af1 Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Sun, 6 Mar 2022 16:57:28 -0800
Subject: [PATCH v7 1/4] plpython: Remove plpythonu, plpython2u and associated
 transform extensions.

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
---
 src/pl/plpython/plpython2u--1.0.sql           | 17 -----------------
 src/pl/plpython/plpython2u.control            |  7 -------
 src/pl/plpython/plpythonu--1.0.sql            | 17 -----------------
 src/pl/plpython/plpythonu.control             |  7 -------
 contrib/hstore_plpython/Makefile              |  4 ++--
 .../hstore_plpython2u--1.0.sql                | 19 -------------------
 .../hstore_plpython/hstore_plpython2u.control |  6 ------
 .../hstore_plpython/hstore_plpythonu--1.0.sql | 19 -------------------
 .../hstore_plpython/hstore_plpythonu.control  |  6 ------
 contrib/jsonb_plpython/Makefile               |  6 +++---
 .../jsonb_plpython/jsonb_plpython2u--1.0.sql  | 19 -------------------
 .../jsonb_plpython/jsonb_plpython2u.control   |  6 ------
 .../jsonb_plpython/jsonb_plpythonu--1.0.sql   | 19 -------------------
 .../jsonb_plpython/jsonb_plpythonu.control    |  6 ------
 contrib/ltree_plpython/Makefile               |  4 ++--
 .../ltree_plpython/ltree_plpython2u--1.0.sql  | 12 ------------
 .../ltree_plpython/ltree_plpython2u.control   |  6 ------
 .../ltree_plpython/ltree_plpythonu--1.0.sql   | 12 ------------
 .../ltree_plpython/ltree_plpythonu.control    |  6 ------
 19 files changed, 7 insertions(+), 191 deletions(-)
 delete mode 100644 src/pl/plpython/plpython2u--1.0.sql
 delete mode 100644 src/pl/plpython/plpython2u.control
 delete mode 100644 src/pl/plpython/plpythonu--1.0.sql
 delete mode 100644 src/pl/plpython/plpythonu.control
 delete mode 100644 contrib/hstore_plpython/hstore_plpython2u--1.0.sql
 delete mode 100644 contrib/hstore_plpython/hstore_plpython2u.control
 delete mode 100644 contrib/hstore_plpython/hstore_plpythonu--1.0.sql
 delete mode 100644 contrib/hstore_plpython/hstore_plpythonu.control
 delete mode 100644 contrib/jsonb_plpython/jsonb_plpython2u--1.0.sql
 delete mode 100644 contrib/jsonb_plpython/jsonb_plpython2u.control
 delete mode 100644 contrib/jsonb_plpython/jsonb_plpythonu--1.0.sql
 delete mode 100644 contrib/jsonb_plpython/jsonb_plpythonu.control
 delete mode 100644 contrib/ltree_plpython/ltree_plpython2u--1.0.sql
 delete mode 100644 contrib/ltree_plpython/ltree_plpython2u.control
 delete mode 100644 contrib/ltree_plpython/ltree_plpythonu--1.0.sql
 delete mode 100644 contrib/ltree_plpython/ltree_plpythonu.control

diff --git a/src/pl/plpython/plpython2u--1.0.sql b/src/pl/plpython/plpython2u--1.0.sql
deleted file mode 100644
index 69f74775678..00000000000
--- a/src/pl/plpython/plpython2u--1.0.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-/* src/pl/plpython/plpython2u--1.0.sql */
-
-CREATE FUNCTION plpython2_call_handler() RETURNS language_handler
-  LANGUAGE c AS 'MODULE_PATHNAME';
-
-CREATE FUNCTION plpython2_inline_handler(internal) RETURNS void
-  STRICT LANGUAGE c AS 'MODULE_PATHNAME';
-
-CREATE FUNCTION plpython2_validator(oid) RETURNS void
-  STRICT LANGUAGE c AS 'MODULE_PATHNAME';
-
-CREATE LANGUAGE plpython2u
-  HANDLER plpython2_call_handler
-  INLINE plpython2_inline_handler
-  VALIDATOR plpython2_validator;
-
-COMMENT ON LANGUAGE plpython2u IS 'PL/Python2U untrusted procedural language';
diff --git a/src/pl/plpython/plpython2u.control b/src/pl/plpython/plpython2u.control
deleted file mode 100644
index 39c2b791efe..00000000000
--- a/src/pl/plpython/plpython2u.control
+++ /dev/null
@@ -1,7 +0,0 @@
-# plpython2u extension
-comment = 'PL/Python2U untrusted procedural language'
-default_version = '1.0'
-module_pathname = '$libdir/plpython2'
-relocatable = false
-schema = pg_catalog
-superuser = true
diff --git a/src/pl/plpython/plpythonu--1.0.sql b/src/pl/plpython/plpythonu--1.0.sql
deleted file mode 100644
index 4c6f7c3f140..00000000000
--- a/src/pl/plpython/plpythonu--1.0.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-/* src/pl/plpython/plpythonu--1.0.sql */
-
-CREATE FUNCTION plpython_call_handler() RETURNS language_handler
-  LANGUAGE c AS 'MODULE_PATHNAME';
-
-CREATE FUNCTION plpython_inline_handler(internal) RETURNS void
-  STRICT LANGUAGE c AS 'MODULE_PATHNAME';
-
-CREATE FUNCTION plpython_validator(oid) RETURNS void
-  STRICT LANGUAGE c AS 'MODULE_PATHNAME';
-
-CREATE LANGUAGE plpythonu
-  HANDLER plpython_call_handler
-  INLINE plpython_inline_handler
-  VALIDATOR plpython_validator;
-
-COMMENT ON LANGUAGE plpythonu IS 'PL/PythonU untrusted procedural language';
diff --git a/src/pl/plpython/plpythonu.control b/src/pl/plpython/plpythonu.control
deleted file mode 100644
index ae91b1c255c..00000000000
--- a/src/pl/plpython/plpythonu.control
+++ /dev/null
@@ -1,7 +0,0 @@
-# plpythonu extension
-comment = 'PL/PythonU untrusted procedural language'
-default_version = '1.0'
-module_pathname = '$libdir/plpython2'
-relocatable = false
-schema = pg_catalog
-superuser = true
diff --git a/contrib/hstore_plpython/Makefile b/contrib/hstore_plpython/Makefile
index 6af097ae68b..19d99a8045e 100644
--- a/contrib/hstore_plpython/Makefile
+++ b/contrib/hstore_plpython/Makefile
@@ -6,8 +6,8 @@ OBJS = \
 	hstore_plpython.o
 PGFILEDESC = "hstore_plpython - hstore transform for plpython"
 
-EXTENSION = hstore_plpythonu hstore_plpython2u hstore_plpython3u
-DATA = hstore_plpythonu--1.0.sql hstore_plpython2u--1.0.sql hstore_plpython3u--1.0.sql
+EXTENSION = hstore_plpython3u
+DATA = hstore_plpython3u--1.0.sql
 
 REGRESS = hstore_plpython
 REGRESS_PLPYTHON3_MANGLE := $(REGRESS)
diff --git a/contrib/hstore_plpython/hstore_plpython2u--1.0.sql b/contrib/hstore_plpython/hstore_plpython2u--1.0.sql
deleted file mode 100644
index 800765f3f0c..00000000000
--- a/contrib/hstore_plpython/hstore_plpython2u--1.0.sql
+++ /dev/null
@@ -1,19 +0,0 @@
-/* contrib/hstore_plpython/hstore_plpython2u--1.0.sql */
-
--- complain if script is sourced in psql, rather than via CREATE EXTENSION
-\echo Use "CREATE EXTENSION hstore_plpython2u" to load this file. \quit
-
-CREATE FUNCTION hstore_to_plpython2(val internal) RETURNS internal
-LANGUAGE C STRICT IMMUTABLE
-AS 'MODULE_PATHNAME', 'hstore_to_plpython';
-
-CREATE FUNCTION plpython2_to_hstore(val internal) RETURNS hstore
-LANGUAGE C STRICT IMMUTABLE
-AS 'MODULE_PATHNAME', 'plpython_to_hstore';
-
-CREATE TRANSFORM FOR hstore LANGUAGE plpython2u (
-    FROM SQL WITH FUNCTION hstore_to_plpython2(internal),
-    TO SQL WITH FUNCTION plpython2_to_hstore(internal)
-);
-
-COMMENT ON TRANSFORM FOR hstore LANGUAGE plpython2u IS 'transform between hstore and Python dict';
diff --git a/contrib/hstore_plpython/hstore_plpython2u.control b/contrib/hstore_plpython/hstore_plpython2u.control
deleted file mode 100644
index ed905671123..00000000000
--- a/contrib/hstore_plpython/hstore_plpython2u.control
+++ /dev/null
@@ -1,6 +0,0 @@
-# hstore_plpython2u extension
-comment = 'transform between hstore and plpython2u'
-default_version = '1.0'
-module_pathname = '$libdir/hstore_plpython2'
-relocatable = true
-requires = 'hstore,plpython2u'
diff --git a/contrib/hstore_plpython/hstore_plpythonu--1.0.sql b/contrib/hstore_plpython/hstore_plpythonu--1.0.sql
deleted file mode 100644
index 52832912abc..00000000000
--- a/contrib/hstore_plpython/hstore_plpythonu--1.0.sql
+++ /dev/null
@@ -1,19 +0,0 @@
-/* contrib/hstore_plpython/hstore_plpythonu--1.0.sql */
-
--- complain if script is sourced in psql, rather than via CREATE EXTENSION
-\echo Use "CREATE EXTENSION hstore_plpythonu" to load this file. \quit
-
-CREATE FUNCTION hstore_to_plpython(val internal) RETURNS internal
-LANGUAGE C STRICT IMMUTABLE
-AS 'MODULE_PATHNAME';
-
-CREATE FUNCTION plpython_to_hstore(val internal) RETURNS hstore
-LANGUAGE C STRICT IMMUTABLE
-AS 'MODULE_PATHNAME';
-
-CREATE TRANSFORM FOR hstore LANGUAGE plpythonu (
-    FROM SQL WITH FUNCTION hstore_to_plpython(internal),
-    TO SQL WITH FUNCTION plpython_to_hstore(internal)
-);
-
-COMMENT ON TRANSFORM FOR hstore LANGUAGE plpythonu IS 'transform between hstore and Python dict';
diff --git a/contrib/hstore_plpython/hstore_plpythonu.control b/contrib/hstore_plpython/hstore_plpythonu.control
deleted file mode 100644
index 8e9b35e43bf..00000000000
--- a/contrib/hstore_plpython/hstore_plpythonu.control
+++ /dev/null
@@ -1,6 +0,0 @@
-# hstore_plpythonu extension
-comment = 'transform between hstore and plpythonu'
-default_version = '1.0'
-module_pathname = '$libdir/hstore_plpython2'
-relocatable = true
-requires = 'hstore,plpythonu'
diff --git a/contrib/jsonb_plpython/Makefile b/contrib/jsonb_plpython/Makefile
index ca767418943..eaab5ca2601 100644
--- a/contrib/jsonb_plpython/Makefile
+++ b/contrib/jsonb_plpython/Makefile
@@ -4,12 +4,12 @@ MODULE_big = jsonb_plpython$(python_majorversion)
 OBJS = \
 	$(WIN32RES) \
 	jsonb_plpython.o
-PGFILEDESC = "jsonb_plpython - transform between jsonb and plpythonu"
+PGFILEDESC = "jsonb_plpython - jsonb transform for plpython"
 
 PG_CPPFLAGS = -I$(top_srcdir)/src/pl/plpython $(python_includespec) -DPLPYTHON_LIBNAME='"plpython$(python_majorversion)"'
 
-EXTENSION = jsonb_plpythonu jsonb_plpython2u jsonb_plpython3u
-DATA = jsonb_plpythonu--1.0.sql jsonb_plpython2u--1.0.sql jsonb_plpython3u--1.0.sql
+EXTENSION = jsonb_plpython3u
+DATA = jsonb_plpython3u--1.0.sql
 
 REGRESS = jsonb_plpython
 REGRESS_PLPYTHON3_MANGLE := $(REGRESS)
diff --git a/contrib/jsonb_plpython/jsonb_plpython2u--1.0.sql b/contrib/jsonb_plpython/jsonb_plpython2u--1.0.sql
deleted file mode 100644
index 2526d14ee19..00000000000
--- a/contrib/jsonb_plpython/jsonb_plpython2u--1.0.sql
+++ /dev/null
@@ -1,19 +0,0 @@
-/* contrib/jsonb_plpython/jsonb_plpython2u--1.0.sql */
-
--- complain if script is sourced in psql, rather than via CREATE EXTENSION
-\echo Use "CREATE EXTENSION jsonb_plpython2u" to load this file. \quit
-
-CREATE FUNCTION jsonb_to_plpython2(val internal) RETURNS internal
-LANGUAGE C STRICT IMMUTABLE
-AS 'MODULE_PATHNAME', 'jsonb_to_plpython';
-
-CREATE FUNCTION plpython2_to_jsonb(val internal) RETURNS jsonb
-LANGUAGE C STRICT IMMUTABLE
-AS 'MODULE_PATHNAME', 'plpython_to_jsonb';
-
-CREATE TRANSFORM FOR jsonb LANGUAGE plpython2u (
-    FROM SQL WITH FUNCTION jsonb_to_plpython2(internal),
-    TO SQL WITH FUNCTION plpython2_to_jsonb(internal)
-);
-
-COMMENT ON TRANSFORM FOR jsonb LANGUAGE plpython2u IS 'transform between jsonb and Python';
diff --git a/contrib/jsonb_plpython/jsonb_plpython2u.control b/contrib/jsonb_plpython/jsonb_plpython2u.control
deleted file mode 100644
index d26368316b6..00000000000
--- a/contrib/jsonb_plpython/jsonb_plpython2u.control
+++ /dev/null
@@ -1,6 +0,0 @@
-# jsonb_plpython2u extension
-comment = 'transform between jsonb and plpython2u'
-default_version = '1.0'
-module_pathname = '$libdir/jsonb_plpython2'
-relocatable = true
-requires = 'plpython2u'
diff --git a/contrib/jsonb_plpython/jsonb_plpythonu--1.0.sql b/contrib/jsonb_plpython/jsonb_plpythonu--1.0.sql
deleted file mode 100644
index 3fa89885a63..00000000000
--- a/contrib/jsonb_plpython/jsonb_plpythonu--1.0.sql
+++ /dev/null
@@ -1,19 +0,0 @@
-/* contrib/jsonb_plpython/jsonb_plpythonu--1.0.sql */
-
--- complain if script is sourced in psql, rather than via CREATE EXTENSION
-\echo Use "CREATE EXTENSION jsonb_plpythonu" to load this file. \quit
-
-CREATE FUNCTION jsonb_to_plpython(val internal) RETURNS internal
-LANGUAGE C STRICT IMMUTABLE
-AS 'MODULE_PATHNAME';
-
-CREATE FUNCTION plpython_to_jsonb(val internal) RETURNS jsonb
-LANGUAGE C STRICT IMMUTABLE
-AS 'MODULE_PATHNAME';
-
-CREATE TRANSFORM FOR jsonb LANGUAGE plpythonu (
-    FROM SQL WITH FUNCTION jsonb_to_plpython(internal),
-    TO SQL WITH FUNCTION plpython_to_jsonb(internal)
-);
-
-COMMENT ON TRANSFORM FOR jsonb LANGUAGE plpythonu IS 'transform between jsonb and Python';
diff --git a/contrib/jsonb_plpython/jsonb_plpythonu.control b/contrib/jsonb_plpython/jsonb_plpythonu.control
deleted file mode 100644
index 6f8fa4f184b..00000000000
--- a/contrib/jsonb_plpython/jsonb_plpythonu.control
+++ /dev/null
@@ -1,6 +0,0 @@
-# jsonb_plpythonu extension
-comment = 'transform between jsonb and plpythonu'
-default_version = '1.0'
-module_pathname = '$libdir/jsonb_plpython2'
-relocatable = true
-requires = 'plpythonu'
diff --git a/contrib/ltree_plpython/Makefile b/contrib/ltree_plpython/Makefile
index 12a01467721..0bccb111e6b 100644
--- a/contrib/ltree_plpython/Makefile
+++ b/contrib/ltree_plpython/Makefile
@@ -6,8 +6,8 @@ OBJS = \
 	ltree_plpython.o
 PGFILEDESC = "ltree_plpython - ltree transform for plpython"
 
-EXTENSION = ltree_plpythonu ltree_plpython2u ltree_plpython3u
-DATA = ltree_plpythonu--1.0.sql ltree_plpython2u--1.0.sql ltree_plpython3u--1.0.sql
+EXTENSION = ltree_plpython3u
+DATA = ltree_plpython3u--1.0.sql
 
 REGRESS = ltree_plpython
 REGRESS_PLPYTHON3_MANGLE := $(REGRESS)
diff --git a/contrib/ltree_plpython/ltree_plpython2u--1.0.sql b/contrib/ltree_plpython/ltree_plpython2u--1.0.sql
deleted file mode 100644
index 5c4a7037013..00000000000
--- a/contrib/ltree_plpython/ltree_plpython2u--1.0.sql
+++ /dev/null
@@ -1,12 +0,0 @@
-/* contrib/ltree_plpython/ltree_plpython2u--1.0.sql */
-
--- complain if script is sourced in psql, rather than via CREATE EXTENSION
-\echo Use "CREATE EXTENSION ltree_plpython2u" to load this file. \quit
-
-CREATE FUNCTION ltree_to_plpython2(val internal) RETURNS internal
-LANGUAGE C STRICT IMMUTABLE
-AS 'MODULE_PATHNAME', 'ltree_to_plpython';
-
-CREATE TRANSFORM FOR ltree LANGUAGE plpython2u (
-    FROM SQL WITH FUNCTION ltree_to_plpython2(internal)
-);
diff --git a/contrib/ltree_plpython/ltree_plpython2u.control b/contrib/ltree_plpython/ltree_plpython2u.control
deleted file mode 100644
index bedfd0acbad..00000000000
--- a/contrib/ltree_plpython/ltree_plpython2u.control
+++ /dev/null
@@ -1,6 +0,0 @@
-# ltree_plpython2u extension
-comment = 'transform between ltree and plpython2u'
-default_version = '1.0'
-module_pathname = '$libdir/ltree_plpython2'
-relocatable = true
-requires = 'ltree,plpython2u'
diff --git a/contrib/ltree_plpython/ltree_plpythonu--1.0.sql b/contrib/ltree_plpython/ltree_plpythonu--1.0.sql
deleted file mode 100644
index ee93edf28b9..00000000000
--- a/contrib/ltree_plpython/ltree_plpythonu--1.0.sql
+++ /dev/null
@@ -1,12 +0,0 @@
-/* contrib/ltree_plpython/ltree_plpythonu--1.0.sql */
-
--- complain if script is sourced in psql, rather than via CREATE EXTENSION
-\echo Use "CREATE EXTENSION ltree_plpythonu" to load this file. \quit
-
-CREATE FUNCTION ltree_to_plpython(val internal) RETURNS internal
-LANGUAGE C STRICT IMMUTABLE
-AS 'MODULE_PATHNAME';
-
-CREATE TRANSFORM FOR ltree LANGUAGE plpythonu (
-    FROM SQL WITH FUNCTION ltree_to_plpython(internal)
-);
diff --git a/contrib/ltree_plpython/ltree_plpythonu.control b/contrib/ltree_plpython/ltree_plpythonu.control
deleted file mode 100644
index b03c89a2e6e..00000000000
--- a/contrib/ltree_plpython/ltree_plpythonu.control
+++ /dev/null
@@ -1,6 +0,0 @@
-# ltree_plpythonu extension
-comment = 'transform between ltree and plpythonu'
-default_version = '1.0'
-module_pathname = '$libdir/ltree_plpython2'
-relocatable = true
-requires = 'ltree,plpythonu'
-- 
2.35.1.354.g715d08a9e5

