Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id B7CE663267C for ; Mon, 11 Jan 2010 12:41:08 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 33014-08 for ; Mon, 11 Jan 2010 16:41:07 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by mail.postgresql.org (Postfix) with ESMTP id F3145632483 for ; Mon, 11 Jan 2010 12:41:07 -0400 (AST) Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by wwwmaster.postgresql.org (8.14.3/8.14.3) with ESMTP id o0BGf7IS063968 for ; Mon, 11 Jan 2010 16:41:07 GMT (envelope-from www@wwwmaster.postgresql.org) Received: (from www@localhost) by wwwmaster.postgresql.org (8.14.3/8.14.3/Submit) id o0BGf7cw063967; Mon, 11 Jan 2010 16:41:07 GMT (envelope-from www) Date: Mon, 11 Jan 2010 16:41:07 GMT Message-Id: <201001111641.o0BGf7cw063967@wwwmaster.postgresql.org> To: pgsql-bugs@postgresql.org Subject: BUG #5272: PL/Python SELECT: return composite fields as dict, not str From: "Steve White" Content-Type: text/plain; charset=utf-8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=x tagged_above=-10 required=5 WHITELISTED X-Spam-Level: X-Archive-Number: 201001/92 X-Sequence-Number: 25596 The following bug has been logged online: Bug reference: 5272 Logged by: Steve White Email address: swhite@aip.de PostgreSQL version: 8.4.2 Operating system: Linux Description: PL/Python SELECT: return composite fields as dict, not str Details: Hi, As recently posted in the mailing list, http://archives.postgresql.org/pgsql-general/2010-01/msg00389.php (where you will find a test file, not reproduced here.): The plpy.execute() command on a SELECT returns a list of nice dictionaries keyed on field names, containing the fields. For numeric types, the type of the dictionary values are as expected. Unfortunately however, if a field contains a composite type, it is flattened to a string. I would have expected a composite type field to be returned as a dictionary of values of the proper types, keyed on the names of the elements of the composite type. After all, it's a DB system that supports hierarchies, and a programming language that beautifully supports them. In my case, I was able to work around this problem in an ugly way, but I can imagine cases where this would render PL/Python unsuitable. 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.) But the best thing to do would be to fix it. For backward compatibility, you might implement a switch that turns on the hierarchical interpretation of fields, and leave the current behaviour as the default. Cheers!