summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavan Deolasee2015-05-22 13:21:28 +0000
committerPavan Deolasee2015-05-22 13:21:28 +0000
commit22b07c3df626245e21b3f955e6da735ae8f99a50 (patch)
treea28d21cd731e61afe6e1595b1808c0c0008e939c
parent71635805676465381088f10b6b897e1aa767e40a (diff)
Add and use macros IS_PGXC_LOCAL_COORDINATOR and IS_PGXC_REMOTE_COORDINATOR
This makes the code much more readable. In passing, also add checks for local and remoted coordinator at bunch of places where we are not expected to send down commands to datanodes from a remote coordinator
-rw-r--r--src/backend/access/transam/xact.c24
-rw-r--r--src/backend/catalog/dependency.c3
-rw-r--r--src/backend/catalog/pg_proc.c2
-rw-r--r--src/backend/commands/dbcommands.c4
-rw-r--r--src/backend/commands/portalcmds.c2
-rw-r--r--src/backend/commands/sequence.c7
-rw-r--r--src/backend/commands/tablecmds.c16
-rw-r--r--src/backend/executor/functions.c2
-rw-r--r--src/backend/optimizer/path/allpaths.c3
-rw-r--r--src/backend/optimizer/plan/createplan.c2
-rw-r--r--src/backend/optimizer/plan/pgxcplan.c4
-rw-r--r--src/backend/optimizer/plan/planner.c8
-rw-r--r--src/backend/optimizer/plan/subselect.c2
-rw-r--r--src/backend/optimizer/util/plancat.c3
-rw-r--r--src/backend/parser/analyze.c2
-rw-r--r--src/backend/pgxc/barrier/barrier.c4
-rw-r--r--src/backend/pgxc/plan/planner.c4
-rw-r--r--src/backend/pgxc/pool/execRemote.c6
-rw-r--r--src/backend/tcop/postgres.c7
-rw-r--r--src/backend/tcop/utility.c130
-rw-r--r--src/backend/utils/adt/dbsize.c10
-rw-r--r--src/backend/utils/adt/lockfuncs.c32
-rw-r--r--src/backend/utils/adt/ruleutils.c4
-rw-r--r--src/backend/utils/cache/plancache.c3
-rw-r--r--src/backend/utils/misc/guc.c2
-rw-r--r--src/backend/utils/time/snapmgr.c2
-rw-r--r--src/include/pgxc/pgxc.h6
27 files changed, 144 insertions, 150 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index 614f917af9..52289ab2af 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -840,7 +840,7 @@ GetCurrentCommandId(bool used)
isCommandIdReceived = false;
currentCommandId = GetReceivedCommandId();
}
- else if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ else if (IS_PGXC_LOCAL_COORDINATOR)
{
/*
* If command id reported by remote node is greater that the current
@@ -2237,7 +2237,7 @@ CommitTransaction(void)
* until we are done with finishing the transaction
*/
s->topGlobalTransansactionId = s->transactionId;
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
XactLocalNodePrepared = false;
if (savePrepareGID)
@@ -2392,7 +2392,7 @@ CommitTransaction(void)
#ifdef XCP
if (IS_PGXC_DATANODE || !IsConnFromCoord())
#else
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
#endif
{
/*
@@ -2519,7 +2519,7 @@ CommitTransaction(void)
if (cluster_ex_lock_held)
{
elog(DEBUG2, "PAUSE CLUSTER still held at commit");
- /*if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ /*if (IS_PGXC_LOCAL_COORDINATOR)
RequestClusterPause(false, NULL);*/
}
#endif
@@ -2590,7 +2590,7 @@ CommitTransaction(void)
* For remote nodes, enforce the command ID sending flag to false to avoid
* sending any command ID by default as now transaction is done.
*/
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
SetReceivedCommandId(FirstCommandId);
else
SetSendCommandId(false);
@@ -2626,7 +2626,7 @@ AtEOXact_GlobalTxn(bool commit)
{
TransactionState s = CurrentTransactionState;
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
if (commit)
{
@@ -2735,7 +2735,7 @@ PrepareTransaction(void)
#ifdef PGXC
#ifndef XCP
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
if (savePrepareGID)
pfree(savePrepareGID);
@@ -3044,7 +3044,7 @@ PrepareTransaction(void)
* channels. So we want to keep receiving signals to avoid infinite
* blocking. But this must be checked for correctness
*/
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
#ifdef XCP
PostPrepare_Remote(savePrepareGID, isImplicit);
@@ -3063,7 +3063,7 @@ PrepareTransaction(void)
* For remote nodes, enforce the command ID sending flag to false to avoid
* sending any command ID by default as now transaction is done.
*/
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
SetReceivedCommandId(FirstCommandId);
else
SetSendCommandId(false);
@@ -3108,7 +3108,7 @@ AbortTransaction(void)
else
s->topGlobalTransansactionId = InvalidTransactionId;
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
/*
* Callback on GTM if necessary, this needs to be done before HOLD_INTERRUPTS
@@ -3317,7 +3317,7 @@ CleanupTransaction(void)
* For remote nodes, enforce the command ID sending flag to false to avoid
* sending any command ID by default as now transaction is done.
*/
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
SetReceivedCommandId(FirstCommandId);
else
SetSendCommandId(false);
@@ -4167,7 +4167,7 @@ BeginTransactionBlock(void)
* from a Coordinator. This may not be always the case depending on the queries being
* run and how command Ids are generated on remote nodes.
*/
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
SetSendCommandId(true);
#endif
}
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index fdffa6a6db..c4e3f97bba 100644
--- a/src/backend/catalog/dependency.c
+++ b/src/backend/catalog/dependency.c
@@ -409,8 +409,7 @@ doRename(const ObjectAddress *object, const char *oldname, const char *newname)
* An operation with GTM can just be done from a remote Coordinator.
*/
if (relKind == RELKIND_SEQUENCE &&
- IS_PGXC_COORDINATOR &&
- !IsConnFromCoord() &&
+ IS_PGXC_LOCAL_COORDINATOR &&
IsTempSequence(object->objectId))
{
Relation relseq = relation_open(object->objectId, AccessShareLock);
diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c
index 6c1cfb80fe..071f28ae50 100644
--- a/src/backend/catalog/pg_proc.c
+++ b/src/backend/catalog/pg_proc.c
@@ -935,7 +935,7 @@ fmgr_sql_validator(PG_FUNCTION_ARGS)
#ifdef PGXC
#ifndef XCP
/* Check if the list of queries contains temporary objects */
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
if (pgxc_query_contains_utility(querytree_sublist))
ereport(ERROR,
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index b2477b2c59..e6cc95621c 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -950,7 +950,7 @@ dropdb(const char *dbname, bool missing_ok)
#ifdef PGXC
/* Drop sequences on gtm that are on the database dropped. */
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
if (DropSequenceGTM((char *)dbname, GTM_SEQ_DB_NAME))
elog(ERROR, "Deletion of sequences on database %s not completed", dbname);
#endif
@@ -1502,7 +1502,7 @@ AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel)
/* this case isn't allowed within a transaction block */
#ifdef PGXC
/* ... but we allow it on remote nodes */
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
#endif
PreventTransactionChain(isTopLevel, "ALTER DATABASE SET TABLESPACE");
diff --git a/src/backend/commands/portalcmds.c b/src/backend/commands/portalcmds.c
index b6fbd48702..5ee1b239d8 100644
--- a/src/backend/commands/portalcmds.c
+++ b/src/backend/commands/portalcmds.c
@@ -85,7 +85,7 @@ PerformCursorOpen(PlannedStmt *stmt, ParamListInfo params,
/*
* Consume the command id of the command creating the cursor
*/
- if (IS_PGXC_COORDINATOR&& !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
GetCurrentCommandId(true);
#endif
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index 51ab31a849..bb1a6761ab 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -312,8 +312,7 @@ DefineSequence(CreateSeqStmt *seq)
* Remote Coordinator is in charge of creating sequence in GTM.
* If sequence is temporary, it is not necessary to create it on GTM.
*/
- if (IS_PGXC_COORDINATOR &&
- !IsConnFromCoord() &&
+ if (IS_PGXC_LOCAL_COORDINATOR &&
(seq->sequence->relpersistence == RELPERSISTENCE_PERMANENT ||
seq->sequence->relpersistence == RELPERSISTENCE_UNLOGGED))
{
@@ -601,9 +600,7 @@ AlterSequence(AlterSeqStmt *stmt)
* Remote Coordinator is in charge of create sequence in GTM
* If sequence is temporary, no need to go through GTM.
*/
- if (IS_PGXC_COORDINATOR &&
- !IsConnFromCoord() &&
- seqrel->rd_backend != MyBackendId)
+ if (IS_PGXC_LOCAL_COORDINATOR && seqrel->rd_backend != MyBackendId)
{
char *seqname = GetGlobalSeqName(seqrel, NULL, NULL);
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index b540abbe94..b3aaa30dfa 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -2652,8 +2652,7 @@ RenameRelationInternal(Oid myrelid, const char *newrelname, bool is_internal)
#ifdef PGXC
/* Operation with GTM can only be done with a Remote Coordinator */
- if (IS_PGXC_COORDINATOR &&
- !IsConnFromCoord() &&
+ if (IS_PGXC_LOCAL_COORDINATOR &&
(targetrelation->rd_rel->reltype == OBJECT_SEQUENCE ||
targetrelation->rd_rel->relkind == RELKIND_SEQUENCE) &&
!IsTempSequence(myrelid)) /* It is possible to rename a sequence with ALTER TABLE */
@@ -3122,7 +3121,7 @@ ATController(Relation rel, List *cmds, bool recurse, LOCKMODE lockmode)
#ifdef PGXC
/* Only check that on local Coordinator */
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
ListCell *ltab;
@@ -3772,8 +3771,7 @@ ATRewriteTables(List **wqueue, LOCKMODE lockmode)
/* Forbid table rewrite operations with online data redistribution */
if (tab->rewrite &&
list_length(tab->subcmds[AT_PASS_DISTRIB]) > 0 &&
- IS_PGXC_COORDINATOR &&
- !IsConnFromCoord())
+ IS_PGXC_LOCAL_COORDINATOR)
ereport(ERROR,
(errcode(ERRCODE_STATEMENT_TOO_COMPLEX),
errmsg("Incompatible operation with data redistribution")));
@@ -7262,7 +7260,7 @@ validateForeignKeyConstraint(char *conname,
* check constraint on the datanodes and at all on just one coordinator
* if we ever support coordinator only relations
*/
- if (IS_PGXC_COORDINATOR && IsConnFromCoord())
+ if (IS_PGXC_REMOTE_COORDINATOR)
return;
#endif
@@ -11199,8 +11197,7 @@ AlterTableNamespaceInternal(Relation rel, Oid oldNspOid, Oid nspOid,
#ifdef PGXC
/* Rename also sequence on GTM for a sequence */
- if (IS_PGXC_COORDINATOR &&
- !IsConnFromCoord() &&
+ if (IS_PGXC_LOCAL_COORDINATOR &&
rel->rd_rel->relkind == RELKIND_SEQUENCE &&
!IsTempSequence(RelationGetRelid(rel)))
{
@@ -11404,8 +11401,7 @@ AlterSeqNamespaces(Relation classRel, Relation rel,
#ifdef PGXC
/* Change also this sequence name on GTM */
- if (IS_PGXC_COORDINATOR &&
- !IsConnFromCoord() &&
+ if (IS_PGXC_LOCAL_COORDINATOR &&
!IsTempSequence(RelationGetRelid(seqRel)))
{
char *seqname = GetGlobalSeqName(seqRel, NULL, NULL);
diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c
index 86feb2917f..71867c9cc5 100644
--- a/src/backend/executor/functions.c
+++ b/src/backend/executor/functions.c
@@ -518,7 +518,7 @@ init_execution_state(List *queryTree_list,
CreateCommandTag(stmt))));
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
if (queryTree->commandType != CMD_UTILITY)
{
diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c
index 99b6147465..8a6368056c 100644
--- a/src/backend/optimizer/path/allpaths.c
+++ b/src/backend/optimizer/path/allpaths.c
@@ -397,8 +397,7 @@ set_plain_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
* the remote query path unless it is a pg_catalog table
* or a sequence relation.
*/
- if (IS_PGXC_COORDINATOR &&
- !IsConnFromCoord() &&
+ if (IS_PGXC_LOCAL_COORDINATOR &&
get_rel_namespace(rte->relid) != PG_CATALOG_NAMESPACE &&
get_rel_relkind(rte->relid) != RELKIND_SEQUENCE &&
!root->parse->is_local)
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
index 88afebb99b..c9d9c2f889 100644
--- a/src/backend/optimizer/plan/createplan.c
+++ b/src/backend/optimizer/plan/createplan.c
@@ -782,7 +782,7 @@ create_join_plan(PlannerInfo *root, JoinPath *best_path)
* Check if this join can be reduced to an equiv. remote scan node
* This can only be executed on a remote Coordinator
*/
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
plan = create_remotejoin_plan(root, best_path, plan, outer_plan, inner_plan);
#endif /* XCP */
#endif /* PGXC */
diff --git a/src/backend/optimizer/plan/pgxcplan.c b/src/backend/optimizer/plan/pgxcplan.c
index 7bb24fdf0a..05488225e0 100644
--- a/src/backend/optimizer/plan/pgxcplan.c
+++ b/src/backend/optimizer/plan/pgxcplan.c
@@ -827,7 +827,7 @@ pgxc_make_modifytable(PlannerInfo *root, Plan *topplan)
* table plan on the top. We should send queries to the remote nodes only
* when there is something to modify.
*/
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
topplan = create_remotedml_plan(root, topplan, mt->operation);
return topplan;
@@ -2540,7 +2540,7 @@ AddRemoteQueryNode(List *stmts, const char *queryString, RemoteQueryExecType rem
return result;
/* Only a remote Coordinator is allowed to send a query to backend nodes */
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
RemoteQuery *step = makeNode(RemoteQuery);
step->combine_type = COMBINE_TYPE_SAME;
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
index a72e1e2c78..d8358a0f27 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -163,7 +163,7 @@ planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
* A Coordinator receiving a query from another Coordinator
* is not allowed to go into PGXC planner.
*/
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
result = pgxc_planner(parse, cursorOptions, boundParams);
else
#endif /* XCP */
@@ -184,7 +184,7 @@ standard_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
*lr;
#ifdef XCP
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord() && parse->utilityStmt &&
+ if (IS_PGXC_LOCAL_COORDINATOR && parse->utilityStmt &&
IsA(parse->utilityStmt, RemoteQuery))
return pgxc_direct_planner(parse, cursorOptions, boundParams);
#endif
@@ -1830,7 +1830,7 @@ grouping_planner(PlannerInfo *root, double tuple_fraction)
* reduce the number drastically. Hence, try pushing GROUP BY
* clauses and aggregates to the datanode, thus saving bandwidth.
*/
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
result_plan = create_remoteagg_plan(root, result_plan);
#endif /* XCP */
#endif /* PGXC */
@@ -1950,7 +1950,7 @@ grouping_planner(PlannerInfo *root, double tuple_fraction)
* reduce the number drastically. Hence, try pushing GROUP BY
* clauses and aggregates to the Datanode, thus saving bandwidth.
*/
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
result_plan = create_remotegrouping_plan(root, result_plan);
#endif /* XCP */
#endif /* PGXC */
diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c
index de70719e72..1ebbab5d68 100644
--- a/src/backend/optimizer/plan/subselect.c
+++ b/src/backend/optimizer/plan/subselect.c
@@ -517,7 +517,7 @@ make_subplan(PlannerInfo *root, Query *orig_subquery, SubLinkType subLinkType,
subLinkType, testexpr, true, isTopQual);
#ifdef PGXC
/* This is not necessary for a PGXC Coordinator, we just need one plan */
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
return result;
#endif
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index 1b7f4b64da..af2a429387 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -450,8 +450,7 @@ estimate_rel_size(Relation rel, int32 *attr_widths,
* Override the estimates only for remote tables (currently
* identified by non-NULL rd_locator_info)
*/
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord() &&
- rel->rd_locator_info)
+ if (IS_PGXC_LOCAL_COORDINATOR && rel->rd_locator_info)
{
*pages = 10;
*tuples = 10;
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c
index 25faaab72e..a30275529a 100644
--- a/src/backend/parser/analyze.c
+++ b/src/backend/parser/analyze.c
@@ -618,7 +618,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
* the parent, set flag to send command ID communication to remote
* nodes in order to maintain global data visibility.
*/
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
target_rte = rt_fetch(qry->resultRelation, pstate->p_rtable);
if (is_relation_child(target_rte, selectQuery->rtable))
diff --git a/src/backend/pgxc/barrier/barrier.c b/src/backend/pgxc/barrier/barrier.c
index 04e1aa568a..272a8c2611 100644
--- a/src/backend/pgxc/barrier/barrier.c
+++ b/src/backend/pgxc/barrier/barrier.c
@@ -54,7 +54,7 @@ ProcessCreateBarrierPrepare(const char *id)
{
StringInfoData buf;
- if (!IS_PGXC_COORDINATOR || !IsConnFromCoord())
+ if (!IS_PGXC_REMOTE_COORDINATOR)
ereport(ERROR,
(errcode(ERRCODE_INTERNAL_ERROR),
errmsg("The CREATE BARRIER PREPARE message is expected to "
@@ -82,7 +82,7 @@ ProcessCreateBarrierEnd(const char *id)
{
StringInfoData buf;
- if (!IS_PGXC_COORDINATOR || !IsConnFromCoord())
+ if (!IS_PGXC_REMOTE_COORDINATOR)
ereport(ERROR,
(errcode(ERRCODE_INTERNAL_ERROR),
errmsg("The CREATE BARRIER END message is expected to "
diff --git a/src/backend/pgxc/plan/planner.c b/src/backend/pgxc/plan/planner.c
index 019f11257f..dbe16c49f8 100644
--- a/src/backend/pgxc/plan/planner.c
+++ b/src/backend/pgxc/plan/planner.c
@@ -2073,7 +2073,7 @@ AddRemoteQueryNode(List *stmts, const char *queryString, RemoteQueryExecType rem
return result;
/* Only a remote Coordinator is allowed to send a query to backend nodes */
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
RemoteQuery *step = makeNode(RemoteQuery);
step->combine_type = COMBINE_TYPE_SAME;
@@ -2140,7 +2140,7 @@ AddRemoteQueryNode(List *stmts, const char *queryString, RemoteQueryExecType rem
/* Only a remote Coordinator is allowed to send a query to backend nodes */
if (remoteExecType == EXEC_ON_CURRENT ||
- (IS_PGXC_COORDINATOR && !IsConnFromCoord()))
+ (IS_PGXC_LOCAL_COORDINATOR))
{
RemoteQuery *step = makeNode(RemoteQuery);
step->combine_type = COMBINE_TYPE_SAME;
diff --git a/src/backend/pgxc/pool/execRemote.c b/src/backend/pgxc/pool/execRemote.c
index 3ecca730e9..788933f109 100644
--- a/src/backend/pgxc/pool/execRemote.c
+++ b/src/backend/pgxc/pool/execRemote.c
@@ -6508,7 +6508,7 @@ PreCommit_Remote(char *prepareGID, char *nodestring, bool preparedLocalNode)
* table finally aborts - remote connections are not holding temporary
* objects in this case.
*/
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord() && MyXactAccessedTempRel)
+ if (IS_PGXC_LOCAL_COORDINATOR && MyXactAccessedTempRel)
temp_object_included = true;
@@ -6718,7 +6718,7 @@ PreAbort_Remote(void)
pfree_pgxc_all_handles(all_handles);
#else
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
cancel_query();
clear_all_data();
@@ -6807,7 +6807,7 @@ PrePrepare_Remote(char *prepareGID, bool localNode, bool implicit)
nodestring = pgxc_node_remote_prepare(prepareGID,
!implicit || localNode);
- if (!implicit && IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (!implicit && IS_PGXC_LOCAL_COORDINATOR)
/* Save the node list and gid on GTM. */
StartPreparedTranGTM(GetTopGlobalTransactionId(), prepareGID,
nodestring);
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index e88f61bb19..1173032d81 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -773,7 +773,7 @@ pg_analyze_and_rewrite(Node *parsetree, const char *query_string,
#ifdef PGXC
#ifndef XCP
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
ListCell *lc;
@@ -1062,8 +1062,7 @@ exec_simple_query(const char *query_string)
parsetree_list = pg_parse_query(query_string);
#ifdef XCP
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord() &&
- list_length(parsetree_list) > 1)
+ if (IS_PGXC_LOCAL_COORDINATOR && list_length(parsetree_list) > 1)
{
/*
* There is a bug in old code, if one query contains multiple utility
@@ -1558,7 +1557,7 @@ exec_parse_message(const char *query_string, /* string to execute */
querytree_list = pg_rewrite_query(query);
#ifdef PGXC
#ifndef XCP
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
ListCell *lc;
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
index 77bd7a2a57..dc1016a5b5 100644
--- a/src/backend/tcop/utility.c
+++ b/src/backend/tcop/utility.c
@@ -422,7 +422,7 @@ standard_ProcessUtility(Node *parsetree,
* This request would fail because the unfinished transaction
* would already hold the advisory lock.
*/
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord() && IsNormalProcessingMode())
+ if (IS_PGXC_LOCAL_COORDINATOR && IsNormalProcessingMode())
{
/* Is the statement a prohibited one? */
if (!IsStmtAllowedInLockedMode(parsetree, queryString))
@@ -489,7 +489,7 @@ standard_ProcessUtility(Node *parsetree,
PreventCommandDuringRecovery("PREPARE TRANSACTION");
#ifdef PGXC
/* Add check if xid is valid */
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord() && !xc_maintenance_mode)
+ if (IS_PGXC_LOCAL_COORDINATOR && !xc_maintenance_mode)
{
if (IsXidImplicit((const char *)stmt->gid))
{
@@ -515,7 +515,7 @@ standard_ProcessUtility(Node *parsetree,
* Commit a transaction which was explicitely prepared
* before
*/
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
if (FinishRemotePreparedTransaction(stmt->gid, true) || xc_maintenance_mode)
FinishPreparedTransaction(stmt->gid, true);
@@ -533,7 +533,7 @@ standard_ProcessUtility(Node *parsetree,
* Abort a transaction which was explicitely prepared
* before
*/
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
if (FinishRemotePreparedTransaction(stmt->gid, false) || xc_maintenance_mode)
FinishPreparedTransaction(stmt->gid, false);
@@ -631,12 +631,12 @@ standard_ProcessUtility(Node *parsetree,
case T_CreateTableSpaceStmt:
/* no event triggers for global objects */
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
#endif
PreventTransactionChain(isTopLevel, "CREATE TABLESPACE");
CreateTableSpace((CreateTableSpaceStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityWithMessage(queryString, sentToRemote, false);
#endif
break;
@@ -645,7 +645,7 @@ standard_ProcessUtility(Node *parsetree,
/* no event triggers for global objects */
#ifdef PGXC
/* Allow this to be run inside transaction block on remote nodes */
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
#endif
PreventTransactionChain(isTopLevel, "DROP TABLESPACE");
@@ -660,7 +660,7 @@ standard_ProcessUtility(Node *parsetree,
/* no event triggers for global objects */
AlterTableSpaceOptions((AlterTableSpaceOptionsStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, true, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -678,7 +678,7 @@ standard_ProcessUtility(Node *parsetree,
* If at least one temporary table is truncated truncate cannot use 2PC
* at commit.
*/
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
bool is_temp = false;
ListCell *cell;
@@ -707,7 +707,7 @@ standard_ProcessUtility(Node *parsetree,
#ifdef PGXC
/* Comment objects depending on their object and temporary types */
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
bool is_temp = false;
CommentStmt *stmt = (CommentStmt *) parsetree;
@@ -750,7 +750,7 @@ standard_ProcessUtility(Node *parsetree,
case T_GrantStmt:
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
RemoteQueryExecType remoteExecType = EXEC_ON_ALL_NODES;
GrantStmt *stmt = (GrantStmt *) parsetree;
@@ -808,7 +808,7 @@ standard_ProcessUtility(Node *parsetree,
GrantRole((GrantRoleStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -816,12 +816,12 @@ standard_ProcessUtility(Node *parsetree,
case T_CreatedbStmt:
/* no event triggers for global objects */
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
#endif
PreventTransactionChain(isTopLevel, "CREATE DATABASE");
createdb((CreatedbStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityWithMessage(queryString, sentToRemote, false);
#endif
break;
@@ -830,7 +830,7 @@ standard_ProcessUtility(Node *parsetree,
/* no event triggers for global objects */
AlterDatabase((AlterDatabaseStmt *) parsetree, isTopLevel);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
/*
* If this is not a SET TABLESPACE statement, just propogate the
@@ -860,7 +860,7 @@ standard_ProcessUtility(Node *parsetree,
/* no event triggers for global objects */
#ifdef PGXC
/* Clean connections before dropping a database on local node */
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
char query[256];
DropDBCleanConnection(stmt->dbname);
@@ -878,14 +878,14 @@ standard_ProcessUtility(Node *parsetree,
#ifdef PGXC
/* Allow this to be run inside transaction block on remote nodes */
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
#endif
PreventTransactionChain(isTopLevel, "DROP DATABASE");
dropdb(stmt->dbname, stmt->missing_ok);
}
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -932,7 +932,7 @@ standard_ProcessUtility(Node *parsetree,
load_file(stmt->filename, !superuser());
}
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_DATANODES, false);
#endif
break;
@@ -941,7 +941,7 @@ standard_ProcessUtility(Node *parsetree,
/* we choose to allow this during "read only" transactions */
PreventCommandDuringRecovery("CLUSTER");
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, true, EXEC_ON_DATANODES, false);
#endif
cluster((ClusterStmt *) parsetree, isTopLevel);
@@ -959,7 +959,7 @@ standard_ProcessUtility(Node *parsetree,
* We have to run the command on nodes before Coordinator because
* vacuum() pops active snapshot and we can not send it to nodes
*/
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, true, EXEC_ON_DATANODES, false);
#endif
vacuum(stmt, InvalidOid, true, NULL, false, isTopLevel);
@@ -980,7 +980,7 @@ standard_ProcessUtility(Node *parsetree,
#ifdef PGXC
#ifndef XCP
/* Let the pooler manage the statement */
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
VariableSetStmt *stmt = (VariableSetStmt *) parsetree;
/*
@@ -1045,7 +1045,7 @@ standard_ProcessUtility(Node *parsetree,
/* no event triggers for global objects */
CreateRole((CreateRoleStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -1054,7 +1054,7 @@ standard_ProcessUtility(Node *parsetree,
/* no event triggers for global objects */
AlterRole((AlterRoleStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -1063,7 +1063,7 @@ standard_ProcessUtility(Node *parsetree,
/* no event triggers for global objects */
AlterRoleSet((AlterRoleSetStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -1072,7 +1072,7 @@ standard_ProcessUtility(Node *parsetree,
/* no event triggers for global objects */
DropRole((DropRoleStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -1081,7 +1081,7 @@ standard_ProcessUtility(Node *parsetree,
/* no event triggers for global objects */
ReassignOwnedObjects((ReassignOwnedStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -1095,7 +1095,7 @@ standard_ProcessUtility(Node *parsetree,
RequireTransactionChain(isTopLevel, "LOCK TABLE");
LockTableCommand((LockStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -1121,7 +1121,7 @@ standard_ProcessUtility(Node *parsetree,
* inside a transaction block, hence it has no effect outside that, so use
* it as a local one.
*/
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord() && IsTransactionBlock())
+ if (IS_PGXC_LOCAL_COORDINATOR && IsTransactionBlock())
{
if (PoolManagerSetCommand(POOL_CMD_LOCAL_SET, queryString) < 0)
elog(ERROR, "Postgres-XC: ERROR SET query");
@@ -1146,7 +1146,7 @@ standard_ProcessUtility(Node *parsetree,
RequestCheckpoint(CHECKPOINT_IMMEDIATE | CHECKPOINT_WAIT |
(RecoveryInProgress() ? 0 : CHECKPOINT_FORCE));
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, true, EXEC_ON_DATANODES, false);
#endif
break;
@@ -1224,7 +1224,7 @@ standard_ProcessUtility(Node *parsetree,
break;
}
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote,
stmt->kind == OBJECT_DATABASE, EXEC_ON_ALL_NODES, false);
#endif
@@ -1259,7 +1259,7 @@ standard_ProcessUtility(Node *parsetree,
case T_RenameStmt:
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
RenameStmt *stmt = (RenameStmt *) parsetree;
RemoteQueryExecType exec_type;
@@ -1316,7 +1316,7 @@ standard_ProcessUtility(Node *parsetree,
case T_AlterObjectSchemaStmt:
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
AlterObjectSchemaStmt *stmt = (AlterObjectSchemaStmt *) parsetree;
RemoteQueryExecType exec_type;
@@ -1387,7 +1387,7 @@ standard_ProcessUtility(Node *parsetree,
ExecAlterOwnerStmt(stmt);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
}
@@ -1508,7 +1508,7 @@ ProcessUtilitySlow(Node *parsetree,
queryString);
#endif
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
/*
* Scan the list of objects.
@@ -1676,7 +1676,7 @@ ProcessUtilitySlow(Node *parsetree,
* Add a RemoteQuery node for a query at top level on a remote
* Coordinator, if not already done so
*/
- if (!sentToRemote)
+ if (IS_PGXC_LOCAL_COORDINATOR && !sentToRemote)
{
bool is_temp = false;
RemoteQueryExecType exec_type;
@@ -1784,7 +1784,7 @@ ProcessUtilitySlow(Node *parsetree,
}
}
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -1841,7 +1841,7 @@ ProcessUtilitySlow(Node *parsetree,
}
}
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -1916,7 +1916,7 @@ ProcessUtilitySlow(Node *parsetree,
case T_CreateExtensionStmt:
CreateExtension((CreateExtensionStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -1924,7 +1924,7 @@ ProcessUtilitySlow(Node *parsetree,
case T_AlterExtensionStmt:
ExecAlterExtensionStmt((AlterExtensionStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -1932,7 +1932,7 @@ ProcessUtilitySlow(Node *parsetree,
case T_AlterExtensionContentsStmt:
ExecAlterExtensionContentsStmt((AlterExtensionContentsStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -2002,7 +2002,7 @@ ProcessUtilitySlow(Node *parsetree,
DefineCompositeType(stmt->typevar, stmt->coldeflist);
}
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -2010,7 +2010,7 @@ ProcessUtilitySlow(Node *parsetree,
case T_CreateEnumStmt: /* CREATE TYPE AS ENUM */
DefineEnum((CreateEnumStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -2018,7 +2018,7 @@ ProcessUtilitySlow(Node *parsetree,
case T_CreateRangeStmt: /* CREATE TYPE AS RANGE */
DefineRange((CreateRangeStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -2030,7 +2030,7 @@ ProcessUtilitySlow(Node *parsetree,
* In this case force autocommit, this transaction cannot be launched
* inside a transaction block.
*/
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -2038,7 +2038,7 @@ ProcessUtilitySlow(Node *parsetree,
case T_ViewStmt: /* CREATE VIEW */
DefineView((ViewStmt *) parsetree, queryString);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
#ifdef XCP
ViewStmt *stmt = (ViewStmt *) parsetree;
@@ -2055,7 +2055,7 @@ ProcessUtilitySlow(Node *parsetree,
case T_CreateFunctionStmt: /* CREATE FUNCTION */
CreateFunction((CreateFunctionStmt *) parsetree, queryString);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -2063,7 +2063,7 @@ ProcessUtilitySlow(Node *parsetree,
case T_AlterFunctionStmt: /* ALTER FUNCTION */
AlterFunction((AlterFunctionStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -2071,7 +2071,7 @@ ProcessUtilitySlow(Node *parsetree,
case T_RuleStmt: /* CREATE RULE */
DefineRule((RuleStmt *) parsetree, queryString);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
RemoteQueryExecType exec_type;
bool is_temp;
@@ -2085,7 +2085,7 @@ ProcessUtilitySlow(Node *parsetree,
case T_CreateSeqStmt:
DefineSequence((CreateSeqStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
CreateSeqStmt *stmt = (CreateSeqStmt *) parsetree;
@@ -2109,7 +2109,7 @@ ProcessUtilitySlow(Node *parsetree,
case T_AlterSeqStmt:
AlterSequence((AlterSeqStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
AlterSeqStmt *stmt = (AlterSeqStmt *) parsetree;
@@ -2182,7 +2182,7 @@ ProcessUtilitySlow(Node *parsetree,
#endif
errdetail("The feature is not currently supported")));
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -2190,7 +2190,7 @@ ProcessUtilitySlow(Node *parsetree,
case T_CreatePLangStmt:
CreateProceduralLanguage((CreatePLangStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -2198,7 +2198,7 @@ ProcessUtilitySlow(Node *parsetree,
case T_CreateDomainStmt:
DefineDomain((CreateDomainStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -2206,7 +2206,7 @@ ProcessUtilitySlow(Node *parsetree,
case T_CreateConversionStmt:
CreateConversionCommand((CreateConversionStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -2214,7 +2214,7 @@ ProcessUtilitySlow(Node *parsetree,
case T_CreateCastStmt:
CreateCast((CreateCastStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -2222,7 +2222,7 @@ ProcessUtilitySlow(Node *parsetree,
case T_CreateOpClassStmt:
DefineOpClass((CreateOpClassStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -2230,7 +2230,7 @@ ProcessUtilitySlow(Node *parsetree,
case T_CreateOpFamilyStmt:
DefineOpFamily((CreateOpFamilyStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -2238,7 +2238,7 @@ ProcessUtilitySlow(Node *parsetree,
case T_AlterOpFamilyStmt:
AlterOpFamily((AlterOpFamilyStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -2246,7 +2246,7 @@ ProcessUtilitySlow(Node *parsetree,
case T_AlterTSDictionaryStmt:
AlterTSDictionary((AlterTSDictionaryStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -2254,7 +2254,7 @@ ProcessUtilitySlow(Node *parsetree,
case T_AlterTSConfigurationStmt:
AlterTSConfiguration((AlterTSConfigurationStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -2282,7 +2282,7 @@ ProcessUtilitySlow(Node *parsetree,
case T_DropOwnedStmt:
DropOwnedObjects((DropOwnedStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -2291,7 +2291,7 @@ ProcessUtilitySlow(Node *parsetree,
ExecAlterDefaultPrivilegesStmt((AlterDefaultPrivilegesStmt *) parsetree);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR)
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
#endif
break;
@@ -2358,7 +2358,7 @@ ExecDropStmt(DropStmt *stmt, bool isTopLevel)
RemoveRelations(stmt);
#ifdef PGXC
/* DROP is done depending on the object type and its temporary type */
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false,
exec_type, is_temp);
}
@@ -2376,7 +2376,7 @@ ExecDropStmt(DropStmt *stmt, bool isTopLevel)
#endif
RemoveObjects(stmt);
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false,
exec_type, is_temp);
}
diff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.c
index f1788b84f3..1feb99457d 100644
--- a/src/backend/utils/adt/dbsize.c
+++ b/src/backend/utils/adt/dbsize.c
@@ -64,7 +64,7 @@ static int64 pgxc_exec_sizefunc(Oid relOid, char *funcname, char *extra_arg);
* locator info, that means it is a Coordinator-only table.
*/
#define COLLECT_FROM_DATANODES(relid) \
- (IS_PGXC_COORDINATOR && !IsConnFromCoord() && \
+ (IS_PGXC_LOCAL_COORDINATOR && \
(GetRelationLocInfo((relid)) != NULL))
#endif
@@ -175,7 +175,7 @@ pg_database_size_oid(PG_FUNCTION_ARGS)
int64 size;
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
PG_RETURN_DATUM(pgxc_database_size(dbOid));
#endif
@@ -195,7 +195,7 @@ pg_database_size_name(PG_FUNCTION_ARGS)
int64 size;
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
PG_RETURN_DATUM(pgxc_database_size(dbOid));
#endif
@@ -294,7 +294,7 @@ pg_tablespace_size_oid(PG_FUNCTION_ARGS)
int64 size;
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
PG_RETURN_DATUM(pgxc_tablespace_size(tblspcOid));
#endif
@@ -314,7 +314,7 @@ pg_tablespace_size_name(PG_FUNCTION_ARGS)
int64 size;
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
PG_RETURN_DATUM(pgxc_tablespace_size(tblspcOid));
#endif
diff --git a/src/backend/utils/adt/lockfuncs.c b/src/backend/utils/adt/lockfuncs.c
index 6e55f08b04..27796243ec 100644
--- a/src/backend/utils/adt/lockfuncs.c
+++ b/src/backend/utils/adt/lockfuncs.c
@@ -586,7 +586,7 @@ pg_advisory_lock_int8(PG_FUNCTION_ARGS)
LOCKTAG tag;
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
pgxc_advisory_lock(key, 0, 0, true, ExclusiveLock, SESSION_LOCK, WAIT);
PG_RETURN_VOID();
@@ -611,7 +611,7 @@ pg_advisory_xact_lock_int8(PG_FUNCTION_ARGS)
LOCKTAG tag;
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
pgxc_advisory_lock(key, 0, 0, true, ExclusiveLock, TRANSACTION_LOCK, WAIT);
PG_RETURN_VOID();
@@ -635,7 +635,7 @@ pg_advisory_lock_shared_int8(PG_FUNCTION_ARGS)
LOCKTAG tag;
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
pgxc_advisory_lock(key, 0, 0, true, ShareLock, SESSION_LOCK, WAIT);
PG_RETURN_VOID();
@@ -660,7 +660,7 @@ pg_advisory_xact_lock_shared_int8(PG_FUNCTION_ARGS)
LOCKTAG tag;
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
pgxc_advisory_lock(key, 0, 0, true, ShareLock, TRANSACTION_LOCK, WAIT);
PG_RETURN_VOID();
@@ -687,7 +687,7 @@ pg_try_advisory_lock_int8(PG_FUNCTION_ARGS)
LockAcquireResult res;
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
PG_RETURN_BOOL(pgxc_advisory_lock(key, 0, 0, true, ExclusiveLock, SESSION_LOCK, DONT_WAIT));
#endif
@@ -712,7 +712,7 @@ pg_try_advisory_xact_lock_int8(PG_FUNCTION_ARGS)
LockAcquireResult res;
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
PG_RETURN_BOOL(pgxc_advisory_lock(key, 0, 0, true, ExclusiveLock, TRANSACTION_LOCK, DONT_WAIT));
#endif
@@ -736,7 +736,7 @@ pg_try_advisory_lock_shared_int8(PG_FUNCTION_ARGS)
LockAcquireResult res;
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
PG_RETURN_BOOL(pgxc_advisory_lock(key, 0, 0, true, ShareLock, SESSION_LOCK, DONT_WAIT));
#endif
@@ -761,7 +761,7 @@ pg_try_advisory_xact_lock_shared_int8(PG_FUNCTION_ARGS)
LockAcquireResult res;
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
PG_RETURN_BOOL(pgxc_advisory_lock(key, 0, 0, true, ShareLock, TRANSACTION_LOCK, DONT_WAIT));
#endif
@@ -821,7 +821,7 @@ pg_advisory_lock_int4(PG_FUNCTION_ARGS)
LOCKTAG tag;
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
pgxc_advisory_lock(0, key1, key2, false, ExclusiveLock, SESSION_LOCK, WAIT);
PG_RETURN_VOID();
@@ -847,7 +847,7 @@ pg_advisory_xact_lock_int4(PG_FUNCTION_ARGS)
LOCKTAG tag;
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
pgxc_advisory_lock(0, key1, key2, false, ExclusiveLock, TRANSACTION_LOCK, WAIT);
PG_RETURN_VOID();
@@ -872,7 +872,7 @@ pg_advisory_lock_shared_int4(PG_FUNCTION_ARGS)
LOCKTAG tag;
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
pgxc_advisory_lock(0, key1, key2, false, ShareLock, SESSION_LOCK, WAIT);
PG_RETURN_VOID();
@@ -898,7 +898,7 @@ pg_advisory_xact_lock_shared_int4(PG_FUNCTION_ARGS)
LOCKTAG tag;
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
{
pgxc_advisory_lock(0, key1, key2, false, ShareLock, TRANSACTION_LOCK, WAIT);
PG_RETURN_VOID();
@@ -926,7 +926,7 @@ pg_try_advisory_lock_int4(PG_FUNCTION_ARGS)
LockAcquireResult res;
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
PG_RETURN_BOOL(pgxc_advisory_lock(0, key1, key2, false, ExclusiveLock, SESSION_LOCK, DONT_WAIT));
#endif
@@ -952,7 +952,7 @@ pg_try_advisory_xact_lock_int4(PG_FUNCTION_ARGS)
LockAcquireResult res;
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
PG_RETURN_BOOL(pgxc_advisory_lock(0, key1, key2, false, ExclusiveLock, TRANSACTION_LOCK, DONT_WAIT));
#endif
@@ -977,7 +977,7 @@ pg_try_advisory_lock_shared_int4(PG_FUNCTION_ARGS)
LockAcquireResult res;
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
PG_RETURN_BOOL(pgxc_advisory_lock(0, key1, key2, false, ShareLock, SESSION_LOCK, DONT_WAIT));
#endif
@@ -1003,7 +1003,7 @@ pg_try_advisory_xact_lock_shared_int4(PG_FUNCTION_ARGS)
LockAcquireResult res;
#ifdef PGXC
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (IS_PGXC_LOCAL_COORDINATOR)
PG_RETURN_BOOL(pgxc_advisory_lock(0, key1, key2, false, ShareLock, TRANSACTION_LOCK, DONT_WAIT));
#endif
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 0485ae2383..de22837b45 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -5474,7 +5474,7 @@ get_insert_query_def(Query *query, deparse_context *context)
* In the case of "INSERT ... DEFAULT VALUES" analyzed in pgxc planner,
* return the sql statement directly if the table has no default values.
*/
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord() && !query->targetList)
+ if (IS_PGXC_LOCAL_COORDINATOR && !query->targetList)
{
appendStringInfo(buf, "%s", query->sql_statement);
return;
@@ -5514,7 +5514,7 @@ get_insert_query_def(Query *query, deparse_context *context)
* sql_statement is rewritten and assigned in RewriteQuery.
* Just return it here.
*/
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord() && values_rte != NULL)
+ if (IS_PGXC_LOCAL_COORDINATOR && values_rte != NULL)
{
appendStringInfo(buf, "%s", query->sql_statement);
return;
diff --git a/src/backend/utils/cache/plancache.c b/src/backend/utils/cache/plancache.c
index dc4cd86c42..1f942e1150 100644
--- a/src/backend/utils/cache/plancache.c
+++ b/src/backend/utils/cache/plancache.c
@@ -1024,8 +1024,7 @@ BuildCachedPlan(CachedPlanSource *plansource, List *qlist,
* If this plansource belongs to a named prepared statement, store the stmt
* name for the Datanode queries.
*/
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord()
- && plansource->stmt_name)
+ if (IS_PGXC_LOCAL_COORDINATOR && plansource->stmt_name)
{
ListCell *lc;
int n;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 3737ced8c4..687477f8af 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -7562,7 +7562,7 @@ set_config_by_name(PG_FUNCTION_ARGS)
* If command is local and we are not in a transaction block do NOT
* send this query to backend nodes, it is just bypassed by the backend.
*/
- if (IS_PGXC_COORDINATOR && !IsConnFromCoord()
+ if (IS_PGXC_LOCAL_COORDINATOR
&& (!is_local || IsTransactionBlock()))
{
PoolCommandType poolcmdType = (is_local ? POOL_CMD_LOCAL_SET : POOL_CMD_GLOBAL_SET);
diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c
index 903e06d8f3..077d272ebd 100644
--- a/src/backend/utils/time/snapmgr.c
+++ b/src/backend/utils/time/snapmgr.c
@@ -639,7 +639,7 @@ GetActiveSnapshot(void)
* Check if topmost snapshot is null or not,
* if it is, a new one will be taken from GTM.
*/
- if (!ActiveSnapshot && IS_PGXC_COORDINATOR && !IsConnFromCoord())
+ if (!ActiveSnapshot && IS_PGXC_LOCAL_COORDINATOR)
return NULL;
#endif
Assert(ActiveSnapshot != NULL);
diff --git a/src/include/pgxc/pgxc.h b/src/include/pgxc/pgxc.h
index 60c0d138b9..d223d3a3b6 100644
--- a/src/include/pgxc/pgxc.h
+++ b/src/include/pgxc/pgxc.h
@@ -51,6 +51,12 @@ extern Datum xc_lockForBackupKey2;
#define IS_PGXC_COORDINATOR isPGXCCoordinator
#define IS_PGXC_DATANODE isPGXCDataNode
+
+#define IS_PGXC_LOCAL_COORDINATOR \
+ (IS_PGXC_COORDINATOR && !IsConnFromCoord())
+#define IS_PGXC_REMOTE_COORDINATOR \
+ (IS_PGXC_COORDINATOR && IsConnFromCoord())
+
#ifdef XCP
#define PGXC_PARENT_NODE parentPGXCNode
#endif