| From: | "Tristan Partin" <tristan(at)partin(dot)io> |
|---|---|
| To: | "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org> |
| Cc: | <malis(at)pgrust(dot)com> |
| Subject: | Fix hashchar() and hashcharextended() to not depend on char signedness |
| Date: | 2026-07-30 06:51:32 |
| Message-ID: | DKBPGEV4AVNC.BRP938ZSVC2L@partin.io |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
In bug #19587[0], the user reported that hashchar() and
hashcharextended() were not producing the same results for the same
input because of sign extension depending on the platform.
Attached are three patches:
1. A series of tests to exercise the issue in a new TAP test and
a regression test for the default path of
`default_char_signedness = true`. The TAP test will show a failure.
2. A fix for the functions to ensure they produce the same results
regardless of platform.
3. A consistency fix for charhashfast() such that it always produces the
same value regardless of platform. This patch is kind of unimportant
because the value is never persisted or sent to another process. I'll
leave it up to the committer to pull the patch in or not.
I am not sure that this can be backpatched before 19. I think it will
cause queries to produce different values. Definitely good to fix before
19 is final though.
[0]: https://www.postgresql.org/message-id/19587-4416a590531c9c73%40postgresql.org
--
Tristan Partin
PostgreSQL Contributors Team
AWS (https://aws.amazon.com)
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Add-tests.patch | text/plain | 6.0 KB |
| v1-0002-Fix-hashchar-and-hashcharextended-to-not-depend-o.patch | text/plain | 3.3 KB |
| v1-0003-Make-charhashfast-return-a-consistent-value-regar.patch | text/plain | 1.6 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jakub Wartak | 2026-07-30 06:59:56 | Re: COPY TO BLACKHOLE / pg_dump -j -Fb |
| Previous Message | Jakub Wartak | 2026-07-30 06:46:27 | Re: log_postmaster_stats |