postgresql/src/fe_utils
Tom Lane fadff3fc94 Prevent mis-encoding of "trailing junk after numeric literal" errors.
Since commit 2549f0661, we reject an identifier immediately following
a numeric literal (without separating whitespace), because that risks
ambiguity with hex/octal/binary integers.  However, that patch used
token patterns like "{integer}{ident_start}", which is problematic
because {ident_start} matches only a single byte.  If the first
character after the integer is a multibyte character, this ends up
with flex reporting an error message that includes a partial multibyte
character.  That can cause assorted bad-encoding problems downstream,
both in the report to the client and in the postmaster log file.

To fix, use {identifier} not {ident_start} in the "junk" token
patterns, so that they will match complete multibyte characters.
This seems generally better user experience quite aside from the
encoding problem: for "123abc" the error message will now say that
the error appeared at or near "123abc" instead of "123a".

While at it, add some commentary about why these patterns exist
and how they work.

Report and patch by Karina Litskevich; review by Pavel Borisov.
Back-patch to v15 where the problem came in.

Discussion: https://postgr.es/m/CACiT8iZ_diop=0zJ7zuY3BXegJpkKK1Av-PU7xh0EDYHsa5+=g@mail.gmail.com
2024-09-05 12:42:33 -04:00
..
.gitignore Move psql's psqlscan.l into src/fe_utils. 2016-03-24 20:28:47 -04:00
archive.c Revise GUC names quoting in messages again 2024-05-17 11:44:26 +02:00
astreamer_file.c Improve file header comments for astramer code. 2024-08-07 08:49:41 -04:00
astreamer_gzip.c Fix typos and grammar in code comments and docs 2024-09-03 14:49:04 +09:00
astreamer_lz4.c Improve file header comments for astramer code. 2024-08-07 08:49:41 -04:00
astreamer_tar.c Move astreamer (except astreamer_inject) to fe_utils. 2024-08-05 11:41:57 -04:00
astreamer_zstd.c Improve file header comments for astramer code. 2024-08-07 08:49:41 -04:00
cancel.c Centralize logic for restoring errno in signal handlers. 2024-02-14 16:34:18 -06:00
conditional.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
connect_utils.c dblink/isolationtester/fe_utils: Use new cancel API 2024-03-18 19:28:58 +01:00
Makefile Move astreamer (except astreamer_inject) to fe_utils. 2024-08-05 11:41:57 -04:00
mbprint.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
meson.build Move astreamer (except astreamer_inject) to fe_utils. 2024-08-05 11:41:57 -04:00
option_utils.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
parallel_slot.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
print.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
psqlscan.l Prevent mis-encoding of "trailing junk after numeric literal" errors. 2024-09-05 12:42:33 -04:00
query_utils.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
recovery_gen.c Fix an assortment of typos 2024-05-04 02:33:25 +12:00
simple_list.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
string_utils.c Update copyright for 2024 2024-01-03 20:49:05 -05:00