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-198. Build-in functions will be executed in resource_negotiator stage which causes it will be executed twice
Date Fri, 26 Feb 2016 03:08:41 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master 1f37293f8 -> 3d39d8f3f


HAWQ-198. Build-in functions will be executed in resource_negotiator stage which causes it
will be executed twice


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

Branch: refs/heads/master
Commit: 3d39d8f3f9c8ff8b0c5fd7d765d2ba569467c717
Parents: 1f37293
Author: Ruilong Huo <rhuo@pivotal.io>
Authored: Thu Feb 25 01:55:28 2016 -0800
Committer: Ruilong Huo <rhuo@pivotal.io>
Committed: Thu Feb 25 19:05:35 2016 -0800

----------------------------------------------------------------------
 src/backend/optimizer/plan/planner.c | 34 +++++++++++++++++++++++++++++++
 src/backend/optimizer/util/clauses.c | 11 ++++++++--
 src/include/optimizer/planner.h      |  4 ++++
 3 files changed, 47 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/3d39d8f3/src/backend/optimizer/plan/planner.c
----------------------------------------------------------------------
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
index c98ba49..025f53e 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -91,6 +91,8 @@ planner_hook_type planner_hook = NULL;
 
 ParamListInfo PlannerBoundParamList = NULL;		/* current boundParams */
 
+static int PlanningDepth = 0;		/* Planning depth */
+
 /* Expression kind codes for preprocess_expression */
 #define EXPRKIND_QUAL			0
 #define EXPRKIND_TARGET			1
@@ -165,6 +167,32 @@ static void sort_canonical_gs_list(List *gs, int *p_nsets, Bitmapset
***p_sets);
 static Plan *pushdown_preliminary_limit(Plan *plan, Node *limitCount, int64 count_est, Node
*limitOffset, int64 offset_est);
 bool is_dummy_plan(Plan *plan);
 
+
+bool is_in_planning_phase(void)
+{
+	if (PlanningDepth > 0)
+	{
+		return true;
+	}
+	else if (PlanningDepth < 0)
+	{
+		elog(ERROR, "Invalid PlanningDepth %d while getting planning phase", PlanningDepth);
+	}
+
+	return false;
+}
+
+void increase_planning_depth(void)
+{
+	PlanningDepth++;
+}
+
+void decrease_planning_depth(void)
+{
+	PlanningDepth--;
+}
+
+
 #ifdef USE_ORCA
 /**
  * Logging of optimization outcome
@@ -300,6 +328,8 @@ planner(Query *parse, int cursorOptions,
 	 * resource to run this query. After gaining the resource, we can perform the
 	 * actual optimization.
 	 */
+	increase_planning_depth();
+
 	plannerLevel++;
 	if (!resourceNegotiateDone)
 	{
@@ -309,6 +339,8 @@ planner(Query *parse, int cursorOptions,
       {
         resource_negotiator(parse, cursorOptions, boundParams, resourceLife, &ppResult);
 
+		decrease_planning_depth();
+
 		if(ppResult->stmt && ppResult->stmt->planTree)
 		{
 			isDispatchParallel = ppResult->stmt->planTree->dispatch == DISPATCH_PARALLEL;
@@ -318,6 +350,8 @@ planner(Query *parse, int cursorOptions,
 	  }
 	  PG_CATCH();
 	  {
+		decrease_planning_depth();
+
 		if ((ppResult != NULL))
 		{
 		  pfree(ppResult);

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/3d39d8f3/src/backend/optimizer/util/clauses.c
----------------------------------------------------------------------
diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c
index a80737f..a3d67f2 100644
--- a/src/backend/optimizer/util/clauses.c
+++ b/src/backend/optimizer/util/clauses.c
@@ -2831,8 +2831,15 @@ simplify_function(Oid funcid, Oid result_type, List *args,
 	if (!HeapTupleIsValid(func_tuple))
 		elog(ERROR, "cache lookup failed for function %u", funcid);
 
-	newexpr = evaluate_function(funcid, result_type, args,
-								func_tuple, context);
+	if (is_in_planning_phase())
+	{
+		newexpr = NULL;
+	}
+	else
+	{
+		newexpr = evaluate_function(funcid, result_type, args,
+		                            func_tuple, context);
+	}
 
 	if (large_const(newexpr, context->max_size))
 	{

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/3d39d8f3/src/include/optimizer/planner.h
----------------------------------------------------------------------
diff --git a/src/include/optimizer/planner.h b/src/include/optimizer/planner.h
index 48de348..cc2eb7d 100644
--- a/src/include/optimizer/planner.h
+++ b/src/include/optimizer/planner.h
@@ -50,4 +50,8 @@ extern bool choose_hashed_grouping(PlannerInfo *root,
 								   double dNumGroups, 
 								   AggClauseCounts *agg_counts);
 
+extern bool is_in_planning_phase(void);
+extern void increase_planning_depth(void);
+extern void decrease_planning_depth(void);
+
 #endif   /* PLANNER_H */


Mime
View raw message