Re: BUG #14394: No error raised in IN-clause when commas are missing

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: andreas(dot)imboden(at)bl(dot)ch
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #14394: No error raised in IN-clause when commas are missing
Date: 2016-10-24 14:46:31
Message-ID: 15138.1477320391@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2016-10-24 14:47:37 Re: BUG #14394: No error raised in IN-clause when commas are missing
Previous Message hubert depesz lubaczewski 2016-10-24 14:44:21 Re: BUG #14394: No error raised in IN-clause when commas are missing