Re: Python setof patch

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, Gerrit van Dyk <gvandyk(at)agileworks(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: Python setof patch
Date: 2005-07-05 17:14:25
Message-ID: 24079.1120583665@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Michael Fuhr <mike(at)fuhr(dot)org> writes:
>> This patch allows the PL/Python module to do (SRF) functions.

> Does this patch work?

Aside from minor problems like being broken and undocumented, there is a
more serious question here: is this even the functionality we want?

The proposed test case is:

CREATE or replace FUNCTION test_setof() returns setof text
AS
'if GD.has_key("calls"):
GD["calls"] = GD["calls"] + 1
if GD["calls"] > 2:
del GD["calls"]
return plpy.EndOfSet
else:
GD["calls"] = 1
return str(GD["calls"])'
LANGUAGE plpythonu;

which is essentially exposing the old value-per-call SRF implementation
to the Python programmer. Do we really want to do that? plperl and
plpgsql have not taken that tack. One reason this doesn't seem a
particularly great idea is that the above example would likely fail
if invoked twice in one query, due to it using only one global state
variable for both invocations.

regards, tom lane

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Michael Fuhr 2005-07-05 17:28:09 Re: Python setof patch
Previous Message Alvaro Herrera 2005-07-05 17:11:53 Re: Autovacuum integration patch