Fix for fragile code in hashtext()

Started by Jeff Davis3 months ago3 messageshackers
Jump to latest
#1Jeff Davis
pgsql@j-davis.com

This is in the ICU-only non-deterministic collation path, so I don't
believe there's an actual bug or results change here. But for libc, it
would have been incorrect.

Regards,
Jeff Davis

Attachments:

t253475_1
v1-0001-hashtext-fix-fragile-code.patchtext/x-patch; charset=UTF-8; name=v1-0001-hashtext-fix-fragile-code.patchDownload+18-8
#2Haibo Yan
tristan.yim@gmail.com
In reply to: Jeff Davis (#1)
Re: Fix for fragile code in hashtext()

On Tue, Aug 18, 2026 at 2:45 PM Jeff Davis <pgsql@j-davis.com> wrote:

This is in the ICU-only non-deterministic collation path, so I don't
believe there's an actual bug or results change here. But for libc, it
would have been incorrect.

Regards,
Jeff Davis

The fix looks right to me.

Perhaps the pg_strnxfrm() comment could state more explicitly that the
first call
is only for buffer sizing, while the return value from the actual
transformation is
the authoritative result length. That seems to be the assumption that was
missed
here.

I don’t think a regression test is necessary unless there’s a simple way to
exercise
rsize < bsize; an ICU test would pass both before and after this patch.

Regards,
Haibo

#3Jeff Davis
pgsql@j-davis.com
In reply to: Haibo Yan (#2)
Re: Fix for fragile code in hashtext()

On Wed, 2026-08-19 at 01:14 -0700, Haibo Yan wrote:

Perhaps the pg_strnxfrm() comment could state more explicitly that
the first call 
is only for buffer sizing, while the return value from the actual
transformation is 
the authoritative result length. That seems to be the assumption that
was missed 
here.

Done, and committed. Thank you!

Regards,
Jeff Davis