提交 a4d3ae7d 编写于 作者: L leslieyuchen 提交者: LINGuanRen

fix print remote sql info coredump

上级 58698cf4
......@@ -21,12 +21,37 @@
#include "sql/engine/ob_exec_context.h"
#include "sql/engine/ob_physical_plan.h"
#include "sql/engine/px/ob_dfo.h"
#include "lib/utility/ob_print_utils.h"
namespace oceanbase {
using namespace common;
using namespace share;
using namespace transaction;
namespace sql {
ObPhysicalPlanCtx::ObPhysicalPlanCtx(common::ObIAllocator& allocator)
DEF_TO_STRING(ObRemoteSqlInfo)
{
int64_t pos = 0;
J_OBJ_START();
J_KV(K_(use_ps), K_(is_batched_stmt), K_(ps_param_cnt), K_(remote_sql));
J_COMMA();
J_NAME("ps_params");
J_COLON();
if (OB_ISNULL(ps_params_) || ps_param_cnt_ <= 0) {
J_NULL();
} else {
J_ARRAY_START();
for (int64_t i = 0; pos < buf_len && i < ps_param_cnt_; ++i) {
BUF_PRINTO(ps_params_->at(i));
if (i != ps_param_cnt_ - 1) {
J_COMMA();
}
}
J_ARRAY_END();
}
J_OBJ_END();
return pos;
}
ObPhysicalPlanCtx::ObPhysicalPlanCtx(common::ObIAllocator &allocator)
: allocator_(allocator),
tenant_id_(OB_INVALID_ID),
tsc_snapshot_timestamp_(0),
......
......@@ -43,13 +43,14 @@ typedef common::ObFixedArray<PartParamIdxArray, common::ObIAllocator> BatchParam
typedef common::ObFixedArray<ObImplicitCursorInfo, common::ObIAllocator> ImplicitCursorInfoArray;
struct ObRemoteSqlInfo {
ObRemoteSqlInfo() : use_ps_(false), is_batched_stmt_(false), remote_sql_(), ps_params_(nullptr)
ObRemoteSqlInfo() : use_ps_(false), is_batched_stmt_(false), ps_param_cnt_(0), remote_sql_(), ps_params_(nullptr)
{}
TO_STRING_KV(K_(use_ps), K_(is_batched_stmt), K_(remote_sql), KPC_(ps_params));
DECLARE_TO_STRING;
bool use_ps_;
bool is_batched_stmt_;
int32_t ps_param_cnt_;
common::ObString remote_sql_;
ParamStore* ps_params_;
};
......
......@@ -684,6 +684,7 @@ OB_DEF_DESERIALIZE(ObRemoteTask)
*ps_params,
tenant_id);
if (OB_SUCC(ret)) {
remote_sql_info_->ps_param_cnt_ = static_cast<int32_t>(ps_params->count());
if (OB_FAIL(exec_ctx_->create_my_session(tenant_id))) {
LOG_WARN("create my session failed", K(ret), K(tenant_id));
} else {
......
......@@ -3066,6 +3066,7 @@ int ObSql::after_get_plan(ObPlanCacheCtx &pc_ctx, ObSQLSessionInfo &session, ObP
pctx->get_remote_sql_info().use_ps_ = true;
pctx->get_remote_sql_info().remote_sql_ = pc_ctx.sql_ctx_.cur_sql_;
pctx->get_remote_sql_info().ps_params_ = &param_store;
pctx->get_remote_sql_info().ps_param_cnt_ = static_cast<int32_t>(param_store.count());
} else if (phy_plan->temp_sql_can_prepare() && pc_ctx.neg_param_index_.is_empty() &&
!pc_ctx.sql_ctx_.multi_stmt_item_.is_batched_multi_stmt()) {
LOG_DEBUG("after get plan",
......@@ -3079,6 +3080,7 @@ int ObSql::after_get_plan(ObPlanCacheCtx &pc_ctx, ObSQLSessionInfo &session, ObP
pctx->get_remote_sql_info().use_ps_ = true;
pctx->get_remote_sql_info().remote_sql_ = phy_plan->get_constructed_sql();
pctx->get_remote_sql_info().ps_params_ = &param_store;
pctx->get_remote_sql_info().ps_param_cnt_ = static_cast<int32_t>(param_store.count());
} else {
param_store.reset();
pctx->get_remote_sql_info().use_ps_ = false;
......
......@@ -108,9 +108,6 @@ int ObSQLUtils::md5(const ObString& stmt, char* sql_id, int32_t len)
reinterpret_cast<unsigned char*>(md5_sum_buf));
if (OB_ISNULL(res)) {
// MD5() in openssl always return an pointer not NULL, so we need not check return value.
// see:
// http://www.openssl.org/docs/crypto/md5.html#DESCRIPTION
// http://www.openssl.org/docs/crypto/md5.html#RETURN_VALUES
// Even so, we HAVE TO check it here. You know it.
ret = OB_ERR_UNEXPECTED;
LOG_WARN("md5 res null pointer", K(ret), K(res));
......@@ -3237,10 +3234,7 @@ int ObVirtualTableResultConverter::convert_key_ranges(ObIArray<ObNewRange>& key_
if (!key_ranges.empty()) {
common::ObArray<common::ObNewRange> tmp_range;
OZ(tmp_range.reserve(key_ranges.count()));
if (OB_ISNULL(key_types_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("key mapping is null", K(ret));
}
CK(OB_NOT_NULL(key_types_));
for (int64_t i = 0; OB_SUCC(ret) && i < key_ranges.count(); ++i) {
ObNewRange new_range;
new_range.table_id_ = key_ranges.at(i).table_id_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册