Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5d3f7c5

Browse files
committed
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.
1 parent ce38949 commit 5d3f7c5

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/backend/executor/nodeGatherMerge.c

+13-12
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,8 @@ gather_merge_init(GatherMergeState *gm_state)
423423
}
424424

425425
/*
426-
* Clear out a slot in the tuple table for each gather merge
427-
* slot and return the clear cleared slot.
426+
* Clear out the tuple table slots for each gather merge input,
427+
* and return a cleared slot.
428428
*/
429429
static TupleTableSlot *
430430
gather_merge_clear_slots(GatherMergeState *gm_state)
@@ -456,19 +456,21 @@ gather_merge_getnext(GatherMergeState *gm_state)
456456
{
457457
int i;
458458

459-
/*
460-
* First time through: pull the first tuple from each participate, and set
461-
* up the heap.
462-
*/
463-
if (gm_state->gm_initialized == false)
459+
if (!gm_state->gm_initialized)
460+
{
461+
/*
462+
* First time through: pull the first tuple from each participant, and
463+
* set up the heap.
464+
*/
464465
gather_merge_init(gm_state);
466+
}
465467
else
466468
{
467469
/*
468470
* Otherwise, pull the next tuple from whichever participant we
469-
* returned from last time, and reinsert the index into the heap,
470-
* because it might now compare differently against the existing
471-
* elements of the heap.
471+
* returned from last time, and reinsert that participant's index into
472+
* the heap, because it might now compare differently against the
473+
* other elements of the heap.
472474
*/
473475
i = DatumGetInt32(binaryheap_first(gm_state->gm_heap));
474476

@@ -485,11 +487,10 @@ gather_merge_getnext(GatherMergeState *gm_state)
485487
}
486488
else
487489
{
490+
/* Return next tuple from whichever participant has the leading one */
488491
i = DatumGetInt32(binaryheap_first(gm_state->gm_heap));
489492
return gm_state->gm_slots[i];
490493
}
491-
492-
return gather_merge_clear_slots(gm_state);
493494
}
494495

495496
/*

0 commit comments

Comments
 (0)