From 3e251d46de5105581acf620773568bb9cdecdf0b Mon Sep 17 00:00:00 2001 From: amit Date: Tue, 19 Dec 2017 13:56:25 +0900 Subject: [PATCH 2/4] ExecFindPartition refactoring --- src/backend/commands/copy.c | 5 +---- src/backend/executor/execPartition.c | 14 ++++++-------- src/backend/executor/nodeModifyTable.c | 5 +---- src/include/executor/execPartition.h | 5 +---- 4 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index c82103e1c5..280d449dec 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -2619,10 +2619,7 @@ CopyFrom(CopyState cstate) * will get us the ResultRelInfo and TupleConversionMap for the * partition, respectively. */ - leaf_part_index = ExecFindPartition(resultRelInfo, - mtstate->mt_partition_dispatch_info, - slot, - estate); + leaf_part_index = ExecFindPartition(mtstate, slot); Assert(leaf_part_index >= 0 && leaf_part_index < mtstate->mt_num_partitions); diff --git a/src/backend/executor/execPartition.c b/src/backend/executor/execPartition.c index d545af2b67..a40c174230 100644 --- a/src/backend/executor/execPartition.c +++ b/src/backend/executor/execPartition.c @@ -155,11 +155,7 @@ ExecSetupPartitionTupleRouting(ModifyTableState *mtstate, } /* - * ExecFindPartition -- Find a leaf partition in the partition tree rooted - * at parent, for the heap tuple contained in *slot - * - * estate must be non-NULL; we'll need it to compute any expressions in the - * partition key(s) + * ExecFindPartition -- Find a leaf partition for tuple contained in slot * * If no leaf partition is found, this routine errors out with the appropriate * error message, else it returns the leaf partition sequence number @@ -167,14 +163,16 @@ ExecSetupPartitionTupleRouting(ModifyTableState *mtstate, * the partition tree. */ int -ExecFindPartition(ResultRelInfo *resultRelInfo, PartitionDispatch *pd, - TupleTableSlot *slot, EState *estate) +ExecFindPartition(ModifyTableState *mtstate, TupleTableSlot *slot) { + EState *estate = mtstate->ps.state; int result; Datum values[PARTITION_MAX_KEYS]; bool isnull[PARTITION_MAX_KEYS]; Relation rel; - PartitionDispatch parent; + PartitionDispatch *pd = mtstate->mt_partition_dispatch_info, + parent; + ResultRelInfo *resultRelInfo = mtstate->resultRelInfo; ExprContext *ecxt = GetPerTupleExprContext(estate); TupleTableSlot *ecxt_scantuple_old = ecxt->ecxt_scantuple; diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c index afb83ed3ae..f836dd3703 100644 --- a/src/backend/executor/nodeModifyTable.c +++ b/src/backend/executor/nodeModifyTable.c @@ -292,10 +292,7 @@ ExecInsert(ModifyTableState *mtstate, * the ResultRelInfo and TupleConversionMap for the partition, * respectively. */ - leaf_part_index = ExecFindPartition(resultRelInfo, - mtstate->mt_partition_dispatch_info, - slot, - estate); + leaf_part_index = ExecFindPartition(mtstate, slot); Assert(leaf_part_index >= 0 && leaf_part_index < mtstate->mt_num_partitions); diff --git a/src/include/executor/execPartition.h b/src/include/executor/execPartition.h index 86a199d169..19e3b9d233 100644 --- a/src/include/executor/execPartition.h +++ b/src/include/executor/execPartition.h @@ -58,9 +58,6 @@ extern void ExecSetupPartitionTupleRouting(ModifyTableState *mtstate, TupleConversionMap ***tup_conv_maps, TupleTableSlot **partition_tuple_slot, int *num_parted, int *num_partitions); -extern int ExecFindPartition(ResultRelInfo *resultRelInfo, - PartitionDispatch *pd, - TupleTableSlot *slot, - EState *estate); +extern int ExecFindPartition(ModifyTableState *mtstate, TupleTableSlot *slot); #endif /* EXECPARTITION_H */ -- 2.11.0