Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id C4E299FB3A7 for ; Mon, 29 Jan 2007 10:29:36 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 71573-04 for ; Mon, 29 Jan 2007 10:29:29 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from rwcrmhc15.comcast.net (rwcrmhc15.comcast.net [204.127.192.85]) by postgresql.org (Postfix) with ESMTP id 95A139FB3A5 for ; Mon, 29 Jan 2007 10:29:29 -0400 (AST) Received: from [192.168.0.9] (c-24-17-161-80.hsd1.wa.comcast.net[24.17.161.80]) by comcast.net (rwcrmhc15) with ESMTP id <20070129142927m1500lb573e>; Mon, 29 Jan 2007 14:29:27 +0000 From: Adrian Klaver To: pgsql-sql@postgresql.org Subject: Re: Function returning SETOF using plpythonu Date: Mon, 29 Jan 2007 06:29:43 -0800 User-Agent: KMail/1.9.1 References: <45BA3964.8070704@ualg.pt> <45BE00CA.1060106@ualg.pt> In-Reply-To: <45BE00CA.1060106@ualg.pt> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200701290629.43520.aklaver@comcast.net> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.514 tagged_above=0 required=5 tests=AWL, BAYES_40, DNS_FROM_RFC_POST X-Spam-Level: X-Archive-Number: 200701/151 X-Sequence-Number: 27303 On Monday 29 January 2007 6:12 am, Lu=EDs Sousa wrote: > 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=3Dplpy.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=3Dplpy.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=EDs Sousa > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Have you searched our list archives? > > http://archives.postgresql.org SETOF in pl/pythonu appeared in 8.2 =2D-=20 Adrian Klaver aklaver@comcast.net