| From: | David Rowley <drowley(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix Memoize using the wrong equality operator for cache keys |
| Date: | 2026-11-11 01:36:05 |
| Message-ID: | E1xQxFt-00000000FX2-30Ji@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Fix Memoize using the wrong equality operator for cache keys
Memoize compared cache keys with the type's default equality operator
rather than the operator used by the parameterized join clause. If a
hashable join operator considers fewer values equal than the type's
default equality operator, two outer values could share one cache
entry, and the inner rows cached for one value were returned for the
other. One example is a byte-wise equality operator on a column with
a case-insensitive nondeterministic collation.
To fix, have check_memoizable() take the hash equality operators from
the clause's hashjoinoperator. When both inputs are of the same type,
use the join operator itself. For cross-type operators, look up the
same-type equality members in the join operator's hash opfamily. If
no such member exists, don't set a hash equality operator, so Memoize
isn't used for that clause. Clauses that aren't hashjoinable keep
using the type's default equality operator along with binary mode, as
before.
Backpatch to all supported versions.
Bug: #19853
Reported-by: chunling qin <303677365(at)qq(dot)com>
Author: David Rowley <dgrowleyml(at)gmail(dot)com>
Discussion: https://postgr.es/m/19853-22fde551f71cbadb@postgresql.org
Backpatch-through: 15
Branch
------
REL_16_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/9846de28b79e507899832dcae37f4a0281981167
Modified Files
--------------
src/backend/optimizer/plan/initsplan.c | 57 ++++++++++++++++++-------
src/test/regress/expected/collate.icu.utf8.out | 58 ++++++++++++++++++++++++++
src/test/regress/sql/collate.icu.utf8.sql | 41 ++++++++++++++++++
3 files changed, 141 insertions(+), 15 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David Rowley | 2026-11-11 01:36:15 | pgsql: Fix Memoize using the wrong equality operator for cache keys |
| Previous Message | David Rowley | 2026-11-11 01:35:51 | pgsql: Fix Memoize using the wrong equality operator for cache keys |