Merge pull request #2585 from citusdata/plan_recursive_exception

Reset planner context instead of popping with recursive planning
pull/2599/head
Burak Velioglu 2019-01-17 17:24:19 +03:00 committed by GitHub
commit 1f4f6ea041
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 5 deletions

View File

@ -84,6 +84,8 @@ static List * CopyPlanParamList(List *originalPlanParamList);
static PlannerRestrictionContext * CreateAndPushPlannerRestrictionContext(void); static PlannerRestrictionContext * CreateAndPushPlannerRestrictionContext(void);
static PlannerRestrictionContext * CurrentPlannerRestrictionContext(void); static PlannerRestrictionContext * CurrentPlannerRestrictionContext(void);
static void PopPlannerRestrictionContext(void); static void PopPlannerRestrictionContext(void);
static void ResetPlannerRestrictionContext(
PlannerRestrictionContext *plannerRestrictionContext);
static bool HasUnresolvedExternParamsWalker(Node *expression, ParamListInfo boundParams); static bool HasUnresolvedExternParamsWalker(Node *expression, ParamListInfo boundParams);
@ -700,12 +702,11 @@ CreateDistributedPlan(uint64 planId, Query *originalQuery, Query *query, ParamLi
{ {
Query *newQuery = copyObject(originalQuery); Query *newQuery = copyObject(originalQuery);
bool setPartitionedTablesInherited = false; bool setPartitionedTablesInherited = false;
PlannerRestrictionContext *currentPlannerRestrictionContext =
CurrentPlannerRestrictionContext();
/* remove the pre-transformation planner restrictions context */ /* reset the current planner restrictions context */
PopPlannerRestrictionContext(); ResetPlannerRestrictionContext(currentPlannerRestrictionContext);
/* create a fresh new planner context */
plannerRestrictionContext = CreateAndPushPlannerRestrictionContext();
/* /*
* We force standard_planner to treat partitioned tables as regular tables * We force standard_planner to treat partitioned tables as regular tables
@ -1534,6 +1535,24 @@ PopPlannerRestrictionContext(void)
} }
/*
* ResetPlannerRestrictionContext resets the element of the given planner
* restriction context.
*/
static void
ResetPlannerRestrictionContext(PlannerRestrictionContext *plannerRestrictionContext)
{
plannerRestrictionContext->relationRestrictionContext =
palloc0(sizeof(RelationRestrictionContext));
plannerRestrictionContext->joinRestrictionContext =
palloc0(sizeof(JoinRestrictionContext));
/* we'll apply logical AND as we add tables */
plannerRestrictionContext->relationRestrictionContext->allReferenceTables = true;
}
/* /*
* HasUnresolvedExternParamsWalker returns true if the passed in expression * HasUnresolvedExternParamsWalker returns true if the passed in expression
* has external parameters that are not contained in boundParams, false * has external parameters that are not contained in boundParams, false