hashing bpchar for nondeterministic collations is broken

Jeff Davis <pgsql@j-davis.com>

From: Jeff Davis <pgsql@j-davis.com>
To: pgsql-bugs@postgresql.org
Date: 2022-12-01T20:11:29Z
Lists: pgsql-bugs

Attachments

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


Commits

  1. Fix broken hash function hashbpcharextended().