[CP] The internal SQL of udf cannot hit the plan cache
This commit is contained in:
@ -1511,6 +1511,7 @@ int ObSql::handle_pl_execute(const ObString &sql,
|
||||
LOG_WARN("failed to init result set", K(ret));
|
||||
} else {
|
||||
context.cur_sql_ = sql;
|
||||
context.is_from_pl_ = true;
|
||||
context.is_dynamic_sql_ = is_dynamic_sql;
|
||||
context.is_prepare_protocol_ = is_prepare_protocol;
|
||||
context.spm_ctx_.bl_key_.db_id_ = session.get_database_id();
|
||||
@ -4173,7 +4174,7 @@ int ObSql::parser_and_check(const ObString &outlined_stmt,
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
//租户级别的read only检查
|
||||
if (session->is_inner() || pc_ctx.is_begin_commit_stmt()) {
|
||||
if ((session->is_inner() && !pc_ctx.sql_ctx_.is_from_pl_) || pc_ctx.is_begin_commit_stmt()) {
|
||||
// FIXME:
|
||||
// schema拆分后,为了避免建租户时获取不到租户read only属性导致建租户失败,对于inner sql
|
||||
// 暂时跳过read only检查。实际上,对于tenant space系统表,不应该检查read only属性。
|
||||
|
||||
@ -634,7 +634,8 @@ public:
|
||||
struct {
|
||||
uint32_t enable_strict_defensive_check_: 1; //TRUE if the _enable_defensive_check is '2'
|
||||
uint32_t enable_user_defined_rewrite_ : 1;//TRUE if enable_user_defined_rewrite_rules is open
|
||||
uint32_t reserved_ : 30;
|
||||
uint32_t is_from_pl_ : 1;
|
||||
uint32_t reserved_ : 29;
|
||||
};
|
||||
};
|
||||
private:
|
||||
|
||||
@ -594,7 +594,10 @@ int ObPlanCache::get_plan(common::ObIAllocator &allocator,
|
||||
if (GCONF.enable_perf_event) {
|
||||
uint64_t tenant_id = pc_ctx.sql_ctx_.session_info_->get_effective_tenant_id();
|
||||
bool read_only = false;
|
||||
if (OB_FAIL(pc_ctx.sql_ctx_.schema_guard_->get_tenant_read_only(tenant_id, read_only))) {
|
||||
if ((pc_ctx.sql_ctx_.session_info_->is_inner() && !pc_ctx.sql_ctx_.is_from_pl_)) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(pc_ctx.sql_ctx_.schema_guard_->get_tenant_read_only(tenant_id,
|
||||
read_only))) {
|
||||
LOG_WARN("failed to check read_only privilege", K(ret));
|
||||
} else if (OB_FAIL(pc_ctx.sql_ctx_.session_info_->check_read_only_privilege(
|
||||
read_only, pc_ctx.sql_traits_))) {
|
||||
@ -2175,7 +2178,6 @@ int ObPlanCache::get_ps_plan(ObCacheObjGuard& guard,
|
||||
int ret = OB_SUCCESS;
|
||||
ObGlobalReqTimeService::check_req_timeinfo();
|
||||
UNUSED(stmt_id);
|
||||
ObSqlTraits sql_traits;
|
||||
pc_ctx.handle_id_ = guard.ref_handle_;
|
||||
int64_t original_param_cnt = 0;
|
||||
|
||||
@ -2228,10 +2230,12 @@ int ObPlanCache::get_ps_plan(ObCacheObjGuard& guard,
|
||||
if (OB_SUCC(ret) && GCONF.enable_perf_event) {
|
||||
uint64_t tenant_id = pc_ctx.sql_ctx_.session_info_->get_effective_tenant_id();
|
||||
bool read_only = false;
|
||||
if (OB_FAIL(pc_ctx.sql_ctx_.schema_guard_->get_tenant_read_only(tenant_id, read_only))) {
|
||||
if ((pc_ctx.sql_ctx_.session_info_->is_inner() && !pc_ctx.sql_ctx_.is_from_pl_)) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(pc_ctx.sql_ctx_.schema_guard_->get_tenant_read_only(tenant_id, read_only))) {
|
||||
SQL_PC_LOG(WARN, "fail to get tenant read only attribute", K(tenant_id), K(ret));
|
||||
} else if (OB_FAIL(pc_ctx.sql_ctx_.session_info_->check_read_only_privilege(read_only,
|
||||
sql_traits))) {
|
||||
pc_ctx.sql_traits_))) {
|
||||
SQL_PC_LOG(WARN, "failed to check read_only privilege", K(ret));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user