From: Jeff Davis <jdavis@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: hashtext: fix fragile code.
Date: Thu, 20 Aug 2026 21:07:06 +0000
Message-ID: <E1wx9yb-00000001PT8-1Osu@gemulon.postgresql.org> (raw)
hashtext: fix fragile code.
Previously, in the path for non-deterministic collations, the code
assumed that bsize==rsize. That assumption seems to be true for ICU,
and all non-deterministic collations are ICU, so it's not known to be
an actual bug.
The only known place where bsize may not equal rsize is in the libc
provider, where strxfrm() can return an upper bound of the size needed
to store the result. That means the initial call to determine the
buffer size (with dest==NULL, n==0) could return a larger number than
the actual call with an adequate dest buffer. That's OK, because libc
locales are always deterministic.
Commit 679c5084cf2 partially fixed the assumption, but missed this
part. Fix it, and add a more prominent documentation note.
Reviewed-by: Haibo Yan <tristan.yim@gmail.com>
Discussion: https://postgr.es/m/CABXr29Hb31nkj1g2Jmk+1BhAm=3ecGs_pWy4tU++j8CQBnbMxQ@mail.gmail.com
Backpatch-through: 16
Branch
------
REL_16_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/f61d6b0e1329841ef8bb0a337ac95700885fe772
Modified Files
--------------
src/backend/access/hash/hashfunc.c | 4 ++--
src/backend/utils/adt/pg_locale.c | 24 +++++++++++++++++++++---
src/backend/utils/adt/varchar.c | 4 ++--
3 files changed, 25 insertions(+), 7 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: jdavis@postgresql.org, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: hashtext: fix fragile code.
In-Reply-To: <E1wx9yb-00000001PT8-1Osu@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox