Commit fb6fcbd3 authored by Tom Lane's avatar Tom Lane

Use LOAD not actual code execution to pull in plpython library.

Commit 866566a6 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.
parent 866566a6
-- make sure the prerequisite libraries are loaded -- make sure the prerequisite libraries are loaded
DO '' LANGUAGE plperl; LOAD 'plperl';
SELECT NULL::hstore; SELECT NULL::hstore;
......
-- make sure the prerequisite libraries are loaded -- make sure the prerequisite libraries are loaded
DO '' LANGUAGE plperlu; LOAD 'plperl';
SELECT NULL::hstore; SELECT NULL::hstore;
......
-- make sure the prerequisite libraries are loaded -- make sure the prerequisite libraries are loaded
DO '1' LANGUAGE plpython2u; LOAD 'plpython2';
SELECT NULL::hstore; SELECT NULL::hstore;
......
-- make sure the prerequisite libraries are loaded -- make sure the prerequisite libraries are loaded
DO '1' LANGUAGE plpython3u; LOAD 'plpython3';
SELECT NULL::hstore; SELECT NULL::hstore;
......
-- make sure the prerequisite libraries are loaded -- 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; SELECT NULL::hstore;
......
-- make sure the prerequisite libraries are loaded -- make sure the prerequisite libraries are loaded
DO '1' LANGUAGE plpython2u; LOAD 'plpython2';
SELECT NULL::ltree; SELECT NULL::ltree;
......
-- make sure the prerequisite libraries are loaded -- make sure the prerequisite libraries are loaded
DO '1' LANGUAGE plpython3u; LOAD 'plpython3';
SELECT NULL::ltree; SELECT NULL::ltree;
......
-- make sure the prerequisite libraries are loaded -- 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; SELECT NULL::ltree;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment