Re: SQL syntax (column alias) - Mailing list pgsql-hackers

From Tom Lane
Subject Re: SQL syntax (column alias)
Date
Msg-id 20681.1036950285@sss.pgh.pa.us
Whole thread Raw
In response to Re: SQL syntax (column alias)  (Joe Conway <mail@joeconway.com>)
List pgsql-hackers
Joe Conway <mail@joeconway.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


pgsql-hackers by date:

Previous
From: Joe Conway
Date:
Subject: Re: SQL syntax (column alias)
Next
From: Michael Meskes
Date:
Subject: Re: c/sql