Shouldn't this be invalid?

Started by Tom Lanealmost 27 years ago1 messageshackers
Jump to latest
#1Tom Lane
tgl@sss.pgh.pa.us

I notice that both 6.4.2 and 6.5-current make no complaint if I do

create table t1 (a int4, b int4);

select a+1,b from t1 group by b;

Shouldn't this draw "Illegal use of aggregates or non-group column in
target list"? It does if there's an aggregate nearby:

select sum(a),a+1,b from t1 group by b;
ERROR: Illegal use of aggregates or non-group column in target list
select sum(a),b from t1 group by b;
[ no problem ]

I think the system is simply failing to apply the check in the case
where there's a GROUP BY but no aggregate functions. Comments?

regards, tom lane