Skip to content

Fix is_plan_node() for PartitionSelector and non-Plan nodes - #2269

Merged
tuhaihe merged 1 commit into
apache:mainfrom
chenjinbao1989:fix-is-plan-node-partition-selector
Nov 9, 2026
Merged

tuhaihe merged 1 commit into
apache:mainfrom
chenjinbao1989:fix-is-plan-node-partition-selector

Conversation

@chenjinbao1989

Copy link
Copy Markdown
Contributor

is_plan_node() checks that the node tag lies in the range T_Plan_Start..T_Plan_End, with T_Plan_End defined as T_PlanRowMark. Since node tags are generated by gen_node_support.pl, in the order the structs appear in plannodes.h, that range is no longer exact:

  • PartitionSelector is defined after PlanRowMark, so it is not considered a Plan node, although its first field is a Plan.
  • ExternalScanInfo and NestLoopParam are defined among the Plan nodes, so they are considered Plan nodes, although they are not.

Missing PartitionSelector makes the walkers that rely on is_plan_node() skip it, and some of them, like shareinput_walker(), its whole subtree. A Shared Scan below a Partition Selector is then not set up, and the query fails, e.g.

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


is_plan_node() checks that the node tag lies in the range
T_Plan_Start..T_Plan_End, with T_Plan_End defined as T_PlanRowMark.
Since node tags are generated by gen_node_support.pl, in the order the
structs appear in plannodes.h, that range is no longer exact:

- PartitionSelector is defined after PlanRowMark, so it is not
  considered a Plan node, although its first field is a Plan.
- ExternalScanInfo and NestLoopParam are defined among the Plan nodes,
  so they are considered Plan nodes, although they are not.

Missing PartitionSelector makes the walkers that rely on is_plan_node()
skip it, and some of them, like shareinput_walker(), its whole subtree.
A Shared Scan below a Partition Selector is then not set up, and the
query fails, e.g.

@my-ship-it my-ship-it left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks!

@lss602726449 lss602726449 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tuhaihe
tuhaihe merged commit d2765af into apache:main Nov 9, 2026
122 of 124 checks passed
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.

4 participants