mirror of https://github.com/citusdata/citus.git
Refactor RecursivelyPlanSubqueriesAndCTEs() to make it ready
to work with subqueriespull/1876/head
parent
393e625cb2
commit
71ce42b936
|
@ -595,6 +595,7 @@ CreateDistributedSelectPlan(uint64 planId, Query *originalQuery, Query *query,
|
|||
MultiTreeRoot *logicalPlan = NULL;
|
||||
DeferredErrorMessage *error = NULL;
|
||||
List *subPlanList = NIL;
|
||||
RecursivePlanningContext context;
|
||||
|
||||
/*
|
||||
* For select queries we, if router executor is enabled, first try to
|
||||
|
@ -648,8 +649,12 @@ CreateDistributedSelectPlan(uint64 planId, Query *originalQuery, Query *query,
|
|||
* Plan subqueries and CTEs that cannot be pushed down by recursively
|
||||
* calling the planner and add the resulting plans to subPlanList.
|
||||
*/
|
||||
error = RecursivelyPlanSubqueriesAndCTEs(originalQuery, plannerRestrictionContext,
|
||||
planId, &subPlanList);
|
||||
context.level = 0;
|
||||
context.planId = planId;
|
||||
context.subPlanList = NIL;
|
||||
context.plannerRestrictionContext = plannerRestrictionContext;
|
||||
|
||||
error = RecursivelyPlanSubqueriesAndCTEs(originalQuery, &context);
|
||||
if (error != NULL)
|
||||
{
|
||||
RaiseDeferredError(error, ERROR);
|
||||
|
@ -663,6 +668,7 @@ CreateDistributedSelectPlan(uint64 planId, Query *originalQuery, Query *query,
|
|||
* with an original query. In that case, we would only have to filter the
|
||||
* planner restriction context.
|
||||
*/
|
||||
subPlanList = context.subPlanList;
|
||||
if (list_length(subPlanList) > 0)
|
||||
{
|
||||
Query *newQuery = copyObject(originalQuery);
|
||||
|
|
|
@ -73,19 +73,6 @@
|
|||
#include "utils/guc.h"
|
||||
|
||||
|
||||
/*
|
||||
* RecursivePlanningContext is used to recursively plan subqueries
|
||||
* and CTEs, pull results to the coordinator, and push it back into
|
||||
* the workers.
|
||||
*/
|
||||
typedef struct RecursivePlanningContext
|
||||
{
|
||||
int level;
|
||||
uint64 planId;
|
||||
List *subPlanList;
|
||||
PlannerRestrictionContext *plannerRestrictionContext;
|
||||
} RecursivePlanningContext;
|
||||
|
||||
/*
|
||||
* CteReferenceWalkerContext is used to collect CTE references in
|
||||
* CteReferenceListWalker.
|
||||
|
@ -133,17 +120,9 @@ static Query * BuildSubPlanResultQuery(Query *subquery, uint64 planId, uint32 su
|
|||
* subplans will be added to subPlanList.
|
||||
*/
|
||||
DeferredErrorMessage *
|
||||
RecursivelyPlanSubqueriesAndCTEs(Query *query,
|
||||
PlannerRestrictionContext *plannerRestrictionContext,
|
||||
uint64 planId, List **subPlanList)
|
||||
RecursivelyPlanSubqueriesAndCTEs(Query *query, RecursivePlanningContext *context)
|
||||
{
|
||||
DeferredErrorMessage *error = NULL;
|
||||
RecursivePlanningContext context;
|
||||
|
||||
context.level = 0;
|
||||
context.planId = planId;
|
||||
context.subPlanList = NIL;
|
||||
context.plannerRestrictionContext = plannerRestrictionContext;
|
||||
|
||||
error = RecursivelyPlanCTEs(query, &context);
|
||||
if (error != NULL)
|
||||
|
@ -166,9 +145,8 @@ RecursivelyPlanSubqueriesAndCTEs(Query *query,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* XXX: plan subqueries */
|
||||
|
||||
*subPlanList = context.subPlanList;
|
||||
/* descend into subqueries */
|
||||
query_tree_walker(query, RecursivelyPlanSubqueryWalker, context, 0);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -92,9 +92,6 @@ extern bool IsModifyDistributedPlan(struct DistributedPlan *distributedPlan);
|
|||
extern bool IsMultiTaskPlan(struct DistributedPlan *distributedPlan);
|
||||
extern bool IsMultiShardModifyPlan(struct DistributedPlan *distributedPlan);
|
||||
extern RangeTblEntry * RemoteScanRangeTableEntry(List *columnNameList);
|
||||
extern char * GenerateResultId(uint64 planId, uint32 subPlanId);
|
||||
|
||||
|
||||
extern int GetRTEIdentity(RangeTblEntry *rte);
|
||||
|
||||
#endif /* DISTRIBUTED_PLANNER_H */
|
||||
|
|
|
@ -18,11 +18,23 @@
|
|||
#include "nodes/relation.h"
|
||||
|
||||
|
||||
/*
|
||||
* RecursivePlanningContext is used to recursively plan subqueries
|
||||
* and CTEs, pull results to the coordinator, and push it back into
|
||||
* the workers.
|
||||
*/
|
||||
typedef struct RecursivePlanningContext
|
||||
{
|
||||
int level;
|
||||
uint64 planId;
|
||||
List *subPlanList;
|
||||
PlannerRestrictionContext *plannerRestrictionContext;
|
||||
} RecursivePlanningContext;
|
||||
|
||||
|
||||
extern DeferredErrorMessage * RecursivelyPlanSubqueriesAndCTEs(Query *query,
|
||||
PlannerRestrictionContext *
|
||||
plannerRestrictionContext,
|
||||
uint64 planId,
|
||||
List **subPlanList);
|
||||
RecursivePlanningContext *
|
||||
context);
|
||||
extern char * GenerateResultId(uint64 planId, uint32 subPlanId);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue