Re: Wrong results from inner-unique joins caused by collation mismatch - Mailing list pgsql-hackers

From Richard Guo
Subject Re: Wrong results from inner-unique joins caused by collation mismatch
Date
Msg-id CAMbWs4-7zLAdSv1AfBwff9gjXpFyPqGWqfvAZioUsEjnUxEZKA@mail.gmail.com
Whole thread
In response to Re: Wrong results from inner-unique joins caused by collation mismatch  (Richard Guo <guofenglinux@gmail.com>)
List pgsql-hackers
On Sat, Apr 25, 2026 at 6:24 PM Richard Guo <guofenglinux@gmail.com> wrote:
> 0001 wrapped the logic in subroutine collations_are_compatible().

I don't think that name is good.  It sounds like a general claim about
the two collations, but what the subroutine actually checks is much
narrower: whether the two collations agree on what counts as equal.
It has nothing to say about ordering, and two deterministic collations
agree on = but can disagree on <.

I renamed it to collations_agree_on_equality(), which seems a better
name to me.  And then I committed this patch and back-patched it to
all supported branches.

> 0002 fixed query_is_distinct_for(), using that subroutine.

This patch changes the signature of query_is_distinct_for, which would
be an ABI break on stable branches.  So in back-patches I added a
local function query_is_distinct_for_with_collations, which is a
collation-aware verson of query_is_distinct_for, and retained
query_is_distinct_for as a thin wrapper that calls that new local
function.

I also committed and back-patched this patch.

- Richard



pgsql-hackers by date:

Previous
From: SATYANARAYANA NARLAPURAM
Date:
Subject: [Patch] Omit virtual generated columns from test_decoding output
Next
From: Chao Li
Date:
Subject: Re: [PATCH] Clean up property graph error messages