diff options
author | Pavan Deolasee | 2018-05-18 11:40:16 +0000 |
---|---|---|
committer | Pavan Deolasee | 2018-05-18 12:23:01 +0000 |
commit | 7dd8490e8861e0f31463385484f73044171c26db (patch) | |
tree | 23ab4cf10c9d89b20f6091aa7ecbf1b94a934a31 | |
parent | 0f65a7193da4b6b0a35b6446b4c904a9f5ac9bf6 (diff) |
Fix post-cherry-pick problems.
-rw-r--r-- | src/backend/commands/analyze.c | 1 | ||||
-rw-r--r-- | src/backend/tcop/postgres.c | 10 | ||||
-rw-r--r-- | src/backend/tcop/utility.c | 51 |
3 files changed, 25 insertions, 37 deletions
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index 8abc3432e3..eb4e91411e 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -3444,7 +3444,6 @@ coord_collect_extended_stats(Relation onerel, int attr_cnt) step->combine_type = COMBINE_TYPE_NONE; step->exec_nodes = NULL; step->sql_statement = query.data; - step->force_autocommit = true; step->exec_type = EXEC_ON_DATANODES; /* Add targetlist entries */ diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 3c73f9bc16..2ba0088286 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -1252,19 +1252,19 @@ exec_simple_query(const char *query_string) */ if (IS_PGXC_DATANODE && IsPostmasterEnvironment) { - if (IsA(parsetree, VacuumStmt)) + if (IsA(parsetree->stmt, VacuumStmt)) { - VacuumStmt *stmt = (VacuumStmt *) parsetree; + VacuumStmt *stmt = (VacuumStmt *) parsetree->stmt; if (stmt->options & VACOPT_VACUUM) SetForceXidFromGTM(true); } - else if (IsA(parsetree, ClusterStmt)) + else if (IsA(parsetree->stmt, ClusterStmt)) { - ClusterStmt *stmt = (ClusterStmt *) parsetree; + ClusterStmt *stmt = (ClusterStmt *) parsetree->stmt; if (stmt->relation == NULL) SetForceXidFromGTM(true); } - else if (IsA(parsetree, ReindexStmt)) + else if (IsA(parsetree->stmt, ReindexStmt)) { ReindexStmt *stmt = (ReindexStmt *) parsetree->stmt; if (stmt->kind == REINDEX_OBJECT_SCHEMA || diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index 6254f1c5a8..7d82c0ae35 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -433,12 +433,11 @@ ProcessUtilityPre(PlannedStmt *pstmt, bool isTopLevel = (context == PROCESS_UTILITY_TOPLEVEL); bool all_done = false; bool is_temp = false; - bool auto_commit = false; bool add_context = false; RemoteQueryExecType exec_type = EXEC_ON_NONE; /* - * auto_commit and is_temp is initialised to false and changed if required. + * is_temp is initialised to false and changed if required. * * exec_type is initialised to EXEC_ON_NONE and updated iff the command * needs remote execution during the preprocessing step. @@ -551,7 +550,7 @@ ProcessUtilityPre(PlannedStmt *pstmt, /* Clean also remote Coordinators */ sprintf(query, "CLEAN CONNECTION TO ALL FOR DATABASE %s;", quote_identifier(stmt->dbname)); - ExecUtilityStmtOnNodes(query, NULL, sentToRemote, true, + ExecUtilityStmtOnNodes(query, NULL, sentToRemote, EXEC_ON_ALL_NODES, false, false); } break; @@ -577,7 +576,13 @@ ProcessUtilityPre(PlannedStmt *pstmt, */ if (!(stmt->options & VACOPT_COORDINATOR)) exec_type = EXEC_ON_DATANODES; - auto_commit = true; + + if (IS_PGXC_LOCAL_COORDINATOR && + !(stmt->options & VACOPT_COORDINATOR)) + { + if (stmt->options & VACOPT_VACUUM) + SetRequireRemoteTransactionAutoCommit(); + } } break; @@ -712,7 +717,7 @@ ProcessUtilityPre(PlannedStmt *pstmt, * connections, then clean local pooler */ if (IS_PGXC_COORDINATOR) - ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, true, + ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, EXEC_ON_ALL_NODES, false, false); CleanConnection((CleanConnStmt *) parsetree); break; @@ -879,7 +884,7 @@ ProcessUtilityPre(PlannedStmt *pstmt, * Send queryString to remote nodes, if needed. */ if (IS_PGXC_LOCAL_COORDINATOR) - ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, auto_commit, + ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, exec_type, is_temp, add_context); @@ -895,12 +900,11 @@ ProcessUtilityPost(PlannedStmt *pstmt, { Node *parsetree = pstmt->utilityStmt; bool is_temp = false; - bool auto_commit = false; bool add_context = false; RemoteQueryExecType exec_type = EXEC_ON_NONE; /* - * auto_commit and is_temp is initialised to false and changed if required. + * is_temp is initialised to false and changed if required. * * exec_type is initialised to EXEC_ON_NONE and updated iff the command * needs remote execution during the preprocessing step. @@ -1059,8 +1063,12 @@ ProcessUtilityPost(PlannedStmt *pstmt, break; case T_ClusterStmt: + if (((ClusterStmt *) parsetree)->relation == NULL) + SetRequireRemoteTransactionAutoCommit(); + exec_type = EXEC_ON_DATANODES; + break; + case T_CheckPointStmt: - auto_commit = true; exec_type = EXEC_ON_DATANODES; break; @@ -1070,7 +1078,6 @@ ProcessUtilityPost(PlannedStmt *pstmt, * For example, temporary tables are created on all Datanodes * and Coordinators. */ - auto_commit = true; exec_type = EXEC_ON_ALL_NODES; break; @@ -1097,11 +1104,6 @@ ProcessUtilityPost(PlannedStmt *pstmt, (int) stmt->kind); break; } - if (IS_PGXC_LOCAL_COORDINATOR) - { - auto_commit = (stmt->kind == REINDEX_OBJECT_DATABASE || - stmt->kind == REINDEX_OBJECT_SCHEMA); - } } break; @@ -1211,7 +1213,6 @@ ProcessUtilityPost(PlannedStmt *pstmt, else exec_type = EXEC_ON_NONE; - auto_commit = stmt->concurrent; if (stmt->isconstraint) exec_type = EXEC_ON_NONE; } @@ -1318,7 +1319,7 @@ ProcessUtilityPost(PlannedStmt *pstmt, } if (IS_PGXC_LOCAL_COORDINATOR) - ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, auto_commit, + ExecUtilityStmtOnNodes(queryString, NULL, sentToRemote, exec_type, is_temp, add_context); } /* @@ -1678,16 +1679,6 @@ standard_ProcessUtility(PlannedStmt *pstmt, /* we choose to allow this during "read only" transactions */ PreventCommandDuringRecovery((stmt->options & VACOPT_VACUUM) ? "VACUUM" : "ANALYZE"); - /* - * 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_LOCAL_COORDINATOR && - !(stmt->options & VACOPT_COORDINATOR)) - { - if (stmt->options & VACOPT_VACUUM) - SetRequireRemoteTransactionAutoCommit(); - } /* forbidden in parallel mode due to CommandIsReadOnly */ ExecVacuum(stmt, isTopLevel); } @@ -4659,8 +4650,6 @@ ExecUtilityStmtOnNodesInternal(const char *queryString, ExecNodes *nodes, bool s * * queryString is the raw query to be executed. * If nodes is NULL then the list of nodes is computed from exec_type. - * If auto_commit is true, then the query is executed without a transaction - * block and auto-committed on the remote node. * exec_type is used to compute the list of remote nodes on which the query is * executed. * is_temp is set to true if the query involves a temporary database object. @@ -4669,13 +4658,13 @@ ExecUtilityStmtOnNodesInternal(const char *queryString, ExecNodes *nodes, bool s */ static void ExecUtilityStmtOnNodes(const char *queryString, ExecNodes *nodes, - bool sentToRemote, bool auto_commit, RemoteQueryExecType exec_type, + bool sentToRemote, RemoteQueryExecType exec_type, bool is_temp, bool add_context) { PG_TRY(); { ExecUtilityStmtOnNodesInternal(queryString, nodes, sentToRemote, - auto_commit, exec_type, is_temp); + exec_type, is_temp); } PG_CATCH(); { |