hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From esp...@apache.org
Subject [10/35] incubator-hawq git commit: HAWQ-1321. failNames wrongly uses memory context to build message when ANALYZE failed
Date Sun, 19 Feb 2017 23:07:45 GMT
HAWQ-1321. failNames wrongly uses memory context to build message when ANALYZE failed


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/256c0668
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/256c0668
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/256c0668

Branch: refs/heads/2.1.0.0-incubating
Commit: 256c0668c94137565c24dc2057fbe3282187165c
Parents: 1c36c28
Author: Yi <yjin@pivotal.io>
Authored: Tue Feb 14 09:43:16 2017 +1100
Committer: Yi <yjin@pivotal.io>
Committed: Tue Feb 14 09:43:16 2017 +1100

----------------------------------------------------------------------
 src/backend/commands/analyze.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/256c0668/src/backend/commands/analyze.c
----------------------------------------------------------------------
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index ae869da..65d9bd3 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -309,8 +309,6 @@ void analyzeStmt(VacuumStmt *stmt, List *relids, int preferred_seg_num)
 	int 					successCount = 0, failCount = 0;
 	StringInfoData 			failNames;
 
-	initStringInfo(&failNames);
-
 	/**
 	 * Ensure that an ANALYZE is requested.
 	 */
@@ -362,6 +360,7 @@ void analyzeStmt(VacuumStmt *stmt, List *relids, int preferred_seg_num)
 
 	MemoryContextSwitchTo(analyzeStatementContext);
 
+	initStringInfo(&failNames);
 
 	/*
 	 * This is a per relation context.
@@ -678,8 +677,12 @@ void analyzeStmt(VacuumStmt *stmt, List *relids, int preferred_seg_num)
 							              RelationGetRelationName(candidateRelation),
 							              edata->message);
 							failCount += 1;
+
+							/* failNames uses memory from statement level context */
+							MemoryContextSwitchTo(analyzeStatementContext);
 							appendStringInfo(&failNames, "%s", failCount == 1 ? "(" : ", ");
 							appendStringInfo(&failNames, "%s", RelationGetRelationName(candidateRelation));
+							MemoryContextSwitchTo(oldcontext);
 
 							/* rollback this table's sub-transaction */
 							RollbackAndReleaseCurrentSubTransaction();


Mime
View raw message