mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +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:
@ -161,11 +161,14 @@ typedef struct CopyStateData
|
||||
ExprState **defexprs; /* array of default att expressions */
|
||||
bool volatile_defexprs; /* is any of defexprs volatile? */
|
||||
List *range_table;
|
||||
|
||||
PartitionDispatch *partition_dispatch_info;
|
||||
int num_dispatch;
|
||||
int num_partitions;
|
||||
ResultRelInfo *partitions;
|
||||
int num_dispatch; /* Number of entries in the above array */
|
||||
int num_partitions; /* Number of members in the following
|
||||
* arrays */
|
||||
ResultRelInfo *partitions; /* Per partition result relation */
|
||||
TupleConversionMap **partition_tupconv_maps;
|
||||
TupleTableSlot *partition_tuple_slot;
|
||||
|
||||
/*
|
||||
* These variables are used to reduce overhead in textual COPY FROM.
|
||||
@ -1409,6 +1412,7 @@ BeginCopy(ParseState *pstate,
|
||||
PartitionDispatch *partition_dispatch_info;
|
||||
ResultRelInfo *partitions;
|
||||
TupleConversionMap **partition_tupconv_maps;
|
||||
TupleTableSlot *partition_tuple_slot;
|
||||
int num_parted,
|
||||
num_partitions;
|
||||
|
||||
@ -1416,12 +1420,14 @@ BeginCopy(ParseState *pstate,
|
||||
&partition_dispatch_info,
|
||||
&partitions,
|
||||
&partition_tupconv_maps,
|
||||
&partition_tuple_slot,
|
||||
&num_parted, &num_partitions);
|
||||
cstate->partition_dispatch_info = partition_dispatch_info;
|
||||
cstate->num_dispatch = num_parted;
|
||||
cstate->partitions = partitions;
|
||||
cstate->num_partitions = num_partitions;
|
||||
cstate->partition_tupconv_maps = partition_tupconv_maps;
|
||||
cstate->partition_tuple_slot = partition_tuple_slot;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2435,15 +2441,6 @@ CopyFrom(CopyState cstate)
|
||||
/* Triggers might need a slot as well */
|
||||
estate->es_trig_tuple_slot = ExecInitExtraTupleSlot(estate);
|
||||
|
||||
/*
|
||||
* Initialize a dedicated slot to manipulate tuples of any given
|
||||
* partition's rowtype.
|
||||
*/
|
||||
if (cstate->partition_dispatch_info)
|
||||
estate->es_partition_tuple_slot = ExecInitExtraTupleSlot(estate);
|
||||
else
|
||||
estate->es_partition_tuple_slot = NULL;
|
||||
|
||||
/*
|
||||
* It's more efficient to prepare a bunch of tuples for insertion, and
|
||||
* insert them in one heap_multi_insert() call, than call heap_insert()
|
||||
@ -2591,7 +2588,7 @@ CopyFrom(CopyState cstate)
|
||||
* we're finished dealing with the partition.
|
||||
*/
|
||||
oldslot = slot;
|
||||
slot = estate->es_partition_tuple_slot;
|
||||
slot = cstate->partition_tuple_slot;
|
||||
Assert(slot != NULL);
|
||||
ExecSetSlotDescriptor(slot, RelationGetDescr(partrel));
|
||||
ExecStoreTuple(tuple, slot, InvalidBuffer, true);
|
||||
@ -2756,6 +2753,9 @@ CopyFrom(CopyState cstate)
|
||||
ExecCloseIndices(resultRelInfo);
|
||||
heap_close(resultRelInfo->ri_RelationDesc, NoLock);
|
||||
}
|
||||
|
||||
/* Release the standalone partition tuple descriptor */
|
||||
ExecDropSingleTupleTableSlot(cstate->partition_tuple_slot);
|
||||
}
|
||||
|
||||
FreeExecutorState(estate);
|
||||
|
Reference in New Issue
Block a user