Re: BUG #13273: A query that returns wrongly labeled result instead of syntax error

From: Václav Brodec <v-brody(at)seznam(dot)cz>
To: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
Cc: PostgreSQL Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #13273: A query that returns wrongly labeled result instead of syntax error
Date: 2015-05-12 08:19:39
Message-ID: 5551B79B.9080005@seznam.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Thomas Munro writes:
> On Tue, May 12, 2015 at 10:46 AM, <v-brody(at)seznam(dot)cz> wrote:
>> The following bug has been logged on the website:
>>
>> Bug reference: 13273
>> Logged by: Missing comma in SELECT list results in wrong label without error
>> Email address: v-brody(at)seznam(dot)cz
>> PostgreSQL version: 9.4.1
>> Operating system: CentOS Linux
>> Description:
>>
>> Following query (notice the missing comma between top-level "x" and "y")
>> returns 1 (which is "x" value) under label "y" without any warning.
>>
>> select
>> "x" "y"
>> from
>> (
>> select
>> "a" as "x", "b" as "y"
>> from
>> (
>> select 1 as "a", 2 as "b"
>> ) "subquery1"
>> ) "subquery2";
>>
>> Expected behavior: syntax error
>
> That is valid syntax, the AS keyword is optional (in PostgreSQL as
> well as in standard SQL):
>
> http://www.postgresql.org/docs/9.4/static/sql-select.html
>
> postgres=# select 42 as y;
> y
> ----
> 42
> (1 row)
>
> postgres=# select 42 y;
> y
> ----
> 42
> (1 row)
>

I'm really sorry, I realized that immediately after submitting.

Although I think that demanding explicit AS in this case (when
overshadowing some name) might be useful. :-)

Thank you for your time,

Václav Brodec

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Berend De Schouwer 2015-05-12 11:22:09 Re: BUG #13267: Some timezones in pg_timezone_names are missing in pg_timezone_abbrevs
Previous Message Thomas Munro 2015-05-12 04:17:17 Re: BUG #13273: A query that returns wrongly labeled result instead of syntax error