* Register a shutdown callback in an ExprContext. * * Shutdown callbacks will be called (in reverse order of registration) * when the ExprContext is deleted or rescanned. This provides a hook * for functions called in the context to do any cleanup needed --- it's * particularly useful for functions returning sets. Note that the * callback will *not* be called in the event that execution is
| 980 | * by an error. |
| 981 | */ |
| 982 | void |
| 983 | RegisterExprContextCallback(ExprContext *econtext, |
| 984 | ExprContextCallbackFunction function, |
| 985 | Datum arg) |
| 986 | { |
| 987 | ExprContext_CB *ecxt_callback; |
| 988 | |
| 989 | /* Save the info in appropriate memory context */ |
| 990 | ecxt_callback = (ExprContext_CB *) |
| 991 | MemoryContextAlloc(econtext->ecxt_per_query_memory, |
| 992 | sizeof(ExprContext_CB)); |
| 993 | |
| 994 | ecxt_callback->function = function; |
| 995 | ecxt_callback->arg = arg; |
| 996 | |
| 997 | /* link to front of list for appropriate execution order */ |
| 998 | ecxt_callback->next = econtext->ecxt_callbacks; |
| 999 | econtext->ecxt_callbacks = ecxt_callback; |
| 1000 | } |
| 1001 | |
| 1002 | /* |
| 1003 | * Deregister a shutdown callback in an ExprContext. |
no test coverage detected