From: Tom Lane <tgl@sss.pgh.pa.us>
To: Chris Travers <chris@metatrontech.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: GROUP BY checks inadequate when set returning functions in column list
Date: Wed, 22 Aug 2012 18:13:18 -0400
Message-ID: <23839.1345673598@sss.pgh.pa.us> (raw)
In-Reply-To: <CAPKNUtcxGUpjRmbm6rQiEa91Kmvsk2T54S3nWeosUe7HDkg6Pw@mail.gmail.com>
References: <CAPKNUtf=0XFxYuy79qmoSQz_Q=663yuZTCZWhF-MXSr_UUXS+Q@mail.gmail.com>
<15650.1345647879@sss.pgh.pa.us>
<CAPKNUtcxGUpjRmbm6rQiEa91Kmvsk2T54S3nWeosUe7HDkg6Pw@mail.gmail.com>
Chris Travers <chris@metatrontech.com> writes:
> On Wed, Aug 22, 2012 at 8:04 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Chris Travers <chris@metatrontech.com> writes:
> mtech_test=# explain analyze select (account_heading__list()).* group by accno
>> Hm, that really ought to throw an error, since you have ungrouped
>> columns in the result. Not sure why it doesn't.
> Yeah, that was my point. I don't know if it is worth fixing but
> always better to report.
I looked into this, and found that the query basically expands to
SELECT (func()).field1, (func()).field2, (func()).field3, ... GROUP BY 2;
There are no Vars in this query; only FuncExprs and FieldSelects.
So that's why the check for ungrouped variables isn't complaining.
To make it complain, we'd have to have a notion that the different
occurrences of the function are generating related columns of a row,
which is something that quite disappears in the *-expansion.
As I said before, this isn't really an area that anybody is excited
about changing --- it's all legacy behavior, and if we change it
we're more likely to get complaints from people whose code broke
than compliments from people who can now use it for something.
Eventually I think SRFs in the targetlist will be deprecated in
favor of LATERAL constructs, though it will be a very long time
before we could consider removing the feature altogether.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, chris@metatrontech.com
Subject: Re: GROUP BY checks inadequate when set returning functions in column list
In-Reply-To: <23839.1345673598@sss.pgh.pa.us>
References: <CAPKNUtf=0XFxYuy79qmoSQz_Q=663yuZTCZWhF-MXSr_UUXS+Q@mail.gmail.com> <15650.1345647879@sss.pgh.pa.us> <CAPKNUtcxGUpjRmbm6rQiEa91Kmvsk2T54S3nWeosUe7HDkg6Pw@mail.gmail.com> <23839.1345673598@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox