Commit 5d3f7c57 authored by Tom Lane's avatar Tom Lane

Remove dead code in nodeGatherMerge.c.

Coverity noted that the last line of gather_merge_getnext() was
unreachable, since each arm of the preceding "if" ends in a "return".
Drop it as an oversight.  In passing, improve some nearby comments.
parent ce38949b
...@@ -423,8 +423,8 @@ reread: ...@@ -423,8 +423,8 @@ reread:
} }
/* /*
* Clear out a slot in the tuple table for each gather merge * Clear out the tuple table slots for each gather merge input,
* slot and return the clear cleared slot. * and return a cleared slot.
*/ */
static TupleTableSlot * static TupleTableSlot *
gather_merge_clear_slots(GatherMergeState *gm_state) gather_merge_clear_slots(GatherMergeState *gm_state)
...@@ -456,19 +456,21 @@ gather_merge_getnext(GatherMergeState *gm_state) ...@@ -456,19 +456,21 @@ gather_merge_getnext(GatherMergeState *gm_state)
{ {
int i; int i;
/* if (!gm_state->gm_initialized)
* First time through: pull the first tuple from each participate, and set {
* up the heap. /*
*/ * First time through: pull the first tuple from each participant, and
if (gm_state->gm_initialized == false) * set up the heap.
*/
gather_merge_init(gm_state); gather_merge_init(gm_state);
}
else else
{ {
/* /*
* Otherwise, pull the next tuple from whichever participant we * Otherwise, pull the next tuple from whichever participant we
* returned from last time, and reinsert the index into the heap, * returned from last time, and reinsert that participant's index into
* because it might now compare differently against the existing * the heap, because it might now compare differently against the
* elements of the heap. * other elements of the heap.
*/ */
i = DatumGetInt32(binaryheap_first(gm_state->gm_heap)); i = DatumGetInt32(binaryheap_first(gm_state->gm_heap));
...@@ -485,11 +487,10 @@ gather_merge_getnext(GatherMergeState *gm_state) ...@@ -485,11 +487,10 @@ gather_merge_getnext(GatherMergeState *gm_state)
} }
else else
{ {
/* Return next tuple from whichever participant has the leading one */
i = DatumGetInt32(binaryheap_first(gm_state->gm_heap)); i = DatumGetInt32(binaryheap_first(gm_state->gm_heap));
return gm_state->gm_slots[i]; return gm_state->gm_slots[i];
} }
return gather_merge_clear_slots(gm_state);
} }
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment