From ec404798ef1afa01af1f49686782189fd1fb4004 Mon Sep 17 00:00:00 2001 From: seuwebber Date: Tue, 7 Nov 2023 16:42:49 +0000 Subject: [PATCH] [to #53026031]fix mysqlTest dbms sql in trigger --- src/pl/sys_package/ob_dbms_sql.cpp | 2 +- src/sql/ob_spi.cpp | 9 ++++++--- src/sql/ob_spi.h | 6 ++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/pl/sys_package/ob_dbms_sql.cpp b/src/pl/sys_package/ob_dbms_sql.cpp index 06d6fa97b..7d2e11738 100644 --- a/src/pl/sys_package/ob_dbms_sql.cpp +++ b/src/pl/sys_package/ob_dbms_sql.cpp @@ -1142,7 +1142,7 @@ int ObPLDbmsSql::do_execute(ObExecContext &exec_ctx, ObPLExecCtx pl_ctx(cursor.get_allocator(), &exec_ctx, ¶ms, NULL/*result*/, &ret, NULL/*func*/, true); OZ (cursor.expand_params()); - OZ (ObSPIService::dbms_dynamic_open(&pl_ctx, cursor)); + OZ (ObSPIService::dbms_dynamic_open(&pl_ctx, cursor, true)); if (OB_SUCC(ret) && cursor.get_into_names().count() > 0) { // DML Returning OZ (do_fetch(exec_ctx, params, result, cursor)); } else { diff --git a/src/sql/ob_spi.cpp b/src/sql/ob_spi.cpp index d9b120117..21bdbac5c 100644 --- a/src/sql/ob_spi.cpp +++ b/src/sql/ob_spi.cpp @@ -1770,7 +1770,8 @@ int ObSPIService::spi_inner_execute(ObPLExecCtx *ctx, int ObSPIService::dbms_cursor_execute(ObPLExecCtx *ctx, const ObString ps_sql, stmt::StmtType stmt_type, - ObDbmsCursorInfo &cursor) + ObDbmsCursorInfo &cursor, + bool is_dbms_sql) { int ret = OB_SUCCESS; ObSQLSessionInfo *session = NULL; @@ -1793,6 +1794,7 @@ int ObSPIService::dbms_cursor_execute(ObPLExecCtx *ctx, HEAP_VAR(ObSPIResultSet, spi_result) { OZ (spi_result.init(*session)); OZ (spi_result.start_nested_stmt_if_need(ctx, sql_stmt, static_cast(stmt_type), cursor.is_for_update())); + OX (spi_result.get_sql_ctx().is_dbms_sql_ = is_dbms_sql); if (OB_SUCC(ret)) { int64_t row_count = 0; ObQueryRetryCtrl retry_ctrl; @@ -3374,7 +3376,8 @@ int ObSPIService::spi_dynamic_open(ObPLExecCtx *ctx, } int ObSPIService::dbms_dynamic_open(ObPLExecCtx *pl_ctx, - ObDbmsCursorInfo &cursor) + ObDbmsCursorInfo &cursor, + bool is_dbms_sql) { int ret = OB_SUCCESS; // ObString &sql_stmt = cursor.get_sql_stmt(); @@ -3390,7 +3393,7 @@ int ObSPIService::dbms_dynamic_open(ObPLExecCtx *pl_ctx, || cursor.get_into_names().count() > 0) { // NOTICE: DML Returning also use cursor impl. OZ (dbms_cursor_open(pl_ctx, cursor, ps_sql, stmt_type, for_update, hidden_rowid), cursor); } else { - OZ (dbms_cursor_execute(pl_ctx, ps_sql, stmt_type, cursor), cursor); + OZ (dbms_cursor_execute(pl_ctx, ps_sql, stmt_type, cursor, is_dbms_sql), cursor); OX (cursor.set_affected_rows(pl_ctx->exec_ctx_->get_my_session()->get_affected_rows())); } return ret; diff --git a/src/sql/ob_spi.h b/src/sql/ob_spi.h index 0aa286a70..0b6117029 100644 --- a/src/sql/ob_spi.h +++ b/src/sql/ob_spi.h @@ -494,7 +494,8 @@ public: uint64_t routine_id, int64_t cursor_index); static int dbms_dynamic_open(pl::ObPLExecCtx *ctx, - pl::ObDbmsCursorInfo &cursor); + pl::ObDbmsCursorInfo &cursor, + bool is_dbms_sql = false); static int dbms_cursor_fetch(pl::ObPLExecCtx *ctx, pl::ObDbmsCursorInfo &cursor, bool is_server_cursor = false); @@ -803,7 +804,8 @@ private: static int dbms_cursor_execute(pl::ObPLExecCtx *ctx, const ObString ps_sql, stmt::StmtType stmt_type, - pl::ObDbmsCursorInfo &cursor); + pl::ObDbmsCursorInfo &cursor, + bool is_dbms_sql); static int adjust_out_params(ObResultSet &result_set, ObSPIOutParams &out_params);