Re: plpython function problem workaround - Mailing list pgsql-general

From Sim Zacks
Subject Re: plpython function problem workaround
Date
Msg-id d145vk$t7o$1@news.hub.org
Whole thread Raw
In response to plpython function problem workaround  ("Sim Zacks" <sim@compulab.co.il>)
Responses Re: plpython function problem workaround
List pgsql-general
Thank You Michael,

It worked when I tried it on the 3 functions that I have.
I checked the archives for any discussion on the Validator and there wasn't
anything specifically discussing it.
I really didn't find a lot of information about the Validators either, for
example where did you see that a validator function gets the language oid
passed in? The only place I could find it was after I looked at the other
languages installed on my system and saw that they all had the same argument
type passed in.

Sim

"Michael Fuhr" <mike@fuhr.org> wrote in message
news:20050314134405.GA20902@winnie.fuhr.org...
> 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/
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
>       subscribe-nomail command to majordomo@postgresql.org so that your
>       message can get through to the mailing list cleanly
>



pgsql-general by date:

Previous
From: Miroslav Šulc
Date:
Subject: Re: free space map settings
Next
From: David Gagnon
Date:
Subject: Re: preoblem in jdbc postgresql and tomcat