postgresql/src/fe_utils
Tom Lane 4fd4d7653e 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 Revert refactoring of restore command code to shell_restore.c 2023-02-06 08:28:42 +09:00
cancel.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
conditional.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
connect_utils.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
Makefile Update copyright for 2023 2023-01-02 15:00:37 -05:00
mbprint.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
meson.build Update copyright for 2023 2023-01-02 15:00:37 -05:00
option_utils.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
parallel_slot.c Don't spuriously report FD_SETSIZE exhaustion on Windows. 2023-10-14 15:54:49 -07:00
print.c Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04: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 2023 2023-01-02 15:00:37 -05:00
recovery_gen.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
simple_list.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
string_utils.c Update copyright for 2023 2023-01-02 15:00:37 -05:00