]> granicus.if.org Git - postgresql/commitdiff
Use LOAD not actual code execution to pull in plpython library.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 12 Jan 2016 01:06:36 +0000 (20:06 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 12 Jan 2016 01:06:36 +0000 (20:06 -0500)
Commit 866566a690bb9916 is insufficient to prevent dump/reload failures
when using transform modules in a database with both plpython2 and
plpython3 installed.  The reason is that the transform extension scripts
use DO blocks as a mechanism to pull in the libpython library before
creating the transform function.  It's necessary to preload the library
because the dynamic loader won't do it for us on every platform, leading
to "unresolved symbol" failures when the transform library is loaded.
But it's *not* necessary to execute Python code, and doing so will
provoke a multiple-Pythons-are-loaded error even after the preceding
commit.

To fix, use LOAD instead of a DO block.  That requires superuser privilege,
but creation of a C function does anyway.  It also embeds knowledge of
the underlying library name for each PL language; but that's wired into
the initdb-time contents of pg_pltemplate too, so that doesn't seem like
a large problem either.  Note that CREATE TRANSFORM as such doesn't call
the language module at all.

Per a report from Paul Jones.  Back-patch to 9.5 where transform modules
were introduced.

contrib/hstore_plperl/hstore_plperl--1.0.sql
contrib/hstore_plperl/hstore_plperlu--1.0.sql
contrib/hstore_plpython/hstore_plpython2u--1.0.sql
contrib/hstore_plpython/hstore_plpython3u--1.0.sql
contrib/hstore_plpython/hstore_plpythonu--1.0.sql
contrib/ltree_plpython/ltree_plpython2u--1.0.sql
contrib/ltree_plpython/ltree_plpython3u--1.0.sql
contrib/ltree_plpython/ltree_plpythonu--1.0.sql

index ea0ad7688d711bd4b65a431f31ffe63e901708e6..a4fd7c22db89cfda47a1d3fcf1dbc6cfba0085d8 100644 (file)
@@ -1,5 +1,5 @@
 -- make sure the prerequisite libraries are loaded
-DO '' LANGUAGE plperl;
+LOAD 'plperl';
 SELECT NULL::hstore;
 
 
index 46ad35c487976e444778913928db585ea43d5df0..2c2e3e3848add6872caaf4f67db51d0bf11ad56e 100644 (file)
@@ -1,5 +1,5 @@
 -- make sure the prerequisite libraries are loaded
-DO '' LANGUAGE plperlu;
+LOAD 'plperl';
 SELECT NULL::hstore;
 
 
index c998de51c96529cde655edd18de914a31ae03ce4..a793dc9c0cd4fa7cbb2dbf12b55ff9e4fac8ef1b 100644 (file)
@@ -1,5 +1,5 @@
 -- make sure the prerequisite libraries are loaded
-DO '1' LANGUAGE plpython2u;
+LOAD 'plpython2';
 SELECT NULL::hstore;
 
 
index 61d0e47793cd1a1de743f9dfc5371392748d3ec7..a85c85d4c1b808204d843632b7bd5b36ba290f37 100644 (file)
@@ -1,5 +1,5 @@
 -- make sure the prerequisite libraries are loaded
-DO '1' LANGUAGE plpython3u;
+LOAD 'plpython3';
 SELECT NULL::hstore;
 
 
index 6acb97aab9ebc5fe1123488ff86572ac0152fb8f..e2e4721dca96cfabdfe990dd7fa032f771bf6bc1 100644 (file)
@@ -1,5 +1,5 @@
 -- make sure the prerequisite libraries are loaded
-DO '1' LANGUAGE plpythonu;
+LOAD 'plpython2';  -- change to plpython3 if that ever becomes the default
 SELECT NULL::hstore;
 
 
index 29a12d45a287846985e8349b2911c399610d5b93..f040bd3f561985aad6aa7fb57cf8d3f8da8b658a 100644 (file)
@@ -1,5 +1,5 @@
 -- make sure the prerequisite libraries are loaded
-DO '1' LANGUAGE plpython2u;
+LOAD 'plpython2';
 SELECT NULL::ltree;
 
 
index 1300a78c66f46bf2242601b3dab49af8e9dd530f..7afe51f1483e7cd310cac00f81fe376e8b751a88 100644 (file)
@@ -1,5 +1,5 @@
 -- make sure the prerequisite libraries are loaded
-DO '1' LANGUAGE plpython3u;
+LOAD 'plpython3';
 SELECT NULL::ltree;
 
 
index 1d1af28f4eb4e96a5318ada9e4100059dc7a191b..50f35dd16b0a7488b97ff91acc7cbc4169d06ea5 100644 (file)
@@ -1,5 +1,5 @@
 -- make sure the prerequisite libraries are loaded
-DO '1' LANGUAGE plpythonu;
+LOAD 'plpython2';  -- change to plpython3 if that ever becomes the default
 SELECT NULL::ltree;