mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
Move partition_tuple_slot out of EState.
Commit 2ac3ef7a01
added a TupleTapleSlot
for partition tuple slot to EState (es_partition_tuple_slot) but it's
more logical to have it as part of ModifyTableState
(mt_partition_tuple_slot) and CopyState (partition_tuple_slot).
Discussion: http://postgr.es/m/1bd459d9-4c0c-197a-346e-e5e59e217d97@lab.ntt.co.jp
Amit Langote, per a gripe from me
This commit is contained in:
@ -3012,6 +3012,9 @@ EvalPlanQualEnd(EPQState *epqstate)
|
||||
* entry for every leaf partition (required to convert input tuple based
|
||||
* on the root table's rowtype to a leaf partition's rowtype after tuple
|
||||
* routing is done
|
||||
* 'partition_tuple_slot' receives a standalone TupleTableSlot to be used
|
||||
* to manipulate any given leaf partition's rowtype after that partition
|
||||
* is chosen by tuple-routing.
|
||||
* 'num_parted' receives the number of partitioned tables in the partition
|
||||
* tree (= the number of entries in the 'pd' output array)
|
||||
* 'num_partitions' receives the number of leaf partitions in the partition
|
||||
@ -3026,6 +3029,7 @@ ExecSetupPartitionTupleRouting(Relation rel,
|
||||
PartitionDispatch **pd,
|
||||
ResultRelInfo **partitions,
|
||||
TupleConversionMap ***tup_conv_maps,
|
||||
TupleTableSlot **partition_tuple_slot,
|
||||
int *num_parted, int *num_partitions)
|
||||
{
|
||||
TupleDesc tupDesc = RelationGetDescr(rel);
|
||||
@ -3043,6 +3047,14 @@ ExecSetupPartitionTupleRouting(Relation rel,
|
||||
*tup_conv_maps = (TupleConversionMap **) palloc0(*num_partitions *
|
||||
sizeof(TupleConversionMap *));
|
||||
|
||||
/*
|
||||
* Initialize an empty slot that will be used to manipulate tuples of any
|
||||
* given partition's rowtype. It is attached to the caller-specified node
|
||||
* (such as ModifyTableState) and released when the node finishes
|
||||
* processing.
|
||||
*/
|
||||
*partition_tuple_slot = MakeTupleTableSlot();
|
||||
|
||||
leaf_part_rri = *partitions;
|
||||
i = 0;
|
||||
foreach(cell, leaf_parts)
|
||||
|
@ -329,7 +329,7 @@ ExecInsert(ModifyTableState *mtstate,
|
||||
* Use the dedicated slot for that.
|
||||
*/
|
||||
oldslot = slot;
|
||||
slot = estate->es_partition_tuple_slot;
|
||||
slot = mtstate->mt_partition_tuple_slot;
|
||||
Assert(slot != NULL);
|
||||
ExecSetSlotDescriptor(slot, RelationGetDescr(partrel));
|
||||
ExecStoreTuple(tuple, slot, InvalidBuffer, true);
|
||||
@ -1738,6 +1738,7 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
|
||||
PartitionDispatch *partition_dispatch_info;
|
||||
ResultRelInfo *partitions;
|
||||
TupleConversionMap **partition_tupconv_maps;
|
||||
TupleTableSlot *partition_tuple_slot;
|
||||
int num_parted,
|
||||
num_partitions;
|
||||
|
||||
@ -1745,21 +1746,15 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
|
||||
&partition_dispatch_info,
|
||||
&partitions,
|
||||
&partition_tupconv_maps,
|
||||
&partition_tuple_slot,
|
||||
&num_parted, &num_partitions);
|
||||
mtstate->mt_partition_dispatch_info = partition_dispatch_info;
|
||||
mtstate->mt_num_dispatch = num_parted;
|
||||
mtstate->mt_partitions = partitions;
|
||||
mtstate->mt_num_partitions = num_partitions;
|
||||
mtstate->mt_partition_tupconv_maps = partition_tupconv_maps;
|
||||
|
||||
/*
|
||||
* Initialize a dedicated slot to manipulate tuples of any given
|
||||
* partition's rowtype.
|
||||
*/
|
||||
estate->es_partition_tuple_slot = ExecInitExtraTupleSlot(estate);
|
||||
mtstate->mt_partition_tuple_slot = partition_tuple_slot;
|
||||
}
|
||||
else
|
||||
estate->es_partition_tuple_slot = NULL;
|
||||
|
||||
/*
|
||||
* Initialize any WITH CHECK OPTION constraints if needed.
|
||||
@ -2100,6 +2095,10 @@ ExecEndModifyTable(ModifyTableState *node)
|
||||
heap_close(resultRelInfo->ri_RelationDesc, NoLock);
|
||||
}
|
||||
|
||||
/* Release the standalone partition tuple descriptor, if any */
|
||||
if (node->mt_partition_tuple_slot)
|
||||
ExecDropSingleTupleTableSlot(node->mt_partition_tuple_slot);
|
||||
|
||||
/*
|
||||
* Free the exprcontext
|
||||
*/
|
||||
|
Reference in New Issue
Block a user