model-writtenrun 2956 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Alexander Lakhin reported that MERGE into an updatable view with WHEN NOT MATCHED BY SOURCE failed with a wrong-varnullingrels error on PostgreSQL 17, while a WHEN MATCHED variant succeeded #1.
- Tom Lane initially suspected missing nullability markings on row-identity Vars #2, and Richard Guo narrowed the problem to source Vars pulled from the merge join condition into the targetlist #3.
- Dean Rasheed extended the diagnosis to action expressions and RETURNING, posting a patch that marked Vars in transform_MERGE_to_join() because later jointree transformations could make marking them in preprocess_targetlist() unsafe #4.
- Tom Lane supported early marking but questioned whether rechecking a join condition with nullified source values was correct #5, while Richard Guo questioned whether marking the condition would incorrectly alter the join's own quals #6.
- Dean Rasheed demonstrated that a non-strict join condition could execute UPDATE instead of DELETE and posted two patches: a source-wholerow IS NOT NULL guard followed by the revised nullability fix, explaining that only the above-join copy of the condition receives markings #7.
- Dean Rasheed deferred replacing the original join recheck entirely with the null test because the associated executor and field-name changes were unsuitable for back-patching and offered an uncertain optimization benefit #7.
- Richard Guo accepted the copied-condition explanation and explained why an intervening Result node exposed the error through stricter nullability checks; stronger checks directly above outer joins remained a difficult possible improvement because of join reordering #8.
- Dean Rasheed committed the first patch from #7 unchanged as d7d297f844 and the second unchanged as 34ae54af92, then confirmed that both fixes had been pushed and back-patched, completing the submitted work #9.