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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Daniel Grace <dgrace(at)wingsnw(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Query with aggregate over subselects fails with ERROR: plan should not reference subplan's variable
Date: 2009-04-25 02:58:00
Message-ID: 24894.1240628280@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Daniel Grace <dgrace(at)wingsnw(dot)com> writes:
> 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.

Yes, it's certainly a real bug, and we appreciate the bug report. My
point is just that the reason it's gone undetected is that it's not a
very useful case in practice; and in particular I don't believe that
it's a case you need to solve your problem.

(To be concrete, the failure case as I understand it is a sub-SELECT
containing an aggregate call containing a sub-sub-SELECT, where the
aggregate call actually belongs to the outermost query level according
to the SQL nesting rules. This is not what you want because the
aggregation is happening, or would happen except for the planner bug,
with entirely the wrong scope for what you want.)

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Alejandro Oyarce 2009-04-25 03:39:51 BUG #4781: Error de Windows Installer
Previous Message Daniel Grace 2009-04-25 02:38:03 Re: Query with aggregate over subselects fails with ERROR: plan should not reference subplan's variable