From 4f7989ad8e3a58ead53106b13f818847a8fea630 Mon Sep 17 00:00:00 2001 From: Marco Slot Date: Fri, 12 Jun 2020 17:11:55 +0200 Subject: [PATCH] Rename WorkersContainingAllShards to PlacementsForWorkersContainingAllShards --- .../planner/multi_physical_planner.c | 2 +- .../planner/multi_router_planner.c | 22 ++++++++----------- .../distributed/multi_router_planner.h | 2 +- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/backend/distributed/planner/multi_physical_planner.c b/src/backend/distributed/planner/multi_physical_planner.c index 1e98892e0..e9582bab8 100644 --- a/src/backend/distributed/planner/multi_physical_planner.c +++ b/src/backend/distributed/planner/multi_physical_planner.c @@ -2646,7 +2646,7 @@ QueryPushdownTaskCreate(Query *originalQuery, int shardIndex, Assert(anchorShardId != INVALID_SHARD_ID); - List *selectPlacementList = WorkersContainingAllShards(taskShardList); + List *selectPlacementList = PlacementsForWorkersContainingAllShards(taskShardList); if (list_length(selectPlacementList) == 0) { ereport(ERROR, (errmsg("cannot find a worker that has active placements for all " diff --git a/src/backend/distributed/planner/multi_router_planner.c b/src/backend/distributed/planner/multi_router_planner.c index 0b1e35be4..a08d4c5f0 100644 --- a/src/backend/distributed/planner/multi_router_planner.c +++ b/src/backend/distributed/planner/multi_router_planner.c @@ -2197,7 +2197,8 @@ CreateTaskPlacementListForShardIntervals(List *shardIntervalListList, bool shard /* * Determine the workers that have all shard placements, if any. */ - List *workerList = WorkersContainingAllShards(shardIntervalListList); + List *shardPlacementList = + PlacementsForWorkersContainingAllShards(shardIntervalListList); if (hasLocalRelation) { @@ -2207,9 +2208,8 @@ CreateTaskPlacementListForShardIntervals(List *shardIntervalListList, bool shard * If there is a local table, we only allow the local placement to * be used. If there is none, we disallow the query. */ - foreach_ptr(taskPlacement, workerList) + foreach_ptr(taskPlacement, shardPlacementList) { - /* include only the local placement */ if (taskPlacement->groupId == GetLocalGroupId()) { placementList = lappend(placementList, taskPlacement); @@ -2218,7 +2218,7 @@ CreateTaskPlacementListForShardIntervals(List *shardIntervalListList, bool shard } else { - placementList = workerList; + placementList = shardPlacementList; } } else if (generateDummyPlacement) @@ -2586,22 +2586,18 @@ RelationPrunesToMultipleShards(List *relationShardList) /* - * WorkersContainingSelectShards returns list of shard placements that contain all - * shard intervals provided to the select query. It returns NIL if no placement - * exists. The caller should check if there are any shard intervals exist for - * placement check prior to calling this function. + * PlacementsForWorkersContainingAllShards returns list of shard placements for workers + * that contain all shard intervals in the given list of shard interval lists. */ List * -WorkersContainingAllShards(List *prunedShardIntervalsList) +PlacementsForWorkersContainingAllShards(List *shardIntervalListList) { - ListCell *prunedShardIntervalCell = NULL; bool firstShard = true; List *currentPlacementList = NIL; + List *shardIntervalList = NIL; - foreach(prunedShardIntervalCell, prunedShardIntervalsList) + foreach_ptr(shardIntervalList, shardIntervalListList) { - List *shardIntervalList = (List *) lfirst(prunedShardIntervalCell); - if (shardIntervalList == NIL) { continue; diff --git a/src/include/distributed/multi_router_planner.h b/src/include/distributed/multi_router_planner.h index 50fdd7d90..62f033fe4 100644 --- a/src/include/distributed/multi_router_planner.h +++ b/src/include/distributed/multi_router_planner.h @@ -56,7 +56,7 @@ extern List * TargetShardIntervalsForRestrictInfo(RelationRestrictionContext * restrictionContext, bool *multiShardQuery, Const **partitionValueConst); -extern List * WorkersContainingAllShards(List *prunedShardIntervalsList); +extern List * PlacementsForWorkersContainingAllShards(List *shardIntervalListList); extern List * IntersectPlacementList(List *lhsPlacementList, List *rhsPlacementList); extern DeferredErrorMessage * ModifyQuerySupported(Query *queryTree, Query *originalQuery, bool multiShardQuery,