Re: Python setof patch - Mailing list pgsql-patches

From Tom Lane
Subject Re: Python setof patch
Date
Msg-id 24079.1120583665@sss.pgh.pa.us
Whole thread Raw
In response to Re: Python setof patch  (Michael Fuhr <mike@fuhr.org>)
Responses Re: Python setof patch
List pgsql-patches
Michael Fuhr <mike@fuhr.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

pgsql-patches by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Autovacuum integration patch
Next
From: Michael Fuhr
Date:
Subject: Re: Python setof patch