Re: SQL syntax (column alias)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: snpe <snpe(at)snpe(dot)co(dot)yu>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: SQL syntax (column alias)
Date: 2002-11-10 17:44:45
Message-ID: 20681.1036950285@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers pgsql-jdbc

Joe Conway <mail(at)joeconway(dot)com> quotes:
> In the SQL92 standard, the optional keyword AS is just noise and can be
> omitted without affecting the meaning. The PostgreSQL parser requires this
> keyword when renaming output columns because the type extensibility features
> lead to parsing ambiguities in this context. AS is optional in FROM items,
> however.

Actually, I think it's not so much datatype extensibility as operator
extensibility, and specifically the fact that we allow postfix
operators. If AS were optional, then

SELECT 1 + x FROM foo;

could be parsed either as "(1 + x)" (infix +, x presumably a column name)
or as "(1 +) x" (postfix +, x an AS-name).

So allowing AS to be optional would at minimum require taking out
postfix operators. There might be other features we'd have to lose,
too; I haven't tried messing with the grammar to see what would happen.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Aurangzeb M. Agha 2002-11-10 19:16:57 Upgrading from 7.1.3 to 7.2.3
Previous Message Doug McNaught 2002-11-10 17:15:09 Re: Stale Process

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Meskes 2002-11-10 17:51:17 Re: c/sql
Previous Message Joe Conway 2002-11-10 16:38:37 Re: SQL syntax (column alias)

Browse pgsql-jdbc by date

  From Date Subject
Next Message M. A. Sridhar 2002-11-11 02:55:30 Help with NPE
Previous Message Joe Conway 2002-11-10 16:38:37 Re: SQL syntax (column alias)