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

   Do recursive call in plan walker for MergeAppend type of plan.
   
   When planner desides to merge two sorted subplans one of which has Share 
Input Scan node, executer fails to execute this, becuase of wrogly aligned 
internals structures.
   
   In turn out, it was forgotten in scareinput tree walker to do proper 
recursion call
   
   
   
   
   repro:
   
   
   
   ```
   
   reshke=# explain
   with inp as MATERIALIZED (select * from  tt4 ) select a,b,c, count(distinct 
d), count(distinct e), count(distinct f) from inp group by 1,2,3
   union all
   select a,b,c, count(distinct d), count(distinct e), count(distinct f) from 
tt4 group by 1,2,3
   order by 1;
                                              QUERY PLAN
   
-------------------------------------------------------------------------------------------------
    Gather Motion 3:1  (slice1; segments: 3)  (cost=1098.77..8775.44 rows=11000 
width=36)
      Merge Key: tt4.a
      ->  Merge Append  (cost=1098.77..1442.11 rows=3667 width=36)
            Sort Key: tt4.a
            ->  GroupAggregate  (cost=864.39..1042.72 rows=333 width=36)
                  Group Key: tt4.a, tt4.b, tt4.c
                  ->  Sort  (cost=864.39..889.39 rows=10000 width=24)
                        Sort Key: tt4.a, tt4.b, tt4.c
                        ->  Shared Scan (share slice:id 1:0)  (cost=39.33..0.00 
rows=3333 width=24)
                              ->  Seq Scan on tt4  (cost=0.00..39.33 rows=3333 
width=24)
            ->  GroupAggregate  (cost=234.38..326.05 rows=3333 width=36)
                  Group Key: tt4_1.a, tt4_1.b, tt4_1.c
                  ->  Sort  (cost=234.38..242.71 rows=3333 width=24)
                        Sort Key: tt4_1.a, tt4_1.b, tt4_1.c
                        ->  Seq Scan on tt4 tt4_1  (cost=0.00..39.33 rows=3333 
width=24)
    Optimizer: Postgres query optimizer
   (16 rows)
   
   reshke=# explain analyze
   with inp as MATERIALIZED (select * from  tt4 ) select a,b,c, count(distinct 
d), count(distinct e), count(distinct f) from inp group by 1,2,3
   union all
   select a,b,c, count(distinct d), count(distinct e), count(distinct f) from 
tt4 group by 1,2,3
   order by 1;
   ERROR:  cannot execute alien Share Input Scan (nodeShareInputScan.c:364)  
(seg1 slice1 127.0.1.1:7003 pid=17684) (nodeShareInputScan.c:364)
   reshke=#
   ```
   
   
   <!-- Thank you for your contribution to Apache Cloudberry (Incubating)! -->
   
   Fixes #ISSUE_Number
   
   ### What does this PR do?
   <!-- Brief overview of the changes, including any major features or fixes -->
   
   ### Type of Change
   - [ ] Bug fix (non-breaking change)
   - [ ] New feature (non-breaking change)
   - [ ] Breaking change (fix or feature with breaking changes)
   - [ ] Documentation update
   
   ### Breaking Changes
   <!-- Remove if not applicable. If yes, explain impact and migration path -->
   
   ### Test Plan
   <!-- How did you test these changes? -->
   - [ ] Unit tests added/updated
   - [ ] Integration tests added/updated
   - [ ] Passed `make installcheck`
   - [ ] Passed `make -C src/test installcheck-cbdb-parallel`
   
   ### Impact
   <!-- Remove sections that don't apply -->
   **Performance:**
   <!-- Any performance implications? -->
   
   **User-facing changes:**
   <!-- Any changes visible to users? -->
   
   **Dependencies:**
   <!-- New dependencies or version changes? -->
   
   ### Checklist
   - [ ] Followed [contribution 
guide](https://cloudberry.apache.org/contribute/code)
   - [ ] Added/updated documentation
   - [ ] Reviewed code for security implications
   - [ ] Requested review from [cloudberry 
committers](https://github.com/orgs/apache/teams/cloudberry-committers)
   
   ### Additional Context
   <!-- Any other information that would help reviewers? Remove if none -->
   
   ### CI Skip Instructions
   <!--
   To skip CI builds, add the appropriate CI skip identifier to your PR title.
   The identifier must:
   - Be in square brackets []
   - Include the word "ci" and either "skip" or "no"
   - Only use for documentation-only changes or when absolutely necessary
   -->
   
   ---
   <!-- Join our community:
   - Mailing list: 
[[email protected]](https://lists.apache.org/[email protected])
 (subscribe: [email protected])
   - Discussions: https://github.com/apache/cloudberry/discussions -->
   


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