Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id B00A09FB3A0 for ; Mon, 29 Jan 2007 10:12:41 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 59852-09 for ; Mon, 29 Jan 2007 10:12:23 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from smtp3.ualg.pt (smtp3.ualg.pt [193.136.224.6]) by postgresql.org (Postfix) with ESMTP id 76B5A9FB39E for ; Mon, 29 Jan 2007 10:12:34 -0400 (AST) Received: by smtp3.ualg.pt (Postfix, from userid 501) id B51711E19A2; Mon, 29 Jan 2007 14:12:29 +0000 (WET) Received: from localhost (smtp3.ualg.pt [127.0.0.1]) by smtp3.ualg.pt (Postfix) with ESMTP id 8A0B91E006A for ; Mon, 29 Jan 2007 14:12:29 +0000 (WET) X-Virus-Scanned: amavisd-new at ualg.pt Received: from smtp3.ualg.pt ([127.0.0.1]) by localhost (smtp3.ualg.pt [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id A9rlGbwvTRov for ; Mon, 29 Jan 2007 14:12:28 +0000 (WET) Received: from [10.17.20.14] (unknown [10.17.20.14]) by smtp3.ualg.pt (Postfix) with ESMTP id B58FE1E0060 for ; Mon, 29 Jan 2007 14:12:28 +0000 (WET) Message-ID: <45BE00CA.1060106@ualg.pt> Date: Mon, 29 Jan 2007 14:12:26 +0000 From: =?ISO-8859-2?Q?Lu=EDs_Sousa?= User-Agent: Debian Thunderbird 1.0.2 (X11/20061113) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql Subject: Re: Function returning SETOF using plpythonu References: <45BA3964.8070704@ualg.pt> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.236 tagged_above=0 required=5 tests=AWL, BAYES_50, SPF_PASS X-Spam-Level: X-Archive-Number: 200701/150 X-Sequence-Number: 27302 Thanks :-) That worked fine. >plpy.execute returns dictionary, and you need a list. You may try this: > >CREATE FUNCTION "test_python_setof"() >RETURNS SETOF text AS ' > records=plpy.execute("SELECT name FROM interface"); > return [ (r["name"]) for r in records] >' LANGUAGE 'plpythonu'; > > > Then I tried to do some changes and try to return a SETOF type: CREATE TYPE "test_python_t" AS ( name varchar(50) ); CREATE FUNCTION "test_python_setof"() RETURNS SETOF test_python_t AS ' records=plpy.execute("SELECT name FROM interface"); return [ (r["name"]) for r in records] ' LANGUAGE 'plpythonu'; And I'm getting ERROR: tuple return types are not supported yet. On my production database server I'm using PostgreSQL 7.4 and using language plpgsql I'm returning some SETOF type without problems. Is this a feature that's missing on this version or I'm I doing something wrong on code? If is a feature missing, is already implemented on some version afterwards? Best regards, Luís Sousa