diff --git a/src/gausskernel/process/tcop/postgres.cpp b/src/gausskernel/process/tcop/postgres.cpp index e3cff8ef0..8ce3c992c 100755 --- a/src/gausskernel/process/tcop/postgres.cpp +++ b/src/gausskernel/process/tcop/postgres.cpp @@ -5308,6 +5308,11 @@ static void exec_execute_message(const char* portal_name, long max_rows) pq_putemptymessage('s'); u_sess->xact_cxt.pbe_execute_complete = false; + /* when only set maxrows, we don't need to set pbe_execute_complete flag. */ + if ((portal_name == NULL || portal_name[0] == '\0') && + max_rows != FETCH_ALL && IsConnFromApp()) { + u_sess->xact_cxt.pbe_execute_complete = true; + } #ifndef ENABLE_MULTIPLE_NODES /* reset stream info for session */ if (u_sess->stream_cxt.global_obj != NULL) { diff --git a/src/gausskernel/runtime/opfusion/opfusion.cpp b/src/gausskernel/runtime/opfusion/opfusion.cpp index f4d4e6c65..20a926b30 100644 --- a/src/gausskernel/runtime/opfusion/opfusion.cpp +++ b/src/gausskernel/runtime/opfusion/opfusion.cpp @@ -379,7 +379,7 @@ void OpFusion::auditRecord() } } -bool OpFusion::executeEnd(const char *portal_name, bool *isQueryCompleted) +bool OpFusion::executeEnd(const char *portal_name, bool *isQueryCompleted, long max_rows) { opfusion_executeEnd(m_global->m_planstmt, ((m_global->m_psrc == NULL) ? NULL : (m_global->m_psrc->query_string)), GetActiveSnapshot()); @@ -424,6 +424,11 @@ bool OpFusion::executeEnd(const char *portal_name, bool *isQueryCompleted) if (isQueryCompleted) *isQueryCompleted = false; u_sess->xact_cxt.pbe_execute_complete = false; + /* when only set maxrows, we don't need to set pbe_execute_complete flag. */ + if ((portal_name == NULL || portal_name[0] == '\0') && + max_rows != FETCH_ALL && IsConnFromApp()) { + u_sess->xact_cxt.pbe_execute_complete = true; + } if (ENABLE_GPC) Assert(locateFusion(m_local.m_portalName) != NULL); } @@ -492,7 +497,7 @@ void OpFusion::fusionExecute(StringInfo msg, char *completionTag, bool isTopLeve #endif u_sess->exec_cxt.need_track_resource = old_status; gstrace_exit(GS_TRC_ID_BypassExecutor); - completed = u_sess->exec_cxt.CurrentOpFusionObj->executeEnd(portal_name, isQueryCompleted); + completed = u_sess->exec_cxt.CurrentOpFusionObj->executeEnd(portal_name, isQueryCompleted, max_rows); if (completed && u_sess->exec_cxt.CurrentOpFusionObj->IsGlobal()) { Assert(ENABLE_GPC); tearDown(u_sess->exec_cxt.CurrentOpFusionObj); diff --git a/src/include/opfusion/opfusion.h b/src/include/opfusion/opfusion.h index bf2e2ac76..1a3628fab 100644 --- a/src/include/opfusion/opfusion.h +++ b/src/include/opfusion/opfusion.h @@ -125,7 +125,7 @@ public: void executeInit(); - bool executeEnd(const char* portal_name, bool* completionTag); + bool executeEnd(const char* portal_name, bool* completionTag, long max_rows); void auditRecord();