Merge pull request #4006 from citusdata/orerror-instead-of-force

Rename ForceXxx functions to to XxxOrError
pull/4136/head
Jelte Fennema 2020-09-01 11:56:52 +02:00 committed by GitHub
commit f38d24f8fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 40 additions and 37 deletions

View File

@ -843,7 +843,7 @@ EnsureTableCanBeColocatedWith(Oid relationId, char replicationModel,
CitusTableCacheEntry *sourceTableEntry = GetCitusTableCacheEntry(sourceRelationId);
char sourceDistributionMethod = sourceTableEntry->partitionMethod;
char sourceReplicationModel = sourceTableEntry->replicationModel;
Var *sourceDistributionColumn = ForceDistPartitionKey(sourceRelationId);
Var *sourceDistributionColumn = DistPartitionKeyOrError(sourceRelationId);
if (sourceDistributionMethod != DISTRIBUTE_BY_HASH)
{

View File

@ -546,7 +546,7 @@ EnsureFunctionCanBeColocatedWithTable(Oid functionOid, Oid distributionColumnTyp
* If the types are the same, we're good. If not, we still check if there
* is any coercion path between the types.
*/
Var *sourceDistributionColumn = ForceDistPartitionKey(sourceRelationId);
Var *sourceDistributionColumn = DistPartitionKeyOrError(sourceRelationId);
Oid sourceDistributionColumnType = sourceDistributionColumn->vartype;
if (sourceDistributionColumnType != distributionColumnType)
{

View File

@ -819,7 +819,7 @@ ErrorIfUnsupportedIndexStmt(IndexStmt *createIndexStatement)
"is currently unsupported")));
}
Var *partitionKey = ForceDistPartitionKey(relationId);
Var *partitionKey = DistPartitionKeyOrError(relationId);
List *indexParameterList = createIndexStatement->indexParams;
IndexElem *indexElement = NULL;
foreach_ptr(indexElement, indexParameterList)

View File

@ -165,7 +165,7 @@ PostprocessCreateTableStmtPartitionOf(CreateStmt *createStatement, const
bool missingOk = false;
Oid relationId = RangeVarGetRelid(createStatement->relation, NoLock,
missingOk);
Var *parentDistributionColumn = ForceDistPartitionKey(parentRelationId);
Var *parentDistributionColumn = DistPartitionKeyOrError(parentRelationId);
char parentDistributionMethod = DISTRIBUTE_BY_HASH;
char *parentRelationName = generate_qualified_relation_name(parentRelationId);
bool viaDeprecatedAPI = false;
@ -242,7 +242,7 @@ PostprocessAlterTableStmtAttachPartition(AlterTableStmt *alterTableStatement,
if (IsCitusTable(relationId) &&
!IsCitusTable(partitionRelationId))
{
Var *distributionColumn = ForceDistPartitionKey(relationId);
Var *distributionColumn = DistPartitionKeyOrError(relationId);
char distributionMethod = DISTRIBUTE_BY_HASH;
char *parentRelationName = generate_qualified_relation_name(relationId);
bool viaDeprecatedAPI = false;

View File

@ -609,7 +609,7 @@ FragmentTransferTaskList(List *fragmentListTransfers)
/* these should have already been pruned away in ColocationTransfers */
Assert(targetNodeId != fragmentsTransfer->nodes.sourceNodeId);
WorkerNode *workerNode = ForceLookupNodeByNodeId(targetNodeId);
WorkerNode *workerNode = LookupNodeByNodeIdOrError(targetNodeId);
ShardPlacement *targetPlacement = CitusMakeNode(ShardPlacement);
SetPlacementNodeMetadata(targetPlacement, workerNode);
@ -638,7 +638,7 @@ QueryStringForFragmentsTransfer(NodeToNodeFragmentsTransfer *fragmentsTransfer)
StringInfo fragmentNamesArrayString = makeStringInfo();
int fragmentCount = 0;
NodePair *nodePair = &fragmentsTransfer->nodes;
WorkerNode *sourceNode = ForceLookupNodeByNodeId(nodePair->sourceNodeId);
WorkerNode *sourceNode = LookupNodeByNodeIdOrError(nodePair->sourceNodeId);
appendStringInfoString(fragmentNamesArrayString, "ARRAY[");

View File

@ -586,11 +586,11 @@ LookupNodeByNodeId(uint32 nodeId)
/*
* ForceLookupNodeByNodeId returns a worker node by nodeId or errors out if the
* LookupNodeByNodeIdOrError returns a worker node by nodeId or errors out if the
* node cannot be found.
*/
WorkerNode *
ForceLookupNodeByNodeId(uint32 nodeId)
LookupNodeByNodeIdOrError(uint32 nodeId)
{
WorkerNode *node = LookupNodeByNodeId(nodeId);
if (node == NULL)

View File

@ -898,7 +898,7 @@ get_shard_id_for_distribution_column(PG_FUNCTION_ARGS)
Oid inputDataType = get_fn_expr_argtype(fcinfo->flinfo, 1);
char *distributionValueString = DatumToString(inputDatum, inputDataType);
Var *distributionColumn = ForceDistPartitionKey(relationId);
Var *distributionColumn = DistPartitionKeyOrError(relationId);
Oid distributionDataType = distributionColumn->vartype;
Datum distributionValueDatum = StringToDatum(distributionValueString,
@ -957,7 +957,7 @@ FindWorkerNode(const char *nodeName, int32 nodePort)
* if it exists otherwise it errors out.
*/
WorkerNode *
ForceFindWorkerNode(const char *nodeName, int32 nodePort)
FindWorkerNodeOrError(const char *nodeName, int32 nodePort)
{
WorkerNode *node = FindWorkerNode(nodeName, nodePort);
if (node == NULL)

View File

@ -686,7 +686,7 @@ CheckDeleteCriteria(Node *deleteCriteria)
static void
CheckPartitionColumn(Oid relationId, Node *whereClause)
{
Var *partitionColumn = ForceDistPartitionKey(relationId);
Var *partitionColumn = DistPartitionKeyOrError(relationId);
List *columnList = pull_var_clause_default(whereClause);
Var *var = NULL;

View File

@ -364,9 +364,9 @@ RepairShardPlacement(int64 shardId, const char *sourceNodeName, int32 sourceNode
/* after successful repair, we update shard state as healthy*/
List *placementList = ShardPlacementList(shardId);
ShardPlacement *placement = ForceSearchShardPlacementInList(placementList,
targetNodeName,
targetNodePort);
ShardPlacement *placement = SearchShardPlacementInListOrError(placementList,
targetNodeName,
targetNodePort);
UpdateShardPlacementState(placement->placementId, SHARD_STATE_ACTIVE);
}
@ -633,18 +633,20 @@ EnsureShardCanBeRepaired(int64 shardId, const char *sourceNodeName, int32 source
{
List *shardPlacementList = ShardPlacementList(shardId);
ShardPlacement *sourcePlacement = ForceSearchShardPlacementInList(shardPlacementList,
sourceNodeName,
sourceNodePort);
ShardPlacement *sourcePlacement = SearchShardPlacementInListOrError(
shardPlacementList,
sourceNodeName,
sourceNodePort);
if (sourcePlacement->shardState != SHARD_STATE_ACTIVE)
{
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("source placement must be in active state")));
}
ShardPlacement *targetPlacement = ForceSearchShardPlacementInList(shardPlacementList,
targetNodeName,
targetNodePort);
ShardPlacement *targetPlacement = SearchShardPlacementInListOrError(
shardPlacementList,
targetNodeName,
targetNodePort);
if (targetPlacement->shardState != SHARD_STATE_INACTIVE)
{
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
@ -663,9 +665,10 @@ EnsureShardCanBeCopied(int64 shardId, const char *sourceNodeName, int32 sourceNo
{
List *shardPlacementList = ShardPlacementList(shardId);
ShardPlacement *sourcePlacement = ForceSearchShardPlacementInList(shardPlacementList,
sourceNodeName,
sourceNodePort);
ShardPlacement *sourcePlacement = SearchShardPlacementInListOrError(
shardPlacementList,
sourceNodeName,
sourceNodePort);
if (sourcePlacement->shardState != SHARD_STATE_ACTIVE)
{
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
@ -707,7 +710,7 @@ SearchShardPlacementInList(List *shardPlacementList, const char *nodeName,
/*
* ForceSearchShardPlacementInList searches a provided list for a shard
* SearchShardPlacementInListOrError searches a provided list for a shard
* placement with the specified node name and port. This function throws an
* error if no such placement exists in the provided list.
*
@ -715,8 +718,8 @@ SearchShardPlacementInList(List *shardPlacementList, const char *nodeName,
* reasons about NULL returns correctly.
*/
ShardPlacement *
ForceSearchShardPlacementInList(List *shardPlacementList, const char *nodeName,
uint32 nodePort)
SearchShardPlacementInListOrError(List *shardPlacementList, const char *nodeName,
uint32 nodePort)
{
ShardPlacement *placement = SearchShardPlacementInList(shardPlacementList, nodeName,
nodePort);

View File

@ -1396,11 +1396,11 @@ DistPartitionKey(Oid relationId)
/*
* ForceDistPartitionKey is the same as DistPartitionKey but errors out instead
* DistPartitionKeyOrError is the same as DistPartitionKey but errors out instead
* of returning NULL if this is called with a relationId of a reference table.
*/
Var *
ForceDistPartitionKey(Oid relationId)
DistPartitionKeyOrError(Oid relationId)
{
Var *partitionKey = DistPartitionKey(relationId);

View File

@ -409,7 +409,7 @@ FindUnionAllVar(PlannerInfo *root, List *appendRelList, Oid relationOid,
return NULL;
}
Var *relationPartitionKey = ForceDistPartitionKey(relationOid);
Var *relationPartitionKey = DistPartitionKeyOrError(relationOid);
#if PG_VERSION_NUM >= PG_VERSION_13
for (; childAttrNumber < targetAppendRelInfo->num_child_cols; childAttrNumber++)

View File

@ -46,7 +46,7 @@ store_intermediate_result_on_node(PG_FUNCTION_ARGS)
CheckCitusVersion(ERROR);
WorkerNode *workerNode = ForceFindWorkerNode(nodeNameString, nodePort);
WorkerNode *workerNode = FindWorkerNodeOrError(nodeNameString, nodePort);
/*
* Make sure that this transaction has a distributed transaction ID.

View File

@ -173,8 +173,8 @@ extern void CopyShardForeignConstraintCommandListGrouped(ShardInterval *shardInt
referenceTableForeignConstraintList);
extern ShardPlacement * SearchShardPlacementInList(List *shardPlacementList,
const char *nodeName, uint32 nodePort);
extern ShardPlacement * ForceSearchShardPlacementInList(List *shardPlacementList,
const char *nodeName,
uint32 nodePort);
extern ShardPlacement * SearchShardPlacementInListOrError(List *shardPlacementList,
const char *nodeName,
uint32 nodePort);
#endif /* COORDINATOR_PROTOCOL_H */

View File

@ -169,7 +169,7 @@ extern char LookupDistributionMethod(Oid distributionMethodOid);
/* access WorkerNodeHash */
extern HTAB * GetWorkerNodeHash(void);
extern WorkerNode * LookupNodeByNodeId(uint32 nodeId);
extern WorkerNode * ForceLookupNodeByNodeId(uint32 nodeId);
extern WorkerNode * LookupNodeByNodeIdOrError(uint32 nodeId);
extern WorkerNode * LookupNodeForGroup(int32 groupId);
/* namespace oids */

View File

@ -105,7 +105,7 @@ extern Var * LeftColumnOrNULL(OpExpr *joinClause);
extern Var * RightColumnOrNULL(OpExpr *joinClause);
extern Var * PartitionColumn(Oid relationId, uint32 rangeTableId);
extern Var * DistPartitionKey(Oid relationId);
extern Var * ForceDistPartitionKey(Oid relationId);
extern Var * DistPartitionKeyOrError(Oid relationId);
extern char PartitionMethod(Oid relationId);
extern char TableReplicationModel(Oid relationId);

View File

@ -80,7 +80,7 @@ extern uint32 ActiveReadableNonCoordinatorNodeCount(void);
extern List * ActiveReadableNonCoordinatorNodeList(void);
extern List * ActiveReadableNodeList(void);
extern WorkerNode * FindWorkerNode(const char *nodeName, int32 nodePort);
extern WorkerNode * ForceFindWorkerNode(const char *nodeName, int32 nodePort);
extern WorkerNode * FindWorkerNodeOrError(const char *nodeName, int32 nodePort);
extern WorkerNode * FindWorkerNodeAnyCluster(const char *nodeName, int32 nodePort);
extern List * ReadDistNode(bool includeNodesFromOtherClusters);
extern void EnsureCoordinator(void);