Skip to content

fix: guard against NULL scanTupleSlot in apply_update_list (#2537) - #2547

Open
waterWang wants to merge 2 commits into
apache:masterfrom
waterWang:fix-2537-delete-merge-segfault
Open

fix: guard against NULL scanTupleSlot in apply_update_list (#2537)#2547
waterWang wants to merge 2 commits into
apache:masterfrom
waterWang:fix-2537-delete-merge-segfault

Conversation

@waterWang

Copy link
Copy Markdown

When a DELETE removes a matched edge before a full-path MERGE, the MERGE's ON MATCH SET branch calls apply_update_list with a NULL scanTupleSlot in the expression context, causing a PostgreSQL backend crash (signal 11, segfault).

Fix: check for NULL scanTupleSlot at the top of apply_update_list and return early — there is no data to update when the scan slot has not been initialized.

Regression test: issue_2537 graph with the exact reproduction from the bug report.

Fixes #2537

DELETE matched relationship followed by full-path MERGE causes a
PostgreSQL backend crash (signal 11, segfault) in apply_update_list
at cypher_set.c:420. The scanTupleSlot in the expression context
is NULL when MERGE's ON MATCH SET branch is reached after a DELETE
has removed the matched edge, because the subtree's projection
does not set ecxt_scantuple.

Fix: check for NULL scanTupleSlot at the top of apply_update_list
and return early — there is no data to update when the scan slot
has not been initialized.

Regression test: issue_2537 graph with the exact reproduction from
the bug report (DELETE edge + CREATE + full-path MERGE).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Prevents a PostgreSQL backend crash when apply_update_list receives an uninitialized scan tuple slot.

Changes:

  • Return early when scanTupleSlot is NULL.
  • Add regression coverage for issue #2537.
  • Record expected successful query output and graph cleanup.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/backend/executor/cypher_set.c Guards against a null scan tuple slot.
regress/sql/cypher_merge.sql Adds the issue #2537 reproduction test.
regress/expected/cypher_merge.out Adds expected regression-test output.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deleting a matched relationship and then executing full-path MERGE causes a PostgreSQL backend segmentation fault

2 participants