| From: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> | 
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> | 
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org | 
| Subject: | Re: SQL-spec incompatibilities in similar_escape() and related stuff | 
| Date: | 2019-05-13 18:39:14 | 
| Message-ID: | 87d0kmfbpq.fsf@news-spur.riddles.org.uk | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
>>>>> "Tom" == Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Geoghegan | 2019-05-13 18:50:26 | Re: What is an item pointer, anyway? | 
| Previous Message | Tom Lane | 2019-05-13 18:15:10 | Re: PANIC :Call AbortTransaction when transaction id is no normal |