| From: | David Rowley <drowley(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix Memoize to correctly use clause's input collation |
| Date: | 2026-11-04 00:44:57 |
| Message-ID: | E1xOP7Z-000000005Lq-2f8d@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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(at)gmail(dot)com>
Reviewed-by: Manu <manuelreyesbravo(at)gmail(dot)com>
Reviewed-by: David Rowley <dgrowleyml(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAGRkXqTBsBegZ8rNMYjwkeu1V5wRQ06zR6jTVickqP_3E7mb8g@mail.gmail.com
Backpatch-through: 14
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/35273454065e6b7f07984e70ac131ce710e6f380
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(+)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David Rowley | 2026-11-04 00:45:10 | pgsql: Fix Memoize to correctly use clause's input collation |
| Previous Message | Michael Paquier | 2026-11-03 23:39:47 | pgsql: Improve stability of authentication test 007_pre_auth |