Re: Add hint for function named "is" - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Add hint for function named "is"
Date
Msg-id 27011.1470952496@sss.pgh.pa.us
Whole thread Raw
In response to Re: Add hint for function named "is"  ("David E. Wheeler" <david@justatheory.com>)
Responses Re: Add hint for function named "is"  (Jim Nasby <Jim.Nasby@BlueTreble.com>)
Re: Add hint for function named "is"  (Greg Stark <stark@mit.edu>)
List pgsql-hackers
"David E. Wheeler" <david@justatheory.com> writes:
> On Aug 11, 2016, at 2:11 PM, Jim Nasby <Jim.Nasby@BlueTreble.com> wrote:
>> SELECT 'x'||is();
>> ERROR:  syntax error at or near "("

> Why does it need quotation marks in this case?

It doesn't, if you do something like

regression=# select is();
ERROR:  function is() does not exist
LINE 1: select is();              ^

which probably contributes to Jim's confusion.  I think what is happening
in the trouble case is that since IS has lower precedence than Op, the
grammar decides it ought to resolve || as a postfix operator, and then
it effectively has('x' ||) IS ...
which leaves noplace to go except IS NULL and other IS-something syntaxes.
You'd likely have similar problems with any other keyword that has lower
precedence than Op; but a large fraction of those are fully-reserved words
and so no one would have had any expectation of being able to leave them
unquoted anyway.

I'm not sure there's much we can do about this.  Even if we had control of
what Bison prints for syntax errors, which we don't really, it's hard to
see what condition we could trigger the hint on that wouldn't result in
false positives at least as often as something helpful.  (Note that the
grammar's behavior can't really depend on whether a function named is()
actually exists in the catalogs.)
        regards, tom lane



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: condition variables
Next
From: Tom Lane
Date:
Subject: Re: condition variables