Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hJR5J-0007cZ-1z for pgsql-bugs@arkaria.postgresql.org; Wed, 24 Apr 2019 23:13:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hJR5H-0000zJ-P4 for pgsql-bugs@arkaria.postgresql.org; Wed, 24 Apr 2019 23:13:47 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hJR4t-0004SW-7v for pgsql-bugs@lists.postgresql.org; Wed, 24 Apr 2019 23:13:23 +0000 Received: from ook.raf.org ([139.99.156.21]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hJR4l-0000xT-Tt for pgsql-bugs@lists.postgresql.org; Wed, 24 Apr 2019 23:13:21 +0000 Received: from localhost (localhost [127.0.0.1]) by ook.raf.org (Postfix) with ESMTP id 309BC5E326 for ; Thu, 25 Apr 2019 09:13:09 +1000 (AEST) X-Virus-Scanned: Debian amavisd-new at ook.raf.org Received: from ook.raf.org ([127.0.0.1]) by localhost (ook.raf.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rbbk4QTvHy_K for ; Thu, 25 Apr 2019 09:13:08 +1000 (AEST) Received: by ook.raf.org (Postfix, from userid 1001) id B2E095E34C; Thu, 25 Apr 2019 09:13:08 +1000 (AEST) Date: Thu, 25 Apr 2019 09:13:08 +1000 From: raf@raf.org To: pgsql-bugs@lists.postgresql.org Subject: Re: bug: evil autoConcat when each string is on new line Message-ID: <20190424231308.epmyxnyym2jjy24m@raf.org> References: <20190424124459.GA26812@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190424124459.GA26812@alvherre.pgsql> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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