postgresql/src
Andrew Gierth 5ec70a9286 Fix lexing of standard multi-character operators in edge cases.
Commits c6b3c939b (which fixed the precedence of >=, <=, <> operators)
and 865f14a2d (which added support for the standard => notation for
named arguments) created a class of lexer tokens which look like
multi-character operators but which have their own token IDs distinct
from Op. However, longest-match rules meant that following any of
these tokens with another operator character, as in (1<>-1), would
cause them to be incorrectly returned as Op.

The error here isn't immediately obvious, because the parser would
usually still find the correct operator via the Op token, but there
were more subtle problems:

1. If immediately followed by a comment or +-, >= <= <> would be given
   the old precedence of Op rather than the correct new precedence;

2. If followed by a comment, != would be returned as Op rather than as
   NOT_EQUAL, causing it not to be found at all;

3. If followed by a comment or +-, the => token for named arguments
   would be lexed as Op, causing the argument to be mis-parsed as a
   simple expression, usually causing an error.

Fix by explicitly checking for the operators in the {operator} code
block in addition to all the existing special cases there.

Backpatch to 9.5 where the problem was introduced.

Analysis and patch by me; review by Tom Lane.
Discussion: https://postgr.es/m/87va851ppl.fsf@news-spur.riddles.org.uk
2018-08-23 21:35:49 +01:00
..
backend Fix lexing of standard multi-character operators in edge cases. 2018-08-23 21:35:49 +01:00
bin Fix set of NLS translation issues 2018-08-21 15:18:00 +09:00
common Adjust error message 2018-08-06 10:54:19 +02:00
fe_utils Fix lexing of standard multi-character operators in edge cases. 2018-08-23 21:35:49 +01:00
include Stamp 9.6.10. 2018-08-06 16:07:43 -04:00
interfaces Fix lexing of standard multi-character operators in edge cases. 2018-08-23 21:35:49 +01:00
makefiles Prevent accidental linking of system-supplied copies of libpq.so etc. 2018-07-09 17:23:31 -04:00
pl Translation updates 2018-08-06 19:44:29 +02:00
port Make snprintf.c follow the C99 standard for snprintf's result value. 2018-08-15 17:25:52 -04:00
template Remove some remains from Alpha support removal 2015-10-29 16:40:14 -04:00
test Fix lexing of standard multi-character operators in edge cases. 2018-08-23 21:35:49 +01:00
timezone Update time zone data files to tzdata release 2018e. 2018-05-09 13:55:48 -04:00
tools pgtest: run clean, build, and check stages separately 2018-07-28 15:34:06 -04:00
tutorial Update copyright for 2016 2016-01-02 13:33:40 -05:00
.gitignore
bcc32.mak
DEVELOPERS
Makefile Install TAP test infrastructure so it's available for extension testing. 2016-09-23 15:50:00 -04:00
Makefile.global.in Prevent accidental linking of system-supplied copies of libpq.so etc. 2018-07-09 17:23:31 -04:00
Makefile.shlib Prevent accidental linking of system-supplied copies of libpq.so etc. 2018-07-09 17:23:31 -04:00
nls-global.mk nls-global.mk: search build dir for source files, too 2016-06-07 18:55:18 -04:00
win32.mak