On Mon, Oct 24, 2016 at 3:46 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> andreas.imboden@bl.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=#