* postgresIterateForeignScan * Retrieve next row from the result set, or clear tuple slot to indicate * EOF. */
| 1596 | * EOF. |
| 1597 | */ |
| 1598 | static TupleTableSlot * |
| 1599 | postgresIterateForeignScan(ForeignScanState *node) |
| 1600 | { |
| 1601 | PgFdwScanState *fsstate = (PgFdwScanState *) node->fdw_state; |
| 1602 | TupleTableSlot *slot = node->ss.ss_ScanTupleSlot; |
| 1603 | |
| 1604 | /* |
| 1605 | * In sync mode, if this is the first call after Begin or ReScan, we need |
| 1606 | * to create the cursor on the remote side. In async mode, we would have |
| 1607 | * already created the cursor before we get here, even if this is the |
| 1608 | * first call after Begin or ReScan. |
| 1609 | */ |
| 1610 | if (!fsstate->cursor_exists) |
| 1611 | create_cursor(node); |
| 1612 | |
| 1613 | /* |
| 1614 | * Get some more tuples, if we've run out. |
| 1615 | */ |
| 1616 | if (fsstate->next_tuple >= fsstate->num_tuples) |
| 1617 | { |
| 1618 | /* In async mode, just clear tuple slot. */ |
| 1619 | if (fsstate->async_capable) |
| 1620 | return ExecClearTuple(slot); |
| 1621 | /* No point in another fetch if we already detected EOF, though. */ |
| 1622 | if (!fsstate->eof_reached) |
| 1623 | fetch_more_data(node); |
| 1624 | /* If we didn't get any tuples, must be end of data. */ |
| 1625 | if (fsstate->next_tuple >= fsstate->num_tuples) |
| 1626 | return ExecClearTuple(slot); |
| 1627 | } |
| 1628 | |
| 1629 | /* |
| 1630 | * Return the next tuple. |
| 1631 | */ |
| 1632 | ExecStoreHeapTuple(fsstate->tuples[fsstate->next_tuple++], |
| 1633 | slot, |
| 1634 | false); |
| 1635 | |
| 1636 | return slot; |
| 1637 | } |
| 1638 | |
| 1639 | /* |
| 1640 | * postgresReScanForeignScan |
nothing calls this directly
no test coverage detected