From: | Pantelis Theodosiou <ypercube(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | andreas(dot)imboden(at)bl(dot)ch, pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #14394: No error raised in IN-clause when commas are missing |
Date: | 2016-10-24 16:41:47 |
Message-ID: | CAE3TBxwwSUxVtAFFOcU2hhYhk_HzUhXAQcvApr2iBydo37TJ+w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Mon, Oct 24, 2016 at 3:46 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> andreas(dot)imboden(at)bl(dot)ch writes:
> > -- no comma after 'two', no error message, incorrect result
> > select sum(cvalue) from abug
> > where cname in (
> > 'one',
> > 'two'
> > 'three',
> > 'four',
> > 'five');
>
> This is not a bug, it's required by the SQL standard's syntax for
> string literals. Per the manual:
>
> Two string constants that are only separated by whitespace *with
> at least one newline* are concatenated and effectively treated as
> if the string had been written as one constant.
>
> https://www.postgresql.org/docs/9.6/static/sql-syntax-
> lexical.html#SQL-SYNTAX-CONSTANTS
>
> regards, tom lane
>
I agree but shouldn't it run without errors when there is no newline (only
spaces or comments) as well?
Which version of the standard has this "at least one newline"?
x=# select version();
version
----------------------------------------------------------------------------------------------------------
PostgreSQL 9.6.0 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu
5.3.1-14ubuntu2) 5.3.1 20160413, 64-bit
(1 row)
x=# select 'two' -- comment
x-# 'x' as a ;
a
------
twox
(1 row)
x=# select 'two' /* comment */ 'x' as a ;
ERROR: syntax error at or near "'x'"
LINE 1: select 'two' /* comment */ 'x' as a ;
^
x=# select 'two' 'x' as a ;
ERROR: syntax error at or near "'x'"
LINE 1: select 'two' 'x' as a ;
^
x=#
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2016-10-24 16:59:28 | Re: BUG #14394: No error raised in IN-clause when commas are missing |
Previous Message | Erik Rijkers | 2016-10-24 14:48:49 | Re: BUG #14394: No error raised in IN-clause when commas are missing |