You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@age.apache.org by "waterWang (via GitHub)" <gi...@apache.org> on 2026/08/23 13:09:02 UTC

[PR] fix: guard against NULL subplan in full-path MERGE sub-case 1 (#2536) [age]

waterWang opened a new pull request, #2546:
URL: https://github.com/apache/age/pull/2546

   Fixes #2536.
   
   **Root cause**: When a full-path MERGE is the first clause followed by a
   WITH (Case 3, sub-case 1, path-not-found → create path), the code assumes
   `node->ss.ps.lefttree` is always a `SubqueryScanState` and reads
   `ExecGetResultType(sss->subplan)`.  When the MERGE path pattern produces
   no base-relation scan (e.g. empty graph), the planner emits a plain
   `Result` plan, the `SubqueryScanState` cast reads through the wrong struct
   layout, `sss->subplan` is `NULL`, and `ExecGetResultType(NULL)` segfaults.
   
   **Fix**: check `IsA(lefttree, SubqueryScanState)` before using
   `SubqueryScanState` internals.  For a `SubqueryScan` child the original
   code path (remake child scan slot via `sss->ss` + `ExecGetResultType(sss->subplan)`)
   is preserved.  For a `Result` child, use the generic `PlanState` API
   (`ExecGetResultType(lefttree)`) and store the remade slot in the MERGE
   node's own `ScanState`.
   
   **Tests**: 41/43 regression tests pass (age_load and age_upgrade are
   pre-existing environment failures).  New regression test added to
   `regress/sql/expr.sql` reproduces the exact query shape from #2536.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: guard against NULL subplan in full-path MERGE sub-case 1 (#2536) [age]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #2546:
URL: https://github.com/apache/age/pull/2546#discussion_r3846056594


##########
regress/expected/expr.out:
##########
@@ -10711,3 +10711,38 @@ NOTICE:  graph "issue_2391" has been dropped
 --
 -- End of tests
 --

Review Comment:
   The expected output still contains the earlier three-line "End of tests" marker (10711–10713) even though additional tests follow it. This makes the output harder to read and no longer matches the intent of an end-of-tests sentinel. Remove the earlier marker so the only end marker is at the end of the file.
   
   This issue also appears on line 10748 of the same file.



##########
regress/sql/expr.sql:
##########
@@ -4203,3 +4203,18 @@ SELECT * FROM drop_graph('issue_2391', true);
 --
 -- End of tests
 --
+
+-- Issue #2536: Full-path MERGE with WITH followed by WHERE
+-- on a non-existing pattern (empty graph). The child plan is a
+-- Result node, not a SubqueryScan, and the code must not assume
+-- SubqueryScanState internals when remaking the scan tuple slot.
+SELECT * FROM create_graph('issue_2536');
+SELECT * FROM cypher('issue_2536', $$
+  MERGE p = (:a)-[:r]->(n)
+  WITH 1 AS y
+  WHERE ('a' STARTS WITH 'a')
+  RETURN y
+$$) AS (y agtype);
+SELECT * FROM drop_graph('issue_2536', true);
+
+-- End of tests

Review Comment:
   The regression file now has two "End of tests" markers: an existing three-line block at 4203–4205 and a new single-line marker at the end. This is confusing because the new Issue #2536 test comes after the earlier end marker and the end marker style becomes inconsistent within the same file. Consider moving the existing end-of-tests block to the end (and keeping the standard three-line form) so the sentinel remains meaningful.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org