Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fdDqc-0000VY-Oc for pgsql-bugs@arkaria.postgresql.org; Wed, 11 Jul 2018 12:03:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fdDqa-0002Qj-P1 for pgsql-bugs@arkaria.postgresql.org; Wed, 11 Jul 2018 12:03:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fdDqa-0002Qc-Iz for pgsql-bugs@lists.postgresql.org; Wed, 11 Jul 2018 12:03:52 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fdDqS-0003pb-Ln for pgsql-bugs@lists.postgresql.org; Wed, 11 Jul 2018 12:03:52 +0000 Received: from [192.168.127.1] (port=45375 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1fdDqQ-000Hjk-6H; Wed, 11 Jul 2018 12:03:42 +0000 Received: from [127.0.0.1] (port=63543 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1fdDqP-000MPX-HZ; Wed, 11 Jul 2018 12:03:41 +0000 From: Andrew Gierth To: Tom Lane Cc: ladayaroslav@yandex.ru, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15273: Lexer bug with UESCAPE In-Reply-To: <23850.1531252251@sss.pgh.pa.us> (Tom Lane's message of "Tue, 10 Jul 2018 15:50:51 -0400") Message-ID: <87bmbekq90.fsf@news-spur.riddles.org.uk> References: <153124291307.1408.15617588871690313363@wrigleys.postgresql.org> <23850.1531252251@sss.pgh.pa.us> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Wed, 11 Jul 2018 13:03:41 +0100 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "Tom" == Tom Lane writes: Tom> Also, I'm going to push back on the claim that allowing comments Tom> there is required by the SQL spec. The relevant rules in SQL:2011 Tom> are Tom> ::= Tom> [ ] Tom> U [ ... ] Tom> [ { [ ... ] }... ] Tom> Tom> ::= Tom> [ UESCAPE ] Tom> I do not see any principled way of arguing that these rules Tom> require comments to be allowed adjacent to UESCAPE without also Tom> claiming that they must be allowed between, say, the initial 'U' Tom> and the ampersand. These are the rules that (as far as I can see) apply to that case: 5.2 and ::= { | }... 7) Any may be followed by a . 5.3 11) In a , there shall be no between the "U" and the nor between the and the . Tom> The only place these rules allow a is between segments Tom> of a multiline literal. It looks to me like an extension that we Tom> even allow whitespace around UESCAPE. I think that that use of is only to indicate that a there is _required_, rather than optional as it usually is after tokens, and that the special rule about requiring newlines also applies only to that specific use of . If the whole is regarded as being a single token, and therefore rule 5.2.7 above didn't apply around the UESCAPE, then there would be no reason to write rule 5.3.11 forbidding separators within the U&' part. (In the case of X'...', there's rule 5.2.5, which as I see it would prevent a space after the X, but that rule explicitly does not apply to the U& cases.) As a related issue, we don't allow comments within the that splits a multiline literal, even though the spec certainly allows those (arguably, since the spec defines that comments are equivalent to newlines, "select 'foo' /**/ 'bar';" should be legal too). I've put up a summary of all these at https://wiki.postgresql.org/wiki/PostgreSQL_vs_SQL_Standard#Lexing_of_string_literals_and_comments (under the assumption that the whole issue is filed under WONTFIX at least for the time being) -- Andrew (irc:RhodiumToad)