Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T4CU8-0003zR-4H for pgsql-bugs@postgresql.org; Wed, 22 Aug 2012 15:04:44 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T4CU5-0001nC-V7 for pgsql-bugs@postgresql.org; Wed, 22 Aug 2012 15:04:43 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id q7MF4dM0015651; Wed, 22 Aug 2012 11:04:39 -0400 (EDT) From: Tom Lane To: Chris Travers cc: pgsql-bugs@postgresql.org Subject: Re: GROUP BY checks inadequate when set returning functions in column list In-reply-to: References: Comments: In-reply-to Chris Travers message dated "Wed, 22 Aug 2012 07:51:47 -0700" Date: Wed, 22 Aug 2012 11:04:39 -0400 Message-ID: <15650.1345647879@sss.pgh.pa.us> X-Pg-Spam-Score: -2.1 (--) X-Archive-Number: 201208/162 X-Sequence-Number: 33886 Chris Travers writes: > It's when we add group by that things appear broken. Note it starts > returning 196 (14 x 14) records, which suggests a cross join against > itself. > mtech_test=# explain analyze select (account_heading__list()).* group by accno > mtech_test-# ; Hm, that really ought to throw an error, since you have ungrouped columns in the result. Not sure why it doesn't. Beyond that, though, using a SRF in the target list this way is a bad idea because the semantics are very ill-defined. Stick to using it in FROM. (The upcoming LATERAL feature will remove the functional limitations associated with that, so we're very unlikely to do anything towards changing the existing behavior of SRFs-in-target-lists, no matter how wacko they might appear.) regards, tom lane