postgresql/src/fe_utils
Tom Lane f37ac613a8 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 Improve frontend error logging style. 2022-04-08 14:55:14 -04:00
cancel.c Avoid calling gettext() in signal handlers. 2022-01-17 13:30:04 -05:00
conditional.c Allow pgbench to retry in some cases. 2022-03-23 19:05:45 +09:00
connect_utils.c Improve frontend error logging style. 2022-04-08 14:55:14 -04:00
Makefile Update copyright for 2022 2022-01-07 19:04:57 -05:00
mbprint.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
option_utils.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
parallel_slot.c Don't spuriously report FD_SETSIZE exhaustion on Windows. 2023-10-14 15:54:49 -07:00
print.c Remove extraneous blank lines before block-closing braces 2022-04-13 19:16:02 +02:00
psqlscan.l Prevent mis-encoding of "trailing junk after numeric literal" errors. 2024-09-05 12:42:33 -04:00
query_utils.c Improve frontend error logging style. 2022-04-08 14:55:14 -04:00
recovery_gen.c Improve frontend error logging style. 2022-04-08 14:55:14 -04:00
simple_list.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
string_utils.c Fix minor memory leaks in psql's tab completion. 2022-07-22 10:53:26 -04:00