fix set transaction characters

This commit is contained in:
chinaxing
2023-10-12 08:40:05 +00:00
committed by ob-robot
parent 729ab79348
commit 989a8f3547
9 changed files with 74 additions and 36 deletions

View File

@ -277,9 +277,16 @@ int ObResultSet::on_cmd_execute()
}
get_exec_context().set_need_disconnect(false);
} else {
// commit current open transaction, synchronously
if (OB_FAIL(ObSqlTransControl::implicit_end_trans(get_exec_context(), false))) {
SQL_ENG_LOG(WARN, "fail end implicit trans on cmd execute", K(ret));
// implicit end transaction and start transaction will not clear next scope transaction settings by:
// a. set by `set transaction read only`
// b. set by `set transaction isolation level XXX`
const int cmd_type = cmd_->get_cmd_type();
bool keep_trans_variable = (cmd_type == stmt::T_START_TRANS);
if (OB_FAIL(ObSqlTransControl::implicit_end_trans(get_exec_context(), false, NULL, !keep_trans_variable))) {
LOG_WARN("fail end implicit trans on cmd execute", K(ret));
} else if (my_session_.need_recheck_txn_readonly() && my_session_.get_tx_read_only()) {
ret = OB_ERR_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION;
LOG_WARN("cmd can not execute because txn is read only", K(ret), K(cmd_type));
}
}
}
@ -967,7 +974,7 @@ OB_INLINE int ObResultSet::auto_end_plan_trans(ObPhysicalPlan& plan,
K(in_trans), K(ac), K(explicit_trans),
K(is_async_end_trans_submitted()));
// explicit start trans will disable auto-commit
if (!explicit_trans && ac) {
if (!explicit_trans && ac && plan.is_need_trans()) {
ObPhysicalPlanCtx *plan_ctx = NULL;
if (OB_ISNULL(plan_ctx = get_exec_context().get_physical_plan_ctx())) {
ret = OB_ERR_UNEXPECTED;
@ -1027,7 +1034,7 @@ OB_INLINE int ObResultSet::auto_end_plan_trans(ObPhysicalPlan& plan,
}
NG_TRACE(auto_end_plan_end);
LOG_TRACE("auto_end_plan_trans.end", K(ret),
K(in_trans), K(ac), K(explicit_trans),
K(in_trans), K(ac), K(explicit_trans), K(plan.is_need_trans()),
K(is_rollback), K(async),
K(is_async_end_trans_submitted()));
return ret;