Re: hashing bpchar for nondeterministic collations is broken

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: hashing bpchar for nondeterministic collations is broken
Date: 2022-12-02 02:30:31
Message-ID: CAMbWs48dYCWaMaPxFCC4hDTf5ZOFX1xcDdAs4kuPq1b7CCTDAA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Dec 2, 2022 at 4:11 AM Jeff Davis <pgsql(at)j-davis(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2022-12-02 02:41:30 Re: INFORMATION_SCHEMA.routines column routine_definition does not show the source
Previous Message Tom Lane 2022-12-02 01:28:39 Re: INFORMATION_SCHEMA.routines column routine_definition does not show the source