Re: multiple CREATE FUNCTION AS items for PLs - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: multiple CREATE FUNCTION AS items for PLs
Date
Msg-id 50DE09A0.5070707@gmx.net
Whole thread Raw
In response to Re: multiple CREATE FUNCTION AS items for PLs  (Hannu Krosing <hannu@krosing.net>)
List pgsql-hackers
On 12/28/12 7:09 AM, Hannu Krosing wrote:
> Maybe just export the function with the same name as is defined in
> CREATE FUNCTION ?
> 
> And in case we do want to override it, call it
> 
> CREATE FUNCTION foo(a int,b int, c text) AS $$
> # plpython: module modulename
> import x,y,z
> 
> def foo(a,b,c):
>     return a + b + c
> 
> def foo2(a,b,c):
>     return foo(a,b,int(c))
> 
> __call__ = foo2
> 
> $$ language plpythonu

I like this approach, except I would call the attribute something like
__plpy_something___.

> If we always require the export using __call__ in new-style pl/python
> functions we could
> leave out the "# plpython: module " part altogether and just test for
> __call__ in the compiled
> modules namespace after trying to compile the source code as module and
> re-compile
> using current methods if this fails.

That's a thought.  I'm not yet sure whether I prefer it.



pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: enhanced error fields
Next
From: Peter Eisentraut
Date:
Subject: Re: proposal: ANSI SQL 2011 syntax for named parameters