Skip to content

Fix writable CTE on replicated tables EXCEPT partition tables.#1290

Merged
avamingli merged 1 commit intoapache:mainfrom
avamingli:fix_except
Sep 9, 2025
Merged

Fix writable CTE on replicated tables EXCEPT partition tables.#1290
avamingli merged 1 commit intoapache:mainfrom
avamingli:fix_except

Conversation

@avamingli
Copy link
Contributor

Fix issue: #1240

Replicated locus could EXCEPT Partitioned locus when there is writable CTE on replicated tables.
We could make them SingleQE or Entry to do the set operation.

with result as (update r_1240 set a = a +1 where a < 5 returning *) select * from result except select * from p1_1240;
                          QUERY PLAN
---------------------------------------------------------------
 HashSetOp Except
   ->  Append
         ->  Explicit Gather Motion 3:1  (slice1; segments: 3)
               ->  Subquery Scan on "*SELECT* 1"
                     ->  Update on r_1240
                           ->  Seq Scan on r_1240
                                 Filter: (a < 5)
         ->  Gather Motion 3:1  (slice2; segments: 3)
               ->  Subquery Scan on "*SELECT* 2"
                     ->  Seq Scan on p1_1240
 Optimizer: Postgres-based planner
(11 rows)

Authored-by: Zhang Mingli avamingli@gmail.com

Fixes #ISSUE_Number

What does this PR do?

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

Test Plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Passed make installcheck
  • Passed make -C src/test installcheck-cbdb-parallel

Impact

Performance:

User-facing changes:

Dependencies:

Checklist

Additional Context

CI Skip Instructions


Fix issue: apache#1240

Replicated locus could EXCEPT Partitioned locus when there is
writable CTE on replicated tables.
We could make them SingleQE or Entry to do the set operation.

with result as (update r_1240 set a = a +1 where a <
5 returning *) select * from result except select * from p1_1240;
                          QUERY PLAN
---------------------------------------------------------------
 HashSetOp Except
   ->  Append
         ->  Explicit Gather Motion 3:1  (slice1; segments: 3)
               ->  Subquery Scan on "*SELECT* 1"
                     ->  Update on r_1240
                           ->  Seq Scan on r_1240
                                 Filter: (a < 5)
         ->  Gather Motion 3:1  (slice2; segments: 3)
               ->  Subquery Scan on "*SELECT* 2"
                     ->  Seq Scan on p1_1240
 Optimizer: Postgres-based planner
(11 rows)

Authored-by: Zhang Mingli avamingli@gmail.com
@avamingli avamingli merged commit 54fc80f into apache:main Sep 9, 2025
27 checks passed
@avamingli avamingli deleted the fix_except branch September 9, 2025 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants