Re: [HACKERS] BUG ON HAVING CLAUSE

Vadim Mikheev <vadim@krs.ru>

From: Vadim Mikheev <vadim@krs.ru>
To: Sferacarta Software <sferac@bo.nettuno.it>
Cc: pgsql-hackers@postgresql.org
Date: 1998-12-05T11:32:20Z
Lists: pgsql-hackers
Sferacarta Software wrote:
> 
> >> Seems that I found a bug on HAVING clause, see attached file.
> >>
> 
> VM> Could you post me data for 8342 rows ?
> 
> I think this bug is not on HAVING but on IN/ANY/ALL, I tried all these

This is bug on handling HAVING in subqueries.
There was no HAVING when I was implementing subqueries and
so I didn't care... The bug is in optimizer:

vac=> explain select * from test where x in (select * from test group by x having 1 < count(x));
NOTICE:  QUERY PLAN:

Seq Scan on test  (cost=0.00 size=0 width=4)
  SubPlan
    ->  Aggregate  (cost=0.00 size=0 width=0)
!          InitPlan
!            ->  Aggregate  (cost=0.00 size=0 width=0)
!              ->  Seq Scan on test  (cost=0.00 size=0 width=4)

There must be no InitPlan here...

          ->  Group  (cost=0.00 size=0 width=0)
                ->  Sort  (cost=0.00 size=0 width=0)
                      ->  Seq Scan on test  (cost=0.00 size=0 width=4)

Currently, my local copy of dev-tree is broken and so I can't
fix this. I'll return to this bug latter if no one else...

Vadim