From 3a1e99265f21f9c7ee31b229093b88b571777b5f Mon Sep 17 00:00:00 2001 From: LiuYoung00 Date: Thu, 2 Mar 2023 16:02:18 +0000 Subject: [PATCH] [to #48075831]set spi_cursor to null when error happend --- src/pl/sys_package/ob_dbms_sql.cpp | 1 + src/sql/ob_spi.cpp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/pl/sys_package/ob_dbms_sql.cpp b/src/pl/sys_package/ob_dbms_sql.cpp index a7fe6f9eba..8f89dafcb1 100644 --- a/src/pl/sys_package/ob_dbms_sql.cpp +++ b/src/pl/sys_package/ob_dbms_sql.cpp @@ -279,6 +279,7 @@ int ObDbmsCursorInfo::parse(const ObString &sql_stmt, ObSQLSessionInfo &session) OZ (prepare_entity(session), sql_stmt); OV (OB_NOT_NULL(get_dbms_entity()), OB_ALLOCATE_MEMORY_FAILED, sql_stmt); OV (OB_NOT_NULL(get_cursor_entity()), OB_ALLOCATE_MEMORY_FAILED, sql_stmt); + OX (set_spi_cursor(NULL)); if (OB_SUCC(ret)) { ObIAllocator &alloc = get_dbms_entity()->get_arena_allocator(); ObParser parser(alloc, session.get_sql_mode(), session.get_local_collation_connection()); diff --git a/src/sql/ob_spi.cpp b/src/sql/ob_spi.cpp index aeace39d67..839be88913 100644 --- a/src/sql/ob_spi.cpp +++ b/src/sql/ob_spi.cpp @@ -3195,6 +3195,7 @@ int ObSPIService::spi_cursor_open(ObPLExecCtx *ctx, || (package_id != OB_INVALID_ID && OB_INVALID_ID == routine_id); if (is_server_cursor) { OZ (ObPLCursorInfo::prepare_entity(*session_info, cursor->get_cursor_entity())); + OX (cursor->set_spi_cursor(NULL)); } } OZ (session_info->ps_use_stream_result_set(use_stream)); @@ -3449,6 +3450,8 @@ int ObSPIService::dbms_cursor_open(ObPLExecCtx *ctx, // 此处只能处理cursor.get_cursor_entity(), 不能处理cursor.get_dbms_entity(),否则exec_params等的值的allocator被reset // 会导致core LOG_WARN("failed to alloc ref cursor entity", K(ret)); + } else { + cursor.set_spi_cursor(NULL); } } }