@ -808,6 +808,19 @@ ExecParallelReinitialize(PlanState *planstate,
/* Old workers must already be shut down */
/* Old workers must already be shut down */
Assert ( pei - > finished ) ;
Assert ( pei - > finished ) ;
/* Clear the instrumentation space from the last round. */
if ( pei - > instrumentation )
{
Instrumentation * instrument ;
SharedExecutorInstrumentation * sh_instr ;
int i ;
sh_instr = pei - > instrumentation ;
instrument = GetInstrumentationArray ( sh_instr ) ;
for ( i = 0 ; i < sh_instr - > num_workers * sh_instr - > num_plan_nodes ; + + i )
InstrInit ( & instrument [ i ] , pei - > planstate - > state - > es_instrument ) ;
}
/* Force parameters we're going to pass to workers to be evaluated. */
/* Force parameters we're going to pass to workers to be evaluated. */
ExecEvalParamExecParams ( sendParams , estate ) ;
ExecEvalParamExecParams ( sendParams , estate ) ;
@ -925,21 +938,33 @@ ExecParallelRetrieveInstrumentation(PlanState *planstate,
for ( n = 0 ; n < instrumentation - > num_workers ; + + n )
for ( n = 0 ; n < instrumentation - > num_workers ; + + n )
InstrAggNode ( planstate - > instrument , & instrument [ n ] ) ;
InstrAggNode ( planstate - > instrument , & instrument [ n ] ) ;
/*
if ( ! planstate - > worker_instrument )
* Also store the per - worker detail .
{
*
/*
* Worker instrumentation should be allocated in the same context as the
* Allocate space for the per - worker detail .
* regular instrumentation information , which is the per - query context .
*
* Switch into per - query memory context .
* Worker instrumentation should be allocated in the same context as
*/
* the regular instrumentation information , which is the per - query
oldcontext = MemoryContextSwitchTo ( planstate - > state - > es_query_cxt ) ;
* context . Switch into per - query memory context .
ibytes = mul_size ( instrumentation - > num_workers , sizeof ( Instrumentation ) ) ;
*/
planstate - > worker_instrument =
oldcontext = MemoryContextSwitchTo ( planstate - > state - > es_query_cxt ) ;
palloc ( ibytes + offsetof ( WorkerInstrumentation , instrument ) ) ;
ibytes =
MemoryContextSwitchTo ( oldcontext ) ;
mul_size ( instrumentation - > num_workers , sizeof ( Instrumentation ) ) ;
planstate - > worker_instrument =
palloc ( ibytes + offsetof ( WorkerInstrumentation , instrument ) ) ;
MemoryContextSwitchTo ( oldcontext ) ;
for ( n = 0 ; n < instrumentation - > num_workers ; + + n )
InstrInit ( & planstate - > worker_instrument - > instrument [ n ] ,
planstate - > state - > es_instrument ) ;
}
planstate - > worker_instrument - > num_workers = instrumentation - > num_workers ;
planstate - > worker_instrument - > num_workers = instrumentation - > num_workers ;
memcpy ( & planstate - > worker_instrument - > instrument , instrument , ibytes ) ;
/* Accumulate the per-worker detail. */
for ( n = 0 ; n < instrumentation - > num_workers ; + + n )
InstrAggNode ( & planstate - > worker_instrument - > instrument [ n ] ,
& instrument [ n ] ) ;
/* Perform any node-type-specific work that needs to be done. */
/* Perform any node-type-specific work that needs to be done. */
switch ( nodeTag ( planstate ) )
switch ( nodeTag ( planstate ) )