summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Haas2018-12-19 19:58:01 +0000
committerRobert Haas2018-12-19 19:58:01 +0000
commit4fcb2ccff043c7261fecc408447df437d5e2b5b6 (patch)
tree4d9ec0b98bbc2e79c11b079ae215bfcca8672124
parent38acf7c9288ae5f72d0dea6453b4dd1ec3f1d733 (diff)
Adapt executor.partdesc
-rw-r--r--src/backend/executor/execPartition.c24
-rw-r--r--src/include/nodes/execnodes.h4
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 */