Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
大炮V587
oceanbase
提交
cd043fb8
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,发现更多精彩内容 >>
提交
cd043fb8
编写于
2月 06, 2023
作者:
O
obdev
提交者:
ob-robot
2月 06, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add params value for text ps in sql audit
上级
99db3122
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
52 addition
and
3 deletion
+52
-3
src/observer/mysql/obmp_query.cpp
src/observer/mysql/obmp_query.cpp
+41
-2
src/observer/mysql/obmp_query.h
src/observer/mysql/obmp_query.h
+5
-0
src/sql/ob_result_set.h
src/sql/ob_result_set.h
+4
-1
src/sql/ob_sql.cpp
src/sql/ob_sql.cpp
+2
-0
未找到文件。
src/observer/mysql/obmp_query.cpp
浏览文件 @
cd043fb8
...
...
@@ -74,7 +74,9 @@ ObMPQuery::ObMPQuery(const ObGlobalContext &gctx)
single_process_timestamp_
(
0
),
exec_start_timestamp_
(
0
),
exec_end_timestamp_
(
0
),
is_com_filed_list_
(
false
)
is_com_filed_list_
(
false
),
params_value_len_
(
0
),
params_value_
(
NULL
)
{
ctx_
.
exec_type_
=
MpQuery
;
}
...
...
@@ -717,7 +719,8 @@ OB_INLINE int ObMPQuery::do_process(ObSQLSessionInfo &session,
ObSqlFatalErrExtraInfoGuard
extra_info_guard
;
extra_info_guard
.
set_cur_sql
(
sql
);
extra_info_guard
.
set_tenant_id
(
session
.
get_effective_tenant_id
());
SMART_VAR
(
ObMySQLResultSet
,
result
,
session
,
CURRENT_CONTEXT
->
get_arena_allocator
())
{
ObIAllocator
&
allocator
=
CURRENT_CONTEXT
->
get_arena_allocator
();
SMART_VAR
(
ObMySQLResultSet
,
result
,
session
,
allocator
)
{
if
(
OB_FAIL
(
get_tenant_schema_info_
(
session
.
get_effective_tenant_id
(),
&
cached_schema_info
,
schema_guard
,
...
...
@@ -951,6 +954,10 @@ OB_INLINE int ObMPQuery::do_process(ObSQLSessionInfo &session,
audit_record
.
is_multi_stmt_
=
session
.
get_capability
().
cap_flags_
.
OB_CLIENT_MULTI_STATEMENTS
;
audit_record
.
is_batched_multi_stmt_
=
ctx_
.
multi_stmt_item_
.
is_batched_multi_stmt
();
OZ
(
store_params_value_to_str
(
allocator
,
session
,
result
.
get_ps_params
()));
audit_record
.
params_value_
=
params_value_
;
audit_record
.
params_value_len_
=
params_value_len_
;
ObPhysicalPlanCtx
*
plan_ctx
=
result
.
get_exec_context
().
get_physical_plan_ctx
();
if
(
OB_ISNULL
(
plan_ctx
))
{
//do nothing
...
...
@@ -1004,6 +1011,38 @@ OB_INLINE int ObMPQuery::do_process(ObSQLSessionInfo &session,
return
ret
;
}
int
ObMPQuery
::
store_params_value_to_str
(
ObIAllocator
&
allocator
,
sql
::
ObSQLSessionInfo
&
session
,
common
::
ParamStore
&
params
)
{
int
ret
=
OB_SUCCESS
;
int64_t
pos
=
0
;
int64_t
length
=
OB_MAX_SQL_LENGTH
;
CK
(
OB_NOT_NULL
(
params_value_
=
static_cast
<
char
*>
(
allocator
.
alloc
(
OB_MAX_SQL_LENGTH
))));
for
(
int64_t
i
=
0
;
OB_SUCC
(
ret
)
&&
i
<
params
.
count
();
++
i
)
{
const
common
::
ObObjParam
&
param
=
params
.
at
(
i
);
if
(
param
.
is_ext
())
{
pos
=
0
;
params_value_
=
NULL
;
params_value_len_
=
0
;
break
;
}
else
{
OZ
(
param
.
print_sql_literal
(
params_value_
,
length
,
pos
,
allocator
,
TZ_INFO
(
&
session
)));
if
(
i
!=
params
.
count
()
-
1
)
{
OZ
(
databuff_printf
(
params_value_
,
length
,
pos
,
allocator
,
","
));
}
}
}
if
(
OB_FAIL
(
ret
))
{
params_value_
=
NULL
;
params_value_len_
=
0
;
ret
=
OB_SUCCESS
;
}
else
{
params_value_len_
=
pos
;
}
return
ret
;
}
//int ObMPQuery::fill_feedback_session_info(ObMySQLResultSet &result,
// ObSQLSessionInfo &session)
//{
...
...
src/observer/mysql/obmp_query.h
浏览文件 @
cd043fb8
...
...
@@ -106,6 +106,9 @@ private:
bool
&
need_disconnect
,
bool
is_ins_multi_val_opt
);
int
deserialize_com_field_list
();
int
store_params_value_to_str
(
ObIAllocator
&
allocator
,
sql
::
ObSQLSessionInfo
&
session
,
common
::
ParamStore
&
params
);
private:
DISALLOW_COPY_AND_ASSIGN
(
ObMPQuery
);
private:
...
...
@@ -119,6 +122,8 @@ private:
//由于mysql的COM_FIELD_LIST命令本质上就是获取列的定义信息,只需要返回列定义
bool
is_com_filed_list_
;
common
::
ObString
wild_str_
;
//used to save wildware string in COM_FIELD_LIST
int64_t
params_value_len_
;
char
*
params_value_
;
};
// end of class ObMPQuery
}
// end of namespace observer
}
// end of namespace oceanbase
...
...
src/sql/ob_result_set.h
浏览文件 @
cd043fb8
...
...
@@ -316,6 +316,7 @@ public:
bool
get_is_com_filed_list
()
{
return
is_com_filed_list_
;
}
void
set_wildcard_string
(
common
::
ObString
string
)
{
wild_str_
=
string
;
}
common
::
ObString
&
get_wildcard_string
()
{
return
wild_str_
;}
common
::
ParamStore
&
get_ps_params
()
{
return
ps_params_
;
}
static
void
replace_lob_type
(
const
ObSQLSessionInfo
&
session
,
const
ObField
&
field
,
obmysql
::
ObMySQLField
&
mfield
);
...
...
@@ -427,6 +428,7 @@ private:
common
::
ObString
wild_str_
;
//uesd to save filed wildcard in COM_FIELD_LIST;
common
::
ObString
ps_sql_
;
// for sql in pl
bool
is_init_
;
common
::
ParamStore
ps_params_
;
// 文本 ps params 记录,用于填入 sql_audit
};
...
...
@@ -500,7 +502,8 @@ inline ObResultSet::ObResultSet(ObSQLSessionInfo &session, common::ObIAllocator
need_revert_tx_
(
false
),
wild_str_
(),
ps_sql_
(),
is_init_
(
false
)
is_init_
(
false
),
ps_params_
(
ObWrapperAllocator
(
&
allocator
))
{
message_
[
0
]
=
'\0'
;
// Always called in the ObResultSet constructor
...
...
src/sql/ob_sql.cpp
浏览文件 @
cd043fb8
...
...
@@ -4884,6 +4884,8 @@ int ObSql::handle_text_execute(const ObStmt *basic_stmt,
result
,
false
/*is_inner_sql*/
)))
{
LOG_WARN
(
"ps execute failed"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
construct_param_store
(
param_store
,
result
.
get_ps_params
())))
{
LOG_WARN
(
"construct ps params failed"
,
K
(
ret
));
}
}
LOG_DEBUG
(
"handle text execute done"
,
K
(
ret
),
KPC
(
exec_stmt
),
K
(
param_store
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录