Re: Wrong results from inner-unique joins caused by collation mismatch
Richard Guo <guofenglinux@gmail.com>
From: Richard Guo <guofenglinux@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Pg Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-04-25T09:24:39Z
Lists: pgsql-hackers
Attachments
- v2-0001-Consider-collation-when-proving-uniqueness-from-u.patch (application/octet-stream) patch v2-0001
- v2-0002-Consider-collation-when-proving-subquery-uniquene.patch (application/octet-stream) patch v2-0002
On Sat, Apr 25, 2026 at 12:44 AM Richard Guo <guofenglinux@gmail.com> wrote: > On Fri, Apr 24, 2026 at 11:53 PM Tom Lane <tgl@sss.pgh.pa.us> wrote: > > 1. I think there are other places in the planner that will need > > substantially this same logic. I recommend breaking out a > > subroutine defined more or less as "do these collations have > > equivalent notions of equality". > Right. I just found several other places that need this same logic, > which are in query_is_distinct_for(). Without it, we produce wrong > results: 0001 wrapped the logic in subroutine collations_are_compatible(). (I'm a little unsure about the InvalidOid cases. The current implementation treats InvalidOid on either side as compatible, as absence of a collation can't conflict with the other side. This generalizes the asymmetric treatment in IndexCollMatchesExprColl().) 0002 fixed query_is_distinct_for(), using that subroutine. - Richard
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Consider collation when proving subquery uniqueness
- 172034f6e088 14.23 landed
- bab4f7fa5621 15.18 landed
- 5a24cef082a0 16.14 landed
- 13226050e85d 17.10 landed
- bed3ffbf9d95 18.4 landed
- 574581b50ac9 19 (unreleased) landed
-
Consider collation when proving uniqueness from unique indexes
- 8395446dff08 14.23 landed
- 872c9fae78bc 15.18 landed
- 748fe9e6085c 16.14 landed
- d0e73bb18017 17.10 landed
- b62f514ac533 18.4 landed
- 5a55ea507a2d 19 (unreleased) landed