Re: [HACKERS] Parser bug: alias is a "non-group column"?
Where did we leave this?
Given
create table t1 (name text, value float8);this works:
SELECT name, value FROM t1 GROUP BY name, value
HAVING value/AVG(value) > 0.75;but this doesn't:
SELECT name AS tempname, value FROM t1 GROUP BY name, value
HAVING value/AVG(value) > 0.75;
ERROR: Illegal use of aggregates or non-group column in target listCuriously, it's fine if the HAVING clause is omitted ... since name is
not mentioned in the HAVING clause, I don't see the connection ...6.4.2 and current sources show the same behavior.
regards, tom lane
--
Bruce Momjian | http://www.op.net/~candle
maillist@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Import Notes
Reply to msg id not found: 21598.923070013@sss.pgh.pa.us
Bruce Momjian <maillist@candle.pha.pa.us> writes:
Where did we leave this?
It's still broken. I have the following notes in my todo list:
Inconsistent handling of attribute renaming:
create table t1 (name text, value float8);
select name as n1 from t1 where n1 = 'one' ;
ERROR: attribute 'n1' not found
but
SELECT name AS tempname, value FROM t1 GROUP BY name, value ;
SELECT name AS tempname, value FROM t1 GROUP BY tempname, value ;
both work. Even stranger,
SELECT name AS tempname, value FROM t1 GROUP BY name, value
HAVING value/AVG(value) > 0.75;
ERROR: Illegal use of aggregates or non-group column in target list
(it thinks tempname is not in the GROUP BY list) but
SELECT name AS tempname, value FROM t1 GROUP BY tempname, value
HAVING value/AVG(value) > 0.75;
works! (6.4.2 has same behavior for all cases...)
Looks like the parser has some problems in the presence of column
renaming. Since 6.4.2 has the same bug I doubt this qualifies as a
showstopper for 6.5; I have other todo items that I consider higher
priority. If someone else wants to dig into this, be my guest...
regards, tom lane
Import Notes
Reply to msg id not found: YourmessageofMon10May1999010322-0400199905100503.BAA24000@candle.pha.pa.us | Resolved by subject fallback