Re: [HACKERS] 6.4 Aggregate Bug and HAVING problems... - Mailing list pgsql-hackers

From Vadim Mikheev
Subject Re: [HACKERS] 6.4 Aggregate Bug and HAVING problems...
Date
Msg-id 35F4D150.EFA75826@krs.ru
Whole thread Raw
In response to Re: [HACKERS] 6.4 Aggregate Bug  (Bruce Momjian <maillist@candle.pha.pa.us>)
List pgsql-hackers
> Added to TODO:
>
> * select upper(usename), count(usesysid) from pg_shadow group by 1 fails

Fixed. Was broken by new HAVING code...

I see another problems in HAVING:

1.
drop table x;
create table x (a int, b int, c int);
insert into x values (1,1,0);
insert into x values (1,1,1);
select a, min (b) from x group by a having min(b) > c;
-- a|min
-- -+---
-- 1|  1
-- (1 row)
delete from x;
vacuum x;
insert into x values (1,1,1);
insert into x values (1,1,0);
select a, min (b) from x group by a having min(b) > c;
-- a|min
-- -+---
-- (0 rows)

Using C-column is illegal!

2.
vac=> select a, min (b) from x group by a having min(b) > 0 or a = 0;
                                                            ^^^^^^^^
ERROR:  This could have been done in a where clause!!
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
No, couldn't! Using GroupBy expr in having must be allowed.

I'm going to change HAVING behaviour...

Also, could someone test is HAVING without aggregates
disallowed or not:

select a, min (b) from x group by a having a = 0;

- ???

Vadim

pgsql-hackers by date:

Previous
From: "Thomas G. Lockhart"
Date:
Subject: Re: [HACKERS] Rules: first fix
Next
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] Macro From Hell