Re: Making plpython 2 and 3 coexist a bit better - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Making plpython 2 and 3 coexist a bit better
Date
Msg-id 865.1452541618@sss.pgh.pa.us
Whole thread Raw
In response to Re: Making plpython 2 and 3 coexist a bit better  (Jim Nasby <Jim.Nasby@BlueTreble.com>)
Responses Re: Making plpython 2 and 3 coexist a bit better
List pgsql-hackers
Jim Nasby <Jim.Nasby@bluetreble.com> writes:
> On 1/11/16 1:00 PM, Tom Lane wrote:
>> The question of whether to do ERROR or FATAL remains open.  I'm not sure
>> I have a strong preference either way.

> If they both get loaded is there risk of bad data happening? Personally, 
> I'll take a traceable FATAL (or even PANIC) over data corruption every 
> time. But I'm guessing that if you tried to use both you'd pretty 
> immediately end up crashing the backend.

Yeah, the conservative solution would definitely be to use FATAL.
It's still a usability improvement over what we have now.

In further experimentation, I found out that even with this patch in
place, the plpython transform extensions still present a dump/reload
hazard:

test=# create extension plpython2u;
CREATE EXTENSION
test=# create extension ltree_plpython3u cascade;
NOTICE:  installing required extension "ltree"
NOTICE:  installing required extension "plpython3u"
ERROR:  multiple Python libraries are present in session
DETAIL:  Only one Python major version can be used in one session.

AFAICS, the reason for that is this code in the transform extension
scripts:

-- make sure the prerequisite libraries are loaded
DO '1' LANGUAGE plpython3u;

It does appear that we need something for this, because if you just
remove it you get failures like

Symbol not found: _PLyUnicode_FromStringAndSize

But I wonder why we couldn't make it do

LOAD 'plpython3';

instead.  If I change the script like that, it seems to go through fine
even with both Python libraries loaded, because CREATE TRANSFORM does not
actually call into the language implementation.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Speedup twophase transactions
Next
From: Simon Riggs
Date:
Subject: Re: Speedup twophase transactions