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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
