hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject incubator-hawq git commit: HAWQ-666. Restore to correct memory context after free query resource in ExecutorEnd
Date Wed, 13 Apr 2016 03:15:38 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master 17389e39a -> c71e20cee


HAWQ-666. Restore to correct memory context after free query resource in ExecutorEnd


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

Branch: refs/heads/master
Commit: c71e20ceee2ee02d4af0b48a4679e0ff8fd7de72
Parents: 17389e3
Author: Ruilong Huo <rhuo@pivotal.io>
Authored: Tue Apr 12 20:12:37 2016 -0700
Committer: Ruilong Huo <rhuo@pivotal.io>
Committed: Tue Apr 12 20:12:37 2016 -0700

----------------------------------------------------------------------
 src/backend/executor/execMain.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/c71e20ce/src/backend/executor/execMain.c
----------------------------------------------------------------------
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index d9830f3..5e8c6b1 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -1302,6 +1302,7 @@ ExecutorEnd(QueryDesc *queryDesc)
 {
 	EState	   *estate;
 	MemoryContext oldcontext;
+	MemoryContext tmpcontext;
 
 	/* sanity checks */
 	Assert(queryDesc != NULL);
@@ -1360,14 +1361,14 @@ ExecutorEnd(QueryDesc *queryDesc)
 	}
 	PG_CATCH();
 	{
-	  /* Cleanup the global resource reference for spi/function resource inheritate. */
-    if (Gp_role == GP_ROLE_DISPATCH) {
-      // we need to free resource in old memory-context.
-      MemoryContextSwitchTo(oldcontext);
-      AutoFreeResource(queryDesc->resource);
-      queryDesc->resource = NULL;
-      oldcontext = MemoryContextSwitchTo(estate->es_query_cxt);
-    }
+		/* Cleanup the global resource reference for spi/function resource inheritate. */
+		if (Gp_role == GP_ROLE_DISPATCH) {
+			/* we need to free resource in old memory-context. */
+			tmpcontext = MemoryContextSwitchTo(oldcontext);
+			AutoFreeResource(queryDesc->resource);
+			queryDesc->resource = NULL;
+			oldcontext = MemoryContextSwitchTo(tmpcontext);
+		}
 
 		/*
 		 * we got an error. do all the necessary cleanup.
@@ -1391,11 +1392,11 @@ ExecutorEnd(QueryDesc *queryDesc)
 
 	/* Cleanup the global resource reference for spi/function resource inheritate. */
 	if ( Gp_role == GP_ROLE_DISPATCH ) {
-	  // we need to free resource in old memory-context.
-	  MemoryContextSwitchTo(oldcontext);
+		/* we need to free resource in old memory-context. */
+		tmpcontext = MemoryContextSwitchTo(oldcontext);
 		AutoFreeResource(queryDesc->resource);
 		queryDesc->resource = NULL;
-		oldcontext = MemoryContextSwitchTo(estate->es_query_cxt);
+		oldcontext = MemoryContextSwitchTo(tmpcontext);
 	}
 
 	/*


Mime
View raw message