* postgresForeignAsyncConfigureWait * Configure a file descriptor event for which we wish to wait. */
| 6967 | * Configure a file descriptor event for which we wish to wait. |
| 6968 | */ |
| 6969 | static void |
| 6970 | postgresForeignAsyncConfigureWait(AsyncRequest *areq) |
| 6971 | { |
| 6972 | ForeignScanState *node = (ForeignScanState *) areq->requestee; |
| 6973 | PgFdwScanState *fsstate = (PgFdwScanState *) node->fdw_state; |
| 6974 | AsyncRequest *pendingAreq = fsstate->conn_state->pendingAreq; |
| 6975 | AppendState *requestor = (AppendState *) areq->requestor; |
| 6976 | WaitEventSet *set = requestor->as_eventset; |
| 6977 | |
| 6978 | /* This should not be called unless callback_pending */ |
| 6979 | Assert(areq->callback_pending); |
| 6980 | |
| 6981 | /* |
| 6982 | * If process_pending_request() has been invoked on the given request |
| 6983 | * before we get here, we might have some tuples already; in which case |
| 6984 | * complete the request |
| 6985 | */ |
| 6986 | if (fsstate->next_tuple < fsstate->num_tuples) |
| 6987 | { |
| 6988 | complete_pending_request(areq); |
| 6989 | if (areq->request_complete) |
| 6990 | return; |
| 6991 | Assert(areq->callback_pending); |
| 6992 | } |
| 6993 | |
| 6994 | /* We must have run out of tuples */ |
| 6995 | Assert(fsstate->next_tuple >= fsstate->num_tuples); |
| 6996 | |
| 6997 | /* The core code would have registered postmaster death event */ |
| 6998 | Assert(GetNumRegisteredWaitEvents(set) >= 1); |
| 6999 | |
| 7000 | /* Begin an asynchronous data fetch if not already done */ |
| 7001 | if (!pendingAreq) |
| 7002 | fetch_more_data_begin(areq); |
| 7003 | else if (pendingAreq->requestor != areq->requestor) |
| 7004 | { |
| 7005 | /* |
| 7006 | * This is the case when the in-process request was made by another |
| 7007 | * Append. Note that it might be useless to process the request, |
| 7008 | * because the query might not need tuples from that Append anymore. |
| 7009 | * If there are any child subplans of the same parent that are ready |
| 7010 | * for new requests, skip the given request. Likewise, if there are |
| 7011 | * any configured events other than the postmaster death event, skip |
| 7012 | * it. Otherwise, process the in-process request, then begin a fetch |
| 7013 | * to configure the event below, because we might otherwise end up |
| 7014 | * with no configured events other than the postmaster death event. |
| 7015 | */ |
| 7016 | if (!bms_is_empty(requestor->as_needrequest)) |
| 7017 | return; |
| 7018 | if (GetNumRegisteredWaitEvents(set) > 1) |
| 7019 | return; |
| 7020 | process_pending_request(pendingAreq); |
| 7021 | fetch_more_data_begin(areq); |
| 7022 | } |
| 7023 | else if (pendingAreq->requestee != areq->requestee) |
| 7024 | { |
| 7025 | /* |
| 7026 | * This is the case when the in-process request was made by the same |
nothing calls this directly
no test coverage detected