Re: Query with aggregate over subselects fails with ERROR: plan should not reference subplan's variable - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Query with aggregate over subselects fails with ERROR: plan should not reference subplan's variable
Date
Msg-id 23921.1240624683@sss.pgh.pa.us
Whole thread Raw
In response to Re: Query with aggregate over subselects fails with ERROR: plan should not reference subplan's variable  (Daniel Grace <dgrace@wingsnw.com>)
Responses Re: Query with aggregate over subselects fails with ERROR: plan should not reference subplan's variable  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Daniel Grace <dgrace@wingsnw.com> writes:
> On Fri, Apr 24, 2009 at 5:38 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Hmmm ... I guess something is getting confused about the level of query
>> nesting.  FWIW, you can avoid the bug in these two examples by omitting
>> the inner "SELECT" keyword, which is useless anyway.  Perhaps it is
>> needed in your real query though ...

> It's required in my case to force the aggregate function to evaluate its
> inputs in a set order.

Really?  Your example doesn't show that.

> SELECT
>     s.fid, c.flags, c.id, c.title, cs.ut_start, cs.ut_end, cr.full_name,
>     cal.title AS cancel_reason,
>     (SELECT GROUP_CONCAT((SELECT s2.fname FROM student AS s2 WHERE s2.id=
       ------
> s.id ORDER BY fname), '; ')) AS students,

I'm talking about the underlined SELECT, not the one inside the
aggregate.  AFAICS this one is totally useless.  If it were useful,
we'd likely have found this issue long ago ...

            regards, tom lane

pgsql-bugs by date:

Previous
From: Daniel Grace
Date:
Subject: Re: Query with aggregate over subselects fails with ERROR: plan should not reference subplan's variable
Next
From: Tom Lane
Date:
Subject: Re: Query with aggregate over subselects fails with ERROR: plan should not reference subplan's variable