* Begin an asynchronous data fetch. * * Note: this function assumes there is no currently-in-progress asynchronous * data fetch. * * Note: fetch_more_data must be called to fetch the result. */
| 7151 | * Note: fetch_more_data must be called to fetch the result. |
| 7152 | */ |
| 7153 | static void |
| 7154 | fetch_more_data_begin(AsyncRequest *areq) |
| 7155 | { |
| 7156 | ForeignScanState *node = (ForeignScanState *) areq->requestee; |
| 7157 | PgFdwScanState *fsstate = (PgFdwScanState *) node->fdw_state; |
| 7158 | char sql[64]; |
| 7159 | |
| 7160 | Assert(!fsstate->conn_state->pendingAreq); |
| 7161 | |
| 7162 | /* Create the cursor synchronously. */ |
| 7163 | if (!fsstate->cursor_exists) |
| 7164 | create_cursor(node); |
| 7165 | |
| 7166 | /* We will send this query, but not wait for the response. */ |
| 7167 | snprintf(sql, sizeof(sql), "FETCH %d FROM c%u", |
| 7168 | fsstate->fetch_size, fsstate->cursor_number); |
| 7169 | |
| 7170 | if (PQsendQuery(fsstate->conn, sql) < 0) |
| 7171 | pgfdw_report_error(ERROR, NULL, fsstate->conn, false, fsstate->query); |
| 7172 | |
| 7173 | /* Remember that the request is in process */ |
| 7174 | fsstate->conn_state->pendingAreq = areq; |
| 7175 | } |
| 7176 | |
| 7177 | /* |
| 7178 | * Process a pending asynchronous request. |
no test coverage detected