pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: SQL-spec incompatibilities in similar_escape() and related stuff
Date: Mon, 13 May 2019 19:39:14 +0100
Message-ID: <87d0kmfbpq.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <4486.1557769997@sss.pgh.pa.us>
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>

>>>>> "Tom" == Tom Lane <tgl@sss.pgh.pa.us> 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)





view thread (16+ messages)  latest in thread

Message-ID: <87d0kmfbpq.fsf@news-spur.riddles.org.uk>
Permalink:  ../87d0kmfbpq.fsf@news-spur.riddles.org.uk/
Also on:    postgresql.org/message-id/87d0kmfbpq.fsf@news-spur.riddles.org.uk

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: andrew@tao11.riddles.org.uk, tgl@sss.pgh.pa.us, pgsql-hackers@lists.postgresql.org
  Subject: Re: SQL-spec incompatibilities in similar_escape() and related stuff
  In-Reply-To: <87d0kmfbpq.fsf@news-spur.riddles.org.uk>

* 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