Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2013-01-02 Thread Hitoshi Harada
On Fri, Dec 28, 2012 at 12:24 AM, Pavel Stehule wrote: > 2012/12/28 Peter Eisentraut : >> On Mon, 2012-12-17 at 16:34 -0500, Peter Eisentraut wrote: >>> Yes, this would be a good solution for some applications, but the only >>> way I can think of to manage the compatibility issue is to invent some

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2013-01-02 Thread Robert Haas
On Fri, Dec 28, 2012 at 7:09 AM, Hannu Krosing wrote: > thus > > CREATE FUNCTION foo(a int,b int, c text) > > would create module > > plpy.modules.foo_int4_int4_text I don't know much of anything about Python, but keep in mind that types can be renamed. It seems like that could break things if t

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-28 Thread Peter Eisentraut
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,

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-28 Thread Hannu Krosing
On 12/28/2012 09:15 AM, Peter Eisentraut wrote: On Mon, 2012-12-17 at 16:34 -0500, Peter Eisentraut wrote: Yes, this would be a good solution for some applications, but the only way I can think of to manage the compatibility issue is to invent some function attribute system like CREATE FUNCTION

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-28 Thread Tom Lane
> On 12/28/2012 09:15 AM, Peter Eisentraut wrote: >> An alternative that has some amount of precedent in the Python world >> would be to use comment pragmas, like this: ... >> This way we could get this done fairly easily without any new >> infrastructure outside the language handler. +1 for not c

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-28 Thread Andrew Dunstan
On 12/28/2012 03:15 AM, Peter Eisentraut wrote: On Mon, 2012-12-17 at 16:34 -0500, Peter Eisentraut wrote: Yes, this would be a good solution for some applications, but the only way I can think of to manage the compatibility issue is to invent some function attribute system like CREATE FUNCTIO

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-28 Thread Hannu Krosing
On 12/28/2012 09:15 AM, Peter Eisentraut wrote: On Mon, 2012-12-17 at 16:34 -0500, Peter Eisentraut wrote: Yes, this would be a good solution for some applications, but the only way I can think of to manage the compatibility issue is to invent some function attribute system like CREATE FUNCTION

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-28 Thread Pavel Stehule
2012/12/28 Peter Eisentraut : > On Mon, 2012-12-17 at 16:34 -0500, Peter Eisentraut wrote: >> Yes, this would be a good solution for some applications, but the only >> way I can think of to manage the compatibility issue is to invent some >> function attribute system like >> >> CREATE FUNCTION ...

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-28 Thread Peter Eisentraut
On Mon, 2012-12-17 at 16:34 -0500, Peter Eisentraut wrote: > Yes, this would be a good solution for some applications, but the only > way I can think of to manage the compatibility issue is to invent some > function attribute system like > > CREATE FUNCTION ... OPTIONS (call_convention 'xyz') An

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-17 Thread Tom Lane
Hannu Krosing writes: > On 12/17/2012 10:34 PM, Peter Eisentraut wrote: >> Yes, this would be a good solution for some applications, but the only >> way I can think of to manage the compatibility issue is to invent some >> function attribute system like >> >> CREATE FUNCTION ... OPTIONS (call_con

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-17 Thread Hannu Krosing
On 12/17/2012 10:34 PM, Peter Eisentraut wrote: On 12/16/12 1:20 PM, Hannu Krosing wrote: I was going to suggest some special function name to be pulled out of code passed to CREATE FUNCTION in line with CREATE FUNCTION foo(a,b,c) AS $$ import x from __future__ import nex_coo

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-17 Thread Pavel Stehule
2012/12/17 Peter Eisentraut : > On 12/16/12 1:20 PM, Hannu Krosing wrote: >> I was going to suggest some special function name to be pulled out of code >> passed to CREATE FUNCTION in line with >> >> CREATE FUNCTION foo(a,b,c) AS $$ >> import x >> from __future__ import nex_cool_fea

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-17 Thread Peter Eisentraut
On 12/16/12 1:20 PM, Hannu Krosing wrote: > I was going to suggest some special function name to be pulled out of code > passed to CREATE FUNCTION in line with > > CREATE FUNCTION foo(a,b,c) AS $$ > import x > from __future__ import nex_cool_feature > > def helper_function

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-16 Thread Hannu Krosing
On 12/16/2012 10:23 PM, Peter Eisentraut wrote: On Sun, 2012-12-16 at 19:13 +0100, Hannu Krosing wrote: As an idea seems quite good, but maybe the "run once" part could use its own keyword in the future, something like PREPARE or REQUIRE? Well, either we do it in a language independent way, in

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-16 Thread Peter Eisentraut
On Sun, 2012-12-16 at 13:03 -0500, Tom Lane wrote: > Sure, but wouldn't it be cleaner to do that via some language-specific > syntax inside the function string? I'm imagining some syntax like > > CREATE FUNCTION ... AS $$ > global[ some definitions here ] > function code h

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-16 Thread Peter Eisentraut
On Sun, 2012-12-16 at 19:13 +0100, Hannu Krosing wrote: > As an idea seems quite good, but maybe the "run once" part could use > its > own keyword in the future, something like PREPARE or REQUIRE? Well, either we do it in a language independent way, in which case this would be too prescriptive, or

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-16 Thread Hannu Krosing
On 12/16/2012 08:44 PM, Andrew Dunstan wrote: On 12/16/2012 01:37 AM, Peter Eisentraut wrote: So in practice this might look like this: CREATE FUNCTION foo(...) ... LANGUAGE plpythonu AS $$ import x import y $$, $$ real code here $$; Bleah. It seems obscure to say the least. Why not have

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-16 Thread Andrew Dunstan
On 12/16/2012 01:37 AM, Peter Eisentraut wrote: So in practice this might look like this: CREATE FUNCTION foo(...) ... LANGUAGE plpythonu AS $$ import x import y $$, $$ real code here $$; Bleah. It seems obscure to say the least. Why not have something along the lines of plperl's on_init

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-16 Thread Hannu Krosing
On 12/16/2012 07:37 PM, Tom Lane wrote: Hannu Krosing writes: On further thought the function name should just be what it is defined in postgresql, like this CREATE FUNCTION foo(a,b,c) AS $$ import x from __future__ import nex_cool_feature def helper_function(x):

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-16 Thread Hannu Krosing
On 12/16/2012 07:44 PM, Tom Lane wrote: Hannu Krosing writes: On further thought the function name should just be what it is defined in postgresql, like this CREATE FUNCTION foo(a,b,c) AS $$ def foo(a,b,c): BTW, how well will that play with overloaded function names? I don't particula

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-16 Thread Tom Lane
Hannu Krosing writes: >> On further thought the function name should just be what it is defined >> in postgresql, like this >> CREATE FUNCTION foo(a,b,c) AS $$ >> def foo(a,b,c): BTW, how well will that play with overloaded function names? I don't particularly care for saying that PL/Pyth

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-16 Thread Tom Lane
Hannu Krosing writes: > On further thought the function name should just be what it is defined > in postgresql, like this > CREATE FUNCTION foo(a,b,c) AS $$ > import x > from __future__ import nex_cool_feature > def helper_function(x): > ... > def fo

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-16 Thread Hannu Krosing
On 12/16/2012 07:20 PM, Hannu Krosing wrote: On 12/16/2012 07:03 PM, Tom Lane wrote: Peter Eisentraut writes: When you do CREATE FUNCTION foo(...) ... LANGUAGE plpythonu AS $$ source code here $$; it internally creates a "source file" that contains --- def __plpython_procedure_foo_12345():

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-16 Thread Hannu Krosing
On 12/16/2012 07:03 PM, Tom Lane wrote: Peter Eisentraut writes: When you do CREATE FUNCTION foo(...) ... LANGUAGE plpythonu AS $$ source code here $$; it internally creates a "source file" that contains --- def __plpython_procedure_foo_12345(): source code here --- It would be useful to b

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-16 Thread Hannu Krosing
On 12/16/2012 07:37 AM, Peter Eisentraut wrote: I'm going to use PL/Python as an example, but I would also like to know if this could be applicable to other languages. When you do CREATE FUNCTION foo(...) ... LANGUAGE plpythonu AS $$ source code here $$; it internally creates a "source file" t

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-16 Thread Tom Lane
Peter Eisentraut writes: > When you do > CREATE FUNCTION foo(...) ... LANGUAGE plpythonu > AS $$ > source code here > $$; > it internally creates a "source file" that contains > --- > def __plpython_procedure_foo_12345(): > source code here > --- > It would be useful to be able to do somet

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-16 Thread Peter Eisentraut
On Sun, 2012-12-16 at 10:20 +0100, Pavel Stehule wrote: > Hello > > I understand to motivation, but proposed syntax is not too intuitive and > robust > > can you do it in one function and call import only in first call? Sometimes, but it's even less intuitive and robust. -- Sent via pgsql-h

Re: [HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-16 Thread Pavel Stehule
Hello I understand to motivation, but proposed syntax is not too intuitive and robust can you do it in one function and call import only in first call? Regards Pavel 2012/12/16 Peter Eisentraut : > I'm going to use PL/Python as an example, but I would also like to know > if this could be appl

[HACKERS] multiple CREATE FUNCTION AS items for PLs

2012-12-15 Thread Peter Eisentraut
I'm going to use PL/Python as an example, but I would also like to know if this could be applicable to other languages. When you do CREATE FUNCTION foo(...) ... LANGUAGE plpythonu AS $$ source code here $$; it internally creates a "source file" that contains --- def __plpython_procedure_foo_123