diff --git a/doc/src/sgml/custom-scan.sgml b/doc/src/sgml/custom-scan.sgml index 93d96f2f56..2ad5c22efa 100644 --- a/doc/src/sgml/custom-scan.sgml +++ b/doc/src/sgml/custom-scan.sgml @@ -76,9 +76,10 @@ typedef struct CustomPath capabilities. flags should include CUSTOMPATH_SUPPORT_BACKWARD_SCAN if the custom path can support a backward scan, CUSTOMPATH_SUPPORT_MARK_RESTORE if it - can support mark and restore, - and CUSTOMPATH_SUPPORT_PROJECTION if it can perform - projections. (If CUSTOMPATH_SUPPORT_PROJECTION is not + can support mark and restore, CUSTOMPATH_SUPPORT_PROJECTION if it + can perform projections and CUSTOMPATH_SUPPORT_ASYNC_EXECUTION + if it can support asynchronous execution. + (If CUSTOMPATH_SUPPORT_PROJECTION is not set, the scan node will only be asked to produce Vars of the scanned relation; while if that flag is set, the scan node must be able to evaluate scalar expressions over these Vars.) @@ -385,6 +386,61 @@ void (*ExplainCustomScan) (CustomScanState *node, be shown even without this callback, but the callback allows the display of additional, private state. + + + +void (*AsyncCustomScanRequest) (AsyncRequest *areq); + + Produce one tuple asynchronously from the custom-scan plan node. + areq is + the AsyncRequest struct describing the + custom-scan node and the parent + Append node that requested the tuple from it. + This function should store the tuple into the slot specified by + areq->result, and set + areq->request_complete to true; + or if it needs to wait on an event external to the core server such as + network I/O, and cannot produce any tuple immediately, set the flag to + false, and set + areq->callback_pending to true + for the custom-scan node to get a callback from + the callback functions described below. If no more tuples are available, + set the slot to NULL or an empty slot, and the + areq->request_complete flag to + true. It's recommended to use + ExecAsyncRequestDone or + ExecAsyncRequestPending to set the output parameters + in the areq. + + + + +void (*AsyncCustomScanConfigureWait) (AsyncRequest *areq); + + Configure a file descriptor event for which the + custom-scan node wishes to wait. + This function will only be called when the + custom-scan node has the + areq->callback_pending flag set, and should add + the event to the as_eventset of the parent + Append node described by the + areq. See the comments for + ExecAsyncConfigureWait in + src/backend/executor/execAsync.c for additional + information. When the file descriptor event occurs, + AsyncCustomScanNotify will be called. + + + + +void (*AsyncCustomScanNotify) (AsyncRequest *areq); + + Process a relevant event that has occurred, then produce one tuple + asynchronously from the custom-scan node. + This function should set the output parameters in the + areq in the same way as + AsyncCustomScanRequest. +