Re: plpython function problem workaround

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Sim Zacks <sim(at)compulab(dot)co(dot)il>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: plpython function problem workaround
Date: 2005-03-14 13:44:05
Message-ID: 20050314134405.GA20902@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Mar 14, 2005 at 02:37:00PM +0200, Sim Zacks wrote:

> I worked around the plpython problem that doesn't allow scripts created on
> Windows to be run on the *nix server with the following statement.
> update pg_proc set prosrc=replace(prosrc,chr(13),'') where prolang=87238
> --plpythonu's oid in my setup is 87238. I don't know if that is a standard
> or just on mine.

The oid is arbitrary, so you should get it via a (sub)query instead
of hardcoding it.

> Is there a way to automate that script every time a plpythonu function is
> created?
> I tried writing a trigger on the pg_proc table but it wouldn't let me:

Hmmm...plpythonu doesn't install a VALIDATOR function. I wonder
if you could exploit that? This is just a brainstorm, but the
following worked for me in trivial tests:

CREATE FUNCTION fixpython(funcoid oid) RETURNS void AS $$
BEGIN
UPDATE pg_proc SET prosrc = replace(prosrc, chr(13), '')
WHERE oid = funcoid;

RETURN;
END;
$$ LANGUAGE plpgsql VOLATILE STRICT;

UPDATE pg_language SET lanvalidator = 'fixpython'::regproc
WHERE lanname = 'plpythonu';

Are there any problems with doing this? Is a VALIDATOR function
permitted to modify the function it's validating? This wouldn't
work if plpythonu ever installs a VALIDATOR, but you might be able
to use it until such time (barring objections about why it's a Bad
Idea, that is).

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Harald Fuchs 2005-03-14 13:50:18 Re: prelimiary performance comparison pgsql vs mysql
Previous Message Mark Rae 2005-03-14 13:31:02 Re: prelimiary performance comparison pgsql vs mysql