aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeGather.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2017-01-22 11:47:38 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2017-01-22 11:47:38 -0500
commit0a8b9d3b2c57028f7100078cd711370f396d5a81 (patch)
tree60e9c4451704a45716f47ea5757339ef252f1fe9 /src/backend/executor/nodeGather.c
parent8f164e1eeaf31438f6706ed45efee607a2c7a21b (diff)
downloadpostgresql-0a8b9d3b2c57028f7100078cd711370f396d5a81.tar.gz
postgresql-0a8b9d3b2c57028f7100078cd711370f396d5a81.zip
Remove no-longer-needed loop in ExecGather().
Coverity complained quite properly that commit ea15e1867 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.
Diffstat (limited to 'src/backend/executor/nodeGather.c')
-rw-r--r--src/backend/executor/nodeGather.c39
1 files changed, 15 insertions, 24 deletions
diff --git a/src/backend/executor/nodeGather.c b/src/backend/executor/nodeGather.c
index 45aa1132d92..a1a3561d48c 100644
--- a/src/backend/executor/nodeGather.c
+++ b/src/backend/executor/nodeGather.c
@@ -135,8 +135,8 @@ ExecGather(GatherState *node)
/*
* Initialize the parallel context and workers on first execution. We do
* this on first execution rather than during node initialization, as it
- * needs to allocate large dynamic segment, so it is better to do if it is
- * really needed.
+ * needs to allocate a large dynamic segment, so it is better to do it
+ * only if it is really needed.
*/
if (!node->initialized)
{
@@ -201,32 +201,23 @@ ExecGather(GatherState *node)
* any previous tuple returned by a TupleQueueReader; to make sure we
* don't leave a dangling pointer around, clear the working slot first.
*/
- ExecClearTuple(node->funnel_slot);
+ ExecClearTuple(fslot);
econtext = node->ps.ps_ExprContext;
ResetExprContext(econtext);
- /* Get and return the next tuple, projecting if necessary. */
- for (;;)
- {
- /*
- * Get next tuple, either from one of our workers, or by running the
- * plan ourselves.
- */
- slot = gather_getnext(node);
- if (TupIsNull(slot))
- return NULL;
-
- /*
- * form the result tuple using ExecProject(), and return it --- unless
- * the projection produces an empty set, in which case we must loop
- * back around for another tuple
- */
- econtext->ecxt_outertuple = slot;
-
- return ExecProject(node->ps.ps_ProjInfo);
- }
+ /*
+ * Get next tuple, either from one of our workers, or by running the plan
+ * ourselves.
+ */
+ slot = gather_getnext(node);
+ if (TupIsNull(slot))
+ return NULL;
- return slot;
+ /*
+ * Form the result tuple using ExecProject(), and return it.
+ */
+ econtext->ecxt_outertuple = slot;
+ return ExecProject(node->ps.ps_ProjInfo);
}
/* ----------------------------------------------------------------