mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
Remove some unnecessary fields from Plan trees.
In the wake of commit f2343653f, we no longer need some fields that
were used before to control executor lock acquisitions:
* PlannedStmt.nonleafResultRelations can go away entirely.
* partitioned_rels can go away from Append, MergeAppend, and ModifyTable.
However, ModifyTable still needs to know the RT index of the partition
root table if any, which was formerly kept in the first entry of that
list. Add a new field "rootRelation" to remember that. rootRelation is
partly redundant with nominalRelation, in that if it's set it will have
the same value as nominalRelation. However, the latter field has a
different purpose so it seems best to keep them distinct.
Amit Langote, reviewed by David Rowley and Jesper Pedersen,
and whacked around a bit more by me
Discussion: https://postgr.es/m/468c85d9-540e-66a2-1dde-fec2b741e688@lab.ntt.co.jp
This commit is contained in:
@@ -124,7 +124,6 @@ static BitmapHeapScan *create_bitmap_scan_plan(PlannerInfo *root,
|
||||
static Plan *create_bitmap_subplan(PlannerInfo *root, Path *bitmapqual,
|
||||
List **qual, List **indexqual, List **indexECs);
|
||||
static void bitmap_subplan_mark_shared(Plan *plan);
|
||||
static List *flatten_partitioned_rels(List *partitioned_rels);
|
||||
static TidScan *create_tidscan_plan(PlannerInfo *root, TidPath *best_path,
|
||||
List *tlist, List *scan_clauses);
|
||||
static SubqueryScan *create_subqueryscan_plan(PlannerInfo *root,
|
||||
@@ -203,8 +202,7 @@ static NamedTuplestoreScan *make_namedtuplestorescan(List *qptlist, List *qpqual
|
||||
static WorkTableScan *make_worktablescan(List *qptlist, List *qpqual,
|
||||
Index scanrelid, int wtParam);
|
||||
static Append *make_append(List *appendplans, int first_partial_plan,
|
||||
List *tlist, List *partitioned_rels,
|
||||
PartitionPruneInfo *partpruneinfo);
|
||||
List *tlist, PartitionPruneInfo *partpruneinfo);
|
||||
static RecursiveUnion *make_recursive_union(List *tlist,
|
||||
Plan *lefttree,
|
||||
Plan *righttree,
|
||||
@@ -280,7 +278,7 @@ static Result *make_result(List *tlist, Node *resconstantqual, Plan *subplan);
|
||||
static ProjectSet *make_project_set(List *tlist, Plan *subplan);
|
||||
static ModifyTable *make_modifytable(PlannerInfo *root,
|
||||
CmdType operation, bool canSetTag,
|
||||
Index nominalRelation, List *partitioned_rels,
|
||||
Index nominalRelation, Index rootRelation,
|
||||
bool partColsUpdated,
|
||||
List *resultRelations, List *subplans, List *subroots,
|
||||
List *withCheckOptionLists, List *returningLists,
|
||||
@@ -1110,8 +1108,7 @@ create_append_plan(PlannerInfo *root, AppendPath *best_path)
|
||||
*/
|
||||
|
||||
plan = make_append(subplans, best_path->first_partial_path,
|
||||
tlist, best_path->partitioned_rels,
|
||||
partpruneinfo);
|
||||
tlist, partpruneinfo);
|
||||
|
||||
copy_generic_path_info(&plan->plan, (Path *) best_path);
|
||||
|
||||
@@ -1253,8 +1250,6 @@ create_merge_append_plan(PlannerInfo *root, MergeAppendPath *best_path)
|
||||
prunequal);
|
||||
}
|
||||
|
||||
node->partitioned_rels =
|
||||
flatten_partitioned_rels(best_path->partitioned_rels);
|
||||
node->mergeplans = subplans;
|
||||
node->part_prune_info = partpruneinfo;
|
||||
|
||||
@@ -2411,7 +2406,7 @@ create_modifytable_plan(PlannerInfo *root, ModifyTablePath *best_path)
|
||||
best_path->operation,
|
||||
best_path->canSetTag,
|
||||
best_path->nominalRelation,
|
||||
best_path->partitioned_rels,
|
||||
best_path->rootRelation,
|
||||
best_path->partColsUpdated,
|
||||
best_path->resultRelations,
|
||||
subplans,
|
||||
@@ -5005,27 +5000,6 @@ bitmap_subplan_mark_shared(Plan *plan)
|
||||
elog(ERROR, "unrecognized node type: %d", nodeTag(plan));
|
||||
}
|
||||
|
||||
/*
|
||||
* flatten_partitioned_rels
|
||||
* Convert List of Lists into a single List with all elements from the
|
||||
* sub-lists.
|
||||
*/
|
||||
static List *
|
||||
flatten_partitioned_rels(List *partitioned_rels)
|
||||
{
|
||||
List *newlist = NIL;
|
||||
ListCell *lc;
|
||||
|
||||
foreach(lc, partitioned_rels)
|
||||
{
|
||||
List *sublist = lfirst(lc);
|
||||
|
||||
newlist = list_concat(newlist, list_copy(sublist));
|
||||
}
|
||||
|
||||
return newlist;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* PLAN NODE BUILDING ROUTINES
|
||||
@@ -5368,8 +5342,7 @@ make_foreignscan(List *qptlist,
|
||||
|
||||
static Append *
|
||||
make_append(List *appendplans, int first_partial_plan,
|
||||
List *tlist, List *partitioned_rels,
|
||||
PartitionPruneInfo *partpruneinfo)
|
||||
List *tlist, PartitionPruneInfo *partpruneinfo)
|
||||
{
|
||||
Append *node = makeNode(Append);
|
||||
Plan *plan = &node->plan;
|
||||
@@ -5380,7 +5353,6 @@ make_append(List *appendplans, int first_partial_plan,
|
||||
plan->righttree = NULL;
|
||||
node->appendplans = appendplans;
|
||||
node->first_partial_plan = first_partial_plan;
|
||||
node->partitioned_rels = flatten_partitioned_rels(partitioned_rels);
|
||||
node->part_prune_info = partpruneinfo;
|
||||
return node;
|
||||
}
|
||||
@@ -6509,7 +6481,7 @@ make_project_set(List *tlist,
|
||||
static ModifyTable *
|
||||
make_modifytable(PlannerInfo *root,
|
||||
CmdType operation, bool canSetTag,
|
||||
Index nominalRelation, List *partitioned_rels,
|
||||
Index nominalRelation, Index rootRelation,
|
||||
bool partColsUpdated,
|
||||
List *resultRelations, List *subplans, List *subroots,
|
||||
List *withCheckOptionLists, List *returningLists,
|
||||
@@ -6538,7 +6510,7 @@ make_modifytable(PlannerInfo *root,
|
||||
node->operation = operation;
|
||||
node->canSetTag = canSetTag;
|
||||
node->nominalRelation = nominalRelation;
|
||||
node->partitioned_rels = flatten_partitioned_rels(partitioned_rels);
|
||||
node->rootRelation = rootRelation;
|
||||
node->partColsUpdated = partColsUpdated;
|
||||
node->resultRelations = resultRelations;
|
||||
node->resultRelIndex = -1; /* will be set correctly in setrefs.c */
|
||||
|
||||
Reference in New Issue
Block a user