From 230d34ce9bc9a570a1155475dc03db693b5fc612 Mon Sep 17 00:00:00 2001 From: obdev Date: Fri, 30 Dec 2022 04:11:58 +0000 Subject: [PATCH] [CP]not allow begin/start transaction statement in xa trans for bug 46947616 --- src/sql/ob_result_set.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/sql/ob_result_set.cpp b/src/sql/ob_result_set.cpp index 57ae4d15d3..17b0f5baff 100644 --- a/src/sql/ob_result_set.cpp +++ b/src/sql/ob_result_set.cpp @@ -238,9 +238,17 @@ int ObResultSet::on_cmd_execute() ret = OB_ERR_UNEXPECTED; LOG_ERROR("invalid inner state", K(cmd_)); } else if (cmd_->cause_implicit_commit()) { - // 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)); + // not allow implicit commit in xa trans + if (my_session_.associated_xa()) { + ret = OB_TRANS_XA_ERR_COMMIT; + get_exec_context().set_need_disconnect(false); + const transaction::ObTxDesc *tx_desc = my_session_.get_tx_desc(); + LOG_WARN("COMMIT is not allowed in a xa trans", K(ret), KPC(tx_desc)); + } 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)); + } } } return ret;