@ -161,11 +161,14 @@ typedef struct CopyStateData
ExprState * * defexprs ; /* array of default att expressions */
ExprState * * defexprs ; /* array of default att expressions */
bool volatile_defexprs ; /* is any of defexprs volatile? */
bool volatile_defexprs ; /* is any of defexprs volatile? */
List * range_table ;
List * range_table ;
PartitionDispatch * partition_dispatch_info ;
PartitionDispatch * partition_dispatch_info ;
int num_dispatch ;
int num_dispatch ; /* Number of entries in the above array */
int num_partitions ;
int num_partitions ; /* Number of members in the following
ResultRelInfo * partitions ;
* arrays */
ResultRelInfo * partitions ; /* Per partition result relation */
TupleConversionMap * * partition_tupconv_maps ;
TupleConversionMap * * partition_tupconv_maps ;
TupleTableSlot * partition_tuple_slot ;
/*
/*
* These variables are used to reduce overhead in textual COPY FROM .
* These variables are used to reduce overhead in textual COPY FROM .
@ -1409,6 +1412,7 @@ BeginCopy(ParseState *pstate,
PartitionDispatch * partition_dispatch_info ;
PartitionDispatch * partition_dispatch_info ;
ResultRelInfo * partitions ;
ResultRelInfo * partitions ;
TupleConversionMap * * partition_tupconv_maps ;
TupleConversionMap * * partition_tupconv_maps ;
TupleTableSlot * partition_tuple_slot ;
int num_parted ,
int num_parted ,
num_partitions ;
num_partitions ;
@ -1416,12 +1420,14 @@ BeginCopy(ParseState *pstate,
& partition_dispatch_info ,
& partition_dispatch_info ,
& partitions ,
& partitions ,
& partition_tupconv_maps ,
& partition_tupconv_maps ,
& partition_tuple_slot ,
& num_parted , & num_partitions ) ;
& num_parted , & num_partitions ) ;
cstate - > partition_dispatch_info = partition_dispatch_info ;
cstate - > partition_dispatch_info = partition_dispatch_info ;
cstate - > num_dispatch = num_parted ;
cstate - > num_dispatch = num_parted ;
cstate - > partitions = partitions ;
cstate - > partitions = partitions ;
cstate - > num_partitions = num_partitions ;
cstate - > num_partitions = num_partitions ;
cstate - > partition_tupconv_maps = partition_tupconv_maps ;
cstate - > partition_tupconv_maps = partition_tupconv_maps ;
cstate - > partition_tuple_slot = partition_tuple_slot ;
}
}
}
}
else
else
@ -2435,15 +2441,6 @@ CopyFrom(CopyState cstate)
/* Triggers might need a slot as well */
/* Triggers might need a slot as well */
estate - > es_trig_tuple_slot = ExecInitExtraTupleSlot ( estate ) ;
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
* 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 ( )
* 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 .
* we ' re finished dealing with the partition .
*/
*/
oldslot = slot ;
oldslot = slot ;
slot = e state- > es_ partition_tuple_slot;
slot = c state- > partition_tuple_slot ;
Assert ( slot ! = NULL ) ;
Assert ( slot ! = NULL ) ;
ExecSetSlotDescriptor ( slot , RelationGetDescr ( partrel ) ) ;
ExecSetSlotDescriptor ( slot , RelationGetDescr ( partrel ) ) ;
ExecStoreTuple ( tuple , slot , InvalidBuffer , true ) ;
ExecStoreTuple ( tuple , slot , InvalidBuffer , true ) ;
@ -2756,6 +2753,9 @@ CopyFrom(CopyState cstate)
ExecCloseIndices ( resultRelInfo ) ;
ExecCloseIndices ( resultRelInfo ) ;
heap_close ( resultRelInfo - > ri_RelationDesc , NoLock ) ;
heap_close ( resultRelInfo - > ri_RelationDesc , NoLock ) ;
}
}
/* Release the standalone partition tuple descriptor */
ExecDropSingleTupleTableSlot ( cstate - > partition_tuple_slot ) ;
}
}
FreeExecutorState ( estate ) ;
FreeExecutorState ( estate ) ;