static void _Function_finalize(PgObject func) { Function self = (Function)func; JNI_deleteGlobalRef(self->clazz); if(!self->isUDT) { if(self->func.nonudt.typeMap != 0) JNI_deleteGlobalRef(self->func.nonudt.typeMap); if(self->func.nonudt.paramTypes != 0) pfree(self->func.nonudt.paramTypes); } }
void Invocation_popInvocation(bool wasException) { CallLocal* cl; Invocation* ctx = currentInvocation->previous; if(currentInvocation->invocation != 0) { if(!wasException) JNI_callVoidMethod(currentInvocation->invocation, s_Invocation_onExit); JNI_deleteGlobalRef(currentInvocation->invocation); } /* * Check for any DualState objects that became unreachable and can be freed. */ pljava_DualState_cleanEnqueuedInstances(); if(currentInvocation->hasConnected) SPI_finish(); JNI_popLocalFrame(0); if(ctx != 0) { PG_TRY(); { Backend_setJavaSecurity(ctx->trusted); } PG_CATCH(); { elog(FATAL, "Failed to reinstate untrusted security after a trusted call or vice versa"); } PG_END_TRY(); MemoryContextSwitchTo(ctx->upperContext); } /** * Reset all local wrappers that has been allocated during this call. Yank them * from the double linked list but do *not* remove them. */ cl = currentInvocation->callLocals; if(cl != 0) { CallLocal* first = cl; do { cl->pointer = 0; cl->invocation = 0; cl = cl->next; } while(cl != first); } currentInvocation = ctx; --s_callLevel; }
static void _closeIteration(CallContextData* ctxData) { currentInvocation->hasConnected = ctxData->hasConnected; currentInvocation->invocation = ctxData->invocation; Type_closeSRF(ctxData->elemType, ctxData->rowProducer); JNI_deleteGlobalRef(ctxData->rowProducer); if(ctxData->rowCollector != 0) JNI_deleteGlobalRef(ctxData->rowCollector); MemoryContextDelete(ctxData->rowContext); if(ctxData->hasConnected && ctxData->spiContext != 0) { /* Connect during SRF_IS_FIRSTCALL(). Switch context back to what * it was at that time and disconnect. */ MemoryContext currCtx = MemoryContextSwitchTo(ctxData->spiContext); Invocation_assertDisconnect(); MemoryContextSwitchTo(currCtx); } }