From 33c8a8dd8bc9a61b37f9bce16bd00e6c4c86eee6 Mon Sep 17 00:00:00 2001 From: obdev Date: Tue, 25 Oct 2022 18:11:07 +0800 Subject: [PATCH] fix expr tmp result allocator sanity check core --- src/sql/engine/expr/ob_expr.cpp | 2 +- src/sql/engine/expr/ob_expr.h | 2 +- src/sql/engine/ob_exec_context.cpp | 4 +++- src/sql/engine/ob_exec_context.h | 3 +++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/sql/engine/expr/ob_expr.cpp b/src/sql/engine/expr/ob_expr.cpp index 2cc00675a9..46f2bf8e6b 100644 --- a/src/sql/engine/expr/ob_expr.cpp +++ b/src/sql/engine/expr/ob_expr.cpp @@ -40,7 +40,7 @@ ObEvalCtx::ObEvalCtx(ObExecContext &exec_ctx) exec_ctx_(exec_ctx), tmp_alloc_(exec_ctx.get_eval_tmp_allocator()), datum_caster_(NULL), - tmp_alloc_used_(false), + tmp_alloc_used_(exec_ctx.get_tmp_alloc_used()), batch_idx_(0), batch_size_(0), expr_res_alloc_(exec_ctx.get_eval_res_allocator()) diff --git a/src/sql/engine/expr/ob_expr.h b/src/sql/engine/expr/ob_expr.h index fea3a77c73..b51ff2b05b 100644 --- a/src/sql/engine/expr/ob_expr.h +++ b/src/sql/engine/expr/ob_expr.h @@ -255,7 +255,7 @@ public: // Can not use allocator for expression result. (ObExpr::get_str_res_mem() is used for result). common::ObArenaAllocator &tmp_alloc_; ObDatumCaster *datum_caster_; - bool tmp_alloc_used_; + bool &tmp_alloc_used_; private: int64_t batch_idx_; int64_t batch_size_; diff --git a/src/sql/engine/ob_exec_context.cpp b/src/sql/engine/ob_exec_context.cpp index beeaf4be74..19cf0059ba 100644 --- a/src/sql/engine/ob_exec_context.cpp +++ b/src/sql/engine/ob_exec_context.cpp @@ -121,7 +121,8 @@ ObExecContext::ObExecContext(ObIAllocator &allocator) parent_ctx_(nullptr), nested_level_(0), is_ps_prepare_stage_(false), - register_op_id_(OB_INVALID_ID) + register_op_id_(OB_INVALID_ID), + tmp_alloc_used_(false) { } @@ -294,6 +295,7 @@ void ObExecContext::destroy_eval_allocator() { eval_res_allocator_.reset(); eval_tmp_allocator_.reset(); + tmp_alloc_used_ = false; } int ObExecContext::get_temp_expr_eval_ctx(const ObTempExpr &temp_expr, diff --git a/src/sql/engine/ob_exec_context.h b/src/sql/engine/ob_exec_context.h index 4509b9179b..aa5155a324 100644 --- a/src/sql/engine/ob_exec_context.h +++ b/src/sql/engine/ob_exec_context.h @@ -286,6 +286,7 @@ public: bool has_non_trivial_expr_op_ctx() const { return has_non_trivial_expr_op_ctx_; } void set_non_trivial_expr_op_ctx(bool v) { has_non_trivial_expr_op_ctx_ = v; } + inline bool &get_tmp_alloc_used() { return tmp_alloc_used_; } VIRTUAL_NEED_SERIALIZE_AND_DESERIALIZE; protected: @@ -613,6 +614,8 @@ protected: bool is_ps_prepare_stage_; // for sql plan monitor int64_t register_op_id_; + // indicate if eval_tmp_allocator_ is used + bool tmp_alloc_used_; // ------------------- private: DISALLOW_COPY_AND_ASSIGN(ObExecContext); -- GitLab