From dbfffa276791cecda39c423006caa4a2bd7d4493 Mon Sep 17 00:00:00 2001 From: amitlan Date: Tue, 12 Jan 2021 14:17:31 +0900 Subject: [PATCH v1 1/2] Export get_partition_for_tuple() Currently, only execPartition.c can see it, although a subsequent change will require it to be callable from another module. To make this possible, also change the interface to accept the partitioning information using more widely available structs. --- src/backend/executor/execPartition.c | 14 +++++++------- src/include/executor/execPartition.h | 3 +++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/backend/executor/execPartition.c b/src/backend/executor/execPartition.c index 941731a0a9..84e50ee7c8 100644 --- a/src/backend/executor/execPartition.c +++ b/src/backend/executor/execPartition.c @@ -182,8 +182,6 @@ static void FormPartitionKeyDatum(PartitionDispatch pd, EState *estate, Datum *values, bool *isnull); -static int get_partition_for_tuple(PartitionDispatch pd, Datum *values, - bool *isnull); static char *ExecBuildSlotPartitionKeyDescription(Relation rel, Datum *values, bool *isnull, @@ -330,7 +328,9 @@ ExecFindPartition(ModifyTableState *mtstate, * these values, error out. */ if (partdesc->nparts == 0 || - (partidx = get_partition_for_tuple(dispatch, values, isnull)) < 0) + (partidx = get_partition_for_tuple(dispatch->key, + dispatch->partdesc, + values, isnull)) < 0) { char *val_desc; @@ -1292,13 +1292,13 @@ FormPartitionKeyDatum(PartitionDispatch pd, * Return value is index of the partition (>= 0 and < partdesc->nparts) if one * found or -1 if none found. */ -static int -get_partition_for_tuple(PartitionDispatch pd, Datum *values, bool *isnull) +int +get_partition_for_tuple(PartitionKey key, + PartitionDesc partdesc, + Datum *values, bool *isnull) { int bound_offset; int part_index = -1; - PartitionKey key = pd->key; - PartitionDesc partdesc = pd->partdesc; PartitionBoundInfo boundinfo = partdesc->boundinfo; /* Route as appropriate based on partitioning strategy. */ diff --git a/src/include/executor/execPartition.h b/src/include/executor/execPartition.h index d30ffde7d9..e5888d54f1 100644 --- a/src/include/executor/execPartition.h +++ b/src/include/executor/execPartition.h @@ -125,5 +125,8 @@ extern PartitionPruneState *ExecCreatePartitionPruneState(PlanState *planstate, extern Bitmapset *ExecFindMatchingSubPlans(PartitionPruneState *prunestate); extern Bitmapset *ExecFindInitialMatchingSubPlans(PartitionPruneState *prunestate, int nsubplans); +extern int get_partition_for_tuple(PartitionKey key, + PartitionDesc partdesc, + Datum *values, bool *isnull); #endif /* EXECPARTITION_H */ -- 2.24.1