diff --git a/src/pl/ob_pl.cpp b/src/pl/ob_pl.cpp index ec212803a8..86f3662123 100644 --- a/src/pl/ob_pl.cpp +++ b/src/pl/ob_pl.cpp @@ -2019,7 +2019,7 @@ int ObPL::generate_pl_function(ObExecContext &ctx, int ret = OB_SUCCESS; ParseNode *block_node = NULL; ObPLFunction *routine = NULL; - ObPLPackageGuard package_guard(PACKAGE_RESV_HANDLE); + ObPLPackageGuard package_guard(ctx.get_my_session()->get_effective_tenant_id()); int64_t compile_start = ObTimeUtility::current_time(); diff --git a/src/pl/ob_pl_resolver.cpp b/src/pl/ob_pl_resolver.cpp index a68a186387..38f99867c3 100644 --- a/src/pl/ob_pl_resolver.cpp +++ b/src/pl/ob_pl_resolver.cpp @@ -7279,20 +7279,20 @@ int ObPLResolver::resolve_condition_compile( ObPLDependencyTable *dep_table) { int ret = OB_SUCCESS; - ObPLPackageGuard local_pkg_guard(PACKAGE_RESV_HANDLE); ObRawExprFactory expr_factory(allocator); CK (OB_NOT_NULL(node)); CK (T_SP_PRE_STMTS == node->type_); CK (OB_NOT_NULL(schema_guard)); - if (OB_SUCC(ret) && OB_ISNULL(package_guard)) { - OZ (local_pkg_guard.init()); - OX (package_guard = &local_pkg_guard); - } if (OB_SUCC(ret) && OB_ISNULL(sql_proxy)) { CK (OB_NOT_NULL(sql_proxy = GCTX.sql_proxy_)); } if (OB_FAIL(ret)) { } else if (OB_ISNULL(session_info)) { + ObPLPackageGuard local_pkg_guard(schema_guard->get_tenant_id()); + if (OB_SUCC(ret) && OB_ISNULL(package_guard)) { + OZ (local_pkg_guard.init()); + OX (package_guard = &local_pkg_guard); + } SMART_VAR(sql::ObSQLSessionInfo, session) { ObExecEnv env; CK (OB_NOT_NULL(exec_env)); @@ -7315,6 +7315,11 @@ int ObPLResolver::resolve_condition_compile( } } } else { + ObPLPackageGuard local_pkg_guard(session_info->get_effective_tenant_id()); + if (OB_SUCC(ret) && OB_ISNULL(package_guard)) { + OZ (local_pkg_guard.init()); + OX (package_guard = &local_pkg_guard); + } ObPLResolver resolver( allocator, *session_info, *schema_guard, *package_guard, *sql_proxy, expr_factory, NULL, false); @@ -8579,7 +8584,7 @@ int ObPLResolver::resolve_raw_expr(const ParseNode &node, } else if (OB_ISNULL(params.secondary_namespace_)) { HEAP_VAR(pl::ObPLFunctionAST, func_ast, *(params.allocator_)) { ObPLStmtBlock *null_block = NULL; - ObPLPackageGuard package_guard(PACKAGE_RESV_HANDLE); + ObPLPackageGuard package_guard(params.session_info_->get_effective_tenant_id()); ObPLResolver resolver(*(params.allocator_), *(params.session_info_), *(params.schema_checker_->get_schema_guard()), diff --git a/src/pl/ob_pl_router.cpp b/src/pl/ob_pl_router.cpp index 12aa4f3503..b4e75ffdc6 100644 --- a/src/pl/ob_pl_router.cpp +++ b/src/pl/ob_pl_router.cpp @@ -189,7 +189,7 @@ int ObPLRouter::simple_resolve(ObPLFunctionAST &func_ast) //Resolver if (OB_SUCC(ret)) { const bool is_prepare_protocol = false; - ObPLPackageGuard package_guard(sql::PACKAGE_RESV_HANDLE); + ObPLPackageGuard package_guard(session_info_.get_effective_tenant_id()); ObPLResolver resolver(inner_allocator_, session_info_, schema_guard_, diff --git a/src/pl/ob_pl_type.cpp b/src/pl/ob_pl_type.cpp index c6b938938a..f46ba1ffa8 100644 --- a/src/pl/ob_pl_type.cpp +++ b/src/pl/ob_pl_type.cpp @@ -111,7 +111,7 @@ int ObPLDataType::get_table_type_by_name(uint64_t tenant_id, OX (pl_type.set_user_type_id(PL_RECORD_TYPE, table_info->get_table_id())); OX (pl_type.set_type_from(PL_TYPE_ATTR_ROWTYPE)); } else { - ObPLPackageGuard dummy_guard(PACKAGE_TYPE_HANDLE); + ObPLPackageGuard dummy_guard(session_info.get_effective_tenant_id()); ObMySQLProxy dummy_proxy; ObPLResolveCtx ctx(allocator, session_info, schema_guard, dummy_guard, dummy_proxy, false); ObRecordType *record_type = NULL; diff --git a/src/sql/ob_spi.cpp b/src/sql/ob_spi.cpp index 32c779c55d..4f786a8c56 100644 --- a/src/sql/ob_spi.cpp +++ b/src/sql/ob_spi.cpp @@ -874,7 +874,6 @@ int ObSPIService::spi_calc_package_expr(ObPLExecCtx *ctx, ObMySQLProxy *sql_proxy = NULL; ObPL *pl_engine = NULL; share::schema::ObSchemaGetterGuard schema_guard; - ObPLPackageGuard package_guard(PACKAGE_RESV_HANDLE); CK (OB_NOT_NULL(ctx), ctx->valid()); CK (OB_NOT_NULL(GCTX.schema_service_)); CK (OB_NOT_NULL(exec_ctx = ctx->exec_ctx_)); @@ -884,8 +883,8 @@ int ObSPIService::spi_calc_package_expr(ObPLExecCtx *ctx, OZ (GCTX.schema_service_->get_tenant_schema_guard( session_info->get_effective_tenant_id(), schema_guard)); - OZ (package_guard.init()); if (OB_SUCC(ret)) { + ObPLPackageGuard package_guard(session_info->get_effective_tenant_id()); ObSqlExpression *sql_expr = NULL; ObPLPackageManager &pl_manager = pl_engine->get_package_manager(); ObPLPackageGuard &guard = ctx->guard_ != NULL ? (*ctx->guard_) : package_guard; @@ -897,6 +896,7 @@ int ObSPIService::spi_calc_package_expr(ObPLExecCtx *ctx, guard, *sql_proxy, false); + OZ (package_guard.init()); OZ (pl_manager.get_package_expr(resolve_ctx, package_id, expr_idx, sql_expr)); CK (OB_NOT_NULL(sql_expr)); OZ (guard.get(package_id, cache_obj_guard)); @@ -939,7 +939,7 @@ int ObSPIService::spi_set_package_variable( if (OB_SUCC(ret)) { ObPLPackageManager &pl_manager = pl_engine->get_package_manager(); share::schema::ObSchemaGetterGuard schema_guard; - ObPLPackageGuard package_guard(PACKAGE_RESV_HANDLE); + ObPLPackageGuard package_guard(session_info->get_effective_tenant_id()); ObPLResolveCtx resolve_ctx(exec_ctx->get_allocator(), *session_info, schema_guard, @@ -2788,7 +2788,6 @@ int ObSPIService::spi_get_package_cursor_info(ObPLExecCtx *ctx, ObMySQLProxy *sql_proxy = NULL; ObPL *pl_engine = NULL; share::schema::ObSchemaGetterGuard schema_guard; - ObPLPackageGuard package_guard(PACKAGE_RESV_HANDLE); UNUSED(routine_id); cursor = NULL; CK (OB_NOT_NULL(ctx), ctx->valid()); @@ -2800,6 +2799,7 @@ int ObSPIService::spi_get_package_cursor_info(ObPLExecCtx *ctx, OZ (GCTX.schema_service_->get_tenant_schema_guard( session_info->get_effective_tenant_id(), schema_guard)); + ObPLPackageGuard package_guard(session_info->get_effective_tenant_id()); OZ (package_guard.init()); if (OB_SUCC(ret)) { ObObj value; @@ -4526,7 +4526,6 @@ int ObSPIService::spi_get_package_allocator( ObMySQLProxy *sql_proxy = NULL; ObPL *pl_engine = NULL; share::schema::ObSchemaGetterGuard schema_guard; - ObPLPackageGuard package_guard(PACKAGE_RESV_HANDLE); CK (OB_NOT_NULL(ctx)); CK (OB_NOT_NULL(GCTX.schema_service_)); CK (OB_NOT_NULL(exec_ctx = ctx->exec_ctx_)); @@ -4536,6 +4535,7 @@ int ObSPIService::spi_get_package_allocator( OZ (GCTX.schema_service_->get_tenant_schema_guard( session_info->get_effective_tenant_id(), schema_guard)); + ObPLPackageGuard package_guard(session_info->get_effective_tenant_id()); OZ (package_guard.init()); OX (allocator = NULL); if (OB_SUCC(ret)) { diff --git a/src/sql/resolver/ob_resolver.cpp b/src/sql/resolver/ob_resolver.cpp index b7528c48ed..64b97f164b 100644 --- a/src/sql/resolver/ob_resolver.cpp +++ b/src/sql/resolver/ob_resolver.cpp @@ -200,7 +200,7 @@ int ObResolver::resolve(IsPrepared if_prepared, const ParseNode &parse_tree, ObS K(params_.allocator_), K(params_.schema_checker_), K(params_.session_info_), K(params_.query_ctx_), KP(params_.expr_factory_)); } else if (T_SP_PRE_STMTS == parse_tree.type_) { - pl::ObPLPackageGuard package_guard(sql::PACKAGE_RESV_HANDLE); + pl::ObPLPackageGuard package_guard(params_.session_info_->get_effective_tenant_id()); pl::ObPLResolver resolver(*(params_.allocator_), *(params_.session_info_), *(params_.schema_checker_->get_schema_guard()), diff --git a/src/sql/resolver/ob_resolver_utils.cpp b/src/sql/resolver/ob_resolver_utils.cpp index cd69da3f3d..83cc0df16f 100644 --- a/src/sql/resolver/ob_resolver_utils.cpp +++ b/src/sql/resolver/ob_resolver_utils.cpp @@ -544,7 +544,7 @@ int ObResolverUtils::check_type_match(ObResolverParams ¶ms, ObPLDataType &dst_pl_type) { int ret = OB_SUCCESS; - ObPLPackageGuard package_guard(PACKAGE_RESV_HANDLE); + ObPLPackageGuard package_guard(params.session_info_->get_effective_tenant_id()); ObPLResolveCtx resolve_ctx(*(params.allocator_), *(params.session_info_), *(params.schema_checker_->get_schema_guard()), @@ -1222,7 +1222,7 @@ int ObResolverUtils::get_routine(ObResolverParams ¶ms, CK (OB_NOT_NULL(params.schema_checker_->get_schema_guard())); CK (OB_NOT_NULL(GCTX.sql_proxy_)); if (OB_SUCC(ret)) { - ObPLPackageGuard package_guard(PACKAGE_RESV_HANDLE); + ObPLPackageGuard package_guard(params.session_info_->get_effective_tenant_id()); ObPLResolveCtx resolve_ctx(*(params.allocator_), *(params.session_info_), *(params.schema_checker_->get_schema_guard()),