From: | Hannu Krosing <hannu(at)2ndQuadrant(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Hannu Krosing <hannu(at)2ndQuadrant(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: multiple CREATE FUNCTION AS items for PLs |
Date: | 2012-12-16 19:01:11 |
Message-ID: | 50CE1A77.6090005@2ndQuadrant.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 12/16/2012 07:37 PM, Tom Lane wrote:
> Hannu Krosing <hannu(at)2ndQuadrant(dot)com> 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 foo(a,b,c):
>> defined function body here
>> def bar(i,j):
>> function body for bar(i,j)
>> $$ language plpythonu;
>>> but this would not be backwards compatible, at least not in any
>>> obvious way.
>> This is still unfortunately true :(
> Could we say that *if* the function text contains a line beginning
> "def function_name" then we interpret it as above, otherwise oldstyle?
> I'm not sure how big a risk of false positives there'd be.
>
You could be inclined to define a recursive function like this under
current pl/python
CREATE FUNCTION factorial(n bigint) returns bigint LANGUAGE plpythonu
AS $$
def factorial(n):
if n==0: return 1
return factorial(n-1) * n
return factorial(n)
$$;
but at least for functions returning a non-null value an old-style
definition usually
end with line in form
return <something>
------------------------
Hannu
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2012-12-16 19:44:38 | Re: multiple CREATE FUNCTION AS items for PLs |
Previous Message | Hannu Krosing | 2012-12-16 18:56:55 | Re: multiple CREATE FUNCTION AS items for PLs |