From 4fcb2ccff043c7261fecc408447df437d5e2b5b6 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Wed, 19 Dec 2018 14:58:01 -0500 Subject: [PATCH] Adapt executor. --- src/backend/executor/execPartition.c | 24 +++++++++++++++++------- src/include/nodes/execnodes.h | 4 ++++ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/backend/executor/execPartition.c b/src/backend/executor/execPartition.c index ed3616e661..ca6698dec1 100644 --- a/src/backend/executor/execPartition.c +++ b/src/backend/executor/execPartition.c @@ -23,6 +23,7 @@ #include "miscadmin.h" #include "nodes/makefuncs.h" #include "partitioning/partbounds.h" +#include "partitioning/partdir.h" #include "partitioning/partprune.h" #include "rewrite/rewriteManip.h" #include "utils/lsyscache.h" @@ -165,8 +166,10 @@ static void ExecInitRoutingInfo(ModifyTableState *mtstate, PartitionDispatch dispatch, ResultRelInfo *partRelInfo, int partidx); -static PartitionDispatch ExecInitPartitionDispatchInfo(PartitionTupleRouting *proute, - Oid partoid, PartitionDispatch parent_pd, int partidx); +static PartitionDispatch ExecInitPartitionDispatchInfo(EState *estate, + PartitionTupleRouting *proute, + Oid partoid, PartitionDispatch parent_pd, + int partidx); static void FormPartitionKeyDatum(PartitionDispatch pd, TupleTableSlot *slot, EState *estate, @@ -227,7 +230,8 @@ ExecSetupPartitionTupleRouting(EState *estate, ModifyTableState *mtstate, Relati * parent as NULL as we don't need to care about any parent of the target * partitioned table. */ - ExecInitPartitionDispatchInfo(proute, RelationGetRelid(rel), NULL, 0); + ExecInitPartitionDispatchInfo(estate, proute, RelationGetRelid(rel), + NULL, 0); /* * If performing an UPDATE with tuple routing, we can reuse partition @@ -428,7 +432,7 @@ ExecFindPartition(ModifyTableState *mtstate, * Create the new PartitionDispatch. We pass the current one * in as the parent PartitionDispatch */ - subdispatch = ExecInitPartitionDispatchInfo(proute, + subdispatch = ExecInitPartitionDispatchInfo(estate, proute, partdesc->oids[partidx], dispatch, partidx); Assert(dispatch->indexes[partidx] >= 0 && @@ -970,8 +974,9 @@ ExecInitRoutingInfo(ModifyTableState *mtstate, * newly created PartitionDispatch later. */ static PartitionDispatch -ExecInitPartitionDispatchInfo(PartitionTupleRouting *proute, Oid partoid, - PartitionDispatch parent_pd, int partidx) +ExecInitPartitionDispatchInfo(EState *estate, PartitionTupleRouting *proute, + Oid partoid, PartitionDispatch parent_pd, + int partidx) { Relation rel; PartitionDesc partdesc; @@ -985,7 +990,12 @@ ExecInitPartitionDispatchInfo(PartitionTupleRouting *proute, Oid partoid, rel = heap_open(partoid, NoLock); else rel = proute->partition_root; - partdesc = RelationGetPartitionDesc(rel); + + if (estate->es_partition_directory == NULL) + estate->es_partition_directory = + CreatePartitionDirectory(estate->es_query_cxt); + partdesc = PartitionDirectoryLookup(estate->es_partition_directory, + rel); pd = (PartitionDispatch) palloc(offsetof(PartitionDispatchData, indexes) + partdesc->nparts * sizeof(int)); diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index 5ed0f40f69..985c752d01 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -21,6 +21,7 @@ #include "lib/pairingheap.h" #include "nodes/params.h" #include "nodes/plannodes.h" +#include "partitioning/partdefs.h" #include "utils/hsearch.h" #include "utils/queryenvironment.h" #include "utils/reltrigger.h" @@ -523,6 +524,9 @@ typedef struct EState */ List *es_tuple_routing_result_relations; + /* Directory of partitions used for any purpose. */ + PartitionDirectory es_partition_directory; + /* Stuff used for firing triggers: */ List *es_trig_target_relations; /* trigger-only ResultRelInfos */ TupleTableSlot *es_trig_tuple_slot; /* for trigger output tuples */ -- 2.30.2