Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 26CCB632DD5 for ; Wed, 8 Sep 2010 10:35:53 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 95999-01 for ; Wed, 8 Sep 2010 13:35:39 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mail.postgresql.org (Postfix) with ESMTP id BA728632CFF for ; Wed, 8 Sep 2010 10:35:39 -0300 (ADT) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1OtKoM-000139-3P for pgsql-sql@postgresql.org; Wed, 08 Sep 2010 15:35:38 +0200 Received: from mtec-hg-docking-1-dhcp-23.ethz.ch ([129.132.133.23]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 08 Sep 2010 15:35:38 +0200 Received: from roederja by mtec-hg-docking-1-dhcp-23.ethz.ch with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 08 Sep 2010 15:35:38 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: =?UTF-8?B?SmFubiBSw7ZkZXI=?= Subject: Table returning functions Date: Wed, 08 Sep 2010 15:35:24 +0200 Lines: 32 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: mtec-hg-docking-1-dhcp-23.ethz.ch User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201009/17 X-Sequence-Number: 34548 Hi, I have a question which does not seem to be covered in the documentation: I have a function f(i) that returns a table with three columns (a, b, c). In the documentation (http://www.postgresql.org/docs/8.4/interactive/xfunc-sql.html#XFUNC-SQL-FUNCTIONS-RETURNING-SET) it says that (even though deprecated) you can call such functions in a SELECT clause like so: SELECT id, f(id) FROM some_table . This will give me a two column table that looks like this: id | (a, b, c) However since I want a 4 column table like this id | a | b | c , I do this instead: SELECT id, (f(id)).a, (f(id)).b, (f(id)).c FROM some_table. However I'm not quite sure if this really gives me what I want (i.e. the same as in the first query only with the tuple elements as separate columns). Of course I'm open to suggestions on how to do this more elegantly and also how one can do something like this without using the deprecated feature of calling a set returning function in SELECT. Jann