Commit 3e321090 authored by Robert Haas's avatar Robert Haas

Use key and partdesc from PartitionDispatch where possible.

Instead of repeatedly fishing the data out of the relcache entry,
let's use the version that we cached in the PartitionDispatch.  We
could alternatively rip out the PartitionDispatch fields altogether,
but it doesn't make much sense to have them and not use them; before
this patch, partdesc was set but altogether unused.  Amit Langote and
I both thought using them was a litle better than removing them, so
this patch takes that approach.

Discussion: http://postgr.es/m/CA+TgmobFnxcaW-Co-XO8=yhJ5pJXoNkCj6Z7jm9Mwj9FGv-D7w@mail.gmail.com
parent 8ce29bb4
...@@ -41,7 +41,7 @@ static void FormPartitionKeyDatum(PartitionDispatch pd, ...@@ -41,7 +41,7 @@ static void FormPartitionKeyDatum(PartitionDispatch pd,
EState *estate, EState *estate,
Datum *values, Datum *values,
bool *isnull); bool *isnull);
static int get_partition_for_tuple(Relation relation, Datum *values, static int get_partition_for_tuple(PartitionDispatch pd, Datum *values,
bool *isnull); bool *isnull);
static char *ExecBuildSlotPartitionKeyDescription(Relation rel, static char *ExecBuildSlotPartitionKeyDescription(Relation rel,
Datum *values, Datum *values,
...@@ -208,13 +208,11 @@ ExecFindPartition(ResultRelInfo *resultRelInfo, PartitionDispatch *pd, ...@@ -208,13 +208,11 @@ ExecFindPartition(ResultRelInfo *resultRelInfo, PartitionDispatch *pd,
parent = pd[0]; parent = pd[0];
while (true) while (true)
{ {
PartitionDesc partdesc;
TupleTableSlot *myslot = parent->tupslot; TupleTableSlot *myslot = parent->tupslot;
TupleConversionMap *map = parent->tupmap; TupleConversionMap *map = parent->tupmap;
int cur_index = -1; int cur_index = -1;
rel = parent->reldesc; rel = parent->reldesc;
partdesc = RelationGetPartitionDesc(rel);
/* /*
* Convert the tuple to this parent's layout so that we can do certain * Convert the tuple to this parent's layout so that we can do certain
...@@ -245,13 +243,13 @@ ExecFindPartition(ResultRelInfo *resultRelInfo, PartitionDispatch *pd, ...@@ -245,13 +243,13 @@ ExecFindPartition(ResultRelInfo *resultRelInfo, PartitionDispatch *pd,
* Nothing for get_partition_for_tuple() to do if there are no * Nothing for get_partition_for_tuple() to do if there are no
* partitions to begin with. * partitions to begin with.
*/ */
if (partdesc->nparts == 0) if (parent->partdesc->nparts == 0)
{ {
result = -1; result = -1;
break; break;
} }
cur_index = get_partition_for_tuple(rel, values, isnull); cur_index = get_partition_for_tuple(parent, values, isnull);
/* /*
* cur_index < 0 means we failed to find a partition of this parent. * cur_index < 0 means we failed to find a partition of this parent.
...@@ -1079,12 +1077,12 @@ FormPartitionKeyDatum(PartitionDispatch pd, ...@@ -1079,12 +1077,12 @@ FormPartitionKeyDatum(PartitionDispatch pd,
* found or -1 if none found. * found or -1 if none found.
*/ */
static int static int
get_partition_for_tuple(Relation relation, Datum *values, bool *isnull) get_partition_for_tuple(PartitionDispatch pd, Datum *values, bool *isnull)
{ {
int bound_offset; int bound_offset;
int part_index = -1; int part_index = -1;
PartitionKey key = RelationGetPartitionKey(relation); PartitionKey key = pd->key;
PartitionDesc partdesc = RelationGetPartitionDesc(relation); PartitionDesc partdesc = pd->partdesc;
PartitionBoundInfo boundinfo = partdesc->boundinfo; PartitionBoundInfo boundinfo = partdesc->boundinfo;
/* Route as appropriate based on partitioning strategy. */ /* Route as appropriate based on partitioning strategy. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment