Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
大炮V587
oceanbase
提交
fdc08f50
O
oceanbase
项目概览
大炮V587
/
oceanbase
与 Fork 源项目一致
Fork自
oceanbase / oceanbase
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oceanbase
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
fdc08f50
编写于
3月 23, 2023
作者:
O
obdev
提交者:
ob-robot
3月 23, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix the failure to get the tenant config
上级
e1656f5d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
24 addition
and
21 deletion
+24
-21
src/sql/ob_sql.cpp
src/sql/ob_sql.cpp
+11
-9
src/sql/plan_cache/ob_plan_cache.cpp
src/sql/plan_cache/ob_plan_cache.cpp
+8
-7
src/sql/udr/ob_udr_utils.cpp
src/sql/udr/ob_udr_utils.cpp
+5
-5
未找到文件。
src/sql/ob_sql.cpp
浏览文件 @
fdc08f50
...
...
@@ -930,6 +930,7 @@ int ObSql::do_real_prepare(const ObString &sql,
bool
is_inner_sql
)
{
int
ret
=
OB_SUCCESS
;
bool
enable_udr
=
false
;
ParseResult
parse_result
;
ObStmt
*
basic_stmt
=
NULL
;
stmt
::
StmtType
stmt_type
=
stmt
::
T_NONE
;
...
...
@@ -957,10 +958,10 @@ int ObSql::do_real_prepare(const ObString &sql,
CHECK_COMPATIBILITY_MODE
(
context
.
session_info_
);
if
(
!
tenant_config
.
is_valid
())
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"tenant config is invalid"
,
K
(
ret
));
}
else
if
(
OB_ISNULL
(
context
.
session_info_
)
||
OB_ISNULL
(
context
.
schema_guard_
))
{
if
(
tenant_config
.
is_valid
())
{
enable_udr
=
tenant_config
->
enable_user_defined_rewrite_rules
;
}
if
(
OB_ISNULL
(
context
.
session_info_
)
||
OB_ISNULL
(
context
.
schema_guard_
))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"session info is NULL"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
parser
.
parse
(
sql
,
...
...
@@ -1006,7 +1007,7 @@ int ObSql::do_real_prepare(const ObString &sql,
LOG_WARN
(
"generate stmt failed"
,
K
(
ret
));
}
else
if
(
!
is_from_pl
&&
!
is_inner_sql
&&
tenant_config
->
enable_user_defined_rewrite_rules
&&
enable_udr
&&
OB_FAIL
(
ObUDRUtils
::
match_udr_item
(
sql
,
session
,
allocator
,
item_guard
)))
{
LOG_WARN
(
"failed to match rewrite rule"
,
K
(
ret
));
}
else
if
(
ObStmt
::
is_dml_stmt
(
stmt_type
)
...
...
@@ -4007,17 +4008,18 @@ int ObSql::pc_add_plan(ObPlanCacheCtx &pc_ctx,
bool
&
plan_added
)
{
int
ret
=
OB_SUCCESS
;
bool
enable_udr
=
false
;
ObPhysicalPlan
*
phy_plan
=
result
.
get_physical_plan
();
pc_ctx
.
fp_result_
.
pc_key_
.
namespace_
=
ObLibCacheNameSpace
::
NS_CRSR
;
plan_added
=
false
;
bool
is_batch_exec
=
pc_ctx
.
sql_ctx_
.
multi_stmt_item_
.
is_batched_multi_stmt
();
omt
::
ObTenantConfigGuard
tenant_config
(
TENANT_CONF
(
MTL_ID
()));
if
(
tenant_config
.
is_valid
())
{
enable_udr
=
tenant_config
->
enable_user_defined_rewrite_rules
;
}
if
(
OB_ISNULL
(
phy_plan
)
||
OB_ISNULL
(
plan_cache
))
{
ret
=
OB_NOT_INIT
;
LOG_WARN
(
"Fail to generate plan"
,
K
(
phy_plan
),
K
(
plan_cache
));
}
else
if
(
!
tenant_config
.
is_valid
())
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"tenant config is invalid"
,
K
(
ret
));
}
else
if
(
OB_USE_PLAN_CACHE_NONE
==
phy_plan
->
get_phy_plan_hint
().
plan_cache_policy_
)
{
LOG_DEBUG
(
"Hint not use plan cache"
);
}
else
if
(
OB_FAIL
(
result
.
to_plan
(
pc_ctx
.
mode_
,
phy_plan
)))
{
...
...
@@ -4040,7 +4042,7 @@ int ObSql::pc_add_plan(ObPlanCacheCtx &pc_ctx,
phy_plan
->
stat_
.
db_id_
=
pc_ctx
.
sql_ctx_
.
spm_ctx_
.
bl_key_
.
db_id_
;
phy_plan
->
stat_
.
is_rewrite_sql_
=
pc_ctx
.
is_rewrite_sql_
;
phy_plan
->
stat_
.
rule_version_
=
rule_mgr
->
get_rule_version
();
phy_plan
->
stat_
.
enable_udr_
=
tenant_config
->
enable_user_defined_rewrite_rules
;
phy_plan
->
stat_
.
enable_udr_
=
enable_udr
;
if
(
PC_PS_MODE
==
pc_ctx
.
mode_
||
PC_PL_MODE
==
pc_ctx
.
mode_
)
{
//远程SQL第二次进入plan,将raw_sql作为pc_key存入plan cache中,
...
...
src/sql/plan_cache/ob_plan_cache.cpp
浏览文件 @
fdc08f50
...
...
@@ -368,18 +368,19 @@ int ObPlanCache::check_after_get_plan(int tmp_ret,
{
int
ret
=
tmp_ret
;
ObPhysicalPlan
*
plan
=
NULL
;
bool
enable_udr
=
false
;
bool
need_late_compilation
=
false
;
ObJITEnableMode
jit_mode
=
ObJITEnableMode
::
OFF
;
omt
::
ObTenantConfigGuard
tenant_config
(
TENANT_CONF
(
MTL_ID
()));
ObPlanCacheCtx
&
pc_ctx
=
static_cast
<
ObPlanCacheCtx
&>
(
ctx
);
if
(
tenant_config
.
is_valid
())
{
enable_udr
=
tenant_config
->
enable_user_defined_rewrite_rules
;
}
if
(
cache_obj
!=
NULL
&&
ObLibCacheNameSpace
::
NS_CRSR
==
cache_obj
->
get_ns
())
{
plan
=
static_cast
<
ObPhysicalPlan
*>
(
cache_obj
);
}
if
(
OB_SUCC
(
ret
))
{
if
(
!
tenant_config
.
is_valid
())
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"tenant config is invalid"
,
K
(
ret
));
}
else
if
(
OB_ISNULL
(
pc_ctx
.
sql_ctx_
.
session_info_
))
{
if
(
OB_ISNULL
(
pc_ctx
.
sql_ctx_
.
session_info_
))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"unexpected null session info"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
pc_ctx
.
sql_ctx_
.
session_info_
->
get_jit_enabled_mode
(
jit_mode
)))
{
...
...
@@ -394,17 +395,17 @@ int ObPlanCache::check_after_get_plan(int tmp_ret,
// when the global rule version changes or enable_user_defined_rewrite_rules changes
// it is necessary to check whether the physical plan are expired
if
((
plan
->
get_rule_version
()
!=
rule_mgr
->
get_rule_version
()
||
plan
->
is_enable_udr
()
!=
tenant_config
->
enable_user_defined_rewrite_rules
))
{
||
plan
->
is_enable_udr
()
!=
enable_udr
))
{
if
(
OB_FAIL
(
rule_mgr
->
fuzzy_check_by_pattern_digest
(
pc_ctx
.
get_normalized_pattern_digest
(),
is_exists
)))
{
LOG_WARN
(
"failed to fuzzy check by pattern digest"
,
K
(
ret
));
}
else
if
(
is_exists
||
plan
->
is_rewrite_sql
())
{
ret
=
OB_OLD_SCHEMA_VERSION
;
LOG_TRACE
(
"Obsolete user-defined rewrite rules require eviction plan"
,
K
(
ret
),
K
(
is_exists
),
K
(
pc_ctx
.
raw_sql_
),
K
(
plan
->
is_enable_udr
()),
K
(
tenant_config
->
enable_user_defined_rewrite_rules
),
K
(
is_exists
),
K
(
pc_ctx
.
raw_sql_
),
K
(
plan
->
is_enable_udr
()),
K
(
enable_udr
),
K
(
plan
->
is_rewrite_sql
()),
K
(
plan
->
get_rule_version
()),
K
(
rule_mgr
->
get_rule_version
()));
}
else
{
plan
->
set_rule_version
(
rule_mgr
->
get_rule_version
());
plan
->
set_is_enable_udr
(
tenant_config
->
enable_user_defined_rewrite_rules
);
plan
->
set_is_enable_udr
(
enable_udr
);
}
}
if
(
OB_SUCC
(
ret
))
{
...
...
src/sql/udr/ob_udr_utils.cpp
浏览文件 @
fdc08f50
...
...
@@ -239,14 +239,14 @@ int ObUDRUtils::match_udr_and_refill_ctx(const ObString &pattern,
ObUDRItemMgr
::
UDRItemRefGuard
&
item_guard
)
{
int
ret
=
OB_SUCCESS
;
bool
enable_udr
=
false
;
is_match_udr
=
false
;
ObSQLSessionInfo
&
session
=
result
.
get_session
();
omt
::
ObTenantConfigGuard
tenant_config
(
TENANT_CONF
(
session
.
get_effective_tenant_id
()));
if
(
!
tenant_config
.
is_valid
())
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"tenant config is invalid"
,
K
(
ret
));
}
else
if
(
tenant_config
->
enable_user_defined_rewrite_rules
&&
!
(
pc_ctx
.
is_inner_sql
()
||
PC_PL_MODE
==
pc_ctx
.
mode_
))
{
if
(
tenant_config
.
is_valid
())
{
enable_udr
=
tenant_config
->
enable_user_defined_rewrite_rules
;
}
if
(
enable_udr
&&
!
(
pc_ctx
.
is_inner_sql
()
||
PC_PL_MODE
==
pc_ctx
.
mode_
))
{
ObIAllocator
&
allocator
=
result
.
get_mem_pool
();
PatternConstConsList
cst_cons_list
;
if
(
OB_FAIL
(
match_udr_item
(
pattern
,
session
,
allocator
,
item_guard
,
&
cst_cons_list
)))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录