summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane2018-10-07 18:33:17 +0000
committerTom Lane2018-10-07 18:33:17 +0000
commit52ed730d511b7b1147f2851a7295ef1fb5273776 (patch)
tree778fcbbacb924e01baacb59ed75d7d10c33b56cc /src/include
parent39808e8868c8fac383b33aa103ab57539b0e2a69 (diff)
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
Diffstat (limited to 'src/include')
-rw-r--r--src/include/nodes/plannodes.h27
-rw-r--r--src/include/nodes/relation.h4
-rw-r--r--src/include/optimizer/pathnode.h2
3 files changed, 12 insertions, 21 deletions
diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
index 8b374370576..5e3d4cdc58d 100644
--- a/src/include/nodes/plannodes.h
+++ b/src/include/nodes/plannodes.h
@@ -69,15 +69,8 @@ typedef struct PlannedStmt
List *resultRelations; /* integer list of RT indexes, or NIL */
/*
- * rtable indexes of non-leaf target relations for UPDATE/DELETE on all
- * the partitioned tables mentioned in the query.
- */
- List *nonleafResultRelations;
-
- /*
- * rtable indexes of root target relations for UPDATE/DELETE; this list
- * maintains a subset of the RT indexes in nonleafResultRelations,
- * indicating the roots of the respective partition hierarchies.
+ * rtable indexes of partitioned table roots that are UPDATE/DELETE
+ * targets; needed for trigger firing.
*/
List *rootResultRelations;
@@ -210,6 +203,12 @@ typedef struct ProjectSet
* Apply rows produced by subplan(s) to result table(s),
* by inserting, updating, or deleting.
*
+ * If the originally named target table is a partitioned table, both
+ * nominalRelation and rootRelation contain the RT index of the partition
+ * root, which is not otherwise mentioned in the plan. Otherwise rootRelation
+ * is zero. However, nominalRelation will always be set, as it's the rel that
+ * EXPLAIN should claim is the INSERT/UPDATE/DELETE target.
+ *
* Note that rowMarks and epqParam are presumed to be valid for all the
* subplan(s); they can't contain any info that varies across subplans.
* ----------------
@@ -220,8 +219,7 @@ typedef struct ModifyTable
CmdType operation; /* INSERT, UPDATE, or DELETE */
bool canSetTag; /* do we set the command tag/es_processed? */
Index nominalRelation; /* Parent RT index for use of EXPLAIN */
- /* RT indexes of non-leaf tables in a partition tree */
- List *partitioned_rels;
+ Index rootRelation; /* Root RT index, if target is partitioned */
bool partColsUpdated; /* some part key in hierarchy updated */
List *resultRelations; /* integer list of RT indexes */
int resultRelIndex; /* index of first resultRel in plan's list */
@@ -259,9 +257,6 @@ typedef struct Append
*/
int first_partial_plan;
- /* RT indexes of non-leaf tables in a partition tree */
- List *partitioned_rels;
-
/* Info for run-time subplan pruning; NULL if we're not doing that */
struct PartitionPruneInfo *part_prune_info;
} Append;
@@ -274,10 +269,8 @@ typedef struct Append
typedef struct MergeAppend
{
Plan plan;
- /* RT indexes of non-leaf tables in a partition tree */
- List *partitioned_rels;
List *mergeplans;
- /* remaining fields are just like the sort-key info in struct Sort */
+ /* these fields are just like the sort-key info in struct Sort: */
int numCols; /* number of sort-key columns */
AttrNumber *sortColIdx; /* their indexes in the target list */
Oid *sortOperators; /* OIDs of operators to sort them by */
diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h
index adb42650479..88d37236f7d 100644
--- a/src/include/nodes/relation.h
+++ b/src/include/nodes/relation.h
@@ -121,7 +121,6 @@ typedef struct PlannerGlobal
List *resultRelations; /* "flat" list of integer RT indexes */
- List *nonleafResultRelations; /* "flat" list of integer RT indexes */
List *rootResultRelations; /* "flat" list of integer RT indexes */
List *relationOids; /* OIDs of relations the plan depends on */
@@ -1717,8 +1716,7 @@ typedef struct ModifyTablePath
CmdType operation; /* INSERT, UPDATE, or DELETE */
bool canSetTag; /* do we set the command tag/es_processed? */
Index nominalRelation; /* Parent RT index for use of EXPLAIN */
- /* RT indexes of non-leaf tables in a partition tree */
- List *partitioned_rels;
+ Index rootRelation; /* Root RT index, if target is partitioned */
bool partColsUpdated; /* some part key in hierarchy updated */
List *resultRelations; /* integer list of RT indexes */
List *subpaths; /* Path(s) producing source data */
diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h
index 7c5ff226501..81abcf53a83 100644
--- a/src/include/optimizer/pathnode.h
+++ b/src/include/optimizer/pathnode.h
@@ -238,7 +238,7 @@ extern LockRowsPath *create_lockrows_path(PlannerInfo *root, RelOptInfo *rel,
extern ModifyTablePath *create_modifytable_path(PlannerInfo *root,
RelOptInfo *rel,
CmdType operation, bool canSetTag,
- Index nominalRelation, List *partitioned_rels,
+ Index nominalRelation, Index rootRelation,
bool partColsUpdated,
List *resultRelations, List *subpaths,
List *subroots,