Re: Postgres Planner Bug - Mailing list pgsql-hackers

From Gavin Sherry
Subject Re: Postgres Planner Bug
Date
Msg-id Pine.LNX.4.21.0210011416330.13713-100000@linuxworld.com.au
Whole thread Raw
In response to Re: Postgres Planner Bug  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-hackers
> > Thanks to a user query (handle: lltd, IRC) I came across a bug in the
> > planner. The query was:
> > 
> > ---
> > select o1.timestamp::date as date, count(*), (select sum(oi.price) from
> > "order" o2, "order_item" oi where oi.order_id = o2.id and
> > o2.timestamp::date = o1.timestamp::date and o2.timestamp is not
> > null) as total from "order" o1 where o1.timestamp is not null
> > group by o1.timestamp::date order by o1.timestamp::date desc;
> > ---
> > 
> > The error he was receiving:
> > 
> > ---
> > ERROR:  Sub-SELECT uses un-GROUPed attribute o1.timestamp from outer query
> > ---
> > 
> > After a bit of looking around, I determined that the cast in the order by
> > clause was causing the error, not the fact that the query had an ungrouped

Mistake here. It relates to the group by clause, not order by.

Gavin



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Postgres Planner Bug
Next
From: Tom Lane
Date:
Subject: Re: Postgres Planner Bug