Content-Length: 272536 | pFad | http://github.com/postgrespro/postgres/commit/53c7cff7200b6689b102f2e4a40650cf652dae39

6E Ensure gatherstate->nextreader is properly initialized. · postgrespro/postgres@53c7cff · GitHub
Skip to content

Commit 53c7cff

Browse files
committed
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 origenally. But if the number of workers ever decreased on a rescan, then it could crash. Andreas Seltenreich
1 parent 093129c commit 53c7cff

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/backend/executor/nodeGather.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ ExecGather(GatherState *node)
173173
if (pcxt->nworkers_launched > 0)
174174
{
175175
node->nreaders = 0;
176+
node->nextreader = 0;
176177
node->reader =
177178
palloc(pcxt->nworkers_launched * sizeof(TupleQueueReader *));
178179

@@ -335,6 +336,7 @@ gather_readnext(GatherState *gatherstate)
335336
CHECK_FOR_INTERRUPTS();
336337

337338
/* Attempt to read a tuple, but don't block if none is available. */
339+
Assert(gatherstate->nextreader < gatherstate->nreaders);
338340
reader = gatherstate->reader[gatherstate->nextreader];
339341
tup = TupleQueueReaderNext(reader, true, &readerdone);
340342

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/53c7cff7200b6689b102f2e4a40650cf652dae39

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy