X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id A22959DD6D4 for ; Thu, 1 Dec 2005 16:27:02 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 71324-02 for ; Thu, 1 Dec 2005 16:26:54 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by postgresql.org (Postfix) with ESMTP id 0B0F69DD6C3 for ; Thu, 1 Dec 2005 16:26:54 -0400 (AST) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id jB1KQl0a069138 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 1 Dec 2005 13:26:52 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.4/8.13.4) with ESMTP id jB1KQlox066847; Thu, 1 Dec 2005 13:26:47 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.4/8.13.4/Submit) id jB1KQlkR066846; Thu, 1 Dec 2005 13:26:47 -0700 (MST) (envelope-from mfuhr) Date: Thu, 1 Dec 2005 13:26:47 -0700 From: Michael Fuhr To: "Joshua D. Drake" Cc: Eugene Prokopiev , pgsql-interfaces@postgresql.org Subject: Re: PL/Python set returning functions Message-ID: <20051201202646.GA66766@winnie.fuhr.org> References: <438F47F7.2040109@stc.donpac.ru> <438F48CE.7030008@commandprompt.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <438F48CE.7030008@commandprompt.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200512/3 X-Sequence-Number: 5871 On Thu, Dec 01, 2005 at 11:02:38AM -0800, Joshua D. Drake wrote: > Eugene Prokopiev wrote: > >How can I return some rows from my PL/Python function? > > > >I wrote: > > > >dbmail=# create type composite as (id bigint, name text); > >CREATE TYPE > >dbmail=# create or replace function csrf() returns setof composite as $$ > >dbmail$# return ((1, "james"), (2, "bob"), (3, "fargus")) > >dbmail$# $$ language plpythonu; > >CREATE FUNCTION > >dbmail=# select csrf(); > >ERROR: plpython functions cannot return tuples yet > > > select * from csrf(); Not in this case: test=# select * from csrf(); ERROR: plpython functions cannot return tuples yet As far as I can tell from the source code, PL/Python doesn't support returning composite types or sets (somebody please correct me if I'm mistaken). You might want to investigate PostgresPy. I haven't used it myself and I think it's still in development, but it's probably worth a look if you're using Python. I'm sure the developer would appreciate any feedback. http://python.projects.postgresql.org/ -- Michael Fuhr