From: | Peter Fein <pfein(at)pobox(dot)com> |
---|---|
To: | Postgresql-General list <pgsql-general(at)postgresql(dot)org> |
Subject: | Return SETOF or array from pl/python |
Date: | 2005-07-15 16:16:07 |
Message-ID: | 42D7E147.6060305@pobox.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Is it possible to return a SETOF text or a text[] from pl/python?
I've got the following test cases:
CREATE OR REPLACE FUNCTION arf()
RETURNS text[] LANGUAGE plpythonu AS
$$return ["one", "two", "three"]$$;
SELECT arf();
ERROR: missing dimension value
CREATE OR REPLACE FUNCTION arf2()
RETURNS text[] LANGUAGE plpythonu AS
$$return '{"one", "two", "three"}'$$;
SELECT arf2();
arf2
-----------------
{one,two,three}
(1 row)
CREATE OR REPLACE FUNCTION srf()
RETURNS SETOF text LANGUAGE plpythonu AS
$$return ["one", "two", "three"]$$;
SELECT * FROM srf();
srf
-------------------------
['one', 'two', 'three']
(1 row)
SELECT srf();
Never returns.
I can obviously use something like arf2 (manually stringifying w/i
python) but this seems ugly. I'd really prefer to return a set, rather
than an array.
--
Peter Fein pfein(at)pobox(dot)com 773-575-0694
Basically, if you're not a utopianist, you're a schmuck. -J. Feldman
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2005-07-15 16:27:42 | Re: CVS - psql segfault |
Previous Message | Chris Browne | 2005-07-15 16:14:04 | Re: Transparent encryption in PostgreSQL? |