From: Tom Lane <tgl@sss.pgh.pa.us>
To: Pantelis Theodosiou <ypercube@gmail.com>
Cc: andreas.imboden@bl.ch
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14394: No error raised in IN-clause when commas are missing
Date: Mon, 24 Oct 2016 12:59:28 -0400
Message-ID: <28326.1477328368@sss.pgh.pa.us> (raw)
In-Reply-To: <CAE3TBxwwSUxVtAFFOcU2hhYhk_HzUhXAQcvApr2iBydo37TJ+w@mail.gmail.com>
References: <20161024142841.1423.19672@wrigleys.postgresql.org>
<15138.1477320391@sss.pgh.pa.us>
<CAE3TBxwwSUxVtAFFOcU2hhYhk_HzUhXAQcvApr2iBydo37TJ+w@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Pantelis Theodosiou <ypercube@gmail.com> writes:
> On Mon, Oct 24, 2016 at 3:46 PM, Tom Lane <tgl@sss.pgh.pa.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>.
The intent of allowing separators at all is evidently to allow very long
literals to be split across lines. Which is fine, but I wish they'd
used some explicit syntax to specify continuation. The existing
definition is pretty error-prone, as you found out.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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: tgl@sss.pgh.pa.us, ypercube@gmail.com, andreas.imboden@bl.ch
Subject: Re: BUG #14394: No error raised in IN-clause when commas are missing
In-Reply-To: <28326.1477328368@sss.pgh.pa.us>
References: <20161024142841.1423.19672@wrigleys.postgresql.org> <15138.1477320391@sss.pgh.pa.us> <CAE3TBxwwSUxVtAFFOcU2hhYhk_HzUhXAQcvApr2iBydo37TJ+w@mail.gmail.com> <28326.1477328368@sss.pgh.pa.us>
* 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