AW: [HACKERS] SELECT ... AS ... names in WHERE/GROUP BY/HAVING

From: Zeugswetter Andreas SB <ZeugswetterA(at)wien(dot)spardat(dot)at>
To: "'pgsql-hackers(at)postgreSQL(dot)org'" <pgsql-hackers(at)postgreSQL(dot)org>
Subject: AW: [HACKERS] SELECT ... AS ... names in WHERE/GROUP BY/HAVING
Date: 1999-12-15 17:37:55
Message-ID: 219F68D65015D011A8E000006F8590C603FDC1C6@sdexcsrv1.f000.d0188.sd.spardat.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


> Next question is, do we want to leave the code as-is, or tighten up
> the parser to reject AS-names and column numbers in GROUP BY?

The numbers are also allowed in other DBMS's, so I would leave that as is.

> It seems to me we should change it, because there are cases where the
> existing code will do the wrong thing according to the SQL spec.
> If "foo" is a column name and also an AS-name for something else,
> "GROUP BY foo" should group on the raw column according to the spec,
> but right now we will pick the SELECT result value instead.

This of course should be handeled the other way around.
Imho the feature to use the AS-names is too convenient,
to drop it alltogether. Remember, that the lable could stand for
a complete subselect, and writing the same subselect again and
again is quite bad for readability.
I would rather extend this AS-names capability to the where
and having clause too.

select
(select max(colname) from syscolumns c
where c.tabid = systables.tabid) as collabel
from systables
where tabname='systables' and collabel matches 'n*';

is imho a very nice and readable syntax .

Andreas

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 1999-12-15 17:38:14 Re: [HACKERS] dumpall prob
Previous Message Tom Lane 1999-12-15 17:27:41 Re: [HACKERS] AND &&