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

From raf@raf.org
Subject Re: bug: evil autoConcat when each string is on new line
Date
Msg-id 20190424231308.epmyxnyym2jjy24m@raf.org
Whole thread Raw
In response to Re: bug: evil autoConcat when each string is on new line  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Responses Re: bug: evil autoConcat when each string is on new line  (Francisco Olarte <folarte@peoplecall.com>)
List pgsql-bugs
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




pgsql-bugs by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: CREATE SUBSCRIPTION fails with long passwords
Next
From: Tom Lane
Date:
Subject: Re: BUG #15672: PostgreSQL 11.1/11.2 crashed after dropping a partition table