Re: Query broken under 7.1RC2

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kyle <kyle(at)actarg(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Query broken under 7.1RC2
Date: 2001-04-04 15:54:22
Message-ID: 10791.986399662@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Kyle <kyle(at)actarg(dot)com> writes:
> The SQL is a little strange because the subquery tries to reference
> individual records from the outer query and then sum them.
> The more I look at it, I wonder if it is not just bad SQL.

It is bad SQL, but pre-7.1 Postgres failed to catch it. Here's the
CVS log entry:

2000-09-25 14:09 tgl

* src/backend/optimizer/plan/planner.c: System neglected to
complain about ungrouped variables passed to sublinks when outer
query contained aggregates but no GROUP clause.

Since you have a SUM(), the outer query is a grouped query, and so
references to the ungrouped h.* columns in the SELECT targetlist are
not well defined. Lord knows what result you were getting from 7.0 ...

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2001-04-04 16:07:17 Re: Strategy for unlocking query
Previous Message Graham Vickrage 2001-04-04 15:34:54 Strategy for unlocking query