>>>>> "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)