Re: bug: evil autoConcat when each string is on new line

From: Francisco Olarte <folarte(at)peoplecall(dot)com>
To: raf(at)raf(dot)org
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: bug: evil autoConcat when each string is on new line
Date: 2019-04-25 08:18:05
Message-ID: CA+bJJbzB0TJoytzqnKHzUbco23cnwxPfjNv_wSnK2XhodXnoGw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Apr 25, 2019 at 1:13 AM <raf(at)raf(dot)org> wrote:

> Many languages automatically concatenate consecutive
> string literals, not just SQL. Even C does it. Probably
> because there's no other useful interpretation of what
> multiple consecutive string literals means. It's either
> concatenate them or treat it as a syntax error.
> Concatenating can be useful so it wins.

In C, IIRC, it is also useful when combined with the stringification
construct of the preprocessor ( #xxx => "xxx" ) to construct things
like long messages ( evaluated at compile time, like #define
PRINT_INT(v) printf( #v "=%d\n",(v)) ).

> Actually, I just tried that command on a single line
> and that was a syntax error. So what do I know?
> Presumably the SQL standard says to do that as well. :-)

Actually when I first saw this it made me curious and I searched for
"string constants" in the doc, the second paragraph in "4.1.2.1.
String Constants" says "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.
For example:", but I suppose reading TFM before reporting a bug is
getting too old fashioned ( and one of my top reasons for using
postgres is doc quality ).

> It does seem like an inconsistency. I wouldn't have
> expected SQL to be so whitespace-dependant but there'll
> be a good reason for it somewhere. And, again, it's not
> the only language where newlines matter. :-)

SQL std is really puzzling and irregular. My usual comment when
reading some of it is "what do these guys smoke, I want some of it".
For me is the type of language which makes for great looking examples
in the manual but when you use it is so irregular to learn and when
you implement is difficult to parse. I mean, substring( "hello" from 1
for 2) may look great, but substr("hello", 1, 2) is, for me, much
regular and easier to remember ( learning the parameters is hard
enough without having to learn the special delimiters too ). String
constant concatenation requiring at least one newline among the
whitespace is one of these things. Although it MAY have a good reason
for it.

Francisco Olarte.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Pavel Stehule 2019-04-25 09:43:01 Re: bug: evil autoConcat when each string is on new line
Previous Message Paul Mansueto Namuag 2019-04-25 06:27:14 Re: CREATE SUBSCRIPTION fails with long passwords