* Call all the shutdown callbacks registered in an ExprContext. * * The callback list is emptied (important in case this is only a rescan * reset, and not deletion of the ExprContext). * * If isCommit is false, just clean the callback list but don't call 'em. * (See comment for FreeExprContext.) */
| 1037 | * (See comment for FreeExprContext.) |
| 1038 | */ |
| 1039 | static void |
| 1040 | ShutdownExprContext(ExprContext *econtext, bool isCommit) |
| 1041 | { |
| 1042 | ExprContext_CB *ecxt_callback; |
| 1043 | MemoryContext oldcontext; |
| 1044 | |
| 1045 | /* Fast path in normal case where there's nothing to do. */ |
| 1046 | if (econtext->ecxt_callbacks == NULL) |
| 1047 | return; |
| 1048 | |
| 1049 | /* |
| 1050 | * Call the callbacks in econtext's per-tuple context. This ensures that |
| 1051 | * any memory they might leak will get cleaned up. |
| 1052 | */ |
| 1053 | oldcontext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory); |
| 1054 | |
| 1055 | /* |
| 1056 | * Call each callback function in reverse registration order. |
| 1057 | */ |
| 1058 | while ((ecxt_callback = econtext->ecxt_callbacks) != NULL) |
| 1059 | { |
| 1060 | econtext->ecxt_callbacks = ecxt_callback->next; |
| 1061 | if (isCommit) |
| 1062 | ecxt_callback->function(ecxt_callback->arg); |
| 1063 | pfree(ecxt_callback); |
| 1064 | } |
| 1065 | |
| 1066 | MemoryContextSwitchTo(oldcontext); |
| 1067 | } |
| 1068 | |
| 1069 | /* |
| 1070 | * GetAttributeByName |
no test coverage detected