Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 99A31632A40 for ; Sun, 31 Jan 2010 08:20:39 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 58261-09 for ; Sun, 31 Jan 2010 12:20:22 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail0.aip.de (maigret.aip.de [141.33.160.2]) by mail.postgresql.org (Postfix) with SMTP id 721556329D9 for ; Sun, 31 Jan 2010 08:20:28 -0400 (AST) Received: (qmail 18864 invoked from network); 31 Jan 2010 12:26:42 -0000 Received: from cashmere.aip.de (141.33.4.98) by mailout.aip.de with SMTP; 31 Jan 2010 12:26:42 -0000 Received: from cashmere.aip.de (localhost.localdomain [127.0.0.1]) by cashmere.aip.de (8.13.8/8.13.8) with ESMTP id o0VCKPkO009950; Sun, 31 Jan 2010 13:20:25 +0100 Received: (from swhite@localhost) by cashmere.aip.de (8.13.8/8.13.8/Submit) id o0VCKPW3009949; Sun, 31 Jan 2010 13:20:25 +0100 X-Authentication-Warning: cashmere.aip.de: swhite set sender to swhite@aip.de using -f Date: Sun, 31 Jan 2010 13:20:25 +0100 From: Steve White To: Robert Haas Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #5272: PL/Python SELECT: return composite fields as dict, not str Message-ID: <20100131122025.GA9797@cashmere.aip.de> References: <201001111641.o0BGf7cw063967@wwwmaster.postgresql.org> <603c8f071001111831j5b05b57cs108d2792c390e26@mail.gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="mYCpIKhGyMATD0i+" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <603c8f071001111831j5b05b57cs108d2792c390e26@mail.gmail.com> User-Agent: Mutt/1.4.2.2i "Organization: Astrophysikalisches Institut Potsdam" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201001/281 X-Sequence-Number: 25785 --mYCpIKhGyMATD0i+ Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit Hi all, Robert suggested that I start some documentation about limitations of PL/Python. Find attached. I think it would also be good to explain the meaning of "trusted" regarding PL/Python, and how it might impact the user. There is already some commented-out doc, and also something in the PL/Perl section. Specifically, a user might want to know if it is actually dangerous to use PL/Python, etc. If it is dangerous, how, and for whom? Where should one be careful? Cheers! On 11.01.10, Robert Haas wrote: > On Mon, Jan 11, 2010 at 11:41 AM, Steve White wrote: > > I see nothing in the documentation about this > >        http://www.postgresql.org/docs/8.4/static/plpython.html > > It only talks about passing composite types into and out of functions. > > > > This is an unpleasant discovery for those working to a deadline.  Perhaps a > > "limitations" section for the doc would be in order.  (You could also list > > the limitations of PL/Python regarding returning RECORD types.) > > Maybe you could suggest some text, perhaps in the form of a context > diff against the current sgml files? > -- | - - - - - - - - - - - - - - - - - - - - - - - - - | Steve White +49(331)7499-202 | e-Science / AstroGrid-D Zi. 35 Bg. 20 | - - - - - - - - - - - - - - - - - - - - - - - - - | Astrophysikalisches Institut Potsdam (AIP) | An der Sternwarte 16, D-14482 Potsdam | | Vorstand: Prof. Dr. Matthias Steinmetz, Peter A. Stolz | | Stiftung privaten Rechts, Stiftungsverzeichnis Brandenburg: III/7-71-026 | - - - - - - - - - - - - - - - - - - - - - - - - - --mYCpIKhGyMATD0i+ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="plpython.sgml.diff" --- plpython.sgml 2009-12-19 23:23:21.000000000 +0100 +++ plpython-new.sgml 2010-01-31 13:17:20.000000000 +0100 @@ -693,6 +693,41 @@ + + Limitations and Work-arounds + + + + + The result of execute() on a SELECT + is a list of dictionary-like objects whose values corresponding to simple + database types are of the corresponding Python type. Unfortunately + however, values corresponding to composite types are returned as string + representations of the composite value. + That is, PL/Python flattens all composite type + values to strings. + + + Work-arounds: (1) Do a SELECT whose result is the + values of the composite entry. (2) Parse up the result strings. + + + + + + PL/Python functions cannot return either type + RECORD or SETOF RECORD. + + + One work-around is to write a PL/pgSQL function + that creates a temporary table, have it call the + PL/Python function to fill the table, + then have function PL/pgSQL function return the + generic RECORD from the temporary table. + + + + --mYCpIKhGyMATD0i+--