MCPcopy Create free account
hub / github.com/apache/cloudberry / postgresForeignAsyncNotify

Function postgresForeignAsyncNotify

contrib/postgres_fdw/postgres_fdw.c:7044–7077  ·  view source on GitHub ↗

* postgresForeignAsyncNotify * Fetch some more tuples from a file descriptor that becomes ready, * requesting next tuple. */

Source from the content-addressed store, hash-verified

7042 * requesting next tuple.
7043 */
7044static void
7045postgresForeignAsyncNotify(AsyncRequest *areq)
7046{
7047 ForeignScanState *node = (ForeignScanState *) areq->requestee;
7048 PgFdwScanState *fsstate = (PgFdwScanState *) node->fdw_state;
7049
7050 /* The core code would have initialized the callback_pending flag */
7051 Assert(!areq->callback_pending);
7052
7053 /*
7054 * If process_pending_request() has been invoked on the given request
7055 * before we get here, we might have some tuples already; in which case
7056 * produce the next tuple
7057 */
7058 if (fsstate->next_tuple < fsstate->num_tuples)
7059 {
7060 produce_tuple_asynchronously(areq, true);
7061 return;
7062 }
7063
7064 /* We must have run out of tuples */
7065 Assert(fsstate->next_tuple >= fsstate->num_tuples);
7066
7067 /* The request should be currently in-process */
7068 Assert(fsstate->conn_state->pendingAreq == areq);
7069
7070 /* On error, report the original query, not the FETCH. */
7071 if (!PQconsumeInput(fsstate->conn))
7072 pgfdw_report_error(ERROR, NULL, fsstate->conn, false, fsstate->query);
7073
7074 fetch_more_data(node);
7075
7076 produce_tuple_asynchronously(areq, true);
7077}
7078
7079/*
7080 * Asynchronously produce next tuple from a foreign PostgreSQL table.

Callers

nothing calls this directly

Calls 4

PQconsumeInputFunction · 0.85
pgfdw_report_errorFunction · 0.85
fetch_more_dataFunction · 0.85

Tested by

no test coverage detected