@ -153,7 +153,6 @@ ExecGather(GatherState *node)
if ( gather - > num_workers > 0 & & IsInParallelMode ( ) )
if ( gather - > num_workers > 0 & & IsInParallelMode ( ) )
{
{
ParallelContext * pcxt ;
ParallelContext * pcxt ;
bool got_any_worker = false ;
/* Initialize the workers required to execute Gather node. */
/* Initialize the workers required to execute Gather node. */
if ( ! node - > pei )
if ( ! node - > pei )
@ -169,30 +168,27 @@ ExecGather(GatherState *node)
LaunchParallelWorkers ( pcxt ) ;
LaunchParallelWorkers ( pcxt ) ;
/* Set up tuple queue readers to read the results. */
/* Set up tuple queue readers to read the results. */
if ( pcxt - > nworkers > 0 )
if ( pcxt - > nworkers_launched > 0 )
{
{
node - > nreaders = 0 ;
node - > nreaders = 0 ;
node - > reader =
node - > reader =
palloc ( pcxt - > nworkers * sizeof ( TupleQueueReader * ) ) ;
palloc ( pcxt - > nworkers_launched * sizeof ( TupleQueueReader * ) ) ;
for ( i = 0 ; i < pcxt - > nworkers ; + + i )
for ( i = 0 ; i < pcxt - > nworkers_launched ; + + i )
{
{
if ( pcxt - > worker [ i ] . bgwhandle = = NULL )
continue ;
shm_mq_set_handle ( node - > pei - > tqueue [ i ] ,
shm_mq_set_handle ( node - > pei - > tqueue [ i ] ,
pcxt - > worker [ i ] . bgwhandle ) ;
pcxt - > worker [ i ] . bgwhandle ) ;
node - > reader [ node - > nreaders + + ] =
node - > reader [ node - > nreaders + + ] =
CreateTupleQueueReader ( node - > pei - > tqueue [ i ] ,
CreateTupleQueueReader ( node - > pei - > tqueue [ i ] ,
fslot - > tts_tupleDescriptor ) ;
fslot - > tts_tupleDescriptor ) ;
got_any_worker = true ;
}
}
}
}
else
{
/* No workers? Then never mind. */
/* No workers? Then never mind. */
if ( ! got_any_worker )
ExecShutdownGatherWorkers ( node ) ;
ExecShutdownGatherWorkers ( node ) ;
}
}
}
/* Run plan locally if no workers or not single-copy. */
/* Run plan locally if no workers or not single-copy. */
node - > need_to_scan_locally = ( node - > reader = = NULL )
node - > need_to_scan_locally = ( node - > reader = = NULL )