implement CanHaveReferenceTablePlacements

improve-drop-trigger2
Onur Tirtir 2020-02-05 03:04:38 +03:00
parent 24dd4ca64f
commit df95b5fe6e
1 changed files with 22 additions and 0 deletions

View File

@ -46,6 +46,7 @@ static WorkerNode * FindRandomNodeFromList(List *candidateWorkerNodeList);
static bool OddNumber(uint32 number); static bool OddNumber(uint32 number);
static bool ListMember(List *currentList, WorkerNode *workerNode); static bool ListMember(List *currentList, WorkerNode *workerNode);
static bool NodeIsPrimaryWorker(WorkerNode *node); static bool NodeIsPrimaryWorker(WorkerNode *node);
static bool CanHaveReferenceTablePlacements(void);
static bool NodeIsReadableWorker(WorkerNode *node); static bool NodeIsReadableWorker(WorkerNode *node);
@ -401,6 +402,27 @@ NodeIsPrimaryWorker(WorkerNode *node)
} }
/*
* CanHaveReferenceTablePlacements returns true if current node can have
* reference table placements. This is only possible if we called below
* command formerly
* "SELECT master_add_node(coordinator_hostname, coordinator_port, groupId => 0)"
*/
static bool
CanHaveReferenceTablePlacements()
{
bool hasReferenceTableReplica = false;
/*
* All groups that have pg_dist_node entries, also have reference
* table placements.
*/
PrimaryNodeForGroup(GetLocalGroupId(), &hasReferenceTableReplica);
return hasReferenceTableReplica;
}
/* /*
* ReferenceTablePlacementNodeList returns the set of nodes that should have * ReferenceTablePlacementNodeList returns the set of nodes that should have
* reference table placements. This includes all primaries, including the * reference table placements. This includes all primaries, including the