mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +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:
@ -848,12 +848,10 @@ set_plan_refs(PlannerInfo *root, Plan *plan, int rtoffset)
|
||||
}
|
||||
|
||||
splan->nominalRelation += rtoffset;
|
||||
if (splan->rootRelation)
|
||||
splan->rootRelation += rtoffset;
|
||||
splan->exclRelRTI += rtoffset;
|
||||
|
||||
foreach(l, splan->partitioned_rels)
|
||||
{
|
||||
lfirst_int(l) += rtoffset;
|
||||
}
|
||||
foreach(l, splan->resultRelations)
|
||||
{
|
||||
lfirst_int(l) += rtoffset;
|
||||
@ -884,24 +882,17 @@ set_plan_refs(PlannerInfo *root, Plan *plan, int rtoffset)
|
||||
list_copy(splan->resultRelations));
|
||||
|
||||
/*
|
||||
* If the main target relation is a partitioned table, the
|
||||
* following list contains the RT indexes of partitioned child
|
||||
* relations including the root, which are not included in the
|
||||
* above list. We also keep RT indexes of the roots
|
||||
* separately to be identified as such during the executor
|
||||
* initialization.
|
||||
* If the main target relation is a partitioned table, also
|
||||
* add the partition root's RT index to rootResultRelations,
|
||||
* and remember its index in that list in rootResultRelIndex.
|
||||
*/
|
||||
if (splan->partitioned_rels != NIL)
|
||||
if (splan->rootRelation)
|
||||
{
|
||||
root->glob->nonleafResultRelations =
|
||||
list_concat(root->glob->nonleafResultRelations,
|
||||
list_copy(splan->partitioned_rels));
|
||||
/* Remember where this root will be in the global list. */
|
||||
splan->rootResultRelIndex =
|
||||
list_length(root->glob->rootResultRelations);
|
||||
root->glob->rootResultRelations =
|
||||
lappend_int(root->glob->rootResultRelations,
|
||||
linitial_int(splan->partitioned_rels));
|
||||
splan->rootRelation);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -915,10 +906,6 @@ set_plan_refs(PlannerInfo *root, Plan *plan, int rtoffset)
|
||||
*/
|
||||
set_dummy_tlist_references(plan, rtoffset);
|
||||
Assert(splan->plan.qual == NIL);
|
||||
foreach(l, splan->partitioned_rels)
|
||||
{
|
||||
lfirst_int(l) += rtoffset;
|
||||
}
|
||||
foreach(l, splan->appendplans)
|
||||
{
|
||||
lfirst(l) = set_plan_refs(root,
|
||||
@ -952,10 +939,6 @@ set_plan_refs(PlannerInfo *root, Plan *plan, int rtoffset)
|
||||
*/
|
||||
set_dummy_tlist_references(plan, rtoffset);
|
||||
Assert(splan->plan.qual == NIL);
|
||||
foreach(l, splan->partitioned_rels)
|
||||
{
|
||||
lfirst_int(l) += rtoffset;
|
||||
}
|
||||
foreach(l, splan->mergeplans)
|
||||
{
|
||||
lfirst(l) = set_plan_refs(root,
|
||||
|
Reference in New Issue
Block a user