pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: raf@raf.org
To: pgsql-bugs@lists.postgresql.org
Subject: Re: bug: evil autoConcat when each string is on new line
Date: Thu, 25 Apr 2019 09:13:08 +1000
Message-ID: <20190424231308.epmyxnyym2jjy24m@raf.org> (raw)
In-Reply-To: <20190424124459.GA26812@alvherre.pgsql>
References: <CAGYHQk6OkeFg1f=7LqtsMRpacJL0Y0y=yeM28dRMG5FKtvSf_g@mail.gmail.com>
	<20190424124459.GA26812@alvherre.pgsql>

Alvaro Herrera wrote:

> On 2019-Apr-24, Jan Skydánek wrote:
> 
> > Works (definitely NOT expected):
> > SELECT
> > 'aaa'
> > 'bbb'
> > 'ccc'
> > ; -- result is: 'aaabbbccc'
> > 
> > I really hope this behavior is not intentional.
> 
> Actually it's the SQL standard that defines that it must work in exactly
> that way.
> 
> -- 
> Álvaro Herrera                https://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Perhaps what Jan meant to do was:

  select
  'aaa',
  'bbb',
  'ccc'
  ;

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.

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

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

cheers,
raf






view thread (8+ messages)  latest in thread

Message-ID: <20190424231308.epmyxnyym2jjy24m@raf.org>
Permalink:  ../20190424231308.epmyxnyym2jjy24m@raf.org/
Also on:    postgresql.org/message-id/20190424231308.epmyxnyym2jjy24m@raf.org

 · 

reply

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: raf@raf.org
  Subject: Re: bug: evil autoConcat when each string is on new line
  In-Reply-To: <20190424231308.epmyxnyym2jjy24m@raf.org>
  References: <CAGYHQk6OkeFg1f=7LqtsMRpacJL0Y0y=yeM28dRMG5FKtvSf_g@mail.gmail.com> <20190424124459.GA26812@alvherre.pgsql> <20190424231308.epmyxnyym2jjy24m@raf.org>

* 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