pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Václav Brodec <v-brody@seznam.cz>
To: Thomas Munro <thomas.munro@enterprisedb.com>
Cc: PostgreSQL Bugs <pgsql-bugs@postgresql.org>
Subject: Re: BUG #13273: A query that returns wrongly labeled result instead of syntax error
Date: Tue, 12 May 2015 10:19:39 +0200
Message-ID: <5551B79B.9080005@seznam.cz> (raw)
In-Reply-To: <CAEepm=1qfYkwg2wUz3wV7Bx+qkfZbd--7-LYyVduEUvZ_mQ7sQ@mail.gmail.com>
References: <20150511224630.2714.40796@wrigleys.postgresql.org>
	<CAEepm=1qfYkwg2wUz3wV7Bx+qkfZbd--7-LYyVduEUvZ_mQ7sQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Thomas Munro writes:
> On Tue, May 12, 2015 at 10:46 AM,  <v-brody@seznam.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@seznam.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


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (3+ messages)

Message-ID: <5551B79B.9080005@seznam.cz>
Permalink:  ../5551B79B.9080005@seznam.cz/
Also on:    postgresql.org/message-id/5551B79B.9080005@seznam.cz

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: v-brody@seznam.cz, thomas.munro@enterprisedb.com
  Subject: Re: BUG #13273: A query that returns wrongly labeled result instead of syntax error
  In-Reply-To: <5551B79B.9080005@seznam.cz>
  References: <20150511224630.2714.40796@wrigleys.postgresql.org> <CAEepm=1qfYkwg2wUz3wV7Bx+qkfZbd--7-LYyVduEUvZ_mQ7sQ@mail.gmail.com> <5551B79B.9080005@seznam.cz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox