From 2cbea6528fb3fabb1002661fb07984b30b43121b Mon Sep 17 00:00:00 2001 From: Onur Tirtir Date: Mon, 18 Aug 2025 10:20:17 +0300 Subject: [PATCH] rename a few more functions --- .../distributed/planner/deparse_shard_query.c | 30 ++++++++++--------- .../planner/multi_physical_planner.c | 3 +- .../distributed/planner/recursive_planning.c | 16 +++++----- src/include/distributed/deparse_shard_query.h | 10 ++++--- src/include/distributed/recursive_planning.h | 10 +++---- 5 files changed, 37 insertions(+), 32 deletions(-) diff --git a/src/backend/distributed/planner/deparse_shard_query.c b/src/backend/distributed/planner/deparse_shard_query.c index e2853a527..b22bb8028 100644 --- a/src/backend/distributed/planner/deparse_shard_query.c +++ b/src/backend/distributed/planner/deparse_shard_query.c @@ -209,11 +209,11 @@ UpdateTaskQueryString(Query *query, Task *task) /* - * DefineQualsForShardInterval creates the necessary qual conditions over the + * CreateQualsForShardInterval creates the necessary qual conditions over the * given attnum and rtindex for the given shard interval. */ Node * -DefineQualsForShardInterval(RelationShard *relationShard, int attnum, int rtindex) +CreateQualsForShardInterval(RelationShard *relationShard, int attnum, int rtindex) { uint64 shardId = relationShard->shardId; Oid relationId = relationShard->relationId; @@ -322,11 +322,11 @@ DefineQualsForShardInterval(RelationShard *relationShard, int attnum, int rtinde /* - * UpdateWhereClauseForOuterJoinWalker walks over the query tree and + * UpdateWhereClauseToPushdownRecurringOuterJoinWalker walks over the query tree and * updates the WHERE clause for outer joins satisfying feasibility conditions. */ bool -UpdateWhereClauseForOuterJoinWalker(Node *node, List *relationShardList) +UpdateWhereClauseToPushdownRecurringOuterJoinWalker(Node *node, List *relationShardList) { if (node == NULL) { @@ -335,14 +335,16 @@ UpdateWhereClauseForOuterJoinWalker(Node *node, List *relationShardList) if (IsA(node, Query)) { - UpdateWhereClauseForOuterJoin((Query *) node, relationShardList); - return query_tree_walker((Query *) node, UpdateWhereClauseForOuterJoinWalker, + UpdateWhereClauseToPushdownRecurringOuterJoin((Query *) node, relationShardList); + return query_tree_walker((Query *) node, + UpdateWhereClauseToPushdownRecurringOuterJoinWalker, relationShardList, QTW_EXAMINE_RTES_BEFORE); } if (!IsA(node, RangeTblEntry)) { - return expression_tree_walker(node, UpdateWhereClauseForOuterJoinWalker, + return expression_tree_walker(node, + UpdateWhereClauseToPushdownRecurringOuterJoinWalker, relationShardList); } @@ -351,7 +353,7 @@ UpdateWhereClauseForOuterJoinWalker(Node *node, List *relationShardList) /* - * UpdateWhereClauseForOuterJoin + * UpdateWhereClauseToPushdownRecurringOuterJoin * * Inject shard interval predicates into the query WHERE clause for certain * outer joins to make the join semantically correct when distributed. @@ -367,7 +369,7 @@ UpdateWhereClauseForOuterJoinWalker(Node *node, List *relationShardList) * * What the function does: * 1. Iterate over the top-level jointree->fromlist. - * 2. For each JoinExpr call CheckPushDownFeasibilityAndComputeIndexes() which: + * 2. For each JoinExpr call CanPushdownRecurringOuterJoinExtended() which: * - Verifies shape / join type is eligible. * - Returns: * outerRtIndex : RT index whose column we will constrain, @@ -376,7 +378,7 @@ UpdateWhereClauseForOuterJoinWalker(Node *node, List *relationShardList) * This is compared to partition column of innerRte. * 3. Find the RelationShard for the inner distributed table (innerRte->relid) * in relationShardList; skip if absent (no fixed shard chosen). - * 4. Build the shard qualification with DefineQualsForShardInterval(): + * 4. Build the shard qualification with CreateQualsForShardInterval(): * (minValue < hash(partcol) AND hash(partcol) <= maxValue) * and, for the first shard only, OR (partcol IS NULL). * The Var refers to (outerRtIndex, attnum) so the restriction applies to @@ -386,7 +388,7 @@ UpdateWhereClauseForOuterJoinWalker(Node *node, List *relationShardList) * The function does not return anything, it modifies the query in place. */ void -UpdateWhereClauseForOuterJoin(Query *query, List *relationShardList) +UpdateWhereClauseToPushdownRecurringOuterJoin(Query *query, List *relationShardList) { if (query == NULL) { @@ -416,8 +418,8 @@ UpdateWhereClauseForOuterJoin(Query *query, List *relationShardList) RangeTblEntry *outerRte = NULL; int outerRtIndex = -1; int attnum; - if (!CheckPushDownFeasibilityAndComputeIndexes(joinExpr, query, &outerRtIndex, - &outerRte, &innerRte, &attnum)) + if (!CanPushdownRecurringOuterJoinExtended(joinExpr, query, &outerRtIndex, + &outerRte, &innerRte, &attnum)) { continue; } @@ -438,7 +440,7 @@ UpdateWhereClauseForOuterJoin(Query *query, List *relationShardList) continue; } - Node *shardIntervalBoundQuals = DefineQualsForShardInterval(relationShard, attnum, + Node *shardIntervalBoundQuals = CreateQualsForShardInterval(relationShard, attnum, outerRtIndex); if (fromExpr->quals == NULL) { diff --git a/src/backend/distributed/planner/multi_physical_planner.c b/src/backend/distributed/planner/multi_physical_planner.c index 7758a1185..c270ce68f 100644 --- a/src/backend/distributed/planner/multi_physical_planner.c +++ b/src/backend/distributed/planner/multi_physical_planner.c @@ -2622,7 +2622,8 @@ QueryPushdownTaskCreate(Query *originalQuery, int shardIndex, if (updateQualsForOuterJoin) { - UpdateWhereClauseForOuterJoinWalker((Node *) taskQuery, relationShardList); + UpdateWhereClauseToPushdownRecurringOuterJoinWalker((Node *) taskQuery, + relationShardList); } diff --git a/src/backend/distributed/planner/recursive_planning.c b/src/backend/distributed/planner/recursive_planning.c index 4f04eb38f..856b09b3c 100644 --- a/src/backend/distributed/planner/recursive_planning.c +++ b/src/backend/distributed/planner/recursive_planning.c @@ -2859,7 +2859,7 @@ JoinTreeContainsLateral(Node *node, List *rtable) /* - * CheckPushDownFeasibilityAndComputeIndexes checks if the given join expression + * CanPushdownRecurringOuterJoinExtended checks if the given join expression * is an outer join between recurring rel -on outer part- and a distributed * rel -on the inner side- and if it is feasible to push down the join. If feasible, * it computes the outer relation's range table index, the outer relation's @@ -2867,9 +2867,9 @@ JoinTreeContainsLateral(Node *node, List *rtable) * attribute number of the partition column in the outer relation. */ bool -CheckPushDownFeasibilityAndComputeIndexes(JoinExpr *joinExpr, Query *query, - int *outerRtIndex, RangeTblEntry **outerRte, - RangeTblEntry **distRte, int *attnum) +CanPushdownRecurringOuterJoinExtended(JoinExpr *joinExpr, Query *query, + int *outerRtIndex, RangeTblEntry **outerRte, + RangeTblEntry **distRte, int *attnum) { if (!EnableRecurringOuterJoinPushdown) { @@ -3013,8 +3013,8 @@ CheckPushDownFeasibilityAndComputeIndexes(JoinExpr *joinExpr, Query *query, /* * CanPushdownRecurringOuterJoin initializes input variables to call - * CheckPushDownFeasibilityAndComputeIndexes. - * See CheckPushDownFeasibilityAndComputeIndexes for more details. + * CanPushdownRecurringOuterJoinExtended. + * See CanPushdownRecurringOuterJoinExtended for more details. */ bool CanPushdownRecurringOuterJoin(JoinExpr *joinExpr, Query *query) @@ -3023,6 +3023,6 @@ CanPushdownRecurringOuterJoin(JoinExpr *joinExpr, Query *query) RangeTblEntry *outerRte = NULL; RangeTblEntry *innerRte = NULL; int attnum; - return CheckPushDownFeasibilityAndComputeIndexes(joinExpr, query, &outerRtIndex, - &outerRte, &innerRte, &attnum); + return CanPushdownRecurringOuterJoinExtended(joinExpr, query, &outerRtIndex, + &outerRte, &innerRte, &attnum); } diff --git a/src/include/distributed/deparse_shard_query.h b/src/include/distributed/deparse_shard_query.h index d5d0ae2d2..751f3bf50 100644 --- a/src/include/distributed/deparse_shard_query.h +++ b/src/include/distributed/deparse_shard_query.h @@ -25,10 +25,12 @@ extern void RebuildQueryStrings(Job *workerJob); extern bool UpdateRelationToShardNames(Node *node, List *relationShardList); -extern void UpdateWhereClauseForOuterJoin(Query *query, List *relationShardList); -extern bool UpdateWhereClauseForOuterJoinWalker(Node *node, List *relationShardList); -Node * DefineQualsForShardInterval(RelationShard *relationShard, int attnum, int - outerRtIndex); +extern void UpdateWhereClauseToPushdownRecurringOuterJoin(Query *query, + List *relationShardList); +extern bool UpdateWhereClauseToPushdownRecurringOuterJoinWalker(Node *node, + List *relationShardList); +Node * CreateQualsForShardInterval(RelationShard *relationShard, int attnum, + int outerRtIndex); extern void SetTaskQueryIfShouldLazyDeparse(Task *task, Query *query); extern void SetTaskQueryString(Task *task, char *queryString); extern void SetTaskQueryStringList(Task *task, List *queryStringList); diff --git a/src/include/distributed/recursive_planning.h b/src/include/distributed/recursive_planning.h index c03a2ab97..219e8b745 100644 --- a/src/include/distributed/recursive_planning.h +++ b/src/include/distributed/recursive_planning.h @@ -54,11 +54,11 @@ extern bool IsRecursivelyPlannableRelation(RangeTblEntry *rangeTableEntry); extern bool IsRelationLocalTableOrMatView(Oid relationId); extern bool ContainsReferencesToOuterQuery(Query *query); extern void UpdateVarNosInNode(Node *node, Index newVarNo); -extern bool CheckPushDownFeasibilityAndComputeIndexes(JoinExpr *joinExpr, Query *query, - int *outerRtIndex, - RangeTblEntry **outerRte, - RangeTblEntry **distRte, - int *attnum); +extern bool CanPushdownRecurringOuterJoinExtended(JoinExpr *joinExpr, Query *query, + int *outerRtIndex, + RangeTblEntry **outerRte, + RangeTblEntry **distRte, + int *attnum); bool ResolveBaseVarFromSubquery(Var *var, Query *query, Var **baseVar, RangeTblEntry **baseRte); #endif /* RECURSIVE_PLANNING_H */