pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix Memoize to correctly use clause's input collation 7+ messages / 1 participants [nested] [flat]
* pgsql: Fix Memoize to correctly use clause's input collation @ 2026-11-04 00:44 David Rowley <drowley@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: David Rowley @ 2026-11-04 00:44 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 ------ 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(+) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix Memoize to correctly use clause's input collation @ 2026-11-04 00:45 David Rowley <drowley@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: David Rowley @ 2026-11-04 00:45 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/0e58f6d737515f6d7f5c910472ffe28dc6fa9f7b 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(+) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix Memoize to correctly use clause's input collation @ 2026-11-04 00:45 David Rowley <drowley@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: David Rowley @ 2026-11-04 00:45 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/9dd02753525ac83b5902bf4456b3bdb276f0271b 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(+) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix Memoize to correctly use clause's input collation @ 2026-11-04 00:45 David Rowley <drowley@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: David Rowley @ 2026-11-04 00:45 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/f79bf8d8f3272e6d4d3dd14f5ffad7c31f017e49 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(+) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix Memoize to correctly use clause's input collation @ 2026-11-04 00:45 David Rowley <drowley@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: David Rowley @ 2026-11-04 00:45 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/083d60e34ae081a18f57071e45fcad9f07d1d7f6 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(+) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix Memoize to correctly use clause's input collation @ 2026-11-04 00:45 David Rowley <drowley@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: David Rowley @ 2026-11-04 00:45 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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(+) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Fix Memoize to correctly use clause's input collation @ 2026-11-04 00:45 David Rowley <drowley@postgresql.org> 0 siblings, 0 replies; 7+ messages in thread From: David Rowley @ 2026-11-04 00:45 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/e22cec1bdb3c4a326152c161d58077c33755a093 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(+) ^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2026-11-04 00:45 UTC | newest] Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-11-04 00:44 pgsql: Fix Memoize to correctly use clause's input collation David Rowley <drowley@postgresql.org> 2026-11-04 00:45 pgsql: Fix Memoize to correctly use clause's input collation David Rowley <drowley@postgresql.org> 2026-11-04 00:45 pgsql: Fix Memoize to correctly use clause's input collation David Rowley <drowley@postgresql.org> 2026-11-04 00:45 pgsql: Fix Memoize to correctly use clause's input collation David Rowley <drowley@postgresql.org> 2026-11-04 00:45 pgsql: Fix Memoize to correctly use clause's input collation David Rowley <drowley@postgresql.org> 2026-11-04 00:45 pgsql: Fix Memoize to correctly use clause's input collation David Rowley <drowley@postgresql.org> 2026-11-04 00:45 pgsql: Fix Memoize to correctly use clause's input collation David Rowley <drowley@postgresql.org>
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