Re: bug: evil autoConcat when each string is on new line - Mailing list pgsql-bugs

From Francisco Olarte
Subject Re: bug: evil autoConcat when each string is on new line
Date
Msg-id CA+bJJbzB0TJoytzqnKHzUbco23cnwxPfjNv_wSnK2XhodXnoGw@mail.gmail.com
Whole thread Raw
In response to Re: bug: evil autoConcat when each string is on new line  (raf@raf.org)
Responses Re: bug: evil autoConcat when each string is on new line  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-bugs
On Thu, Apr 25, 2019 at 1:13 AM <raf@raf.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.



pgsql-bugs by date:

Previous
From: Paul Mansueto Namuag
Date:
Subject: Re: CREATE SUBSCRIPTION fails with long passwords
Next
From: Pavel Stehule
Date:
Subject: Re: bug: evil autoConcat when each string is on new line