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

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Pantelis Theodosiou <ypercube(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, andreas(dot)imboden(at)bl(dot)ch, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14394: No error raised in IN-clause when commas are missing
Date: 2016-10-24 17:42:22
Message-ID: CAKFQuwas7TB+NrZEbom8x4LUNP5Ymhqo5LjGs2Eg98a3kvHOSA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, Oct 24, 2016 at 10:14 AM, Pantelis Theodosiou <ypercube(at)gmail(dot)com>
wrote:

>
>
> On Mon, Oct 24, 2016 at 5:59 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
>> Pantelis Theodosiou <ypercube(at)gmail(dot)com> writes:
>> > On Mon, Oct 24, 2016 at 3:46 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> >> 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.
>>
>> > I agree but shouldn't it run without errors when there is no newline
>> (only
>> > spaces or comments) as well?
>>
>> No, because then the syntax rule that causes the literals to be merged
>> into a single literal doesn't apply, so you get a syntax error.
>>
>> > Which version of the standard has this "at least one newline"?
>>
>> All of them. SQL92 for instance says (see 5.2 <token> and <separator>
>> and 5.3 <literal>):
>>
>> <separator> ::= { <comment> | <space> | <newline> }...
>
>
>> <character string literal> ::=
>> [ <introducer><character set specification> ]
>> <quote> [ <character representation>... ] <quote>
>> [ { <separator>... <quote> [ <character
>> representation>... ] <quote> }... ]
>>
>> 1) In a <character string literal> or <national character string
>> literal>, the sequence:
>>
>> <quote> <character representation>... <quote>
>> <separator>... <quote> <character representation>... <quote>
>>
>> is equivalent to the sequence
>>
>> <quote> <character representation>... <character representa-
>> tion>... <quote>
>>
>> 4) In a <character string literal>, <national character string
>> literal>, <bit string literal>, or <hex string literal>, a
>> <sep-
>> arator> shall contain a <newline>.
>>
>
> Thank you, I missed that rule.
>

​To restate part of the above: <separator> can be a single newline;
otherwise any multi-character​ sequence must contain (end with?) a new
line. <'pre' /* comment */ 'post'> doesn't qualify for #1 since the
comment does not include a newline.

> It's not consistent with this rule:
>
> SQL text containing one or more instances of <comment> is equivalent to
> the same SQL text with the
> <comment> replaced with <newline>.
>

​​Our docs state we (effectively...) replace comments with a single
space...is this (or can it cause) an incompatibility?

https://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-COMMENTS

David J.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2016-10-24 19:09:13 Re: BUG #14394: No error raised in IN-clause when commas are missing
Previous Message Pantelis Theodosiou 2016-10-24 17:14:45 Re: BUG #14394: No error raised in IN-clause when commas are missing