Skip to content

Commit

Permalink
[BACKPORT 2.20.1][#19694] YSQL: Missing finalize_primnode calls
Browse files Browse the repository at this point in the history
Summary:
Original commit: 5875a24 / D29710
The finalize_plan function in subselect.c basically collects and
summarizes information about parameter references in the subplan.

It calls finalize_primnode to recursively process all possible
containers where Param nodes may be found. We introduced PushdownExprs,
where qual list may contain Param expression, but we didn't update the
finalize_plan function to call finalize_primnode on them.

The only known manifestation is Parallel Query where Gather node does
not transfer parameter values to and from background workers.
Jira: DB-8494

Test Plan: Run regression tests

Reviewers: jason, tnayak

Reviewed By: jason, tnayak

Subscribers: smishra, yql

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D31303
  • Loading branch information
andrei-mart committed Dec 21, 2023
1 parent 0c7ec92 commit 6a3badc
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/postgres/src/backend/optimizer/plan/subselect.c
Original file line number Diff line number Diff line change
Expand Up @@ -2033,7 +2033,12 @@ finalize_plan(PlannerInfo *root, Plan *plan,
break;

case T_SeqScan:
context.paramids = bms_add_members(context.paramids, scan_params);
break;

case T_YbSeqScan:
finalize_primnode((Node *) ((YbSeqScan *) plan)->yb_pushdown.quals,
&context);
context.paramids = bms_add_members(context.paramids, scan_params);
break;

Expand All @@ -2048,6 +2053,10 @@ finalize_plan(PlannerInfo *root, Plan *plan,
&context);
finalize_primnode((Node *) ((IndexScan *) plan)->indexorderby,
&context);
finalize_primnode((Node *) ((IndexScan *) plan)->yb_rel_pushdown.quals,
&context);
finalize_primnode((Node *) ((IndexScan *) plan)->yb_idx_pushdown.quals,
&context);

/*
* we need not look at indexqualorig, since it will have the same
Expand All @@ -2062,6 +2071,8 @@ finalize_plan(PlannerInfo *root, Plan *plan,
&context);
finalize_primnode((Node *) ((IndexOnlyScan *) plan)->indexorderby,
&context);
finalize_primnode((Node *) ((IndexOnlyScan *) plan)->yb_pushdown.quals,
&context);

/*
* we need not look at indextlist, since it cannot contain Params.
Expand Down

0 comments on commit 6a3badc

Please sign in to comment.