From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix Memoize to correctly use clause's input collation
Date: Wed, 04 Nov 2026 00:45:45 +0000
Message-ID: <E1xOP8L-000000005Po-2iuh@gemulon.postgresql.org> (raw)
Fix Memoize to correctly use clause's input collation
When building Memoize cache keys from a parameterized path's join clauses,
paraminfo_get_equal_hashops() used the outer side expression of each
clause verbatim, which meant the cache was hashed and probed using that
expression's collation rather than the input collation of the join
condition.
If the expression's collation is nondeterministic and the clause compares
using a different collation, values that the clause can distinguish, such
as 'abc' and 'ABC' under a case-insensitive collation, could be treated as
equal by the cache. This could cause a lookup to return the cached
results for another value, giving wrong query results.
Here we fix this by relabeling the cache key expression with the join
clause's input collation, so that cache lookups match values the same way
as the join clause does.
Author: shihao zhong <zhong950419@gmail.com>
Reviewed-by: Manu <manuelreyesbravo@gmail.com>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/CAGRkXqTBsBegZ8rNMYjwkeu1V5wRQ06zR6jTVickqP_3E7mb8g@mail.gmail.com
Backpatch-through: 14
Branch
------
REL_15_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/2da9b7f9b22dbcc64bffeab3612fc9f3ca063db9
Modified Files
--------------
src/backend/optimizer/path/joinpath.c | 11 +++++++
src/test/regress/expected/collate.icu.utf8.out | 42 ++++++++++++++++++++++++++
src/test/regress/sql/collate.icu.utf8.sql | 25 +++++++++++++++
3 files changed, 78 insertions(+)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: drowley@postgresql.org
Subject: Re: pgsql: Fix Memoize to correctly use clause's input collation
In-Reply-To: <E1xOP8L-000000005Po-2iuh@gemulon.postgresql.org>
References: <E1xOP8L-000000005Po-2iuh@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox