pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Further varnullingrels fixes for MERGE WHEN NOT MATCHED BY SOURC
4+ messages / 1 participants
[nested] [flat]

* pgsql: Further varnullingrels fixes for MERGE WHEN NOT MATCHED BY SOURC
@ 2026-11-12 09:44  Dean Rasheed <dean.a.rasheed@gmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Dean Rasheed @ 2026-11-12 09:44 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Further varnullingrels fixes for MERGE WHEN NOT MATCHED BY SOURCE.

Commit 259a0a99fe3 fixed a "wrong varnullingrels" error in MERGE with
WHEN NOT MATCHED BY SOURCE actions by marking any Vars referring to
the source relation as nullable by the join. However, that overlooked
the fact that the source relation might itself be a join relation, and
there may be Vars referring to relations under the source join.
Depending the query, this could lead to further "wrong varnullingrels"
errors or incorrect query results.

Fix by ensuring that all Vars referring to the source join relation or
any relations under it are marked as nullable by the merge join.

Back-patch to v17, where WHEN NOT MATCHED BY SOURCE support was added
to MERGE.

Reported-by: Shihao Zhong <zhong950419@gmail.com>
Author: Shihao Zhong <zhong950419@gmail.com>
Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>
Discussion: https://postgr.es/m/CAGRkXqR7VXacmRP41UBaM5u4aseeCH5ECVmQgn_YS%3DL7%3DxdhTw%40mail.gmail.com
Backpatch-through: 17

Branch
------
master

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

Modified Files
--------------
src/backend/optimizer/prep/prepjointree.c | 16 ++++++++---
src/test/regress/expected/merge.out       | 45 ++++++++++++++++++++++++++++++-
src/test/regress/sql/merge.sql            | 28 ++++++++++++++++++-
3 files changed, 83 insertions(+), 6 deletions(-)



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

* pgsql: Further varnullingrels fixes for MERGE WHEN NOT MATCHED BY SOURC
@ 2026-11-12 09:44  Dean Rasheed <dean.a.rasheed@gmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Dean Rasheed @ 2026-11-12 09:44 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Further varnullingrels fixes for MERGE WHEN NOT MATCHED BY SOURCE.

Commit 259a0a99fe3 fixed a "wrong varnullingrels" error in MERGE with
WHEN NOT MATCHED BY SOURCE actions by marking any Vars referring to
the source relation as nullable by the join. However, that overlooked
the fact that the source relation might itself be a join relation, and
there may be Vars referring to relations under the source join.
Depending the query, this could lead to further "wrong varnullingrels"
errors or incorrect query results.

Fix by ensuring that all Vars referring to the source join relation or
any relations under it are marked as nullable by the merge join.

Back-patch to v17, where WHEN NOT MATCHED BY SOURCE support was added
to MERGE.

Reported-by: Shihao Zhong <zhong950419@gmail.com>
Author: Shihao Zhong <zhong950419@gmail.com>
Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>
Discussion: https://postgr.es/m/CAGRkXqR7VXacmRP41UBaM5u4aseeCH5ECVmQgn_YS%3DL7%3DxdhTw%40mail.gmail.com
Backpatch-through: 17

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/1d83c23f2912972a9cd3a6241be92ed30efffaf5

Modified Files
--------------
src/backend/optimizer/prep/prepjointree.c | 16 ++++++++---
src/test/regress/expected/merge.out       | 45 ++++++++++++++++++++++++++++++-
src/test/regress/sql/merge.sql            | 28 ++++++++++++++++++-
3 files changed, 83 insertions(+), 6 deletions(-)



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

* pgsql: Further varnullingrels fixes for MERGE WHEN NOT MATCHED BY SOURC
@ 2026-11-12 09:44  Dean Rasheed <dean.a.rasheed@gmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Dean Rasheed @ 2026-11-12 09:44 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Further varnullingrels fixes for MERGE WHEN NOT MATCHED BY SOURCE.

Commit 259a0a99fe3 fixed a "wrong varnullingrels" error in MERGE with
WHEN NOT MATCHED BY SOURCE actions by marking any Vars referring to
the source relation as nullable by the join. However, that overlooked
the fact that the source relation might itself be a join relation, and
there may be Vars referring to relations under the source join.
Depending the query, this could lead to further "wrong varnullingrels"
errors or incorrect query results.

Fix by ensuring that all Vars referring to the source join relation or
any relations under it are marked as nullable by the merge join.

Back-patch to v17, where WHEN NOT MATCHED BY SOURCE support was added
to MERGE.

Reported-by: Shihao Zhong <zhong950419@gmail.com>
Author: Shihao Zhong <zhong950419@gmail.com>
Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>
Discussion: https://postgr.es/m/CAGRkXqR7VXacmRP41UBaM5u4aseeCH5ECVmQgn_YS%3DL7%3DxdhTw%40mail.gmail.com
Backpatch-through: 17

Branch
------
REL_18_STABLE

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

Modified Files
--------------
src/backend/optimizer/prep/prepjointree.c | 16 ++++++++---
src/test/regress/expected/merge.out       | 45 ++++++++++++++++++++++++++++++-
src/test/regress/sql/merge.sql            | 28 ++++++++++++++++++-
3 files changed, 83 insertions(+), 6 deletions(-)



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

* pgsql: Further varnullingrels fixes for MERGE WHEN NOT MATCHED BY SOURC
@ 2026-11-12 09:44  Dean Rasheed <dean.a.rasheed@gmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Dean Rasheed @ 2026-11-12 09:44 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Further varnullingrels fixes for MERGE WHEN NOT MATCHED BY SOURCE.

Commit 259a0a99fe3 fixed a "wrong varnullingrels" error in MERGE with
WHEN NOT MATCHED BY SOURCE actions by marking any Vars referring to
the source relation as nullable by the join. However, that overlooked
the fact that the source relation might itself be a join relation, and
there may be Vars referring to relations under the source join.
Depending the query, this could lead to further "wrong varnullingrels"
errors or incorrect query results.

Fix by ensuring that all Vars referring to the source join relation or
any relations under it are marked as nullable by the merge join.

Back-patch to v17, where WHEN NOT MATCHED BY SOURCE support was added
to MERGE.

Reported-by: Shihao Zhong <zhong950419@gmail.com>
Author: Shihao Zhong <zhong950419@gmail.com>
Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>
Discussion: https://postgr.es/m/CAGRkXqR7VXacmRP41UBaM5u4aseeCH5ECVmQgn_YS%3DL7%3DxdhTw%40mail.gmail.com
Backpatch-through: 17

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/179f22f256ab50bdd0a4351a8b9def13876e4c43

Modified Files
--------------
src/backend/optimizer/prep/prepjointree.c | 18 +++++++++----
src/test/regress/expected/merge.out       | 45 ++++++++++++++++++++++++++++++-
src/test/regress/sql/merge.sql            | 28 ++++++++++++++++++-
3 files changed, 84 insertions(+), 7 deletions(-)



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


end of thread, other threads:[~2026-11-12 09:44 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-12 09:44 pgsql: Further varnullingrels fixes for MERGE WHEN NOT MATCHED BY SOURC Dean Rasheed <dean.a.rasheed@gmail.com>
2026-11-12 09:44 pgsql: Further varnullingrels fixes for MERGE WHEN NOT MATCHED BY SOURC Dean Rasheed <dean.a.rasheed@gmail.com>
2026-11-12 09:44 pgsql: Further varnullingrels fixes for MERGE WHEN NOT MATCHED BY SOURC Dean Rasheed <dean.a.rasheed@gmail.com>
2026-11-12 09:44 pgsql: Further varnullingrels fixes for MERGE WHEN NOT MATCHED BY SOURC Dean Rasheed <dean.a.rasheed@gmail.com>

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