Add params value for text ps in sql audit
This commit is contained in:
parent
99db3122b5
commit
cd043fb8d0
@ -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 ¶ms)
|
||||
{
|
||||
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 ¶m = 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)
|
||||
//{
|
||||
|
@ -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 ¶ms);
|
||||
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
|
||||
|
@ -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
|
||||
|
@ -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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user