summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Vondra2016-11-07 22:01:44 +0000
committerTomas Vondra2016-11-07 22:01:44 +0000
commit34dc176d579395abb048cdad78b415d55aa0ae82 (patch)
treec036067eeab1d97111301d344e20f6441a7ae9d0
parentcff1501d449c54e3996ec5a38875150619b15f5d (diff)
fix some of the compilation errors in planner (pathification etc.)
there's still quite a few errors and unresolved conflicts in planner.c
-rw-r--r--src/backend/optimizer/plan/createplan.c59
-rw-r--r--src/include/optimizer/planmain.h3
2 files changed, 27 insertions, 35 deletions
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
index 775756f67d..b51cfa1efc 100644
--- a/src/backend/optimizer/plan/createplan.c
+++ b/src/backend/optimizer/plan/createplan.c
@@ -141,7 +141,7 @@ static LockRows *create_lockrows_plan(PlannerInfo *root, LockRowsPath *best_path
int flags);
static ModifyTable *create_modifytable_plan(PlannerInfo *root, ModifyTablePath *best_path);
static Limit *create_limit_plan(PlannerInfo *root, LimitPath *best_path,
- int flags);
+ int flags, int64 offset_est, int64 count_est);
static SeqScan *create_seqscan_plan(PlannerInfo *root, Path *best_path,
List *tlist, List *scan_clauses);
static SampleScan *create_samplescan_plan(PlannerInfo *root, Path *best_path,
@@ -223,7 +223,8 @@ static CteScan *make_ctescan(List *qptlist, List *qpqual,
static WorkTableScan *make_worktablescan(List *qptlist, List *qpqual,
Index scanrelid, int wtParam);
static Append *make_append(List *appendplans, List *tlist);
-static RecursiveUnion *make_recursive_union(List *tlist,
+static RecursiveUnion *make_recursive_union(PlannerInfo *root,
+ List *tlist,
Plan *lefttree,
Plan *righttree,
int wtParam,
@@ -506,7 +507,7 @@ create_plan_recurse(PlannerInfo *root, Path *best_path, int flags)
case T_Limit:
plan = (Plan *) create_limit_plan(root,
(LimitPath *) best_path,
- flags);
+ flags, 0, 1);
break;
default:
elog(ERROR, "unrecognized node type: %d",
@@ -1899,7 +1900,8 @@ create_minmaxagg_plan(PlannerInfo *root, MinMaxAggPath *best_path)
plan = (Plan *) make_limit(plan,
subparse->limitOffset,
- subparse->limitCount);
+ subparse->limitCount,
+ 0, 1);
/* Must apply correct cost/width data to Limit node */
plan->startup_cost = mminfo->path->startup_cost;
@@ -2182,7 +2184,8 @@ create_recursiveunion_plan(PlannerInfo *root, RecursiveUnionPath *best_path)
/* Convert numGroups to long int --- but 'ware overflow! */
numGroups = (long) Min(best_path->numGroups, (double) LONG_MAX);
- plan = make_recursive_union(tlist,
+ plan = make_recursive_union(root,
+ tlist,
leftplan,
rightplan,
best_path->wtParam,
@@ -2282,7 +2285,8 @@ create_modifytable_plan(PlannerInfo *root, ModifyTablePath *best_path)
* for its subpaths.
*/
static Limit *
-create_limit_plan(PlannerInfo *root, LimitPath *best_path, int flags)
+create_limit_plan(PlannerInfo *root, LimitPath *best_path, int flags,
+ int64 offset_est, int64 count_est)
{
Limit *plan;
Plan *subplan;
@@ -2292,7 +2296,8 @@ create_limit_plan(PlannerInfo *root, LimitPath *best_path, int flags)
plan = make_limit(subplan,
best_path->limitOffset,
- best_path->limitCount);
+ best_path->limitCount,
+ offset_est, count_est);
copy_generic_path_info(&plan->plan, (Path *) best_path);
@@ -2397,17 +2402,15 @@ create_remotescan_plan(PlannerInfo *root,
adjust_subplan_distribution(root, best_path->path.distribution,
best_path->subpath->distribution);
- subplan = create_plan_recurse(root, best_path->subpath);
-
/* We don't want any excess columns in the remote tuples */
- disuse_physical_tlist(root, subplan, best_path->subpath);
+ subplan = create_plan_recurse(root, best_path->subpath, CP_SMALL_TLIST);
plan = make_remotesubplan(root, subplan,
best_path->path.distribution,
best_path->subpath->distribution,
best_path->path.pathkeys);
- copy_path_costsize(&plan->scan.plan, (Path *) best_path);
+ copy_generic_path_info(&plan->scan.plan, (Path *) best_path);
/* restore current restrict */
bms_free(root->curOuterRestrict);
@@ -2443,23 +2446,14 @@ find_push_down_plan_int(PlannerInfo *root, Plan *plan, bool force, bool delete,
{
Plan *subplan = ((SubqueryScan *)plan)->subplan;
RemoteSubplan *remote_plan = find_push_down_plan_int(root,
- ((SubqueryScan *)plan)->subplan, force, delete,
- &((SubqueryScan *)plan)->subplan);
+ subplan, force, delete, &subplan);
/*
- * If caller has asked for removing the RemoteSubplan and if its a
- * subquery plan, then we must also update the link stored in the
- * RelOptInfo corresponding to this subquery
+ * XXX This used to update rel->subplan, but thanks to upper-planner
+ * pathification the field was removed. But maybe this needs to tweak
+ * subroot instead?
*/
- if ((((Plan *)remote_plan) == subplan) && parent)
- {
- RelOptInfo *rel = NULL;
-
- Assert(root);
- rel = find_base_rel(root, ((SubqueryScan *)plan)->scan.scanrelid);
- rel->subplan = ((SubqueryScan *)plan)->subplan;
- }
return remote_plan;
}
return NULL;
@@ -5230,7 +5224,7 @@ make_remotesubplan(PlannerInfo *root,
/* Use Result node to calculate expression */
List *newtlist = list_copy(lefttree->targetlist);
newtlist = lappend(newtlist, newtle);
- lefttree = (Plan *) make_result(root, newtlist, NULL, lefttree);
+ lefttree = (Plan *) make_result(newtlist, NULL, lefttree);
}
node->distributionKey = newtle->resno;
@@ -5421,7 +5415,7 @@ make_remotesubplan(PlannerInfo *root,
continue;
sortexpr = em->em_expr;
exprvars = pull_var_clause((Node *) sortexpr,
- PVC_INCLUDE_AGGREGATES,
+ PVC_INCLUDE_AGGREGATES |
PVC_INCLUDE_PLACEHOLDERS);
foreach(k, exprvars)
{
@@ -5445,8 +5439,7 @@ make_remotesubplan(PlannerInfo *root,
{
/* copy needed so we don't modify input's tlist below */
tlist = copyObject(tlist);
- lefttree = (Plan *) make_result(root, tlist, NULL,
- lefttree);
+ lefttree = (Plan *) make_result(tlist, NULL, lefttree);
}
/*
@@ -5562,10 +5555,7 @@ make_append(List *appendplans, List *tlist)
}
static RecursiveUnion *
-make_recursive_union(
-#ifdef XCP
- PlannerInfo *root,
-#endif
+make_recursive_union(PlannerInfo *root,
List *tlist,
Plan *lefttree,
Plan *righttree,
@@ -7080,7 +7070,8 @@ make_lockrows(Plan *lefttree, List *rowMarks, int epqParam)
* Build a Limit plan node
*/
Limit *
-make_limit(Plan *lefttree, Node *limitOffset, Node *limitCount)
+make_limit(Plan *lefttree, Node *limitOffset, Node *limitCount,
+ int64 offset_est, int64 count_est)
{
Limit *node = makeNode(Limit);
Plan *plan = &node->plan;
@@ -7098,7 +7089,7 @@ make_limit(Plan *lefttree, Node *limitOffset, Node *limitCount)
#ifdef XCP
/*
- * We want to push down LIMTI clause to the remote side in order to limit
+ * We want to push down LIMIT clause to the remote side in order to limit
* the number of rows that get shipped from the remote side. This can be
* done even if there is an ORDER BY clause, as long as we fetch minimum
* number of rows from all the nodes and then do a local sort and apply the
diff --git a/src/include/optimizer/planmain.h b/src/include/optimizer/planmain.h
index 1da50f09d2..7e26896118 100644
--- a/src/include/optimizer/planmain.h
+++ b/src/include/optimizer/planmain.h
@@ -67,7 +67,8 @@ extern Agg *make_agg(List *tlist, List *qual,
int numGroupCols, AttrNumber *grpColIdx, Oid *grpOperators,
List *groupingSets, List *chain,
double dNumGroups, Plan *lefttree);
-extern Limit *make_limit(Plan *lefttree, Node *limitOffset, Node *limitCount);
+extern Limit *make_limit(Plan *lefttree, Node *limitOffset, Node *limitCount,
+ int64 offset_est, int64 count_est);
/*
* prototypes for plan/initsplan.c