Re: hashing bpchar for nondeterministic collations is broken

Richard Guo <guofenglinux@gmail.com>

From: Richard Guo <guofenglinux@gmail.com>
To: Jeff Davis <pgsql@j-davis.com>
Cc: pgsql-bugs@postgresql.org
Date: 2022-12-02T02:30:31Z
Lists: pgsql-bugs
On Fri, Dec 2, 2022 at 4:11 AM Jeff Davis <pgsql@j-davis.com> wrote:

> 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)


Good catch.  This really shouldn't happen for bpchar as the trailing
blanks are supposed to be ignored.  I can see hashbpchar is doing it
with the correct "true" length, so maybe this is a copy-and-pasteo from
hashtextextended?


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


I'm not familiar with the backporting policy, but I also think we need
to as this fixes an obvious oversight.

Thanks
Richard

Commits

  1. Fix broken hash function hashbpcharextended().