| From: | Álvaro Herrera <alvherre(at)kurilemu(dot)de> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix calculating length of match to localized month/weekday names |
| Date: | 2026-08-05 13:58:52 |
| Message-ID: | E1wrc8y-00000000JG3-3ZUL@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Fix calculating length of match to localized month/weekday names
seq_search_localized() returns the length of the matching prefix in
*len, but because it internally case-folds the inputs, it gets
confused on the length. The caller expects to get the length of the
prefix in the original string, but what it actually returns is the
length of the prefix after case-folding, which can be different if the
case-folded characters have different byte-length than the original,
or with ICU, if the case-folding changes the number of characters
(e.g. "ß", the German double s).
To fix, once we have determined that we have a match, work harder to
find the match's length in the original string. This adds some
overhead, but the strings are expected to be short.
The function does "case-folding" by converting a string to upper-case,
then to lower-case, which is a little ugly given that we have
dedicated functions for case-folding nowadays. But switching to that
doesn't seem appropriate to backpatch in a security fix, and that's
not available in older stable versions, anyway.
Author: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
Reported-by: Xint Code
Reviewed-by: Jeff Davis <pgsql(at)j-davis(dot)com>
Branch
------
REL_15_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/0de744cd5281021c96ce7366efae2b17321909f8
Modified Files
--------------
src/backend/utils/adt/formatting.c | 137 +++++++++++++++++++----
src/test/regress/expected/collate.linux.utf8.out | 18 +++
src/test/regress/sql/collate.linux.utf8.sql | 3 +
3 files changed, 138 insertions(+), 20 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Melanie Plageman | 2026-08-05 15:44:52 | pgsql: Make local buffers pin limit more conservative |
| Previous Message | Peter Eisentraut | 2026-08-05 08:57:43 | pgsql: Disallow aggregates, window functions, and SRFs in GRAPH_TABLE C |