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

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Francisco Olarte <folarte(at)peoplecall(dot)com>
Cc: raf(at)raf(dot)org, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: bug: evil autoConcat when each string is on new line
Date: 2019-04-25 09:43:01
Message-ID: CAFj8pRBoqewXFxr0FkS-HpgZOVz57zOPpPh4KuLQSy5BNiS74Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

čt 25. 4. 2019 v 10:18 odesílatel Francisco Olarte <folarte(at)peoplecall(dot)com>
napsal:

> 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.
>

There is a impact of some older traditions. Originally SQL was a language
for ending users, it was not designed for developers.

Regards

Pavel

> Francisco Olarte.
>
>
>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Amit Langote 2019-04-25 10:02:12 Re: BUG #15672: PostgreSQL 11.1/11.2 crashed after dropping a partition table
Previous Message Francisco Olarte 2019-04-25 08:18:05 Re: bug: evil autoConcat when each string is on new line