summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPavan Deolasee2017-08-30 05:40:19 +0000
committerPavan Deolasee2017-08-30 05:40:19 +0000
commit46ff0d1eb1b7dcba0598fc99531a435c3930ae17 (patch)
tree71bb0a1763c8416ed8d649ab6accbfddba9727c6 /src
parent968106ef5bfbee49bbd4f931d9903636e600c302 (diff)
Fetch the target remote nodes to run CREATE STATISTICS command
Some database objects are created only on a subset of nodes. For example, views are created only on the coordinators. Similarly, temp tables are created on the local coordinator and all datanodes. So we must consult the relation kind before executing the CREATE STATISTICS command on the remote nodes. Otherwise we might try to execute it on a node where the underlying object is missing, resulting in errors. Patch by senhu ([email protected]) which was later reworked by me.
Diffstat (limited to 'src')
-rw-r--r--src/backend/tcop/utility.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
index e65ffc7fc1..8bdcf810b9 100644
--- a/src/backend/tcop/utility.c
+++ b/src/backend/tcop/utility.c
@@ -2576,7 +2576,26 @@ ProcessUtilitySlow(ParseState *pstate,
address = CreateStatistics((CreateStatsStmt *) parsetree);
#ifdef PGXC
if (IS_PGXC_LOCAL_COORDINATOR)
- ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, false, EXEC_ON_ALL_NODES, false);
+ {
+ bool is_temp;
+ CreateStatsStmt *stmt = (CreateStatsStmt *) parsetree;
+ RangeVar *rln = linitial(stmt->relations);
+ Relation rel = relation_openrv((RangeVar *) rln, ShareUpdateExclusiveLock);
+
+ /*
+ * Get the target nodes to run the CREATE STATISTICS
+ * command. Since the grammar does not tell us about the
+ * underlying object type, we use the other variant to
+ * fetch the nodes. This is ok because the command must
+ * only be even used on some kind of relation.
+ */
+ RemoteQueryExecType exec_type =
+ ExecUtilityFindNodesRelkind(RelationGetRelid(rel), &is_temp);
+
+ ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote,
+ false, exec_type, false);
+ relation_close(rel, NoLock);
+ }
#endif
break;