提交 3e6a171f 编写于 作者: O obdev 提交者: wangzelin.wzl

fix used incorrect cached temp expr ctx bug

上级 042a195f
......@@ -1021,6 +1021,8 @@ int ObLoadDataSPImpl::exec_shuffle(int64_t task_id, ObShuffleTaskHandle *handle)
LOG_WARN("fail to init buffer", K(ret));
} else if (OB_FAIL(parse_result.prepare_allocate(handle->generator.get_field_exprs().count()))) {
LOG_WARN("fail to allocate", K(ret));
} else {
handle->exec_ctx.set_use_temp_expr_ctx_cache(true);
}
while (OB_SUCC(ret) && ptr < end) {
......
......@@ -229,9 +229,9 @@ int ObExprToOutfileRow::extract_fisrt_wchar_from_varhcar(const ObObj &obj, int32
// as NULL, not \N.
int ObExprToOutfileRow::print_field(char *buf, const int64_t buf_len, int64_t &pos,
const ObObj &obj, ObExprOutFileInfo &out_info)
{
int ret = OB_SUCCESS;
int64_t tmp_pos = 0;
{
int ret = OB_SUCCESS;
int64_t tmp_pos = 0;
const bool need_enclose = 0 != out_info.wchar_enclose_ &&
(!out_info.is_optional_ || obj.is_string_type());
if (need_enclose) {
......
......@@ -216,6 +216,7 @@ DEFINE_DESERIALIZE(ObDesExecContext)
LOG_WARN("init exec context expr op failed", K(ret));
}
}
use_temp_expr_ctx_cache_ = true;
return ret;
}
}/* ns sql*/
......
......@@ -112,6 +112,7 @@ ObExecContext::ObExecContext(ObIAllocator &allocator)
px_batch_id_(0),
admission_version_(UINT64_MAX),
admission_addr_map_(),
use_temp_expr_ctx_cache_(false),
temp_expr_ctx_map_(),
dml_event_(ObDmlEventType::DE_INVALID),
update_columns_(nullptr),
......@@ -301,25 +302,29 @@ int ObExecContext::get_temp_expr_eval_ctx(const ObTempExpr &temp_expr,
ObTempExprCtx *&temp_expr_ctx)
{
int ret = OB_SUCCESS;
if (!temp_expr_ctx_map_.created()) {
OZ(temp_expr_ctx_map_.create(8, ObLabel("TempExprCtx")));
}
if (OB_SUCC(ret)) {
int64_t ctx_ptr = 0;
if (OB_FAIL(temp_expr_ctx_map_.get_refactored(reinterpret_cast<int64_t>(&temp_expr),
ctx_ptr))) {
if (OB_HASH_NOT_EXIST == ret) {
ret = OB_SUCCESS;
OZ(build_temp_expr_ctx(temp_expr, temp_expr_ctx));
CK(OB_NOT_NULL(temp_expr_ctx));
OZ(temp_expr_ctx_map_.set_refactored(reinterpret_cast<int64_t>(&temp_expr),
reinterpret_cast<int64_t>(temp_expr_ctx)));
if (use_temp_expr_ctx_cache_) {
if (!temp_expr_ctx_map_.created()) {
OZ(temp_expr_ctx_map_.create(8, ObLabel("TempExprCtx")));
}
if (OB_SUCC(ret)) {
int64_t ctx_ptr = 0;
if (OB_FAIL(temp_expr_ctx_map_.get_refactored(reinterpret_cast<int64_t>(&temp_expr),
ctx_ptr))) {
if (OB_HASH_NOT_EXIST == ret) {
ret = OB_SUCCESS;
OZ(build_temp_expr_ctx(temp_expr, temp_expr_ctx));
CK(OB_NOT_NULL(temp_expr_ctx));
OZ(temp_expr_ctx_map_.set_refactored(reinterpret_cast<int64_t>(&temp_expr),
reinterpret_cast<int64_t>(temp_expr_ctx)));
} else {
LOG_WARN("fail to get temp expr ctx", K(temp_expr), K(ret));
}
} else {
LOG_WARN("fail to get temp expr ctx", K(temp_expr), K(ret));
temp_expr_ctx = reinterpret_cast<ObTempExprCtx *>(ctx_ptr);
}
} else {
temp_expr_ctx = reinterpret_cast<ObTempExprCtx *>(ctx_ptr);
}
} else {
OZ(build_temp_expr_ctx(temp_expr, temp_expr_ctx));
}
return ret;
......
......@@ -369,6 +369,8 @@ public:
// for granule iterator
int get_gi_task_map(GIPrepareTaskMap *&gi_prepare_task_map);
void set_use_temp_expr_ctx_cache(bool v) { use_temp_expr_ctx_cache_ = v; }
// for udf
int get_udf_ctx_mgr(ObUdfCtxMgr *&udf_ctx_mgr);
......@@ -599,6 +601,7 @@ protected:
uint64_t admission_version_;
hash::ObHashMap<ObAddr, int64_t> admission_addr_map_;
// used for temp expr ctx manager
bool use_temp_expr_ctx_cache_;
hash::ObHashMap<int64_t, int64_t> temp_expr_ctx_map_;
// for pl/trigger
ObDmlEventType dml_event_;
......
......@@ -59,6 +59,7 @@ int ObExecutor::execute_plan(ObExecContext &ctx)
ObSQLSessionInfo *session_info = ctx.get_my_session();
ObPhysicalPlanCtx *plan_ctx = ctx.get_physical_plan_ctx();
int64_t batched_stmt_cnt = ctx.get_sql_ctx()->multi_stmt_item_.get_batched_stmt_cnt();
ctx.set_use_temp_expr_ctx_cache(true);
// If the batch execution is rewritten by insert multi values, there is no need to repack multiple times
if (ctx.get_sql_ctx()->multi_stmt_item_.is_ins_multi_val_opt()) {
batched_stmt_cnt = 0;
......
......@@ -426,6 +426,7 @@ int ObRemoteBaseExecuteP<T>::execute_remote_plan(ObExecContext &exec_ctx,
ObSQLSessionInfo *session = exec_ctx.get_my_session();
ObPhysicalPlanCtx *plan_ctx = exec_ctx.get_physical_plan_ctx();
ObOperator *se_op = nullptr; // static engine operator
exec_ctx.set_use_temp_expr_ctx_cache(true);
if (OB_ISNULL(plan_ctx) || OB_ISNULL(session)) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("op is NULL", K(ret), K(plan_ctx), K(session));
......@@ -633,6 +634,7 @@ int ObRemoteBaseExecuteP<T>::execute_with_sql(ObRemoteTask &task)
bool enable_sql_audit = GCONF.enable_sql_audit;
ObPhysicalPlan *plan = nullptr;
ObPhysicalPlanCtx *plan_ctx = nullptr;
exec_ctx_.set_use_temp_expr_ctx_cache(false);
int inject_err_no = EVENT_CALL(EventTable::EN_REMOTE_EXEC_ERR);
if (0 != inject_err_no) {
ret = inject_err_no;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册