Centralize more of distributed planning into CreateDistributedPlan().

The name CreatePhysicalPlan() hasn't been accurate for a while, and
the split of work between multi_planner() and CreatePhysicalPlan()
doesn't seem perfect.  So rename to CreateDistributedPlan() and move a
bit more logic in there.
pull/1134/head
Andres Freund 2017-01-19 17:21:31 -08:00
parent 557ccc6fda
commit 7681f6ab9d
1 changed files with 14 additions and 14 deletions

View File

@ -39,7 +39,9 @@ static void CheckNodeIsDumpable(Node *node);
static char * GetMultiPlanString(PlannedStmt *result); static char * GetMultiPlanString(PlannedStmt *result);
static PlannedStmt * MultiQueryContainerNode(PlannedStmt *result, static PlannedStmt * MultiQueryContainerNode(PlannedStmt *result,
struct MultiPlan *multiPlan); struct MultiPlan *multiPlan);
static struct MultiPlan * CreatePhysicalPlan(Query *originalQuery, Query *query, static struct PlannedStmt * CreateDistributedPlan(PlannedStmt *localPlan,
Query *originalQuery,
Query *query,
RelationRestrictionContext * RelationRestrictionContext *
restrictionContext); restrictionContext);
static RelationRestrictionContext * CreateAndPushRestrictionContext(void); static RelationRestrictionContext * CreateAndPushRestrictionContext(void);
@ -100,11 +102,8 @@ multi_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
if (needsDistributedPlanning) if (needsDistributedPlanning)
{ {
MultiPlan *physicalPlan = CreatePhysicalPlan(originalQuery, parse, result = CreateDistributedPlan(result, originalQuery, parse,
restrictionContext); restrictionContext);
/* store required data into the planned statement */
result = MultiQueryContainerNode(result, physicalPlan);
} }
} }
PG_CATCH(); PG_CATCH();
@ -122,14 +121,14 @@ multi_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
/* /*
* CreatePhysicalPlan encapsulates the logic needed to transform a particular * CreateDistributedPlan encapsulates the logic needed to transform a particular
* query into a physical plan. For modifications, queries immediately enter * query into a distributed plan. For modifications, queries immediately enter
* the physical planning stage, since they are essentially "routed" to remote * the physical planning stage, since they are essentially "routed" to remote
* target shards. SELECT queries go through the full logical plan/optimize/ * target shards. SELECT queries go through the full logical plan/optimize/
* physical plan process needed to produce distributed query plans. * physical plan process needed to produce distributed query plans.
*/ */
static MultiPlan * static PlannedStmt *
CreatePhysicalPlan(Query *originalQuery, Query *query, CreateDistributedPlan(PlannedStmt *localPlan, Query *originalQuery, Query *query,
RelationRestrictionContext *restrictionContext) RelationRestrictionContext *restrictionContext)
{ {
MultiPlan *physicalPlan = MultiRouterPlanCreate(originalQuery, query, MultiPlan *physicalPlan = MultiRouterPlanCreate(originalQuery, query,
@ -153,7 +152,8 @@ CreatePhysicalPlan(Query *originalQuery, Query *query,
physicalPlan = MultiPhysicalPlanCreate(logicalPlan); physicalPlan = MultiPhysicalPlanCreate(logicalPlan);
} }
return physicalPlan; /* store required data into the planned statement */
return MultiQueryContainerNode(localPlan, physicalPlan);
} }