Rename WorkersContainingAllShards to PlacementsForWorkersContainingAllShards

pull/3887/head
Marco Slot 2020-06-12 17:11:55 +02:00 committed by Hadi Moshayedi
parent 080f711e62
commit 4f7989ad8e
3 changed files with 11 additions and 15 deletions

View File

@ -2646,7 +2646,7 @@ QueryPushdownTaskCreate(Query *originalQuery, int shardIndex,
Assert(anchorShardId != INVALID_SHARD_ID); Assert(anchorShardId != INVALID_SHARD_ID);
List *selectPlacementList = WorkersContainingAllShards(taskShardList); List *selectPlacementList = PlacementsForWorkersContainingAllShards(taskShardList);
if (list_length(selectPlacementList) == 0) if (list_length(selectPlacementList) == 0)
{ {
ereport(ERROR, (errmsg("cannot find a worker that has active placements for all " ereport(ERROR, (errmsg("cannot find a worker that has active placements for all "

View File

@ -2197,7 +2197,8 @@ CreateTaskPlacementListForShardIntervals(List *shardIntervalListList, bool shard
/* /*
* Determine the workers that have all shard placements, if any. * Determine the workers that have all shard placements, if any.
*/ */
List *workerList = WorkersContainingAllShards(shardIntervalListList); List *shardPlacementList =
PlacementsForWorkersContainingAllShards(shardIntervalListList);
if (hasLocalRelation) if (hasLocalRelation)
{ {
@ -2207,9 +2208,8 @@ CreateTaskPlacementListForShardIntervals(List *shardIntervalListList, bool shard
* If there is a local table, we only allow the local placement to * If there is a local table, we only allow the local placement to
* be used. If there is none, we disallow the query. * 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()) if (taskPlacement->groupId == GetLocalGroupId())
{ {
placementList = lappend(placementList, taskPlacement); placementList = lappend(placementList, taskPlacement);
@ -2218,7 +2218,7 @@ CreateTaskPlacementListForShardIntervals(List *shardIntervalListList, bool shard
} }
else else
{ {
placementList = workerList; placementList = shardPlacementList;
} }
} }
else if (generateDummyPlacement) else if (generateDummyPlacement)
@ -2586,22 +2586,18 @@ RelationPrunesToMultipleShards(List *relationShardList)
/* /*
* WorkersContainingSelectShards returns list of shard placements that contain all * PlacementsForWorkersContainingAllShards returns list of shard placements for workers
* shard intervals provided to the select query. It returns NIL if no placement * that contain all shard intervals in the given list of shard interval lists.
* exists. The caller should check if there are any shard intervals exist for
* placement check prior to calling this function.
*/ */
List * List *
WorkersContainingAllShards(List *prunedShardIntervalsList) PlacementsForWorkersContainingAllShards(List *shardIntervalListList)
{ {
ListCell *prunedShardIntervalCell = NULL;
bool firstShard = true; bool firstShard = true;
List *currentPlacementList = NIL; List *currentPlacementList = NIL;
List *shardIntervalList = NIL;
foreach(prunedShardIntervalCell, prunedShardIntervalsList) foreach_ptr(shardIntervalList, shardIntervalListList)
{ {
List *shardIntervalList = (List *) lfirst(prunedShardIntervalCell);
if (shardIntervalList == NIL) if (shardIntervalList == NIL)
{ {
continue; continue;

View File

@ -56,7 +56,7 @@ extern List * TargetShardIntervalsForRestrictInfo(RelationRestrictionContext *
restrictionContext, restrictionContext,
bool *multiShardQuery, bool *multiShardQuery,
Const **partitionValueConst); Const **partitionValueConst);
extern List * WorkersContainingAllShards(List *prunedShardIntervalsList); extern List * PlacementsForWorkersContainingAllShards(List *shardIntervalListList);
extern List * IntersectPlacementList(List *lhsPlacementList, List *rhsPlacementList); extern List * IntersectPlacementList(List *lhsPlacementList, List *rhsPlacementList);
extern DeferredErrorMessage * ModifyQuerySupported(Query *queryTree, Query *originalQuery, extern DeferredErrorMessage * ModifyQuerySupported(Query *queryTree, Query *originalQuery,
bool multiShardQuery, bool multiShardQuery,