Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
大炮V587
oceanbase
提交
649a2dc6
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,发现更多精彩内容 >>
提交
649a2dc6
编写于
8月 25, 2022
作者:
O
obdev
提交者:
wangzelin.wzl
8月 25, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[CP] Fix execution failure due to incorrect plan sharing
上级
aac5b028
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
34 addition
and
16 deletion
+34
-16
src/sql/ob_sql.cpp
src/sql/ob_sql.cpp
+12
-4
src/sql/ob_sql.h
src/sql/ob_sql.h
+3
-1
src/sql/plan_cache/ob_ps_sql_utils.cpp
src/sql/plan_cache/ob_ps_sql_utils.cpp
+14
-7
src/sql/plan_cache/ob_ps_sql_utils.h
src/sql/plan_cache/ob_ps_sql_utils.h
+5
-4
未找到文件。
src/sql/ob_sql.cpp
浏览文件 @
649a2dc6
...
@@ -808,7 +808,8 @@ int ObSql::construct_not_paramalize(
...
@@ -808,7 +808,8 @@ int ObSql::construct_not_paramalize(
return
ret
;
return
ret
;
}
}
int
ObSql
::
construct_no_check_type_params
(
const
ObIArray
<
int64_t
>
&
offsets
,
ParamStore
&
params_store
)
int
ObSql
::
construct_no_check_type_params
(
const
ObIArray
<
int64_t
>
&
offsets
,
const
ObBitSet
<>
&
need_check_type_offsets
,
ParamStore
&
params_store
)
{
{
int
ret
=
OB_SUCCESS
;
int
ret
=
OB_SUCCESS
;
for
(
int64_t
i
=
0
;
OB_SUCC
(
ret
)
&&
i
<
offsets
.
count
();
i
++
)
{
for
(
int64_t
i
=
0
;
OB_SUCC
(
ret
)
&&
i
<
offsets
.
count
();
i
++
)
{
...
@@ -816,6 +817,8 @@ int ObSql::construct_no_check_type_params(const ObIArray<int64_t> &offsets, Para
...
@@ -816,6 +817,8 @@ int ObSql::construct_no_check_type_params(const ObIArray<int64_t> &offsets, Para
if
(
offset
<
0
||
offset
>=
params_store
.
count
())
{
if
(
offset
<
0
||
offset
>=
params_store
.
count
())
{
ret
=
OB_INVALID_ARGUMENT
;
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"Invalid offset"
,
K
(
ret
),
K
(
offset
),
K
(
params_store
.
count
()));
LOG_WARN
(
"Invalid offset"
,
K
(
ret
),
K
(
offset
),
K
(
params_store
.
count
()));
}
else
if
(
need_check_type_offsets
.
has_member
(
offset
))
{
// do nothing
}
else
if
(
!
params_store
.
at
(
offset
).
is_ext
())
{
// extend type need to be checked
}
else
if
(
!
params_store
.
at
(
offset
).
is_ext
())
{
// extend type need to be checked
params_store
.
at
(
offset
).
set_need_to_check_type
(
false
);
params_store
.
at
(
offset
).
set_need_to_check_type
(
false
);
}
else
{
}
else
{
...
@@ -3255,6 +3258,7 @@ int ObSql::handle_parser(const ObString &sql, ObExecContext &exec_ctx, ObPlanCac
...
@@ -3255,6 +3258,7 @@ int ObSql::handle_parser(const ObString &sql, ObExecContext &exec_ctx, ObPlanCac
int64_t
question_mark_count
=
0
;
int64_t
question_mark_count
=
0
;
ObArray
<
int64_t
>
not_param_offsets
;
ObArray
<
int64_t
>
not_param_offsets
;
ObArray
<
int64_t
>
no_check_type_offsets
;
ObArray
<
int64_t
>
no_check_type_offsets
;
ObBitSet
<>
need_check_type_param_offsets
;
ObIAllocator
&
allocator
=
pc_ctx
.
allocator_
;
ObIAllocator
&
allocator
=
pc_ctx
.
allocator_
;
ObSQLSessionInfo
&
session
=
*
(
pc_ctx
.
sql_ctx_
.
session_info_
);
ObSQLSessionInfo
&
session
=
*
(
pc_ctx
.
sql_ctx_
.
session_info_
);
ObParser
parser
(
allocator
,
session
.
get_sql_mode
(),
session
.
get_local_collation_connection
());
ObParser
parser
(
allocator
,
session
.
get_sql_mode
(),
session
.
get_local_collation_connection
());
...
@@ -3263,12 +3267,16 @@ int ObSql::handle_parser(const ObString &sql, ObExecContext &exec_ctx, ObPlanCac
...
@@ -3263,12 +3267,16 @@ int ObSql::handle_parser(const ObString &sql, ObExecContext &exec_ctx, ObPlanCac
}
else
if
(
OB_ISNULL
(
parse_result
.
result_tree_
))
{
}
else
if
(
OB_ISNULL
(
parse_result
.
result_tree_
))
{
ret
=
OB_INVALID_ARGUMENT
;
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"result_tree should not be null"
,
K
(
ret
),
K
(
sql
));
LOG_WARN
(
"result_tree should not be null"
,
K
(
ret
),
K
(
sql
));
}
else
if
(
OB_FAIL
(
helper
.
find_special_paramalize
(
}
else
if
(
OB_FAIL
(
helper
.
find_special_paramalize
(
*
parse_result
.
result_tree_
,
*
parse_result
.
result_tree_
,
question_mark_count
,
no_check_type_offsets
,
not_param_offsets
)))
{
question_mark_count
,
no_check_type_offsets
,
need_check_type_param_offsets
,
not_param_offsets
)))
{
LOG_WARN
(
"invalid argument"
,
K
(
ret
),
KP
(
parse_result
.
result_tree_
));
LOG_WARN
(
"invalid argument"
,
K
(
ret
),
KP
(
parse_result
.
result_tree_
));
}
else
if
(
OB_FAIL
(
construct_not_paramalize
(
not_param_offsets
,
pctx
->
get_param_store
(),
pc_ctx
)))
{
}
else
if
(
OB_FAIL
(
construct_not_paramalize
(
not_param_offsets
,
pctx
->
get_param_store
(),
pc_ctx
)))
{
LOG_WARN
(
"construct not paramalize failed"
,
K
(
ret
));
LOG_WARN
(
"construct not paramalize failed"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
construct_no_check_type_params
(
no_check_type_offsets
,
pctx
->
get_param_store_for_update
())))
{
}
else
if
(
OB_FAIL
(
construct_no_check_type_params
(
no_check_type_offsets
,
need_check_type_param_offsets
,
pctx
->
get_param_store_for_update
())))
{
LOG_WARN
(
"construct no check type params failed"
,
K
(
ret
));
LOG_WARN
(
"construct no check type params failed"
,
K
(
ret
));
}
else
{
}
else
{
parse_result
.
question_mark_ctx_
.
count_
=
static_cast
<
int
>
(
question_mark_count
);
parse_result
.
question_mark_ctx_
.
count_
=
static_cast
<
int
>
(
question_mark_count
);
...
...
src/sql/ob_sql.h
浏览文件 @
649a2dc6
...
@@ -191,7 +191,9 @@ public:
...
@@ -191,7 +191,9 @@ public:
static
int
construct_not_paramalize
(
static
int
construct_not_paramalize
(
const
ObIArray
<
int64_t
>&
offsets
,
const
ParamStore
&
param_store
,
ObPlanCacheCtx
&
plan_ctx
);
const
ObIArray
<
int64_t
>&
offsets
,
const
ParamStore
&
param_store
,
ObPlanCacheCtx
&
plan_ctx
);
static
int
construct_no_check_type_params
(
const
ObIArray
<
int64_t
>&
offsets
,
ParamStore
&
param_store
);
static
int
construct_no_check_type_params
(
const
ObIArray
<
int64_t
>&
offsets
,
const
ObBitSet
<>
&
need_check_type_offsets
,
ParamStore
&
param_store
);
static
int
construct_ps_param
(
const
ParamStore
&
params
,
ObPlanCacheCtx
&
phy_ctx
);
static
int
construct_ps_param
(
const
ParamStore
&
params
,
ObPlanCacheCtx
&
phy_ctx
);
storage
::
ObPartitionService
*
get_partition_service
()
const
storage
::
ObPartitionService
*
get_partition_service
()
const
...
...
src/sql/plan_cache/ob_ps_sql_utils.cpp
浏览文件 @
649a2dc6
...
@@ -35,8 +35,8 @@ int ObPsSqlUtils::deep_copy_str(common::ObIAllocator& allocator, const common::O
...
@@ -35,8 +35,8 @@ int ObPsSqlUtils::deep_copy_str(common::ObIAllocator& allocator, const common::O
return
ret
;
return
ret
;
}
}
int
ObPsSqlParamHelper
::
find_special_paramalize
(
const
ParseNode
&
parse_node
,
int64_t
&
question_mark_count
,
int
ObPsSqlParamHelper
::
find_special_paramalize
(
const
ParseNode
&
parse_node
,
int64_t
&
question_mark_count
,
ObIArray
<
int64_t
>
&
no_check_type_offsets
,
ObIArray
<
int64_t
>&
not_param_offsets
)
ObIArray
<
int64_t
>
&
no_check_type_offsets
,
ObBitSet
<>
&
need_check_type_offsets
,
ObIArray
<
int64_t
>
&
not_param_offsets
)
{
{
int
ret
=
OB_SUCCESS
;
int
ret
=
OB_SUCCESS
;
TraverseContext
ctx
;
TraverseContext
ctx
;
...
@@ -44,7 +44,7 @@ int ObPsSqlParamHelper::find_special_paramalize(const ParseNode& parse_node, int
...
@@ -44,7 +44,7 @@ int ObPsSqlParamHelper::find_special_paramalize(const ParseNode& parse_node, int
question_mark_count
=
0
;
question_mark_count
=
0
;
SQL_PC_LOG
(
DEBUG
,
"traverse syntax tree for ps mode"
,
"result_tree"
,
SJ
(
ObParserResultPrintWrapper
(
parse_node
)));
SQL_PC_LOG
(
DEBUG
,
"traverse syntax tree for ps mode"
,
"result_tree"
,
SJ
(
ObParserResultPrintWrapper
(
parse_node
)));
if
(
OB_FAIL
(
traverse
(
ctx
,
no_check_type_offsets
,
not_param_offsets
)))
{
if
(
OB_FAIL
(
traverse
(
ctx
,
no_check_type_offsets
,
n
eed_check_type_offsets
,
n
ot_param_offsets
)))
{
LOG_WARN
(
"traverse node failed"
,
K
(
ret
));
LOG_WARN
(
"traverse node failed"
,
K
(
ret
));
}
else
{
}
else
{
question_mark_count
=
ctx
.
question_marks_
.
num_members
();
question_mark_count
=
ctx
.
question_marks_
.
num_members
();
...
@@ -58,8 +58,10 @@ int ObPsSqlParamHelper::find_special_paramalize(const ParseNode& parse_node, int
...
@@ -58,8 +58,10 @@ int ObPsSqlParamHelper::find_special_paramalize(const ParseNode& parse_node, int
// return bret;
// return bret;
//}
//}
int
ObPsSqlParamHelper
::
traverse
(
// TODO: 这里目前比较受限,只能判断是否对整个表达式的子节点是否not param
TraverseContext
&
ctx
,
ObIArray
<
int64_t
>&
no_check_type_offsets
,
ObIArray
<
int64_t
>&
not_param_offsets
)
// 应该按照ObSqlParameterization::mark_tree()的方式来做
int
ObPsSqlParamHelper
::
traverse
(
TraverseContext
&
ctx
,
ObIArray
<
int64_t
>
&
no_check_type_offsets
,
ObBitSet
<>
&
need_check_type_offsets
,
ObIArray
<
int64_t
>
&
not_param_offsets
)
{
{
int
ret
=
OB_SUCCESS
;
int
ret
=
OB_SUCCESS
;
bool
is_overflow
=
false
;
bool
is_overflow
=
false
;
...
@@ -87,13 +89,18 @@ int ObPsSqlParamHelper::traverse(
...
@@ -87,13 +89,18 @@ int ObPsSqlParamHelper::traverse(
LOG_INFO
(
"pushback offset success"
,
K
(
ctx
));
LOG_INFO
(
"pushback offset success"
,
K
(
ctx
));
}
}
}
}
if
(
OB_SUCC
(
ret
)
&&
INSERT_VALUE_VECTOR_CHILD_LEVEL
==
ctx
.
insert_vector_level_
)
{
if
(
OB_FAIL
(
ret
))
{
}
else
if
(
INSERT_VALUE_VECTOR_CHILD_LEVEL
==
ctx
.
insert_vector_level_
)
{
// insert values (?, ?), ? do not need check type
// insert values (?, ?), ? do not need check type
if
(
OB_FAIL
(
no_check_type_offsets
.
push_back
(
parent
.
value_
)))
{
if
(
OB_FAIL
(
no_check_type_offsets
.
push_back
(
parent
.
value_
)))
{
LOG_WARN
(
"failed to push back element"
,
K
(
ret
));
LOG_WARN
(
"failed to push back element"
,
K
(
ret
));
}
else
{
}
else
{
LOG_DEBUG
(
"pushback offset success"
,
K
(
ret
),
K
(
parent
.
value_
));
LOG_DEBUG
(
"pushback offset success"
,
K
(
ret
),
K
(
parent
.
value_
));
}
}
}
else
{
if
(
OB_FAIL
(
need_check_type_offsets
.
add_member
(
parent
.
value_
)))
{
LOG_WARN
(
"failed to add member"
,
K
(
parent
.
value_
));
}
}
}
if
(
OB_SUCC
(
ret
))
{
if
(
OB_SUCC
(
ret
))
{
if
(
OB_FAIL
(
ctx
.
question_marks_
.
add_member
(
parent
.
value_
)))
{
if
(
OB_FAIL
(
ctx
.
question_marks_
.
add_member
(
parent
.
value_
)))
{
...
@@ -124,7 +131,7 @@ int ObPsSqlParamHelper::traverse(
...
@@ -124,7 +131,7 @@ int ObPsSqlParamHelper::traverse(
ctx
.
is_child_not_param_
=
true
;
ctx
.
is_child_not_param_
=
true
;
}
}
ctx
.
node_
=
parent
.
children_
[
i
];
ctx
.
node_
=
parent
.
children_
[
i
];
if
(
OB_FAIL
(
traverse
(
ctx
,
no_check_type_offsets
,
not_param_offsets
)))
{
if
(
OB_FAIL
(
traverse
(
ctx
,
no_check_type_offsets
,
n
eed_check_type_offsets
,
n
ot_param_offsets
)))
{
LOG_WARN
(
"visit child node failed"
,
K
(
i
));
LOG_WARN
(
"visit child node failed"
,
K
(
i
));
}
}
}
}
...
...
src/sql/plan_cache/ob_ps_sql_utils.h
浏览文件 @
649a2dc6
...
@@ -98,13 +98,14 @@ public:
...
@@ -98,13 +98,14 @@ public:
{}
{}
// find param that should no be paramalize
// find param that should no be paramalize
int
find_special_paramalize
(
const
ParseNode
&
parse_node
,
int64_t
&
question_mark_count
,
int
find_special_paramalize
(
const
ParseNode
&
parse_node
,
int64_t
&
question_mark_count
,
common
::
ObIArray
<
int64_t
>&
no_check_type_offsets
,
common
::
ObIArray
<
int64_t
>&
not_param_offsets
);
common
::
ObIArray
<
int64_t
>
&
no_check_type_offsets
,
common
::
ObBitSet
<>
&
need_check_type_offsets
,
common
::
ObIArray
<
int64_t
>
&
not_param_offsets
);
private:
private:
static
const
int64_t
INSERT_VALUE_VECTOR_CHILD_LEVEL
=
1
;
static
const
int64_t
INSERT_VALUE_VECTOR_CHILD_LEVEL
=
1
;
int
traverse
(
TraverseContext
&
ctx
,
common
::
ObIArray
<
int64_t
>&
no_check_type_offsets
,
int
traverse
(
TraverseContext
&
ctx
,
common
::
ObIArray
<
int64_t
>
&
no_check_type_offsets
,
common
::
Ob
IArray
<
int64_t
>&
not_param_offsets
);
common
::
Ob
BitSet
<>
&
need_check_type_offsets
,
common
::
ObIArray
<
int64_t
>
&
not_param_offsets
);
private:
private:
DISALLOW_COPY_AND_ASSIGN
(
ObPsSqlParamHelper
);
DISALLOW_COPY_AND_ASSIGN
(
ObPsSqlParamHelper
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录