!3049 修复JDBC setMaxRows查询完成后不会自动提交事务的bug

Merge pull request !3049 from Cross-罗/fix_jdbc
This commit is contained in:
opengauss-bot
2023-03-08 14:09:37 +00:00
committed by Gitee
3 changed files with 13 additions and 3 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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();