mirror of
https://github.com/postgres/postgres.git
synced 2026-04-15 22:10:45 -04:00
Ensure gatherstate->nextreader is properly initialized.
The previously code worked OK as long as a Gather node was never rescanned, or if it was rescanned, as long as it got at least as many workers on rescan as it had originally. But if the number of workers ever decreased on a rescan, then it could crash. Andreas Seltenreich
This commit is contained in:
parent
093129c9d9
commit
53c7cff720
1 changed files with 2 additions and 0 deletions
|
|
@ -173,6 +173,7 @@ ExecGather(GatherState *node)
|
|||
if (pcxt->nworkers_launched > 0)
|
||||
{
|
||||
node->nreaders = 0;
|
||||
node->nextreader = 0;
|
||||
node->reader =
|
||||
palloc(pcxt->nworkers_launched * sizeof(TupleQueueReader *));
|
||||
|
||||
|
|
@ -335,6 +336,7 @@ gather_readnext(GatherState *gatherstate)
|
|||
CHECK_FOR_INTERRUPTS();
|
||||
|
||||
/* Attempt to read a tuple, but don't block if none is available. */
|
||||
Assert(gatherstate->nextreader < gatherstate->nreaders);
|
||||
reader = gatherstate->reader[gatherstate->nextreader];
|
||||
tup = TupleQueueReaderNext(reader, true, &readerdone);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue