diff --git a/src/gausskernel/runtime/codegen/gscodegen.cpp b/src/gausskernel/runtime/codegen/gscodegen.cpp index ae515cfeb..d69cbfb6f 100644 --- a/src/gausskernel/runtime/codegen/gscodegen.cpp +++ b/src/gausskernel/runtime/codegen/gscodegen.cpp @@ -1036,7 +1036,8 @@ void CodeGenThreadInitialize() bool CodeGenThreadObjectReady() { - return t_thrd.codegen_cxt.thr_codegen_obj != NULL && !t_thrd.codegen_cxt.g_runningInFmgr; + return t_thrd.codegen_cxt.thr_codegen_obj != NULL && !t_thrd.codegen_cxt.g_runningInFmgr + && !((dorado::GsCodeGen*)t_thrd.codegen_cxt.thr_codegen_obj)->IsCompiled(); } /** diff --git a/src/gausskernel/runtime/executor/execMain.cpp b/src/gausskernel/runtime/executor/execMain.cpp index 5440a4c3e..dc311abb8 100755 --- a/src/gausskernel/runtime/executor/execMain.cpp +++ b/src/gausskernel/runtime/executor/execMain.cpp @@ -787,7 +787,8 @@ void standard_ExecutorEnd(QueryDesc *queryDesc) UnregisterSnapshot(estate->es_crosscheck_snapshot); #ifdef ENABLE_LLVM_COMPILE - if (!t_thrd.codegen_cxt.g_runningInFmgr) { + /* Do not release codegen in Fmgr and Procedure */ + if (!t_thrd.codegen_cxt.g_runningInFmgr && u_sess->SPI_cxt._connected == -1) { CodeGenThreadTearDown(); } #endif @@ -3826,4 +3827,4 @@ TupleTableSlot* FetchPlanSlot(PlanState* subPlanState, ProjectionInfo** projInfo } else { return ExecProcNode(subPlanState); } -} \ No newline at end of file +} diff --git a/src/include/codegen/gscodegen.h b/src/include/codegen/gscodegen.h index d26efb5ac..1684c5857 100644 --- a/src/include/codegen/gscodegen.h +++ b/src/include/codegen/gscodegen.h @@ -539,6 +539,14 @@ public: m_currentModule = NULL; } + /* + * @Description : Get m_moduleCompiled. + */ + inline bool IsCompiled() + { + return m_moduleCompiled; + } + /* * @Description : IR compile to machine code. */