Skip to content

fix(reject_partition_fullscan): look up relkind/partition count from catalog (#2342) - #2382

Open
lqriu wants to merge 1 commit into
apache:mainfrom
lqriu:fix/2342-reject-partition-fullscan
Open

lqriu wants to merge 1 commit into
apache:mainfrom
lqriu:fix/2342-reject-partition-fullscan

Conversation

@lqriu

@lqriu lqriu commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

What

Fix two bugs in the reject_partition_fullscan gpcontrib extension reported in #2342.

Bug 1 — GPORCA full scans not rejected. The dynamic-scan check trusted
rte->relkind, which ORCA leaves unset on the dynamic scan's RTE, so the walker
returned early and ORCA-planned full partition scans were never rejected. Now the
relkind is looked up from the catalog via get_rel_relkind().

Bug 2 — planner threshold=0 rejects legitimate partial scans. With the
Postgres planner and partition_fullscan_threshold = 0, an Append produced by
plan-time static pruning (a subset of partitions, no PartitionPruneInfo) was
rejected as if it were a full scan. Now the surviving subplan count is compared
against the catalog partition count (find_inheritance_children), so only true
full scans are rejected — mirroring the ORCA path's logic.

Changes

  • reject_partition_fullscan.c: use get_rel_relkind() for the dynamic-scan
    relkind check (Bug 1); compare against catalog partition count at threshold 0
    in check_append_no_pruneinfo (Bug 2).
  • sql/partition_fullscan_reject.sql: add Test 12 (planner partial scan must pass,
    full scan still rejected) and Test 13 (ORCA full scan must be rejected, pruned
    query passes) — the GPORCA dynamic-scan coverage that was previously missing.
  • expected/partition_fullscan_reject.out: add the regression baseline (the
    module had no expected/ directory).

Verification

Built Apache Cloudberry (main, --enable-orca --enable-pax) from source in the
official cbdb-build-rocky9 image on Rocky Linux 9, created a gpdemo cluster, and
ran make installcheck:

  • Test 12 (planner, threshold=0): partial scan keeping 2/3 partitions passes;
    full count(*) is rejected.
  • Test 13 (ORCA): unfiltered full count(*) is rejected; pruned query passes.
  • make installcheck → All 1 tests passed.

Fixes #2342.

…catalog

- ORCA dynamic scans: use get_rel_relkind() since ORCA leaves rte->relkind
  unset, so full scans were not rejected (issue apache#2342)
- planner threshold=0: compare surviving subplans against catalog partition
  count so statically-pruned partial scans are not rejected (issue apache#2342)
- add Test 12/13 regression cases and expected/ baseline (verified on gpdemo)

Signed-off-by: liu qiren <13559537330@163.com>
@lqriu

lqriu commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

@tuhaihe this PR addresses both bugs you reported in #2342:

  • Bug 1 (GPORCA): the dynamic-scan check now looks up relkind via get_rel_relkind(rte->relid) instead of trusting rte->relkind, which ORCA leaves unset — so ORCA-planned full partition scans are now rejected.
  • Bug 2 (planner, threshold=0): check_append_no_pruneinfo now compares the surviving subplan count against the catalog partition count, so statically-pruned partial scans are no longer rejected as full scans.

It also adds the previously-missing GPORCA dynamic-scan regression coverage (Test 12/13) and an expected/ baseline.

Verified on a from-source build (--enable-orca --enable-pax) with a gpdemo cluster:

  • Test 12 (planner, threshold=0): partial scan keeping 2/3 partitions passes; full count(*) is rejected.
  • Test 13 (ORCA): unfiltered full count(*) is rejected; pruned query passes.
  • make installcheck → All 1 tests passed.

Could a committer approve the workflows / take a look when you have a chance? Thanks!

@tuhaihe

tuhaihe commented Nov 20, 2026

Copy link
Copy Markdown
Member
  1. The CI workflow has been approved to run.
  2. Is there a need to upgrade the extension version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] reject_partition_fullscan does not reject full scans planned by GPORCA, and threshold 0 rejects partial scans under the planner

2 participants