diff --git a/src/backend/executor/execPartition.c b/src/backend/executor/execPartition.c index 7a4665cc4e..81fe6cdcf7 100644 --- a/src/backend/executor/execPartition.c +++ b/src/backend/executor/execPartition.c @@ -927,7 +927,6 @@ get_partition_dispatch_recurse(Relation rel, Relation parent, { TupleDesc tupdesc = RelationGetDescr(rel); PartitionDesc partdesc = RelationGetPartitionDesc(rel); - PartitionKey partkey = RelationGetPartitionKey(rel); PartitionDispatch pd; int i; @@ -937,9 +936,7 @@ get_partition_dispatch_recurse(Relation rel, Relation parent, pd = (PartitionDispatch) palloc(sizeof(PartitionDispatchData)); *pds = lappend(*pds, pd); pd->reldesc = rel; - pd->key = partkey; pd->keystate = NIL; - pd->partdesc = partdesc; if (parent != NULL) { /* @@ -1027,23 +1024,24 @@ FormPartitionKeyDatum(PartitionDispatch pd, Datum *values, bool *isnull) { + PartitionKey key = RelationGetPartitionKey(pd->reldesc); ListCell *partexpr_item; int i; - if (pd->key->partexprs != NIL && pd->keystate == NIL) + if (key->partexprs != NIL && pd->keystate == NIL) { /* Check caller has set up context correctly */ Assert(estate != NULL && GetPerTupleExprContext(estate)->ecxt_scantuple == slot); /* First time through, set up expression evaluation state */ - pd->keystate = ExecPrepareExprList(pd->key->partexprs, estate); + pd->keystate = ExecPrepareExprList(key->partexprs, estate); } partexpr_item = list_head(pd->keystate); - for (i = 0; i < pd->key->partnatts; i++) + for (i = 0; i < key->partnatts; i++) { - AttrNumber keycol = pd->key->partattrs[i]; + AttrNumber keycol = key->partattrs[i]; Datum datum; bool isNull; diff --git a/src/include/executor/execPartition.h b/src/include/executor/execPartition.h index 862bf65060..6f6a8d56a7 100644 --- a/src/include/executor/execPartition.h +++ b/src/include/executor/execPartition.h @@ -23,25 +23,21 @@ * hierarchy required to route a tuple to one of its partitions * * reldesc Relation descriptor of the table - * key Partition key information of the table * keystate Execution state required for expressions in the partition key - * partdesc Partition descriptor of the table * tupslot A standalone TupleTableSlot initialized with this table's tuple * descriptor * tupmap TupleConversionMap to convert from the parent's rowtype to * this table's rowtype (when extracting the partition key of a * tuple just before routing it through this table) - * indexes Array with partdesc->nparts members (for details on what - * individual members represent, see how they are set in - * get_partition_dispatch_recurse()) + * indexes Array with as many members as the rel's PartitionDesc (for + * details on what individual members represent, see how they + * are set in get_partition_dispatch_recurse()) *----------------------- */ typedef struct PartitionDispatchData { Relation reldesc; - PartitionKey key; List *keystate; /* list of ExprState */ - PartitionDesc partdesc; TupleTableSlot *tupslot; TupleConversionMap *tupmap; int *indexes;