Skip to content

Commit 0a8b9d3

Browse files
committed
Remove no-longer-needed loop in ExecGather().
Coverity complained quite properly that commit ea15e18 had introduced unreachable code into ExecGather(); to wit, it was no longer possible to iterate the final for-loop more or less than once. So remove the for(). In passing, clean up a couple of comments, and make better use of a local variable.
1 parent 8f164e1 commit 0a8b9d3

File tree

1 file changed

+15
-24
lines changed

1 file changed

+15
-24
lines changed

src/backend/executor/nodeGather.c

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ ExecGather(GatherState *node)
135135
/*
136136
* Initialize the parallel context and workers on first execution. We do
137137
* this on first execution rather than during node initialization, as it
138-
* needs to allocate large dynamic segment, so it is better to do if it is
139-
* really needed.
138+
* needs to allocate a large dynamic segment, so it is better to do it
139+
* only if it is really needed.
140140
*/
141141
if (!node->initialized)
142142
{
@@ -201,32 +201,23 @@ ExecGather(GatherState *node)
201201
* any previous tuple returned by a TupleQueueReader; to make sure we
202202
* don't leave a dangling pointer around, clear the working slot first.
203203
*/
204-
ExecClearTuple(node->funnel_slot);
204+
ExecClearTuple(fslot);
205205
econtext = node->ps.ps_ExprContext;
206206
ResetExprContext(econtext);
207207

208-
/* Get and return the next tuple, projecting if necessary. */
209-
for (;;)
210-
{
211-
/*
212-
* Get next tuple, either from one of our workers, or by running the
213-
* plan ourselves.
214-
*/
215-
slot = gather_getnext(node);
216-
if (TupIsNull(slot))
217-
return NULL;
218-
219-
/*
220-
* form the result tuple using ExecProject(), and return it --- unless
221-
* the projection produces an empty set, in which case we must loop
222-
* back around for another tuple
223-
*/
224-
econtext->ecxt_outertuple = slot;
225-
226-
return ExecProject(node->ps.ps_ProjInfo);
227-
}
208+
/*
209+
* Get next tuple, either from one of our workers, or by running the plan
210+
* ourselves.
211+
*/
212+
slot = gather_getnext(node);
213+
if (TupIsNull(slot))
214+
return NULL;
228215

229-
return slot;
216+
/*
217+
* Form the result tuple using ExecProject(), and return it.
218+
*/
219+
econtext->ecxt_outertuple = slot;
220+
return ExecProject(node->ps.ps_ProjInfo);
230221
}
231222

232223
/* ----------------------------------------------------------------

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy