* Fetch a tuple from either the outer plan (for phase 1) or from the sorter * populated by the previous phase. Copy it to the sorter for the next phase * if any. * * Callers cannot rely on memory for tuple in returned slot remaining valid * past any subsequently fetched tuple. */
| 581 | * past any subsequently fetched tuple. |
| 582 | */ |
| 583 | static TupleTableSlot * |
| 584 | fetch_input_tuple(AggState *aggstate) |
| 585 | { |
| 586 | TupleTableSlot *slot; |
| 587 | |
| 588 | if (aggstate->sort_in) |
| 589 | { |
| 590 | /* make sure we check for interrupts in either path through here */ |
| 591 | CHECK_FOR_INTERRUPTS(); |
| 592 | if (!tuplesort_gettupleslot(aggstate->sort_in, true, false, |
| 593 | aggstate->sort_slot, NULL)) |
| 594 | return NULL; |
| 595 | slot = aggstate->sort_slot; |
| 596 | } |
| 597 | else |
| 598 | slot = ExecProcNode(outerPlanState(aggstate)); |
| 599 | |
| 600 | if (!TupIsNull(slot) && aggstate->sort_out) |
| 601 | tuplesort_puttupleslot(aggstate->sort_out, slot); |
| 602 | |
| 603 | return slot; |
| 604 | } |
| 605 | |
| 606 | /* |
| 607 | * (Re)Initialize an individual aggregate. |
no test coverage detected