summaryrefslogtreecommitdiff
path: root/src/backend/executor/execPartition.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/executor/execPartition.c')
-rw-r--r--src/backend/executor/execPartition.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/backend/executor/execPartition.c b/src/backend/executor/execPartition.c
index 746cd1e9d7a..b9e4f2d80b1 100644
--- a/src/backend/executor/execPartition.c
+++ b/src/backend/executor/execPartition.c
@@ -176,7 +176,8 @@ static void ExecInitRoutingInfo(ModifyTableState *mtstate,
int partidx);
static PartitionDispatch ExecInitPartitionDispatchInfo(EState *estate,
PartitionTupleRouting *proute,
- Oid partoid, PartitionDispatch parent_pd, int partidx);
+ Oid partoid, PartitionDispatch parent_pd,
+ int partidx, ResultRelInfo *rootResultRelInfo);
static void FormPartitionKeyDatum(PartitionDispatch pd,
TupleTableSlot *slot,
EState *estate,
@@ -238,7 +239,7 @@ ExecSetupPartitionTupleRouting(EState *estate, ModifyTableState *mtstate,
* partitioned table.
*/
ExecInitPartitionDispatchInfo(estate, proute, RelationGetRelid(rel),
- NULL, 0);
+ NULL, 0, NULL);
/*
* If performing an UPDATE with tuple routing, we can reuse partition
@@ -432,10 +433,11 @@ ExecFindPartition(ModifyTableState *mtstate,
* Create the new PartitionDispatch. We pass the current one
* in as the parent PartitionDispatch
*/
- subdispatch = ExecInitPartitionDispatchInfo(mtstate->ps.state,
+ subdispatch = ExecInitPartitionDispatchInfo(estate,
proute,
partdesc->oids[partidx],
- dispatch, partidx);
+ dispatch, partidx,
+ mtstate->rootResultRelInfo);
Assert(dispatch->indexes[partidx] >= 0 &&
dispatch->indexes[partidx] < proute->num_dispatch);
@@ -547,7 +549,7 @@ ExecHashSubPlanResultRelsByOid(ModifyTableState *mtstate,
* compatible with the root partitioned table's tuple descriptor. When
* generating the per-subplan result rels, this was not set.
*/
- rri->ri_PartitionRoot = proute->partition_root;
+ rri->ri_RootResultRelInfo = mtstate->rootResultRelInfo;
}
}
@@ -567,8 +569,8 @@ ExecInitPartitionInfo(ModifyTableState *mtstate, EState *estate,
int partidx)
{
ModifyTable *node = (ModifyTable *) mtstate->ps.plan;
- Relation rootrel = rootResultRelInfo->ri_RelationDesc,
- partrel;
+ Relation partrel;
+ int firstVarno = mtstate->resultRelInfo[0].ri_RangeTableIndex;
Relation firstResultRel = mtstate->resultRelInfo[0].ri_RelationDesc;
ResultRelInfo *leaf_part_rri;
MemoryContext oldcxt;
@@ -582,8 +584,8 @@ ExecInitPartitionInfo(ModifyTableState *mtstate, EState *estate,
leaf_part_rri = makeNode(ResultRelInfo);
InitResultRelInfo(leaf_part_rri,
partrel,
- node ? node->rootRelation : 1,
- rootrel,
+ 0,
+ rootResultRelInfo,
estate->es_instrument);
/*
@@ -617,7 +619,6 @@ ExecInitPartitionInfo(ModifyTableState *mtstate, EState *estate,
List *wcoList;
List *wcoExprs = NIL;
ListCell *ll;
- int firstVarno = mtstate->resultRelInfo[0].ri_RangeTableIndex;
/*
* In the case of INSERT on a partitioned table, there is only one
@@ -681,7 +682,6 @@ ExecInitPartitionInfo(ModifyTableState *mtstate, EState *estate,
TupleTableSlot *slot;
ExprContext *econtext;
List *returningList;
- int firstVarno = mtstate->resultRelInfo[0].ri_RangeTableIndex;
/* See the comment above for WCO lists. */
Assert((node->operation == CMD_INSERT &&
@@ -740,7 +740,6 @@ ExecInitPartitionInfo(ModifyTableState *mtstate, EState *estate,
*/
if (node && node->onConflictAction != ONCONFLICT_NONE)
{
- int firstVarno = mtstate->resultRelInfo[0].ri_RangeTableIndex;
TupleDesc partrelDesc = RelationGetDescr(partrel);
ExprContext *econtext = mtstate->ps.ps_ExprContext;
ListCell *lc;
@@ -917,7 +916,7 @@ ExecInitPartitionInfo(ModifyTableState *mtstate, EState *estate,
if (mtstate->mt_transition_capture || mtstate->mt_oc_transition_capture)
leaf_part_rri->ri_ChildToRootMap =
convert_tuples_by_name(RelationGetDescr(leaf_part_rri->ri_RelationDesc),
- RelationGetDescr(leaf_part_rri->ri_PartitionRoot));
+ RelationGetDescr(rootResultRelInfo->ri_RelationDesc));
/*
* Since we've just initialized this ResultRelInfo, it's not in any list
@@ -951,6 +950,7 @@ ExecInitRoutingInfo(ModifyTableState *mtstate,
ResultRelInfo *partRelInfo,
int partidx)
{
+ ResultRelInfo *rootRelInfo = partRelInfo->ri_RootResultRelInfo;
MemoryContext oldcxt;
int rri_index;
@@ -961,7 +961,7 @@ ExecInitRoutingInfo(ModifyTableState *mtstate,
* partition from the parent's type to the partition's.
*/
partRelInfo->ri_RootToPartitionMap =
- convert_tuples_by_name(RelationGetDescr(partRelInfo->ri_PartitionRoot),
+ convert_tuples_by_name(RelationGetDescr(rootRelInfo->ri_RelationDesc),
RelationGetDescr(partRelInfo->ri_RelationDesc));
/*
@@ -1055,7 +1055,8 @@ ExecInitRoutingInfo(ModifyTableState *mtstate,
static PartitionDispatch
ExecInitPartitionDispatchInfo(EState *estate,
PartitionTupleRouting *proute, Oid partoid,
- PartitionDispatch parent_pd, int partidx)
+ PartitionDispatch parent_pd, int partidx,
+ ResultRelInfo *rootResultRelInfo)
{
Relation rel;
PartitionDesc partdesc;
@@ -1153,7 +1154,7 @@ ExecInitPartitionDispatchInfo(EState *estate,
{
ResultRelInfo *rri = makeNode(ResultRelInfo);
- InitResultRelInfo(rri, rel, 1, proute->partition_root, 0);
+ InitResultRelInfo(rri, rel, 0, rootResultRelInfo, 0);
proute->nonleaf_partitions[dispatchidx] = rri;
}
else