Re: plpython returns integer[] fails for multi-dimensional array - Mailing list pgsql-general

From Thom Brown
Subject Re: plpython returns integer[] fails for multi-dimensional array
Date
Msg-id AANLkTimgj2sVEuktPBixGgOggp=3Gk5iaQjkQwthQtYZ@mail.gmail.com
Whole thread Raw
In response to plpython returns integer[] fails for multi-dimensional array  ("TJ O'Donnell" <tjo@acm.org>)
Responses Re: plpython returns integer[] fails for multi-dimensional array  (Peter Geoghegan <peter.geoghegan86@gmail.com>)
List pgsql-general
On 21 December 2010 22:48, TJ O'Donnell <tjo@acm.org> wrote:
> In postgresql-9.0.1 I have to modify my plpython functions that return arrays.
> It seems one dimesional arrays are handled properly, but not
> 2-dimensional arrays.
>
> create or replace function atest() returns integer[] as $eopy$
>  a = list()
>  a.append(1)
>  a.append(2)
>  a.append(3)
>  #return a works fine
>  b = list()
>  b.append(a)
>  b.append(a)
>  # error
>  return b
> $eopy$ language plpythonu
>
>
> select atest() gives
> obtest=# select atest();
> ERROR:  invalid input syntax for integer: "[1, 2, 3]"
> CONTEXT:  while creating return value
> PL/Python function "atest"
>
> How can I return multi-dimensional arrays in plpython?

Are you sure that "a" returns okay in that scenario.  You're using a
list.  Shouldn't you be using an array?  Like: a = []

--
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

pgsql-general by date:

Previous
From: "TJ O'Donnell"
Date:
Subject: plpython returns integer[] fails for multi-dimensional array
Next
From: Peter Geoghegan
Date:
Subject: Re: plpython returns integer[] fails for multi-dimensional array