| From: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Further varnullingrels fixes for MERGE WHEN NOT MATCHED BY SOURC |
| Date: | 2026-11-12 09:44:26 |
| Message-ID: | E1xRRM2-00000000Q8d-3SFx@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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(at)gmail(dot)com>
Author: Shihao Zhong <zhong950419(at)gmail(dot)com>
Reviewed-by: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)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(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Eisentraut | 2026-11-12 10:33:23 | pgsql: Add missing exclude_file_patterns |
| Previous Message | Michael Paquier | 2026-11-12 06:02:20 | Re: pgsql: Make GetSnapshotData() more resilient on out-of-memory errors |