From 84fb03e7cbb7c887ec926724c81c3baa5a7a7b9d Mon Sep 17 00:00:00 2001 From: Osumi Takamichi Date: Thu, 18 Nov 2021 11:44:46 +0000 Subject: [PATCH v13 2/3] Export PartitionTupleRouting for transaction size calculation Apply worker utilizes ApplyExecutionData and its one of the members is PartitionTupleRouting. This is dynamically allocated during apply and need to make it exported if the target relation is partitioned to calculate transaction memory consumption. --- src/backend/executor/execPartition.c | 70 ------------------------------------ src/include/executor/execPartition.h | 69 +++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 70 deletions(-) diff --git a/src/backend/executor/execPartition.c b/src/backend/executor/execPartition.c index 5c723bc..2467f4c 100644 --- a/src/backend/executor/execPartition.c +++ b/src/backend/executor/execPartition.c @@ -34,76 +34,6 @@ #include "utils/rls.h" #include "utils/ruleutils.h" - -/*----------------------- - * PartitionTupleRouting - Encapsulates all information required to - * route a tuple inserted into a partitioned table to one of its leaf - * partitions. - * - * partition_root - * The partitioned table that's the target of the command. - * - * partition_dispatch_info - * Array of 'max_dispatch' elements containing a pointer to a - * PartitionDispatch object for every partitioned table touched by tuple - * routing. The entry for the target partitioned table is *always* - * present in the 0th element of this array. See comment for - * PartitionDispatchData->indexes for details on how this array is - * indexed. - * - * nonleaf_partitions - * Array of 'max_dispatch' elements containing pointers to fake - * ResultRelInfo objects for nonleaf partitions, useful for checking - * the partition constraint. - * - * num_dispatch - * The current number of items stored in the 'partition_dispatch_info' - * array. Also serves as the index of the next free array element for - * new PartitionDispatch objects that need to be stored. - * - * max_dispatch - * The current allocated size of the 'partition_dispatch_info' array. - * - * partitions - * Array of 'max_partitions' elements containing a pointer to a - * ResultRelInfo for every leaf partition touched by tuple routing. - * Some of these are pointers to ResultRelInfos which are borrowed out of - * the owning ModifyTableState node. The remainder have been built - * especially for tuple routing. See comment for - * PartitionDispatchData->indexes for details on how this array is - * indexed. - * - * is_borrowed_rel - * Array of 'max_partitions' booleans recording whether a given entry - * in 'partitions' is a ResultRelInfo pointer borrowed from the owning - * ModifyTableState node, rather than being built here. - * - * num_partitions - * The current number of items stored in the 'partitions' array. Also - * serves as the index of the next free array element for new - * ResultRelInfo objects that need to be stored. - * - * max_partitions - * The current allocated size of the 'partitions' array. - * - * memcxt - * Memory context used to allocate subsidiary structs. - *----------------------- - */ -struct PartitionTupleRouting -{ - Relation partition_root; - PartitionDispatch *partition_dispatch_info; - ResultRelInfo **nonleaf_partitions; - int num_dispatch; - int max_dispatch; - ResultRelInfo **partitions; - bool *is_borrowed_rel; - int num_partitions; - int max_partitions; - MemoryContext memcxt; -}; - /*----------------------- * PartitionDispatch - information about one partitioned table in a partition * hierarchy required to route a tuple to any of its partitions. A diff --git a/src/include/executor/execPartition.h b/src/include/executor/execPartition.h index 694e38b..4c796ab 100644 --- a/src/include/executor/execPartition.h +++ b/src/include/executor/execPartition.h @@ -110,6 +110,75 @@ typedef struct PartitionPruneState PartitionPruningData *partprunedata[FLEXIBLE_ARRAY_MEMBER]; } PartitionPruneState; +/*----------------------- + * PartitionTupleRouting - Encapsulates all information required to + * route a tuple inserted into a partitioned table to one of its leaf + * partitions. + * + * partition_root + * The partitioned table that's the target of the command. + * + * partition_dispatch_info + * Array of 'max_dispatch' elements containing a pointer to a + * PartitionDispatch object for every partitioned table touched by tuple + * routing. The entry for the target partitioned table is *always* + * present in the 0th element of this array. See comment for + * PartitionDispatchData->indexes for details on how this array is + * indexed. + * + * nonleaf_partitions + * Array of 'max_dispatch' elements containing pointers to fake + * ResultRelInfo objects for nonleaf partitions, useful for checking + * the partition constraint. + * + * num_dispatch + * The current number of items stored in the 'partition_dispatch_info' + * array. Also serves as the index of the next free array element for + * new PartitionDispatch objects that need to be stored. + * + * max_dispatch + * The current allocated size of the 'partition_dispatch_info' array. + * + * partitions + * Array of 'max_partitions' elements containing a pointer to a + * ResultRelInfo for every leaf partition touched by tuple routing. + * Some of these are pointers to ResultRelInfos which are borrowed out of + * the owning ModifyTableState node. The remainder have been built + * especially for tuple routing. See comment for + * PartitionDispatchData->indexes for details on how this array is + * indexed. + * + * is_borrowed_rel + * Array of 'max_partitions' booleans recording whether a given entry + * in 'partitions' is a ResultRelInfo pointer borrowed from the owning + * ModifyTableState node, rather than being built here. + * + * num_partitions + * The current number of items stored in the 'partitions' array. Also + * serves as the index of the next free array element for new + * ResultRelInfo objects that need to be stored. + * + * max_partitions + * The current allocated size of the 'partitions' array. + * + * memcxt + * Memory context used to allocate subsidiary structs. + *----------------------- + */ +struct PartitionTupleRouting +{ + Relation partition_root; + PartitionDispatch *partition_dispatch_info; + ResultRelInfo **nonleaf_partitions; + int num_dispatch; + int max_dispatch; + ResultRelInfo **partitions; + bool *is_borrowed_rel; + int num_partitions; + int max_partitions; + MemoryContext memcxt; +}; + extern PartitionTupleRouting *ExecSetupPartitionTupleRouting(EState *estate, Relation rel); extern ResultRelInfo *ExecFindPartition(ModifyTableState *mtstate, -- 2.2.0