Rename planContext->parse to planContext->query

use-plancontext-more
Jelte Fennema 2020-01-06 12:56:08 +01:00
parent d4352646b9
commit 7c76a5ab95
3 changed files with 15 additions and 18 deletions

View File

@ -128,7 +128,7 @@ distributed_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
bool fastPathRouterQuery = false; bool fastPathRouterQuery = false;
Const *distributionKeyValue = NULL; Const *distributionKeyValue = NULL;
DistributedPlanningContext planContext = { DistributedPlanningContext planContext = {
.parse = parse, .query = parse,
.cursorOptions = cursorOptions, .cursorOptions = cursorOptions,
.boundParams = boundParams, .boundParams = boundParams,
}; };
@ -234,7 +234,7 @@ distributed_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
* restriction information per table and parse tree transformations made by * restriction information per table and parse tree transformations made by
* postgres' planner. * postgres' planner.
*/ */
planContext.plan = standard_planner(planContext.parse, planContext.plan = standard_planner(planContext.query,
planContext.cursorOptions, planContext.cursorOptions,
planContext.boundParams); planContext.boundParams);
if (needsDistributedPlanning) if (needsDistributedPlanning)
@ -548,7 +548,7 @@ PlanFastPathDistributedStmt(DistributedPlanningContext *planContext,
planContext->plannerRestrictionContext->fastPathRestrictionContext-> planContext->plannerRestrictionContext->fastPathRestrictionContext->
distributionKeyValue = distributionKeyValue; distributionKeyValue = distributionKeyValue;
planContext->plan = FastPathPlanner(planContext->originalQuery, planContext->parse, planContext->plan = FastPathPlanner(planContext->originalQuery, planContext->query,
planContext->boundParams); planContext->boundParams);
return CreateDistributedPlannedStmt(planContext); return CreateDistributedPlannedStmt(planContext);
@ -565,7 +565,7 @@ PlanDistributedStmt(DistributedPlanningContext *planContext,
int rteIdCounter) int rteIdCounter)
{ {
/* may've inlined new relation rtes */ /* may've inlined new relation rtes */
rangeTableList = ExtractRangeTableEntryList(planContext->parse); rangeTableList = ExtractRangeTableEntryList(planContext->query);
rteIdCounter = AssignRTEIdentities(rangeTableList, rteIdCounter); rteIdCounter = AssignRTEIdentities(rangeTableList, rteIdCounter);
@ -615,11 +615,8 @@ CreateDistributedPlannedStmt(DistributedPlanningContext *planContext)
planContext->plannerRestrictionContext->joinRestrictionContext = planContext->plannerRestrictionContext->joinRestrictionContext =
RemoveDuplicateJoinRestrictions(joinRestrictionContext); RemoveDuplicateJoinRestrictions(joinRestrictionContext);
DistributedPlan *distributedPlan = DistributedPlan *distributedPlan = CreateDistributedPlan(planId, planContext,
CreateDistributedPlan(planId, planContext->originalQuery, planContext->parse, hasUnresolvedParams);
planContext->boundParams,
hasUnresolvedParams,
planContext->plannerRestrictionContext);
/* /*
* If no plan was generated, prepare a generic error to be emitted. * If no plan was generated, prepare a generic error to be emitted.

View File

@ -130,19 +130,19 @@ TryToDelegateFunctionCall(DistributedPlanningContext *planContext)
return NULL; return NULL;
} }
if (planContext->parse == NULL) if (planContext->query == NULL)
{ {
/* no query (mostly here to be defensive) */ /* no query (mostly here to be defensive) */
return NULL; return NULL;
} }
if (planContext->parse->commandType != CMD_SELECT) if (planContext->query->commandType != CMD_SELECT)
{ {
/* not a SELECT */ /* not a SELECT */
return NULL; return NULL;
} }
FromExpr *joinTree = planContext->parse->jointree; FromExpr *joinTree = planContext->query->jointree;
if (joinTree == NULL) if (joinTree == NULL)
{ {
/* no join tree (mostly here to be defensive) */ /* no join tree (mostly here to be defensive) */
@ -172,7 +172,7 @@ TryToDelegateFunctionCall(DistributedPlanningContext *planContext)
if (IsA(reference, RangeTblRef)) if (IsA(reference, RangeTblRef))
{ {
RangeTblEntry *rtentry = rt_fetch(reference->rtindex, RangeTblEntry *rtentry = rt_fetch(reference->rtindex,
planContext->parse->rtable); planContext->query->rtable);
if (rtentry->rtekind != RTE_RESULT) if (rtentry->rtekind != RTE_RESULT)
{ {
/* e.g. SELECT f() FROM rel */ /* e.g. SELECT f() FROM rel */
@ -201,8 +201,8 @@ TryToDelegateFunctionCall(DistributedPlanningContext *planContext)
#endif #endif
} }
targetList = planContext->parse->targetList; targetList = planContext->query->targetList;
if (list_length(planContext->parse->targetList) != 1) if (list_length(planContext->query->targetList) != 1)
{ {
/* multiple target list items */ /* multiple target list items */
return NULL; return NULL;
@ -365,7 +365,7 @@ TryToDelegateFunctionCall(DistributedPlanningContext *planContext)
ereport(DEBUG1, (errmsg("pushing down the function call"))); ereport(DEBUG1, (errmsg("pushing down the function call")));
queryString = makeStringInfo(); queryString = makeStringInfo();
pg_get_query_def(planContext->parse, queryString); pg_get_query_def(planContext->query, queryString);
task = CitusMakeNode(Task); task = CitusMakeNode(Task);
task->taskType = SELECT_TASK; task->taskType = SELECT_TASK;
@ -376,7 +376,7 @@ TryToDelegateFunctionCall(DistributedPlanningContext *planContext)
job = CitusMakeNode(Job); job = CitusMakeNode(Job);
job->jobId = UniqueJobId(); job->jobId = UniqueJobId();
job->jobQuery = planContext->parse; job->jobQuery = planContext->query;
job->taskList = list_make1(task); job->taskList = list_make1(task);
distributedPlan = CitusMakeNode(DistributedPlan); distributedPlan = CitusMakeNode(DistributedPlan);

View File

@ -133,7 +133,7 @@ typedef struct DistributedPlanningContext
{ {
/* The parsed query that is given to the planner. It is a slightly modified /* The parsed query that is given to the planner. It is a slightly modified
* to work with the standard_planner */ * to work with the standard_planner */
Query *parse; Query *query;
/* A copy of the original parsed query that is given to the planner. This /* A copy of the original parsed query that is given to the planner. This
* doesn't contain most of the changes that are made to parse. There's one * doesn't contain most of the changes that are made to parse. There's one