diff --git a/src/pl/ob_pl.cpp b/src/pl/ob_pl.cpp index 2ee87b65ab..af4a78fa00 100644 --- a/src/pl/ob_pl.cpp +++ b/src/pl/ob_pl.cpp @@ -1563,6 +1563,7 @@ int ObPL::get_pl_function(ObExecContext &ctx, OZ (ObPLContext::valid_execute_context(ctx)); if (OB_SUCC(ret)) { ObPlanCache *plan_cache = ctx.get_my_session()->get_plan_cache(); + ObPlanBaseKeyGuard guard(ctx.get_sql_ctx()->spm_ctx_.bl_key_); ObPlanCacheCtx pc_ctx(sql, true, // PS_MODE ctx.get_allocator(), @@ -1691,6 +1692,7 @@ int ObPL::get_pl_function(ObExecContext &ctx, } else { // standalone routine static const ObString PLSQL = ObString("PL/SQL"); ObPlanCache *plan_cache = ctx.get_my_session()->get_plan_cache(); + ObPlanBaseKeyGuard guard(ctx.get_sql_ctx()->spm_ctx_.bl_key_); ObPlanCacheCtx pc_ctx(PLSQL, false, // ps mode ctx.get_allocator(), diff --git a/src/sql/ob_sql.h b/src/sql/ob_sql.h index 681d5bacb9..cfbbf49aa3 100644 --- a/src/sql/ob_sql.h +++ b/src/sql/ob_sql.h @@ -61,9 +61,9 @@ class ObResultSet; class ObPlanBaseKeyGuard { public: - explicit ObPlanBaseKeyGuard(ObBaselineKey &bl_key) - : bl_key_(bl_key), - ori_bl_key_(bl_key) {} + [[nodiscard]] explicit ObPlanBaseKeyGuard(ObBaselineKey &bl_key) + : bl_key_(bl_key), + ori_bl_key_(bl_key) {} ~ObPlanBaseKeyGuard() { bl_key_ = ori_bl_key_;