hashing bpchar for nondeterministic collations is broken

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: hashing bpchar for nondeterministic collations is broken
Date: 2022-12-01 20:11:29
Message-ID: eb83d0ac7b299eb08f9b900dd08a5a0c5d90e517.camel@j-davis.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

CREATE COLLATION ctest_nondet(
provider = icu, locale = '', deterministic = false);

=# select hashbpcharextended('a' collate ctest_nondet, 3);
hashbpcharextended
---------------------
2792701603979490504
(1 row)

=# select hashbpcharextended('a ' collate ctest_nondet, 3);
hashbpcharextended
----------------------
-4885217598372536483
(1 row)

I don't see any major consequences, because in both hash indexes and
partitioning it appears that the trailing spaces on the key are already
gone before hashbpcharextended is called. If someone does see bigger
consequences here, please let me know.

Seems to be an oversight. Patch attached.

Also, does someone have an opinion on backporting this? I'm inclined
to.

--
Jeff Davis
PostgreSQL Contributor Team - AWS

Attachment Content-Type Size
v1-0001-Fix-broken-hash-function-hashbpcharextended.patch text/x-patch 1.0 KB

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2022-12-01 20:43:14 Re: Bug in jsonb_path_exists (maybe _match) one-element scalar/variable jsonpath handling
Previous Message Tom Lane 2022-12-01 15:37:05 Re: pg_catalog.pg_get_viewdef pretty-print removes important parentheses