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 1hQFrA-0007C6-HE for pgsql-hackers@arkaria.postgresql.org; Mon, 13 May 2019 18:39:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hQFr7-0005NX-CB for pgsql-hackers@arkaria.postgresql.org; Mon, 13 May 2019 18:39:21 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1hQFr7-0005NQ-3Q for pgsql-hackers@lists.postgresql.org; Mon, 13 May 2019 18:39:21 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hQFr3-0000DR-F2 for pgsql-hackers@lists.postgresql.org; Mon, 13 May 2019 18:39:20 +0000 Received: from [192.168.127.1] (port=64537 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 1hQFr1-000OmE-EM; Mon, 13 May 2019 18:39:15 +0000 Received: from [127.0.0.1] (port=53929 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1hQFr0-0009fP-OI; Mon, 13 May 2019 18:39:14 +0000 From: Andrew Gierth To: Tom Lane Cc: pgsql-hackers@lists.postgresql.org Subject: Re: SQL-spec incompatibilities in similar_escape() and related stuff In-Reply-To: <4486.1557769997@sss.pgh.pa.us> (Tom Lane's message of "Mon, 13 May 2019 13:53:17 -0400") Message-ID: <87d0kmfbpq.fsf@news-spur.riddles.org.uk> References: <14047.1557708214@sss.pgh.pa.us> <8736lihni6.fsf@news-spur.riddles.org.uk> <87v9yeg69c.fsf@news-spur.riddles.org.uk> <87k1eufem8.fsf@news-spur.riddles.org.uk> <4486.1557769997@sss.pgh.pa.us> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Mon, 13 May 2019 19:39:14 +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> Hmm. Oddly, you can't fix it by adding parens: Tom> regression=# select 'foo' similar to ('f' || escape) escape escape from (values ('oo')) v(escape); Tom> psql: ERROR: syntax error at or near "escape" Tom> LINE 1: select 'foo' similar to ('f' || escape) escape escape from (... Tom> ^ Tom> Since "escape" is an unreserved word, I'd have expected that to Tom> work. Odd. Simpler cases fail too: select 'f' || escape from (values ('o')) v(escape); psql: ERROR: syntax error at or near "escape" select 1 + escape from (values (1)) v(escape); -- works select 1 & escape from (values (1)) v(escape); -- fails in short ESCAPE can't follow any generic operator, because its lower precedence forces the operator to be reduced as a postfix op instead. Tom> The big picture here is that fixing grammar ambiguities by adding Tom> precedence is a dangerous business :-( Yeah. But the alternative is usually reserving words more strictly, which has its own issues :-( Or we could kill off postfix operators... -- Andrew (irc:RhodiumToad)