diff options
author | Ashutosh Bapat | 2013-02-07 04:49:22 +0000 |
---|---|---|
committer | Ashutosh Bapat | 2013-02-07 04:49:22 +0000 |
commit | 5181a5e03416b09ca805be2342832ca6a45f0782 (patch) | |
tree | 08388da89ee0f2df1bd63c7411d2e0b574976077 | |
parent | 7d7bc1351125cf43568990b19d1b41e57949e87f (diff) |
Add convenience macros to get the distribution type from ExecNodes and
RelationLocInfo structures.
-rw-r--r-- | src/backend/optimizer/path/pgxcpath.c | 4 | ||||
-rw-r--r-- | src/backend/optimizer/plan/pgxcplan.c | 4 | ||||
-rw-r--r-- | src/backend/optimizer/util/pgxcship.c | 30 | ||||
-rw-r--r-- | src/backend/pgxc/copy/remotecopy.c | 2 | ||||
-rw-r--r-- | src/backend/pgxc/locator/locator.c | 6 | ||||
-rw-r--r-- | src/backend/pgxc/locator/redistrib.c | 10 | ||||
-rw-r--r-- | src/backend/pgxc/pool/execRemote.c | 2 | ||||
-rw-r--r-- | src/include/pgxc/locator.h | 7 |
8 files changed, 36 insertions, 29 deletions
diff --git a/src/backend/optimizer/path/pgxcpath.c b/src/backend/optimizer/path/pgxcpath.c index e51d1b3359..4b22bba308 100644 --- a/src/backend/optimizer/path/pgxcpath.c +++ b/src/backend/optimizer/path/pgxcpath.c @@ -140,7 +140,7 @@ create_plainrel_rqpath(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte) * GetRelationNodes(). * create_remotequery_plan would reduce the number of nodes to 1. */ - if (IsLocatorReplicated(rel_loc_info->locatorType)) + if (IsRelationReplicated(rel_loc_info)) { list_free(exec_nodes->nodeList); exec_nodes->nodeList = list_copy(rel_loc_info->nodeList); @@ -210,7 +210,7 @@ pgxc_is_join_reducible(ExecNodes *inner_en, ExecNodes *outer_en, Relids in_relid * such case, we can reduce the JOIN if the distribution nodelist is also * same. */ - if (IsLocatorDistributedByValue(inner_en->baselocatortype) && + if (IsExecNodesDistributedByValue(inner_en) && inner_en->baselocatortype == outer_en->baselocatortype && !merge_replicated_only) { diff --git a/src/backend/optimizer/plan/pgxcplan.c b/src/backend/optimizer/plan/pgxcplan.c index 280cd717fd..cfe05ff420 100644 --- a/src/backend/optimizer/plan/pgxcplan.c +++ b/src/backend/optimizer/plan/pgxcplan.c @@ -684,7 +684,7 @@ create_remotequery_plan(PlannerInfo *root, RemoteQueryPath *best_path) * For replicated results, we need to choose one of the nodes, if there are * many of them. */ - if (IsLocatorReplicated(result_node->exec_nodes->baselocatortype)) + if (IsExecNodesReplicated(result_node->exec_nodes)) result_node->exec_nodes->nodeList = GetPreferredReplicationNode(result_node->exec_nodes->nodeList); @@ -2675,7 +2675,7 @@ validate_part_col_updatable(const Query *query) return; /* Only relations distributed by value can be checked */ - if (IsLocatorDistributedByValue(rel_loc_info->locatorType)) + if (IsRelationDistributedByValue(rel_loc_info)) { /* It is a partitioned table, check partition column in targetList */ foreach(lc, query->targetList) diff --git a/src/backend/optimizer/util/pgxcship.c b/src/backend/optimizer/util/pgxcship.c index 13f55f8a59..3fa5f9c76c 100644 --- a/src/backend/optimizer/util/pgxcship.c +++ b/src/backend/optimizer/util/pgxcship.c @@ -250,7 +250,7 @@ pgxc_FQS_find_datanodes(Shippability_context *sc_context) } if (varno == 1) { - if (IsLocatorColumnDistributed(rel_exec_nodes->baselocatortype)) + if (IsExecNodesColumnDistributed(rel_exec_nodes)) { RelationLocInfo *rel_loc_info = GetRelationLocInfo(rte->relid); distcol_type = get_atttype(rte->relid, @@ -264,7 +264,7 @@ pgxc_FQS_find_datanodes(Shippability_context *sc_context) } } if (exec_nodes && - IsLocatorDistributedByValue(exec_nodes->baselocatortype) && + IsExecNodesDistributedByValue(exec_nodes) && OidIsValid(distcol_type) && bms_num_members(dist_varnos) > 0 && exec_nodes->baselocatortype == rel_exec_nodes->baselocatortype) { @@ -334,7 +334,7 @@ pgxc_FQS_find_datanodes(Shippability_context *sc_context) * replicated JOIN, choose only one of them. If one of them is a * preferred node choose that one, otherwise choose the first one. */ - if (IsLocatorReplicated(exec_nodes->baselocatortype) && + if (IsExecNodesReplicated(exec_nodes) && exec_nodes->accesstype == RELATION_ACCESS_READ) { List *tmp_list = exec_nodes->nodeList; @@ -441,13 +441,13 @@ pgxc_FQS_get_relation_nodes(RangeTblEntry *rte, Index varno, Query *query) * the JOIN is replicated. */ if (rel_access == RELATION_ACCESS_READ && - IsLocatorReplicated(rel_loc_info->locatorType)) + IsRelationReplicated(rel_loc_info)) { list_free(rel_exec_nodes->nodeList); rel_exec_nodes->nodeList = list_copy(rel_loc_info->nodeList); } else if (rel_access == RELATION_ACCESS_INSERT && - IsLocatorDistributedByValue(rel_loc_info->locatorType)) + IsRelationDistributedByValue(rel_loc_info)) { ListCell *lc; TargetEntry *tle; @@ -1421,8 +1421,8 @@ pgxc_merge_exec_nodes(ExecNodes *en1, ExecNodes *en2, bool merge_dist_equijoin, en1->accesstype != RELATION_ACCESS_READ || en2->accesstype != RELATION_ACCESS_READ) return NULL; - if (IsLocatorReplicated(en1->baselocatortype) && - IsLocatorReplicated(en2->baselocatortype)) + if (IsExecNodesReplicated(en1) && + IsExecNodesReplicated(en2)) { /* * Replicated/replicated join case @@ -1451,8 +1451,8 @@ pgxc_merge_exec_nodes(ExecNodes *en1, ExecNodes *en2, bool merge_dist_equijoin, return merged_en; } - if (IsLocatorReplicated(en1->baselocatortype) && - IsLocatorColumnDistributed(en2->baselocatortype)) + if (IsExecNodesReplicated(en1) && + IsExecNodesColumnDistributed(en2)) { List *diff_nodelist = NULL; /* @@ -1476,8 +1476,8 @@ pgxc_merge_exec_nodes(ExecNodes *en1, ExecNodes *en2, bool merge_dist_equijoin, return merged_en; } - if (IsLocatorColumnDistributed(en1->baselocatortype) && - IsLocatorReplicated(en2->baselocatortype)) + if (IsExecNodesColumnDistributed(en1) && + IsExecNodesReplicated(en2)) { List *diff_nodelist = NULL; /* @@ -1502,8 +1502,8 @@ pgxc_merge_exec_nodes(ExecNodes *en1, ExecNodes *en2, bool merge_dist_equijoin, return merged_en; } - if (IsLocatorColumnDistributed(en1->baselocatortype) && - IsLocatorColumnDistributed(en2->baselocatortype)) + if (IsExecNodesColumnDistributed(en1) && + IsExecNodesColumnDistributed(en2)) { /* * Distributed/distributed case @@ -1602,7 +1602,7 @@ pgxc_check_index_shippability(RelationLocInfo *relLocInfo, */ if (is_exclusion) { - if (!IsLocatorReplicated(relLocInfo->locatorType)) + if (!IsRelationReplicated(relLocInfo)) { result = false; goto finish; @@ -1779,7 +1779,7 @@ pgxc_check_fk_shippability(RelationLocInfo *parentLocInfo, */ /* A replicated child cannot refer to a distributed parent */ - if (IsLocatorReplicated(childLocInfo->locatorType)) + if (IsRelationReplicated(childLocInfo)) { result = false; break; diff --git a/src/backend/pgxc/copy/remotecopy.c b/src/backend/pgxc/copy/remotecopy.c index 5ac20dc60a..016ea1425b 100644 --- a/src/backend/pgxc/copy/remotecopy.c +++ b/src/backend/pgxc/copy/remotecopy.c @@ -55,7 +55,7 @@ RemoteCopy_GetRelationLoc(RemoteCopyData *state, */ exec_nodes = makeNode(ExecNodes); if (!state->is_from && - IsLocatorReplicated(state->rel_loc->locatorType)) + IsRelationReplicated(state->rel_loc)) exec_nodes->nodeList = GetPreferredReplicationNode(state->rel_loc->nodeList); else { diff --git a/src/backend/pgxc/locator/locator.c b/src/backend/pgxc/locator/locator.c index 5d15ae578b..3ccb06418d 100644 --- a/src/backend/pgxc/locator/locator.c +++ b/src/backend/pgxc/locator/locator.c @@ -233,7 +233,7 @@ GetRelationDistribColumn(RelationLocInfo *locInfo) return NULL; /* No distribution column if relation is not distributed with a key */ - if (!IsLocatorDistributedByValue(locInfo->locatorType)) + if (!IsRelationDistributedByValue(locInfo)) return NULL; /* Return column name */ @@ -255,7 +255,7 @@ IsDistribColumn(Oid relid, AttrNumber attNum) return false; /* No distribution column if relation is not distributed with a key */ - if (!IsLocatorDistributedByValue(locInfo->locatorType)) + if (!IsRelationDistributedByValue(locInfo)) return false; /* Finally check if attribute is distributed */ @@ -571,7 +571,7 @@ GetRelationNodesByQuals(Oid reloid, Index varno, Node *quals, * If the table distributed by value, check if we can reduce the Datanodes * by looking at the qualifiers for this relation */ - if (IsLocatorDistributedByValue(rel_loc_info->locatorType)) + if (IsRelationDistributedByValue(rel_loc_info)) { Oid disttype = get_atttype(reloid, rel_loc_info->partAttrNum); int32 disttypmod = get_atttypmod(reloid, rel_loc_info->partAttrNum); diff --git a/src/backend/pgxc/locator/redistrib.c b/src/backend/pgxc/locator/redistrib.c index 961405d505..c99bfe822e 100644 --- a/src/backend/pgxc/locator/redistrib.c +++ b/src/backend/pgxc/locator/redistrib.c @@ -159,8 +159,8 @@ pgxc_redist_build_replicate_to_distrib(RedistribState *distribState, return; /* Redistribution is done from replication to distributed (with value) */ - if (!IsLocatorReplicated(oldLocInfo->locatorType) || - !IsLocatorDistributedByValue(newLocInfo->locatorType)) + if (!IsRelationReplicated(oldLocInfo) || + !IsRelationDistributedByValue(newLocInfo)) return; /* Get the list of nodes that are added to the relation */ @@ -243,8 +243,8 @@ pgxc_redist_build_replicate(RedistribState *distribState, return; /* Case of a replicated table whose set of nodes is changed */ - if (!IsLocatorReplicated(newLocInfo->locatorType) || - !IsLocatorReplicated(oldLocInfo->locatorType)) + if (!IsRelationReplicated(newLocInfo) || + !IsRelationReplicated(oldLocInfo)) return; /* Get the list of nodes that are added to the relation */ @@ -721,7 +721,7 @@ distrib_delete_hash(RedistribState *distribState, ExecNodes *exec_nodes) hashfuncname = get_compute_hash_function(hashtype, locinfo->locatorType); /* Get distribution column name */ - if (IsLocatorDistributedByValue(locinfo->locatorType)) + if (IsRelationDistributedByValue(locinfo)) colname = GetRelationDistribColumn(locinfo); else ereport(ERROR, diff --git a/src/backend/pgxc/pool/execRemote.c b/src/backend/pgxc/pool/execRemote.c index 9d78a8c11f..15eccd6fda 100644 --- a/src/backend/pgxc/pool/execRemote.c +++ b/src/backend/pgxc/pool/execRemote.c @@ -2840,7 +2840,7 @@ pgxc_start_command_on_connection(PGXCNodeHandle *connection, static bool IsReturningDMLOnReplicatedTable(RemoteQuery *rq) { - if (IsLocatorReplicated(rq->exec_nodes->baselocatortype) && + if (IsExecNodesReplicated(rq->exec_nodes) && rq->base_tlist != NULL && /* Means DML has RETURNING */ (rq->exec_nodes->accesstype == RELATION_ACCESS_UPDATE || rq->exec_nodes->accesstype == RELATION_ACCESS_INSERT)) diff --git a/src/include/pgxc/locator.h b/src/include/pgxc/locator.h index 62b5c7cffa..aaef9079ef 100644 --- a/src/include/pgxc/locator.h +++ b/src/include/pgxc/locator.h @@ -64,6 +64,9 @@ typedef struct ListCell *roundRobinNode; /* Index of the next node to use */ } RelationLocInfo; +#define IsRelationReplicated(rel_loc) IsLocatorReplicated((rel_loc)->locatorType) +#define IsRelationColumnDistributed(rel_loc) IsLocatorColumnDistributed((rel_loc)->locatorType) +#define IsRelationDistributedByValue(rel_loc) IsLocatorDistributedByValue((rel_loc)->locatorType) /* * Nodes to execute on * primarynodelist is for replicated table writes, where to execute first. @@ -84,6 +87,10 @@ typedef struct * nodes */ } ExecNodes; +#define IsExecNodesReplicated(en) IsLocatorReplicated((en)->baselocatortype) +#define IsExecNodesColumnDistributed(en) IsLocatorColumnDistributed((en)->baselocatortype) +#define IsExecNodesDistributedByValue(en) IsLocatorDistributedByValue((en)->baselocatortype) + /* Extern variables related to locations */ extern Oid primary_data_node; extern Oid preferred_data_node[MAX_PREFERRED_NODES]; |