[CP] [to #53512507]fixed cursor exec param in process_record
This commit is contained in:
@ -516,7 +516,8 @@ int ObInnerSQLConnection::process_record(sql::ObResultSet &result_set,
|
|||||||
ObExecTimestamp &exec_timestamp,
|
ObExecTimestamp &exec_timestamp,
|
||||||
bool has_tenant_resource,
|
bool has_tenant_resource,
|
||||||
const ObString &ps_sql,
|
const ObString &ps_sql,
|
||||||
bool is_from_pl)
|
bool is_from_pl,
|
||||||
|
ObString *pl_exec_params)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
const bool enable_perf_event = lib::is_diagnose_info_enabled();
|
const bool enable_perf_event = lib::is_diagnose_info_enabled();
|
||||||
@ -545,10 +546,9 @@ int ObInnerSQLConnection::process_record(sql::ObResultSet &result_set,
|
|||||||
if (enable_sql_audit) {
|
if (enable_sql_audit) {
|
||||||
ret = process_audit_record(result_set, sql_ctx, session, last_ret, execution_id,
|
ret = process_audit_record(result_set, sql_ctx, session, last_ret, execution_id,
|
||||||
ps_stmt_id, has_tenant_resource, ps_sql, is_from_pl);
|
ps_stmt_id, has_tenant_resource, ps_sql, is_from_pl);
|
||||||
if (is_from_pl && NULL != result_set.get_exec_context().get_physical_plan_ctx()) {
|
if (NULL != pl_exec_params) {
|
||||||
ObMPStmtExecute::store_params_value_to_str(alloc, session,
|
audit_record.params_value_ = pl_exec_params->ptr();
|
||||||
&result_set.get_exec_context().get_physical_plan_ctx()->get_param_store_for_update(),
|
audit_record.params_value_len_ = pl_exec_params->length();
|
||||||
audit_record.params_value_, audit_record.params_value_len_);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ObSQLUtils::handle_audit_record(false, sql::PSCursor == audit_record.exec_timestamp_.exec_type_
|
ObSQLUtils::handle_audit_record(false, sql::PSCursor == audit_record.exec_timestamp_.exec_type_
|
||||||
|
|||||||
@ -286,7 +286,8 @@ public:
|
|||||||
sql::ObExecTimestamp &exec_timestamp,
|
sql::ObExecTimestamp &exec_timestamp,
|
||||||
bool has_tenant_resource,
|
bool has_tenant_resource,
|
||||||
const ObString &ps_sql,
|
const ObString &ps_sql,
|
||||||
bool is_from_pl = false);
|
bool is_from_pl = false,
|
||||||
|
ObString *pl_exec_params = NULL);
|
||||||
static int process_audit_record(sql::ObResultSet &result_set,
|
static int process_audit_record(sql::ObResultSet &result_set,
|
||||||
sql::ObSqlCtx &sql_ctx,
|
sql::ObSqlCtx &sql_ctx,
|
||||||
sql::ObSQLSessionInfo &session,
|
sql::ObSQLSessionInfo &session,
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
#include "observer/ob_server_struct.h"
|
#include "observer/ob_server_struct.h"
|
||||||
#include "observer/mysql/ob_query_retry_ctrl.h"
|
#include "observer/mysql/ob_query_retry_ctrl.h"
|
||||||
#include "observer/mysql/ob_sync_cmd_driver.h"
|
#include "observer/mysql/ob_sync_cmd_driver.h"
|
||||||
|
#include "observer/mysql/obmp_stmt_execute.h"
|
||||||
#include "sql/parser/ob_parser.h"
|
#include "sql/parser/ob_parser.h"
|
||||||
#include "sql/resolver/expr/ob_raw_expr_util.h"
|
#include "sql/resolver/expr/ob_raw_expr_util.h"
|
||||||
#include "sql/resolver/ob_stmt_resolver.h"
|
#include "sql/resolver/ob_stmt_resolver.h"
|
||||||
@ -1728,7 +1729,8 @@ int ObSPIService::spi_inner_execute(ObPLExecCtx *ctx,
|
|||||||
exec_timestamp,
|
exec_timestamp,
|
||||||
true,
|
true,
|
||||||
sql != NULL ? sql : ps_sql,
|
sql != NULL ? sql : ps_sql,
|
||||||
true);
|
true,
|
||||||
|
spi_result.get_exec_params_str_ptr());
|
||||||
session_info->get_raw_audit_record().exec_record_ = record_bk;
|
session_info->get_raw_audit_record().exec_record_ = record_bk;
|
||||||
session_info->get_raw_audit_record().try_cnt_ = try_cnt;
|
session_info->get_raw_audit_record().try_cnt_ = try_cnt;
|
||||||
} else {
|
} else {
|
||||||
@ -1952,7 +1954,8 @@ int ObSPIService::dbms_cursor_execute(ObPLExecCtx *ctx,
|
|||||||
exec_timestamp,
|
exec_timestamp,
|
||||||
true,
|
true,
|
||||||
ps_sql,
|
ps_sql,
|
||||||
true);
|
true,
|
||||||
|
spi_result.get_exec_params_str_ptr());
|
||||||
} else {
|
} else {
|
||||||
LOG_DEBUG("result set is not inited, do not process record",
|
LOG_DEBUG("result set is not inited, do not process record",
|
||||||
K(ret), K(ps_sql), K(sql_stmt), K(stmt_type));
|
K(ret), K(ps_sql), K(sql_stmt), K(stmt_type));
|
||||||
@ -2928,7 +2931,8 @@ int ObSPIService::spi_execute_immediate(ObPLExecCtx *ctx,
|
|||||||
exec_timestamp,
|
exec_timestamp,
|
||||||
true,
|
true,
|
||||||
0 == param_count ? sql_str.string() : ps_sql,
|
0 == param_count ? sql_str.string() : ps_sql,
|
||||||
true);
|
true,
|
||||||
|
spi_result.get_exec_params_str_ptr());
|
||||||
session->get_raw_audit_record().exec_record_ = record_bk;
|
session->get_raw_audit_record().exec_record_ = record_bk;
|
||||||
session->get_raw_audit_record().try_cnt_ = try_cnt;
|
session->get_raw_audit_record().try_cnt_ = try_cnt;
|
||||||
} else {
|
} else {
|
||||||
@ -3773,6 +3777,8 @@ int ObSPIService::dbms_cursor_open(ObPLExecCtx *ctx,
|
|||||||
exec_timestamp.exec_type_ = cursor.is_ps_cursor() ? sql::PSCursor : sql::DbmsCursor;
|
exec_timestamp.exec_type_ = cursor.is_ps_cursor() ? sql::PSCursor : sql::DbmsCursor;
|
||||||
ObWaitEventDesc max_wait_desc;
|
ObWaitEventDesc max_wait_desc;
|
||||||
ObWaitEventStat total_wait_desc;
|
ObWaitEventStat total_wait_desc;
|
||||||
|
ObArenaAllocator exec_param_alloc;
|
||||||
|
ObString exec_param_str;
|
||||||
const bool enable_perf_event = lib::is_diagnose_info_enabled();
|
const bool enable_perf_event = lib::is_diagnose_info_enabled();
|
||||||
const bool enable_sql_audit = GCONF.enable_sql_audit
|
const bool enable_sql_audit = GCONF.enable_sql_audit
|
||||||
&& ctx->exec_ctx_->get_my_session()->get_local_ob_enable_sql_audit();
|
&& ctx->exec_ctx_->get_my_session()->get_local_ob_enable_sql_audit();
|
||||||
@ -3804,6 +3810,17 @@ int ObSPIService::dbms_cursor_open(ObPLExecCtx *ctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (OB_SUCC(ret) && exec_params.count() > 0) {
|
||||||
|
char *tmp_ptr = NULL;
|
||||||
|
int64_t tmp_len = 0;
|
||||||
|
OZ (ObMPStmtExecute::store_params_value_to_str(exec_param_alloc,
|
||||||
|
*session,
|
||||||
|
&exec_params,
|
||||||
|
tmp_ptr,
|
||||||
|
tmp_len));
|
||||||
|
OX (exec_param_str.assign(tmp_ptr, tmp_len));
|
||||||
|
}
|
||||||
|
|
||||||
if (OB_FAIL(ret)) {
|
if (OB_FAIL(ret)) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else if (!for_update && use_stream) {
|
} else if (!for_update && use_stream) {
|
||||||
@ -3916,7 +3933,8 @@ int ObSPIService::dbms_cursor_open(ObPLExecCtx *ctx,
|
|||||||
exec_timestamp,
|
exec_timestamp,
|
||||||
true,
|
true,
|
||||||
(exec_params.count() > 0 || cursor.is_ps_cursor()) ? ps_sql : sql_str,
|
(exec_params.count() > 0 || cursor.is_ps_cursor()) ? ps_sql : sql_str,
|
||||||
true);
|
true,
|
||||||
|
&exec_param_str);
|
||||||
session_info->get_raw_audit_record().exec_record_ = record_bk;
|
session_info->get_raw_audit_record().exec_record_ = record_bk;
|
||||||
session_info->get_raw_audit_record().try_cnt_ = try_cnt;
|
session_info->get_raw_audit_record().try_cnt_ = try_cnt;
|
||||||
}
|
}
|
||||||
@ -4021,7 +4039,8 @@ int ObSPIService::dbms_cursor_open(ObPLExecCtx *ctx,
|
|||||||
exec_timestamp,
|
exec_timestamp,
|
||||||
true,
|
true,
|
||||||
(exec_params.count() > 0 || cursor.is_ps_cursor()) ? ps_sql : sql_str,
|
(exec_params.count() > 0 || cursor.is_ps_cursor()) ? ps_sql : sql_str,
|
||||||
true);
|
true,
|
||||||
|
&exec_param_str);
|
||||||
session_info->get_raw_audit_record().exec_record_ = record_bk;
|
session_info->get_raw_audit_record().exec_record_ = record_bk;
|
||||||
session_info->get_raw_audit_record().try_cnt_ = retry_cnt;
|
session_info->get_raw_audit_record().try_cnt_ = retry_cnt;
|
||||||
}
|
}
|
||||||
@ -4248,7 +4267,8 @@ int ObSPIService::do_cursor_fetch(ObPLExecCtx *ctx,
|
|||||||
exec_timestamp,
|
exec_timestamp,
|
||||||
true,
|
true,
|
||||||
ObString(),
|
ObString(),
|
||||||
true);
|
true,
|
||||||
|
spi_result->get_exec_params_str_ptr());
|
||||||
session_info->get_raw_audit_record().exec_record_ = record_bk;
|
session_info->get_raw_audit_record().exec_record_ = record_bk;
|
||||||
session_info->get_raw_audit_record().try_cnt_ = try_cnt;
|
session_info->get_raw_audit_record().try_cnt_ = try_cnt;
|
||||||
}
|
}
|
||||||
@ -6323,6 +6343,20 @@ int ObSPIService::inner_open(ObPLExecCtx *ctx,
|
|||||||
OZ (construct_exec_params(ctx, param_allocator, param_exprs, param_count,
|
OZ (construct_exec_params(ctx, param_allocator, param_exprs, param_count,
|
||||||
into_exprs, into_count, exec_params, out_params, is_forall),
|
into_exprs, into_count, exec_params, out_params, is_forall),
|
||||||
K(sql), K(type), K(param_count), K(out_params), K(exec_params));
|
K(sql), K(type), K(param_count), K(out_params), K(exec_params));
|
||||||
|
if (OB_SUCC(ret)
|
||||||
|
&& OB_NOT_NULL(ctx)
|
||||||
|
&& OB_NOT_NULL(ctx->exec_ctx_)
|
||||||
|
&& OB_NOT_NULL(ctx->exec_ctx_->get_my_session())) {
|
||||||
|
// add exec_param_info for sql_audit
|
||||||
|
char *tmp_ptr = NULL;
|
||||||
|
int64_t tmp_len = 0;
|
||||||
|
OZ (ObMPStmtExecute::store_params_value_to_str(spi_result.get_allocaor(),
|
||||||
|
*ctx->exec_ctx_->get_my_session(),
|
||||||
|
&exec_params,
|
||||||
|
tmp_ptr,
|
||||||
|
tmp_len));
|
||||||
|
OX (spi_result.get_exec_params_str_ptr()->assign(tmp_ptr, tmp_len));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OB_SUCC(ret) && is_forall) {
|
if (OB_SUCC(ret) && is_forall) {
|
||||||
|
|||||||
@ -126,7 +126,8 @@ public:
|
|||||||
orign_session_value_(NULL),
|
orign_session_value_(NULL),
|
||||||
cursor_session_value_(NULL),
|
cursor_session_value_(NULL),
|
||||||
nested_session_value_(NULL),
|
nested_session_value_(NULL),
|
||||||
out_params_() {
|
out_params_(),
|
||||||
|
exec_params_str_() {
|
||||||
}
|
}
|
||||||
~ObSPIResultSet() { reset(); }
|
~ObSPIResultSet() { reset(); }
|
||||||
int init(sql::ObSQLSessionInfo &session_info);
|
int init(sql::ObSQLSessionInfo &session_info);
|
||||||
@ -157,8 +158,8 @@ public:
|
|||||||
cursor_session_value_ = NULL;
|
cursor_session_value_ = NULL;
|
||||||
nested_session_value_ = NULL;
|
nested_session_value_ = NULL;
|
||||||
out_params_.reset();
|
out_params_.reset();
|
||||||
|
exec_params_str_.reset();
|
||||||
allocator_.reset();
|
allocator_.reset();
|
||||||
|
|
||||||
is_inited_ = false;
|
is_inited_ = false;
|
||||||
}
|
}
|
||||||
void reset_member_for_retry(sql::ObSQLSessionInfo &session_info)
|
void reset_member_for_retry(sql::ObSQLSessionInfo &session_info)
|
||||||
@ -167,6 +168,7 @@ public:
|
|||||||
result_set_->~ObResultSet();
|
result_set_->~ObResultSet();
|
||||||
}
|
}
|
||||||
sql_ctx_.reset();
|
sql_ctx_.reset();
|
||||||
|
exec_params_str_.reset();
|
||||||
//allocator_.reset();
|
//allocator_.reset();
|
||||||
mem_context_->get_arena_allocator().reset();
|
mem_context_->get_arena_allocator().reset();
|
||||||
result_set_ = new (buf_) ObResultSet(session_info, mem_context_->get_arena_allocator());
|
result_set_ = new (buf_) ObResultSet(session_info, mem_context_->get_arena_allocator());
|
||||||
@ -212,6 +214,7 @@ public:
|
|||||||
void end_cursor_stmt(pl::ObPLExecCtx *pl_ctx, int &result);
|
void end_cursor_stmt(pl::ObPLExecCtx *pl_ctx, int &result);
|
||||||
int start_nested_stmt_if_need(pl::ObPLExecCtx *pl_ctx, const ObString &sql, stmt::StmtType stmt_type, bool for_update);
|
int start_nested_stmt_if_need(pl::ObPLExecCtx *pl_ctx, const ObString &sql, stmt::StmtType stmt_type, bool for_update);
|
||||||
void end_nested_stmt_if_need(pl::ObPLExecCtx *pl_ctx, int &result);
|
void end_nested_stmt_if_need(pl::ObPLExecCtx *pl_ctx, int &result);
|
||||||
|
ObString *get_exec_params_str_ptr() { return &exec_params_str_; }
|
||||||
private:
|
private:
|
||||||
bool is_inited_;
|
bool is_inited_;
|
||||||
EndStmtType need_end_nested_stmt_;
|
EndStmtType need_end_nested_stmt_;
|
||||||
@ -232,6 +235,7 @@ private:
|
|||||||
sql::ObSQLSessionInfo::StmtSavedValue *cursor_session_value_;
|
sql::ObSQLSessionInfo::StmtSavedValue *cursor_session_value_;
|
||||||
sql::ObSQLSessionInfo::StmtSavedValue *nested_session_value_;
|
sql::ObSQLSessionInfo::StmtSavedValue *nested_session_value_;
|
||||||
ObSPIOutParams out_params_; // 用于记录function的返回值
|
ObSPIOutParams out_params_; // 用于记录function的返回值
|
||||||
|
ObString exec_params_str_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ObSPIService
|
class ObSPIService
|
||||||
|
|||||||
Reference in New Issue
Block a user