mirror of https://github.com/citusdata/citus.git
Merge pull request #4006 from citusdata/orerror-instead-of-force
Rename ForceXxx functions to to XxxOrErrorpull/4136/head
commit
f38d24f8fb
|
@ -843,7 +843,7 @@ EnsureTableCanBeColocatedWith(Oid relationId, char replicationModel,
|
||||||
CitusTableCacheEntry *sourceTableEntry = GetCitusTableCacheEntry(sourceRelationId);
|
CitusTableCacheEntry *sourceTableEntry = GetCitusTableCacheEntry(sourceRelationId);
|
||||||
char sourceDistributionMethod = sourceTableEntry->partitionMethod;
|
char sourceDistributionMethod = sourceTableEntry->partitionMethod;
|
||||||
char sourceReplicationModel = sourceTableEntry->replicationModel;
|
char sourceReplicationModel = sourceTableEntry->replicationModel;
|
||||||
Var *sourceDistributionColumn = ForceDistPartitionKey(sourceRelationId);
|
Var *sourceDistributionColumn = DistPartitionKeyOrError(sourceRelationId);
|
||||||
|
|
||||||
if (sourceDistributionMethod != DISTRIBUTE_BY_HASH)
|
if (sourceDistributionMethod != DISTRIBUTE_BY_HASH)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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
|
* If the types are the same, we're good. If not, we still check if there
|
||||||
* is any coercion path between the types.
|
* is any coercion path between the types.
|
||||||
*/
|
*/
|
||||||
Var *sourceDistributionColumn = ForceDistPartitionKey(sourceRelationId);
|
Var *sourceDistributionColumn = DistPartitionKeyOrError(sourceRelationId);
|
||||||
Oid sourceDistributionColumnType = sourceDistributionColumn->vartype;
|
Oid sourceDistributionColumnType = sourceDistributionColumn->vartype;
|
||||||
if (sourceDistributionColumnType != distributionColumnType)
|
if (sourceDistributionColumnType != distributionColumnType)
|
||||||
{
|
{
|
||||||
|
|
|
@ -819,7 +819,7 @@ ErrorIfUnsupportedIndexStmt(IndexStmt *createIndexStatement)
|
||||||
"is currently unsupported")));
|
"is currently unsupported")));
|
||||||
}
|
}
|
||||||
|
|
||||||
Var *partitionKey = ForceDistPartitionKey(relationId);
|
Var *partitionKey = DistPartitionKeyOrError(relationId);
|
||||||
List *indexParameterList = createIndexStatement->indexParams;
|
List *indexParameterList = createIndexStatement->indexParams;
|
||||||
IndexElem *indexElement = NULL;
|
IndexElem *indexElement = NULL;
|
||||||
foreach_ptr(indexElement, indexParameterList)
|
foreach_ptr(indexElement, indexParameterList)
|
||||||
|
|
|
@ -165,7 +165,7 @@ PostprocessCreateTableStmtPartitionOf(CreateStmt *createStatement, const
|
||||||
bool missingOk = false;
|
bool missingOk = false;
|
||||||
Oid relationId = RangeVarGetRelid(createStatement->relation, NoLock,
|
Oid relationId = RangeVarGetRelid(createStatement->relation, NoLock,
|
||||||
missingOk);
|
missingOk);
|
||||||
Var *parentDistributionColumn = ForceDistPartitionKey(parentRelationId);
|
Var *parentDistributionColumn = DistPartitionKeyOrError(parentRelationId);
|
||||||
char parentDistributionMethod = DISTRIBUTE_BY_HASH;
|
char parentDistributionMethod = DISTRIBUTE_BY_HASH;
|
||||||
char *parentRelationName = generate_qualified_relation_name(parentRelationId);
|
char *parentRelationName = generate_qualified_relation_name(parentRelationId);
|
||||||
bool viaDeprecatedAPI = false;
|
bool viaDeprecatedAPI = false;
|
||||||
|
@ -242,7 +242,7 @@ PostprocessAlterTableStmtAttachPartition(AlterTableStmt *alterTableStatement,
|
||||||
if (IsCitusTable(relationId) &&
|
if (IsCitusTable(relationId) &&
|
||||||
!IsCitusTable(partitionRelationId))
|
!IsCitusTable(partitionRelationId))
|
||||||
{
|
{
|
||||||
Var *distributionColumn = ForceDistPartitionKey(relationId);
|
Var *distributionColumn = DistPartitionKeyOrError(relationId);
|
||||||
char distributionMethod = DISTRIBUTE_BY_HASH;
|
char distributionMethod = DISTRIBUTE_BY_HASH;
|
||||||
char *parentRelationName = generate_qualified_relation_name(relationId);
|
char *parentRelationName = generate_qualified_relation_name(relationId);
|
||||||
bool viaDeprecatedAPI = false;
|
bool viaDeprecatedAPI = false;
|
||||||
|
|
|
@ -609,7 +609,7 @@ FragmentTransferTaskList(List *fragmentListTransfers)
|
||||||
/* these should have already been pruned away in ColocationTransfers */
|
/* these should have already been pruned away in ColocationTransfers */
|
||||||
Assert(targetNodeId != fragmentsTransfer->nodes.sourceNodeId);
|
Assert(targetNodeId != fragmentsTransfer->nodes.sourceNodeId);
|
||||||
|
|
||||||
WorkerNode *workerNode = ForceLookupNodeByNodeId(targetNodeId);
|
WorkerNode *workerNode = LookupNodeByNodeIdOrError(targetNodeId);
|
||||||
|
|
||||||
ShardPlacement *targetPlacement = CitusMakeNode(ShardPlacement);
|
ShardPlacement *targetPlacement = CitusMakeNode(ShardPlacement);
|
||||||
SetPlacementNodeMetadata(targetPlacement, workerNode);
|
SetPlacementNodeMetadata(targetPlacement, workerNode);
|
||||||
|
@ -638,7 +638,7 @@ QueryStringForFragmentsTransfer(NodeToNodeFragmentsTransfer *fragmentsTransfer)
|
||||||
StringInfo fragmentNamesArrayString = makeStringInfo();
|
StringInfo fragmentNamesArrayString = makeStringInfo();
|
||||||
int fragmentCount = 0;
|
int fragmentCount = 0;
|
||||||
NodePair *nodePair = &fragmentsTransfer->nodes;
|
NodePair *nodePair = &fragmentsTransfer->nodes;
|
||||||
WorkerNode *sourceNode = ForceLookupNodeByNodeId(nodePair->sourceNodeId);
|
WorkerNode *sourceNode = LookupNodeByNodeIdOrError(nodePair->sourceNodeId);
|
||||||
|
|
||||||
appendStringInfoString(fragmentNamesArrayString, "ARRAY[");
|
appendStringInfoString(fragmentNamesArrayString, "ARRAY[");
|
||||||
|
|
||||||
|
|
|
@ -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.
|
* node cannot be found.
|
||||||
*/
|
*/
|
||||||
WorkerNode *
|
WorkerNode *
|
||||||
ForceLookupNodeByNodeId(uint32 nodeId)
|
LookupNodeByNodeIdOrError(uint32 nodeId)
|
||||||
{
|
{
|
||||||
WorkerNode *node = LookupNodeByNodeId(nodeId);
|
WorkerNode *node = LookupNodeByNodeId(nodeId);
|
||||||
if (node == NULL)
|
if (node == NULL)
|
||||||
|
|
|
@ -898,7 +898,7 @@ get_shard_id_for_distribution_column(PG_FUNCTION_ARGS)
|
||||||
Oid inputDataType = get_fn_expr_argtype(fcinfo->flinfo, 1);
|
Oid inputDataType = get_fn_expr_argtype(fcinfo->flinfo, 1);
|
||||||
char *distributionValueString = DatumToString(inputDatum, inputDataType);
|
char *distributionValueString = DatumToString(inputDatum, inputDataType);
|
||||||
|
|
||||||
Var *distributionColumn = ForceDistPartitionKey(relationId);
|
Var *distributionColumn = DistPartitionKeyOrError(relationId);
|
||||||
Oid distributionDataType = distributionColumn->vartype;
|
Oid distributionDataType = distributionColumn->vartype;
|
||||||
|
|
||||||
Datum distributionValueDatum = StringToDatum(distributionValueString,
|
Datum distributionValueDatum = StringToDatum(distributionValueString,
|
||||||
|
@ -957,7 +957,7 @@ FindWorkerNode(const char *nodeName, int32 nodePort)
|
||||||
* if it exists otherwise it errors out.
|
* if it exists otherwise it errors out.
|
||||||
*/
|
*/
|
||||||
WorkerNode *
|
WorkerNode *
|
||||||
ForceFindWorkerNode(const char *nodeName, int32 nodePort)
|
FindWorkerNodeOrError(const char *nodeName, int32 nodePort)
|
||||||
{
|
{
|
||||||
WorkerNode *node = FindWorkerNode(nodeName, nodePort);
|
WorkerNode *node = FindWorkerNode(nodeName, nodePort);
|
||||||
if (node == NULL)
|
if (node == NULL)
|
||||||
|
|
|
@ -686,7 +686,7 @@ CheckDeleteCriteria(Node *deleteCriteria)
|
||||||
static void
|
static void
|
||||||
CheckPartitionColumn(Oid relationId, Node *whereClause)
|
CheckPartitionColumn(Oid relationId, Node *whereClause)
|
||||||
{
|
{
|
||||||
Var *partitionColumn = ForceDistPartitionKey(relationId);
|
Var *partitionColumn = DistPartitionKeyOrError(relationId);
|
||||||
|
|
||||||
List *columnList = pull_var_clause_default(whereClause);
|
List *columnList = pull_var_clause_default(whereClause);
|
||||||
Var *var = NULL;
|
Var *var = NULL;
|
||||||
|
|
|
@ -364,7 +364,7 @@ RepairShardPlacement(int64 shardId, const char *sourceNodeName, int32 sourceNode
|
||||||
|
|
||||||
/* after successful repair, we update shard state as healthy*/
|
/* after successful repair, we update shard state as healthy*/
|
||||||
List *placementList = ShardPlacementList(shardId);
|
List *placementList = ShardPlacementList(shardId);
|
||||||
ShardPlacement *placement = ForceSearchShardPlacementInList(placementList,
|
ShardPlacement *placement = SearchShardPlacementInListOrError(placementList,
|
||||||
targetNodeName,
|
targetNodeName,
|
||||||
targetNodePort);
|
targetNodePort);
|
||||||
UpdateShardPlacementState(placement->placementId, SHARD_STATE_ACTIVE);
|
UpdateShardPlacementState(placement->placementId, SHARD_STATE_ACTIVE);
|
||||||
|
@ -633,7 +633,8 @@ EnsureShardCanBeRepaired(int64 shardId, const char *sourceNodeName, int32 source
|
||||||
{
|
{
|
||||||
List *shardPlacementList = ShardPlacementList(shardId);
|
List *shardPlacementList = ShardPlacementList(shardId);
|
||||||
|
|
||||||
ShardPlacement *sourcePlacement = ForceSearchShardPlacementInList(shardPlacementList,
|
ShardPlacement *sourcePlacement = SearchShardPlacementInListOrError(
|
||||||
|
shardPlacementList,
|
||||||
sourceNodeName,
|
sourceNodeName,
|
||||||
sourceNodePort);
|
sourceNodePort);
|
||||||
if (sourcePlacement->shardState != SHARD_STATE_ACTIVE)
|
if (sourcePlacement->shardState != SHARD_STATE_ACTIVE)
|
||||||
|
@ -642,7 +643,8 @@ EnsureShardCanBeRepaired(int64 shardId, const char *sourceNodeName, int32 source
|
||||||
errmsg("source placement must be in active state")));
|
errmsg("source placement must be in active state")));
|
||||||
}
|
}
|
||||||
|
|
||||||
ShardPlacement *targetPlacement = ForceSearchShardPlacementInList(shardPlacementList,
|
ShardPlacement *targetPlacement = SearchShardPlacementInListOrError(
|
||||||
|
shardPlacementList,
|
||||||
targetNodeName,
|
targetNodeName,
|
||||||
targetNodePort);
|
targetNodePort);
|
||||||
if (targetPlacement->shardState != SHARD_STATE_INACTIVE)
|
if (targetPlacement->shardState != SHARD_STATE_INACTIVE)
|
||||||
|
@ -663,7 +665,8 @@ EnsureShardCanBeCopied(int64 shardId, const char *sourceNodeName, int32 sourceNo
|
||||||
{
|
{
|
||||||
List *shardPlacementList = ShardPlacementList(shardId);
|
List *shardPlacementList = ShardPlacementList(shardId);
|
||||||
|
|
||||||
ShardPlacement *sourcePlacement = ForceSearchShardPlacementInList(shardPlacementList,
|
ShardPlacement *sourcePlacement = SearchShardPlacementInListOrError(
|
||||||
|
shardPlacementList,
|
||||||
sourceNodeName,
|
sourceNodeName,
|
||||||
sourceNodePort);
|
sourceNodePort);
|
||||||
if (sourcePlacement->shardState != SHARD_STATE_ACTIVE)
|
if (sourcePlacement->shardState != SHARD_STATE_ACTIVE)
|
||||||
|
@ -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
|
* placement with the specified node name and port. This function throws an
|
||||||
* error if no such placement exists in the provided list.
|
* error if no such placement exists in the provided list.
|
||||||
*
|
*
|
||||||
|
@ -715,7 +718,7 @@ SearchShardPlacementInList(List *shardPlacementList, const char *nodeName,
|
||||||
* reasons about NULL returns correctly.
|
* reasons about NULL returns correctly.
|
||||||
*/
|
*/
|
||||||
ShardPlacement *
|
ShardPlacement *
|
||||||
ForceSearchShardPlacementInList(List *shardPlacementList, const char *nodeName,
|
SearchShardPlacementInListOrError(List *shardPlacementList, const char *nodeName,
|
||||||
uint32 nodePort)
|
uint32 nodePort)
|
||||||
{
|
{
|
||||||
ShardPlacement *placement = SearchShardPlacementInList(shardPlacementList, nodeName,
|
ShardPlacement *placement = SearchShardPlacementInList(shardPlacementList, nodeName,
|
||||||
|
|
|
@ -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.
|
* of returning NULL if this is called with a relationId of a reference table.
|
||||||
*/
|
*/
|
||||||
Var *
|
Var *
|
||||||
ForceDistPartitionKey(Oid relationId)
|
DistPartitionKeyOrError(Oid relationId)
|
||||||
{
|
{
|
||||||
Var *partitionKey = DistPartitionKey(relationId);
|
Var *partitionKey = DistPartitionKey(relationId);
|
||||||
|
|
||||||
|
|
|
@ -409,7 +409,7 @@ FindUnionAllVar(PlannerInfo *root, List *appendRelList, Oid relationOid,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Var *relationPartitionKey = ForceDistPartitionKey(relationOid);
|
Var *relationPartitionKey = DistPartitionKeyOrError(relationOid);
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_13
|
#if PG_VERSION_NUM >= PG_VERSION_13
|
||||||
for (; childAttrNumber < targetAppendRelInfo->num_child_cols; childAttrNumber++)
|
for (; childAttrNumber < targetAppendRelInfo->num_child_cols; childAttrNumber++)
|
||||||
|
|
|
@ -46,7 +46,7 @@ store_intermediate_result_on_node(PG_FUNCTION_ARGS)
|
||||||
|
|
||||||
CheckCitusVersion(ERROR);
|
CheckCitusVersion(ERROR);
|
||||||
|
|
||||||
WorkerNode *workerNode = ForceFindWorkerNode(nodeNameString, nodePort);
|
WorkerNode *workerNode = FindWorkerNodeOrError(nodeNameString, nodePort);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure that this transaction has a distributed transaction ID.
|
* Make sure that this transaction has a distributed transaction ID.
|
||||||
|
|
|
@ -173,7 +173,7 @@ extern void CopyShardForeignConstraintCommandListGrouped(ShardInterval *shardInt
|
||||||
referenceTableForeignConstraintList);
|
referenceTableForeignConstraintList);
|
||||||
extern ShardPlacement * SearchShardPlacementInList(List *shardPlacementList,
|
extern ShardPlacement * SearchShardPlacementInList(List *shardPlacementList,
|
||||||
const char *nodeName, uint32 nodePort);
|
const char *nodeName, uint32 nodePort);
|
||||||
extern ShardPlacement * ForceSearchShardPlacementInList(List *shardPlacementList,
|
extern ShardPlacement * SearchShardPlacementInListOrError(List *shardPlacementList,
|
||||||
const char *nodeName,
|
const char *nodeName,
|
||||||
uint32 nodePort);
|
uint32 nodePort);
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,7 @@ extern char LookupDistributionMethod(Oid distributionMethodOid);
|
||||||
/* access WorkerNodeHash */
|
/* access WorkerNodeHash */
|
||||||
extern HTAB * GetWorkerNodeHash(void);
|
extern HTAB * GetWorkerNodeHash(void);
|
||||||
extern WorkerNode * LookupNodeByNodeId(uint32 nodeId);
|
extern WorkerNode * LookupNodeByNodeId(uint32 nodeId);
|
||||||
extern WorkerNode * ForceLookupNodeByNodeId(uint32 nodeId);
|
extern WorkerNode * LookupNodeByNodeIdOrError(uint32 nodeId);
|
||||||
extern WorkerNode * LookupNodeForGroup(int32 groupId);
|
extern WorkerNode * LookupNodeForGroup(int32 groupId);
|
||||||
|
|
||||||
/* namespace oids */
|
/* namespace oids */
|
||||||
|
|
|
@ -105,7 +105,7 @@ extern Var * LeftColumnOrNULL(OpExpr *joinClause);
|
||||||
extern Var * RightColumnOrNULL(OpExpr *joinClause);
|
extern Var * RightColumnOrNULL(OpExpr *joinClause);
|
||||||
extern Var * PartitionColumn(Oid relationId, uint32 rangeTableId);
|
extern Var * PartitionColumn(Oid relationId, uint32 rangeTableId);
|
||||||
extern Var * DistPartitionKey(Oid relationId);
|
extern Var * DistPartitionKey(Oid relationId);
|
||||||
extern Var * ForceDistPartitionKey(Oid relationId);
|
extern Var * DistPartitionKeyOrError(Oid relationId);
|
||||||
extern char PartitionMethod(Oid relationId);
|
extern char PartitionMethod(Oid relationId);
|
||||||
extern char TableReplicationModel(Oid relationId);
|
extern char TableReplicationModel(Oid relationId);
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ extern uint32 ActiveReadableNonCoordinatorNodeCount(void);
|
||||||
extern List * ActiveReadableNonCoordinatorNodeList(void);
|
extern List * ActiveReadableNonCoordinatorNodeList(void);
|
||||||
extern List * ActiveReadableNodeList(void);
|
extern List * ActiveReadableNodeList(void);
|
||||||
extern WorkerNode * FindWorkerNode(const char *nodeName, int32 nodePort);
|
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 WorkerNode * FindWorkerNodeAnyCluster(const char *nodeName, int32 nodePort);
|
||||||
extern List * ReadDistNode(bool includeNodesFromOtherClusters);
|
extern List * ReadDistNode(bool includeNodesFromOtherClusters);
|
||||||
extern void EnsureCoordinator(void);
|
extern void EnsureCoordinator(void);
|
||||||
|
|
Loading…
Reference in New Issue