Re: PL/Python array support - Mailing list pgsql-hackers

From Teodor Sigaev
Subject Re: PL/Python array support
Date
Msg-id 4AFD7F62.3010901@sigaev.ru
Whole thread Raw
In response to Re: PL/Python array support  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: PL/Python array support
List pgsql-hackers
CREATE OR REPLACE FUNCTION incr(stuff int[]) RETURNS int[] AS $$
for x in stuff:    yield x+1
$$
LANGUAGE 'plpythonu';

# select incr(ARRAY[1,2,3]);
ERROR:  invalid memory alloc request size 18446744073709551608
CONTEXT:  while creating return value
PL/Python function "incr"


Suppose, it could be fixed by additional check in PLy_function_handler near line 
947 :
if (proc->is_setof) { ...
}
else if (PyIter_Check(plrv))
{    ereport(ERROR,           (errcode(ERRCODE_DATATYPE_MISMATCH),            errmsg("returned object should be
iterated"),           errdetail("PL/Python returns iterable object in non-setof returning 
 
context")));
}


Peter Eisentraut wrote:
> On ons, 2009-11-04 at 16:02 +0200, Peter Eisentraut wrote:
>> Here is a patch to support arrays in PL/Python as parameters and
>> return values.
> 
> Slightly updated version with fixed reference counting.
> 
> 
> ------------------------------------------------------------------------
> 
> 

-- 
Teodor Sigaev                                   E-mail: teodor@sigaev.ru
  WWW: http://www.sigaev.ru/
 


pgsql-hackers by date:

Previous
From: "Florian G. Pflug"
Date:
Subject: Re: Check constraint on domain over an array not executed for array literals
Next
From: Robert Haas
Date:
Subject: Re: next CommitFest