Re: SQL-spec incompatibilities in similar_escape() and related stuff - Mailing list pgsql-hackers

From Andrew Gierth
Subject Re: SQL-spec incompatibilities in similar_escape() and related stuff
Date
Msg-id 87d0kmfbpq.fsf@news-spur.riddles.org.uk
Whole thread Raw
In response to Re: SQL-spec incompatibilities in similar_escape() and related stuff  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: SQL-spec incompatibilities in similar_escape() and related stuff  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
>>>>> "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)



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: PANIC :Call AbortTransaction when transaction id is no normal
Next
From: Peter Geoghegan
Date:
Subject: Re: What is an item pointer, anyway?