pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix Memoize using the wrong equality operator for cache keys
6+ messages / 1 participants
[nested] [flat]

* pgsql: Fix Memoize using the wrong equality operator for cache keys
@ 2026-11-11 01:35  David Rowley <drowley@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: David Rowley @ 2026-11-11 01:35 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@qq.com>
Author: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/19853-22fde551f71cbadb@postgresql.org
Backpatch-through: 15

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/8cdf3c9214feb48179a3cc0fbb0bae0e0f38f2cb

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix Memoize using the wrong equality operator for cache keys
@ 2026-11-11 01:35  David Rowley <drowley@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: David Rowley @ 2026-11-11 01:35 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@qq.com>
Author: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/19853-22fde551f71cbadb@postgresql.org
Backpatch-through: 15

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/04c5de538e860f5a4d05caeac92ca490e0991c49

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix Memoize using the wrong equality operator for cache keys
@ 2026-11-11 01:35  David Rowley <drowley@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: David Rowley @ 2026-11-11 01:35 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@qq.com>
Author: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/19853-22fde551f71cbadb@postgresql.org
Backpatch-through: 15

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/91ab6a72962cb120f7a4d589633011545cb8df70

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix Memoize using the wrong equality operator for cache keys
@ 2026-11-11 01:35  David Rowley <drowley@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: David Rowley @ 2026-11-11 01:35 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@qq.com>
Author: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/19853-22fde551f71cbadb@postgresql.org
Backpatch-through: 15

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/c4d8000eb29ed6cd811d2f71ff687961c21e7a99

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix Memoize using the wrong equality operator for cache keys
@ 2026-11-11 01:36  David Rowley <drowley@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: David Rowley @ 2026-11-11 01:36 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@qq.com>
Author: David Rowley <dgrowleyml@gmail.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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix Memoize using the wrong equality operator for cache keys
@ 2026-11-11 01:36  David Rowley <drowley@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: David Rowley @ 2026-11-11 01:36 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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@qq.com>
Author: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/19853-22fde551f71cbadb@postgresql.org
Backpatch-through: 15

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a9ad341bd6862c4cbc220b9a2835c794fab7114f

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2026-11-11 01:36 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-11 01:35 pgsql: Fix Memoize using the wrong equality operator for cache keys David Rowley <drowley@postgresql.org>
2026-11-11 01:35 pgsql: Fix Memoize using the wrong equality operator for cache keys David Rowley <drowley@postgresql.org>
2026-11-11 01:35 pgsql: Fix Memoize using the wrong equality operator for cache keys David Rowley <drowley@postgresql.org>
2026-11-11 01:35 pgsql: Fix Memoize using the wrong equality operator for cache keys David Rowley <drowley@postgresql.org>
2026-11-11 01:36 pgsql: Fix Memoize using the wrong equality operator for cache keys David Rowley <drowley@postgresql.org>
2026-11-11 01:36 pgsql: Fix Memoize using the wrong equality operator for cache keys 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