roaldm153 opened a new pull request, #1865:
URL: https://github.com/apache/cloudberry/pull/1865

   If subtree on QE lives in another slice there is not guards and it crashes 
with segfault, so I fixed it
   
   <!-- Thank you for your contribution to Apache Cloudberry (Incubating)! -->
   
   Fixes #ISSUE_Number
   
   ### What does this PR do?
   This change fixes a crash that occurs on the Query Executor (QE) when a 
subtree lives in a different slice.
   The original code assumed that planstate is always non‑NULL and directly 
dereferenced planstate->plan.
   When the subtree is not instantiated in the current slice, planstate can be 
NULL, leading to a segmentation fault.
   The patch adds:
   
   A NULL guard for planstate at the start of ExplainNode.
   Moves the assignment plan = planstate->plan after the guard.
   Additional guard when recursing into the outer plan to avoid calling 
ExplainNode with a NULL outerPlanState.
   These changes make EXPLAIN robust across slice boundaries without altering 
any existing functionality.
   
   ### Type of Change
   - [x] Bug fix (non-breaking change)
   - [ ] New feature (non-breaking change)
   - [ ] Breaking change (fix or feature with breaking changes)
   - [ ] Documentation update
   
   ### Breaking Changes
   No breaking changes. The public API and plan execution behavior remain 
unchanged; only additional safety checks were added.
   
   ### Test Plan
   Unit tests: No new unit tests were added because the fix is defensive and 
does not change the logical output of EXPLAIN.
   Integration tests: Ran the full regression test suite, including parallel 
tests, and verified that the previously failing scenario no longer crashes.
   
   - [x] Passed `make installcheck`
   - [x] Passed `make -C src/test installcheck-cbdb-parallel`
   
   ### Impact
   **Performance:**
   Negligible impact – the added NULL checks are inexpensive branch predictions 
and do not affect the typical execution path.
   
   **User-facing changes:**
   ExplainPrintPlan now works on QE
   
   **Dependencies:**
   Nope
   
   ### Checklist
   - [x] Followed [contribution 
guide](https://cloudberry.apache.org/contribute/code)
   - [x] Added/updated documentation
   - [x] Reviewed code for security implications
   - [ ] This PR contains AI-assisted code generation
   - [x] Requested review from [cloudberry 
committers](https://github.com/orgs/apache/teams/cloudberry-committers)
   
   ### Additional Context
   ExplainNode was called from the QE side with a planstate that had not been 
instantiated because the subtree resides entirely in another slice.
   


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to