Mandatory AS keyword in SELECT statements

Lists: pgsql-general
From: <vincent(dot)moreau(at)adeoservices(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Mandatory AS keyword in SELECT statements
Date: 2007-12-31 14:45:57
Message-ID: 477900A5.7010700@adeoservices.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi,

We are currently trying to migrate an Oracle database to PostgreSQL.
Unfortunately, the Java application that access the database does not
use the AS keyword to alias column names in select statements.

Thus, the following statement "SELECT col1 alias1 FROM any_table" fails.

AFAIK, AS is optional according to SQL Standard.
Is there a way to workaround this behaviour, as it will be not possible
for us to modify the application ?
Is there a plan to support this in future PostgreSQL releases ?

I apologize in advance if this question has already been submited, I was
not able to find some threads discussing this point.

Thanks for your help,
Best Regards,
Vincent

Ce message et toutes les pièces jointes sont établis à l'attention exclusive de leurs destinataires et sont confidentiels. Si vous recevez ce message par erreur, merci de le détruire et d'en avertir immédiatement l'expéditeur. L'internet ne permettant pas d'assurer l'intégrité de ce message, le contenu de ce message ne représente en aucun cas un engagement de la part de Adeo Services.


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: vincent(dot)moreau(at)adeoservices(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Mandatory AS keyword in SELECT statements
Date: 2008-01-04 14:31:41
Message-ID: 200801041431.m04EVfT11927@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

vincent(dot)moreau(at)adeoservices(dot)com wrote:
> Hi,
>
> We are currently trying to migrate an Oracle database to PostgreSQL.
> Unfortunately, the Java application that access the database does not
> use the AS keyword to alias column names in select statements.
>
> Thus, the following statement "SELECT col1 alias1 FROM any_table" fails.
>
> AFAIK, AS is optional according to SQL Standard.
> Is there a way to workaround this behaviour, as it will be not possible
> for us to modify the application ?
> Is there a plan to support this in future PostgreSQL releases ?
>
> I apologize in advance if this question has already been submited, I was
> not able to find some threads discussing this point.

Unfortunately, this is on our TODO list as something we are not planning
to do:

* Allow AS in "SELECT col AS label" to be optional (not wanted)

Because we support postfix operators, it isn't possible to make AS
optional and continue to use bison.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://postgres.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: vincent(dot)moreau(at)adeoservices(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: Mandatory AS keyword in SELECT statements
Date: 2008-01-04 15:52:22
Message-ID: 20080104155222.GA9833@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Fri, Jan 04, 2008 at 09:31:41AM -0500, Bruce Momjian wrote:
> Unfortunately, this is on our TODO list as something we are not planning
> to do:
>
> * Allow AS in "SELECT col AS label" to be optional (not wanted)
>
> Because we support postfix operators, it isn't possible to make AS
> optional and continue to use bison.

For reference, the problematic examples are:

SELECT a + b; -- Is this (a +) aliased to "b", or (a+b) with no alias
SELECT 'foo'::character varying -- Is "varying" an alias or part of the type name?

See this thread:
http://archives.postgresql.org/pgsql-hackers/2003-04/msg00436.php

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Those who make peaceful revolution impossible will make violent revolution inevitable.
> -- John F Kennedy


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: vincent(dot)moreau(at)adeoservices(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: Mandatory AS keyword in SELECT statements
Date: 2008-01-04 15:58:40
Message-ID: 200801041558.m04Fwei11568@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Martijn van Oosterhout wrote:
-- Start of PGP signed section.
> On Fri, Jan 04, 2008 at 09:31:41AM -0500, Bruce Momjian wrote:
> > Unfortunately, this is on our TODO list as something we are not planning
> > to do:
> >
> > * Allow AS in "SELECT col AS label" to be optional (not wanted)
> >
> > Because we support postfix operators, it isn't possible to make AS
> > optional and continue to use bison.
>
> For reference, the problematic examples are:
>
> SELECT a + b; -- Is this (a +) aliased to "b", or (a+b) with no alias
> SELECT 'foo'::character varying -- Is "varying" an alias or part of the type name?
>
> See this thread:
> http://archives.postgresql.org/pgsql-hackers/2003-04/msg00436.php

Interesting. I have added that URL to the TODO list.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://postgres.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +