Permalink
Browse files

Refactor and clean-up of relation locator code

Locator is the part in charge of managing, building and referencing
distribution information of tables in catalogs by providing sufficient
functions that backends can refer to.
Some of this code was pretty outdated and a portion of the APIs used
were duplicated, making the code more difficult to apprehend. Locator
information also included the following information:
- OID of relation it refers to
- Attribute number of distribution key if distribution is value-based
- Column name of distribution key
As column name can be retrieved from system cache by using simply OID
and attribute number, the column name is removed, simplifying the code
by that much. So now all the APIs of locator.c and related only use the
attribute number of a relation when referencing the distribution key inside
code. This cleanup also tackles some potential bugs related to hash/modulo
management that might have appeared if other value-based distribution would
have been defined in XC. So code is more extensible now.
  • Loading branch information...
1 parent dfb46fa commit d165a5c2458e97cbf943135cf1bb534b8f8af807 @michaelpq michaelpq committed Oct 12, 2012
View
6 src/backend/catalog/heap.c
@@ -1033,7 +1033,7 @@ GetRelationDistributionItems(Oid relid,
for (i = 0; i < descriptor->natts; i++)
{
attr = descriptor->attrs[i];
- if (IsTypeHashDistributable(attr->atttypid))
+ if (IsTypeDistributable(attr->atttypid))
{
/* distribute on this column */
local_attnum = i + 1;
@@ -1065,7 +1065,7 @@ GetRelationDistributionItems(Oid relid,
errmsg("Invalid distribution column specified")));
}
- if (!IsTypeHashDistributable(descriptor->attrs[local_attnum - 1]->atttypid))
+ if (!IsTypeDistributable(descriptor->attrs[local_attnum - 1]->atttypid))
{
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
@@ -1088,7 +1088,7 @@ GetRelationDistributionItems(Oid relid,
errmsg("Invalid distribution column specified")));
}
- if (!IsTypeModuloDistributable(descriptor->attrs[local_attnum - 1]->atttypid))
+ if (!IsTypeDistributable(descriptor->attrs[local_attnum - 1]->atttypid))
{
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
View
14 src/backend/commands/tablecmds.c
@@ -10277,12 +10277,16 @@ ATCheckCmd(Relation rel, AlterTableCmd *cmd)
switch (cmd->subtype)
{
case AT_DropColumn:
- /* Distribution column cannot be dropped */
- if (IsDistColumnForRelId(RelationGetRelid(rel), cmd->name))
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ {
+ AttrNumber attnum = get_attnum(RelationGetRelid(rel),
+ cmd->name);
+ /* Distribution column cannot be dropped */
+ if (IsDistribColumn(RelationGetRelid(rel), attnum))
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("Distribution column cannot be dropped")));
- break;
+ break;
+ }
default:
break;
View
9 src/backend/optimizer/plan/pgxcplan.c
@@ -2647,24 +2647,23 @@ validate_part_col_updatable(const Query *query)
if (!rel_loc_info)
return;
-
- /* Only LOCATOR_TYPE_HASH & LOCATOR_TYPE_MODULO should be checked */
- if ( (rel_loc_info->partAttrName != NULL) &&
- ( (rel_loc_info->locatorType == LOCATOR_TYPE_HASH) || (rel_loc_info->locatorType == LOCATOR_TYPE_MODULO) ) )
+ /* Only relations distributed by value can be checked */
+ if (IsLocatorDistributedByValue(rel_loc_info->locatorType))
{
/* It is a partitioned table, check partition column in targetList */
foreach(lc, query->targetList)
{
TargetEntry *tle = (TargetEntry *) lfirst(lc);
+ /* Nothing to do for a junk entry */
if (tle->resjunk)
continue;
/*
* See if we have a constant expression comparing against the
* designated partitioned column
*/
- if (strcmp(tle->resname, rel_loc_info->partAttrName) == 0)
+ if (strcmp(tle->resname, GetRelationDistribColumn(rel_loc_info)) == 0)
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
(errmsg("Partition column can't be updated in current version"))));
View
2 src/backend/optimizer/util/pgxcship.c
@@ -462,7 +462,7 @@ pgxc_FQS_get_relation_nodes(RangeTblEntry *rte, Index varno, Query *query)
if (tle->resjunk)
continue;
- if (strcmp(tle->resname, rel_loc_info->partAttrName) == 0)
+ if (strcmp(tle->resname, GetRelationDistribColumn(rel_loc_info)) == 0)
break;
}
/* Not found, bail out */
View
11 src/backend/parser/parse_utilcmd.c
@@ -1891,13 +1891,16 @@ transformFKConstraints(CreateStmtContext *cxt,
* If not yet set, set it to first column in FK constraint
* if it references a partitioned table
*/
- if (IS_PGXC_COORDINATOR && !cxt->fallback_dist_col)
+ if (IS_PGXC_COORDINATOR &&
+ !cxt->fallback_dist_col &&
+ list_length(constraint->pk_attrs) != 0)
{
Oid pk_rel_id = RangeVarGetRelid(constraint->pktable, NoLock, false);
+ AttrNumber attnum = get_attnum(pk_rel_id,
+ strVal(list_nth(constraint->fk_attrs, 0)));
- /* make sure it is a partitioned column */
- if (list_length(constraint->pk_attrs) != 0
- && IsHashColumnForRelId(pk_rel_id, strVal(list_nth(constraint->pk_attrs,0))))
+ /* Make sure key is done on a partitioned column */
+ if (IsDistribColumn(pk_rel_id, attnum))
{
/* take first column */
char *colstr = strdup(strVal(list_nth(constraint->fk_attrs,0)));
View
334 src/backend/pgxc/locator/locator.c
@@ -50,7 +50,7 @@
#include "catalog/namespace.h"
#include "access/hash.h"
-static Expr *pgxc_find_distcol_expr(Index varno, PartAttrNumber partAttrNum,
+static Expr *pgxc_find_distcol_expr(Index varno, AttrNumber attrNum,
Node *quals);
Oid primary_data_node = InvalidOid;
@@ -222,145 +222,53 @@ get_node_from_modulo(int modulo, List *nodeList)
/*
- * GetRelationDistColumn - Returns the name of the hash or modulo distribution column
- * First hash distribution is checked
- * Retuens NULL if the table is neither hash nor modulo distributed
+ * GetRelationDistribColumn
+ * Return hash column name for relation or NULL if relation is not distributed.
*/
char *
-GetRelationDistColumn(RelationLocInfo * rel_loc_info)
+GetRelationDistribColumn(RelationLocInfo *locInfo)
{
-char *pColName;
-
- pColName = NULL;
-
- pColName = GetRelationHashColumn(rel_loc_info);
- if (pColName == NULL)
- pColName = GetRelationModuloColumn(rel_loc_info);
-
- return pColName;
-}
-
-/*
- * Returns whether or not the data type is hash distributable with PG-XC
- * PGXCTODO - expand support for other data types!
- */
-bool
-IsTypeHashDistributable(Oid col_type)
-{
- if(col_type == INT8OID
- || col_type == INT2OID
- || col_type == OIDOID
- || col_type == INT4OID
- || col_type == BOOLOID
- || col_type == CHAROID
- || col_type == NAMEOID
- || col_type == INT2VECTOROID
- || col_type == TEXTOID
- || col_type == OIDVECTOROID
- || col_type == FLOAT4OID
- || col_type == FLOAT8OID
- || col_type == ABSTIMEOID
- || col_type == RELTIMEOID
- || col_type == CASHOID
- || col_type == BPCHAROID
- || col_type == BYTEAOID
- || col_type == VARCHAROID
- || col_type == DATEOID
- || col_type == TIMEOID
- || col_type == TIMESTAMPOID
- || col_type == TIMESTAMPTZOID
- || col_type == INTERVALOID
- || col_type == TIMETZOID
- || col_type == NUMERICOID
- )
- return true;
-
- return false;
-}
-
-/*
- * GetRelationHashColumn - return hash column for relation.
- *
- * Returns NULL if the relation is not hash partitioned.
- */
-char *
-GetRelationHashColumn(RelationLocInfo * rel_loc_info)
-{
- char *column_str = NULL;
-
- if (rel_loc_info == NULL)
- column_str = NULL;
- else if (rel_loc_info->locatorType != LOCATOR_TYPE_HASH)
- column_str = NULL;
- else
- {
- int len = strlen(rel_loc_info->partAttrName);
-
- column_str = (char *) palloc(len + 1);
- strncpy(column_str, rel_loc_info->partAttrName, len + 1);
- }
-
- return column_str;
-}
-
-/*
- * IsHashColumn - return whether or not column for relation is hashed.
- *
- */
-bool
-IsHashColumn(RelationLocInfo *rel_loc_info, char *part_col_name)
-{
- bool ret_value = false;
+ /* No relation, so simply leave */
+ if (!locInfo)
+ return NULL;
- if (!rel_loc_info || !part_col_name)
- ret_value = false;
- else if (rel_loc_info->locatorType != LOCATOR_TYPE_HASH)
- ret_value = false;
- else
- ret_value = !strcmp(part_col_name, rel_loc_info->partAttrName);
+ /* No distribution column if relation is not distributed with a key */
+ if (!IsLocatorDistributedByValue(locInfo->locatorType))
+ return NULL;
- return ret_value;
+ /* Return column name */
+ return get_attname(locInfo->relid, locInfo->partAttrNum);
}
/*
- * IsHashColumnForRelId - return whether or not column for relation is hashed.
- *
+ * IsDistribColumn
+ * Return whether column for relation is used for distribution or not.
*/
bool
-IsHashColumnForRelId(Oid relid, char *part_col_name)
+IsDistribColumn(Oid relid, AttrNumber attNum)
{
- RelationLocInfo *rel_loc_info = GetRelationLocInfo(relid);
-
- return IsHashColumn(rel_loc_info, part_col_name);
-}
+ RelationLocInfo *locInfo = GetRelationLocInfo(relid);
-/*
- * IsDistColumnForRelId - return whether or not column for relation is used for hash or modulo distribution
- *
- */
-bool
-IsDistColumnForRelId(Oid relid, char *part_col_name)
-{
- bool bRet;
- RelationLocInfo *rel_loc_info;
+ /* No locator info, so leave */
+ if (!locInfo)
+ return false;
- rel_loc_info = GetRelationLocInfo(relid);
- bRet = false;
+ /* No distribution column if relation is not distributed with a key */
+ if (!IsLocatorDistributedByValue(locInfo->locatorType))
+ return false;
- bRet = IsHashColumn(rel_loc_info, part_col_name);
- if (bRet == false)
- IsModuloColumn(rel_loc_info, part_col_name);
- return bRet;
+ /* Finally check if attribute is distributed */
+ return locInfo->partAttrNum == attNum;
}
/*
- * Returns whether or not the data type is modulo distributable with PG-XC
- * PGXCTODO - expand support for other data types!
+ * IsTypeDistributable
+ * Returns whether the data type is distributable using a column value.
*/
bool
-IsTypeModuloDistributable(Oid col_type)
+IsTypeDistributable(Oid col_type)
{
if(col_type == INT8OID
|| col_type == INT2OID
@@ -393,65 +301,10 @@ IsTypeModuloDistributable(Oid col_type)
return false;
}
-/*
- * GetRelationModuloColumn - return modulo column for relation.
- *
- * Returns NULL if the relation is not modulo partitioned.
- */
-char *
-GetRelationModuloColumn(RelationLocInfo * rel_loc_info)
-{
- char *column_str = NULL;
-
- if (rel_loc_info == NULL)
- column_str = NULL;
- else if (rel_loc_info->locatorType != LOCATOR_TYPE_MODULO)
- column_str = NULL;
- else
- {
- int len = strlen(rel_loc_info->partAttrName);
-
- column_str = (char *) palloc(len + 1);
- strncpy(column_str, rel_loc_info->partAttrName, len + 1);
- }
-
- return column_str;
-}
/*
- * IsModuloColumn - return whether or not column for relation is used for modulo distribution.
- *
- */
-bool
-IsModuloColumn(RelationLocInfo *rel_loc_info, char *part_col_name)
-{
- bool ret_value = false;
-
- if (!rel_loc_info || !part_col_name)
- ret_value = false;
- else if (rel_loc_info->locatorType != LOCATOR_TYPE_MODULO)
- ret_value = false;
- else
- ret_value = !strcmp(part_col_name, rel_loc_info->partAttrName);
-
- return ret_value;
-}
-
-
-/*
- * IsModuloColumnForRelId - return whether or not column for relation is used for modulo distribution.
- */
-bool
-IsModuloColumnForRelId(Oid relid, char *part_col_name)
-{
- RelationLocInfo *rel_loc_info = GetRelationLocInfo(relid);
-
- return IsModuloColumn(rel_loc_info, part_col_name);
-}
-
-/*
- * Update the round robin node for the relation
- *
+ * GetRoundRobinNode
+ * Update the round robin node for the relation.
* PGXCTODO - may not want to bother with locking here, we could track
* these in the session memory context instead...
*/
@@ -480,7 +333,6 @@ GetRoundRobinNode(Oid relid)
/*
* IsTableDistOnPrimary
- *
* Does the table distribution list include the primary node?
*/
bool
@@ -507,24 +359,25 @@ IsTableDistOnPrimary(RelationLocInfo *rel_loc_info)
* Check equality of given locator information
*/
bool
-IsLocatorInfoEqual(RelationLocInfo *rel_loc_info1, RelationLocInfo *rel_loc_info2)
+IsLocatorInfoEqual(RelationLocInfo *locInfo1,
+ RelationLocInfo *locInfo2)
{
List *nodeList1, *nodeList2;
- Assert(rel_loc_info1 && rel_loc_info2);
+ Assert(locInfo1 && locInfo2);
- nodeList1 = rel_loc_info1->nodeList;
- nodeList2 = rel_loc_info2->nodeList;
+ nodeList1 = locInfo1->nodeList;
+ nodeList2 = locInfo2->nodeList;
/* Same relation? */
- if (rel_loc_info1->relid != rel_loc_info2->relid)
+ if (locInfo1->relid != locInfo2->relid)
return false;
/* Same locator type? */
- if (rel_loc_info1->locatorType != rel_loc_info2->locatorType)
+ if (locInfo1->locatorType != locInfo2->locatorType)
return false;
/* Same attribute number? */
- if (rel_loc_info1->partAttrNum != rel_loc_info2->partAttrNum)
+ if (locInfo1->partAttrNum != locInfo2->partAttrNum)
return false;
/* Same node list? */
@@ -770,59 +623,24 @@ GetRelationNodesByQuals(Oid reloid, Index varno, Node *quals,
}
/*
- * ConvertToLocatorType
- * get locator distribution type
- * We really should just have pgxc_class use disttype instead...
- */
-char
-ConvertToLocatorType(int disttype)
-{
- char loctype = LOCATOR_TYPE_NONE;
-
- switch (disttype)
- {
- case DISTTYPE_HASH:
- loctype = LOCATOR_TYPE_HASH;
- break;
- case DISTTYPE_ROUNDROBIN:
- loctype = LOCATOR_TYPE_RROBIN;
- break;
- case DISTTYPE_REPLICATION:
- loctype = LOCATOR_TYPE_REPLICATED;
- break;
- case DISTTYPE_MODULO:
- loctype = LOCATOR_TYPE_MODULO;
- break;
- default:
- ereport(ERROR,
- (errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("Invalid distribution type")));
- break;
- }
-
- return loctype;
-}
-
-
-/*
- * GetLocatorType - Returns the locator type of the table
- *
+ * GetLocatorType
+ * Returns the locator type of the table.
*/
char
GetLocatorType(Oid relid)
{
- char ret = '\0';
-
- RelationLocInfo *ret_loc_info = GetRelationLocInfo(relid);
+ char ret = LOCATOR_TYPE_NONE;
+ RelationLocInfo *locInfo = GetRelationLocInfo(relid);
- if (ret_loc_info != NULL)
- ret = ret_loc_info->locatorType;
+ if (locInfo != NULL)
+ ret = locInfo->locatorType;
return ret;
}
/*
+ * GetAllDataNodes
* Return a list of all Datanodes.
* We assume all tables use all nodes in the prototype, so just return a list
* from first one.
@@ -840,6 +658,7 @@ GetAllDataNodes(void)
}
/*
+ * GetAllCoordNodes
* Return a list of all Coordinators
* This is used to send DDL to all nodes and to clean up pooler connections.
* Do not put in the list the local Coordinator where this function is launched.
@@ -866,6 +685,7 @@ GetAllCoordNodes(void)
/*
+ * RelationBuildLocator
* Build locator information associated with the specified relation.
*/
void
@@ -910,9 +730,6 @@ RelationBuildLocator(Relation rel)
relationLocInfo->locatorType = pgxc_class->pclocatortype;
relationLocInfo->partAttrNum = pgxc_class->pcattnum;
-
- relationLocInfo->partAttrName = get_attname(relationLocInfo->relid, pgxc_class->pcattnum);
-
relationLocInfo->nodeList = NIL;
for (j = 0; j < pgxc_class->nodeoids.dim1; j++)
@@ -948,7 +765,8 @@ RelationBuildLocator(Relation rel)
}
/*
- * GetLocatorRelationInfo - Returns the locator information for relation,
+ * GetLocatorRelationInfo
+ * Returns the locator information for relation,
* in a copy of the RelationLocatorInfo struct in relcache
*/
RelationLocInfo *
@@ -969,60 +787,43 @@ GetRelationLocInfo(Oid relid)
}
/*
- * Get the distribution type of relation.
- */
-char
-GetRelationLocType(Oid relid)
-{
- RelationLocInfo *locinfo = GetRelationLocInfo(relid);
- if (!locinfo)
- return LOCATOR_TYPE_NONE;
-
- return locinfo->locatorType;
-}
-
-/*
+ * CopyRelationLocInfo
* Copy the RelationLocInfo struct
*/
RelationLocInfo *
-CopyRelationLocInfo(RelationLocInfo * src_info)
+CopyRelationLocInfo(RelationLocInfo *srcInfo)
{
- RelationLocInfo *dest_info;
-
- Assert(src_info);
+ RelationLocInfo *destInfo;
- dest_info = (RelationLocInfo *) palloc0(sizeof(RelationLocInfo));
+ Assert(srcInfo);
+ destInfo = (RelationLocInfo *) palloc0(sizeof(RelationLocInfo));
- dest_info->relid = src_info->relid;
- dest_info->locatorType = src_info->locatorType;
- dest_info->partAttrNum = src_info->partAttrNum;
- if (src_info->partAttrName)
- dest_info->partAttrName = pstrdup(src_info->partAttrName);
+ destInfo->relid = srcInfo->relid;
+ destInfo->locatorType = srcInfo->locatorType;
+ destInfo->partAttrNum = srcInfo->partAttrNum;
+ if (srcInfo->nodeList)
+ destInfo->nodeList = list_copy(srcInfo->nodeList);
- if (src_info->nodeList)
- dest_info->nodeList = list_copy(src_info->nodeList);
- /* Note, for round robin, we use the relcache entry */
-
- return dest_info;
+ /* Note: for roundrobin, we use the relcache entry */
+ return destInfo;
}
/*
+ * FreeRelationLocInfo
* Free RelationLocInfo struct
*/
void
FreeRelationLocInfo(RelationLocInfo *relationLocInfo)
{
if (relationLocInfo)
- {
- if (relationLocInfo->partAttrName)
- pfree(relationLocInfo->partAttrName);
pfree(relationLocInfo);
- }
}
/*
- * Free the contents of the ExecNodes expression */
+ * FreeExecNodes
+ * Free the contents of the ExecNodes expression
+ */
void
FreeExecNodes(ExecNodes **exec_nodes)
{
@@ -1050,8 +851,9 @@ FreeExecNodes(ExecNodes **exec_nodes)
* this function returns NULL.
*/
static Expr *
-pgxc_find_distcol_expr(Index varno, PartAttrNumber partAttrNum,
- Node *quals)
+pgxc_find_distcol_expr(Index varno,
+ AttrNumber attrNum,
+ Node *quals)
{
List *lquals;
ListCell *qual_cell;
@@ -1123,7 +925,7 @@ pgxc_find_distcol_expr(Index varno, PartAttrNumber partAttrNum,
* If Var found is not the distribution column of required relation,
* check next qual
*/
- if (var_expr->varno != varno || var_expr->varattno != partAttrNum)
+ if (var_expr->varno != varno || var_expr->varattno != attrNum)
continue;
/*
* If the operator is not an assignment operator, check next
View
6 src/backend/pgxc/locator/redistrib.c
@@ -721,10 +721,8 @@ distrib_delete_hash(RedistribState *distribState, ExecNodes *exec_nodes)
hashfuncname = get_compute_hash_function(hashtype, locinfo->locatorType);
/* Get distribution column name */
- if (locinfo->locatorType == LOCATOR_TYPE_HASH)
- colname = GetRelationHashColumn(locinfo);
- else if (locinfo->locatorType == LOCATOR_TYPE_MODULO)
- colname = GetRelationModuloColumn(locinfo);
+ if (IsLocatorDistributedByValue(locinfo->locatorType))
+ colname = GetRelationDistribColumn(locinfo);
else
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
View
2 src/backend/rewrite/rewriteHandler.c
@@ -1330,7 +1330,7 @@ rewriteTargetListUD(Query *parsetree, RangeTblEntry *target_rte,
*/
if (IS_PGXC_COORDINATOR &&
!IsConnFromCoord() &&
- !IsLocatorReplicated(GetRelationLocType(RelationGetRelid(target_relation))))
+ !IsLocatorReplicated(GetLocatorType(RelationGetRelid(target_relation))))
{
var = makeVar(parsetree->resultRelation,
XC_NodeIdAttributeNumber,
View
83 src/include/pgxc/locator.h
@@ -44,8 +44,6 @@
#include "nodes/primnodes.h"
#include "utils/relcache.h"
-typedef int PartAttrNumber;
-
/*
* How relation is accessed in the query
*/
@@ -59,12 +57,11 @@ typedef enum
typedef struct
{
- Oid relid;
- char locatorType;
- PartAttrNumber partAttrNum; /* if partitioned */
- char *partAttrName; /* if partitioned */
- List *nodeList; /* Node Indices */
- ListCell *roundRobinNode; /* index of the next one to use */
+ Oid relid; /* OID of relation */
+ char locatorType; /* locator type, see above */
+ AttrNumber partAttrNum; /* Distribution column attribute */
+ List *nodeList; /* Node indices where data is located */
+ ListCell *roundRobinNode; /* Index of the next node to use */
} RelationLocInfo;
/*
@@ -76,52 +73,48 @@ typedef struct
typedef struct
{
NodeTag type;
- List *primarynodelist;
- List *nodeList;
- char baselocatortype;
- Expr *en_expr; /* expression to evaluate at execution time if planner
- * can not determine execution nodes */
- Oid en_relid; /* Relation to determine execution nodes */
- RelationAccessType accesstype; /* Access type to determine execution nodes */
+ List *primarynodelist; /* Primary node list indexes */
+ List *nodeList; /* Node list indexes */
+ char baselocatortype; /* Locator type, see above */
+ Expr *en_expr; /* Expression to evaluate at execution time
+ * if planner can not determine execution
+ * nodes */
+ Oid en_relid; /* Relation to determine execution nodes */
+ RelationAccessType accesstype; /* Access type to determine execution
+ * nodes */
} ExecNodes;
/* Extern variables related to locations */
extern Oid primary_data_node;
extern Oid preferred_data_node[MAX_PREFERRED_NODES];
extern int num_preferred_data_nodes;
-extern void InitRelationLocInfo(void);
-extern char GetLocatorType(Oid relid);
-extern char ConvertToLocatorType(int disttype);
-
-extern char *GetRelationHashColumn(RelationLocInfo *rel_loc_info);
-extern RelationLocInfo *GetRelationLocInfo(Oid relid);
-extern RelationLocInfo *CopyRelationLocInfo(RelationLocInfo *src_info);
-extern char GetRelationLocType(Oid relid);
-extern bool IsTableDistOnPrimary(RelationLocInfo *rel_loc_info);
-extern bool IsLocatorInfoEqual(RelationLocInfo *rel_loc_info1, RelationLocInfo *rel_loc_info2);
-extern ExecNodes *GetRelationNodes(RelationLocInfo *rel_loc_info, Datum valueForDistCol,
- bool isValueNull, Oid typeOfValueForDistCol,
- RelationAccessType accessType);
-extern ExecNodes *GetRelationNodesByQuals(Oid reloid, Index varno, Node *quals,
- RelationAccessType relaccess);
-extern bool IsHashColumn(RelationLocInfo *rel_loc_info, char *part_col_name);
-extern bool IsHashColumnForRelId(Oid relid, char *part_col_name);
-extern int GetRoundRobinNode(Oid relid);
-
-extern bool IsTypeHashDistributable(Oid col_type);
-extern List *GetAllDataNodes(void);
-extern List *GetAllCoordNodes(void);
-extern List *GetPreferredReplicationNode(List *relNodes);
+/* Function for RelationLocInfo building and management */
extern void RelationBuildLocator(Relation rel);
+extern RelationLocInfo *GetRelationLocInfo(Oid relid);
+extern RelationLocInfo *CopyRelationLocInfo(RelationLocInfo *srcInfo);
extern void FreeRelationLocInfo(RelationLocInfo *relationLocInfo);
-
-extern bool IsTypeModuloDistributable(Oid col_type);
-extern char *GetRelationModuloColumn(RelationLocInfo *rel_loc_info);
-extern bool IsModuloColumn(RelationLocInfo *rel_loc_info, char *part_col_name);
-extern bool IsModuloColumnForRelId(Oid relid, char *part_col_name);
-extern char *GetRelationDistColumn(RelationLocInfo *rel_loc_info);
-extern bool IsDistColumnForRelId(Oid relid, char *part_col_name);
+extern char *GetRelationDistribColumn(RelationLocInfo *locInfo);
+extern char GetLocatorType(Oid relid);
+extern List *GetPreferredReplicationNode(List *relNodes);
+extern bool IsTableDistOnPrimary(RelationLocInfo *locInfo);
+extern bool IsLocatorInfoEqual(RelationLocInfo *locInfo1,
+ RelationLocInfo *locInfo2);
+extern int GetRoundRobinNode(Oid relid);
+extern bool IsTypeDistributable(Oid colType);
+extern bool IsDistribColumn(Oid relid, AttrNumber attNum);
+extern ExecNodes *GetRelationNodes(RelationLocInfo *rel_loc_info,
+ Datum valueForDistCol,
+ bool isValueNull,
+ Oid typeOfValueForDistCol,
+ RelationAccessType accessType);
+extern ExecNodes *GetRelationNodesByQuals(Oid reloid,
+ Index varno,
+ Node *quals,
+ RelationAccessType relaccess);
+/* Global locator data */
extern void FreeExecNodes(ExecNodes **exec_nodes);
+extern List *GetAllDataNodes(void);
+extern List *GetAllCoordNodes(void);
#endif /* LOCATOR_H */

0 comments on commit d165a5c

Please sign in to comment.