Re: Query with aggregate over subselects fails with ERROR: plan should not reference subplan's variable

Поиск
Список
Период
Сортировка
От Daniel Grace
Тема Re: Query with aggregate over subselects fails with ERROR: plan should not reference subplan's variable
Дата
Msg-id 8a80df380904241938r127d290ara46af51f747df0c6@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Query with aggregate over subselects fails with ERROR: plan should not reference subplan's variable  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Query with aggregate over subselects fails with ERROR: plan should not reference subplan's variable  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
No luck there either (runs, but with incorrect results), but since I know
this isn't a support list and is a bugs list I just would like to point out
that: Even though what I was doing that triggered the bug is apparently
incorrect and 'silly', it's still possible that some complicated legitimate
query might trigger the same problem -- so it may be worth looking into.

On Fri, Apr 24, 2009 at 7:19 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> I wrote:
> > I'm talking about the underlined SELECT, not the one inside the
> > aggregate.  AFAICS this one is totally useless.
>
> Oh, wait.  It is useless in the query as written, but now that I think
> twice about what you're trying to accomplish, you do need three levels
> of SELECT keywords.  Just not like that.  I think what you actually
> want is
>
> SELECT
>    ...
>    (SELECT GROUP_CONCAT(t.fname, '; ') FROM
>       (SELECT s2.fname FROM student AS s2
>        WHERE s2.id=s.id ORDER BY fname) AS t) AS students,
>    ...
> FROM
>    student AS s
>
> What you wrote instead is just wrong --- it would fail if there were
> multiple students with the same id (can that actually happen?
> Maybe there's more wrong with this query...), because what you
> wrote is a scalar sub-SELECT inside an aggregate call that belongs
> to the outermost query.
>
>                        regards, tom lane
>



--
Daniel Grace
AGE, LLC
System Administrator and Software Developer
dgrace@wingsnw.com // (425)327-0079 // www.wingsnw.com

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Query with aggregate over subselects fails with ERROR: plan should not reference subplan's variable
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Query with aggregate over subselects fails with ERROR: plan should not reference subplan's variable