From 74cb7c51f4d5edf5b4edf6c5be01034c750f67a9 Mon Sep 17 00:00:00 2001 From: Larry955 <1412857955@qq.com> Date: Sun, 13 Nov 2022 02:33:32 +0800 Subject: [PATCH] fix eval questionmark table assign val failed bug --- .../ob_static_engine_expr_cg.cpp | 16 ++++++---------- src/sql/engine/expr/ob_expr_to_outfile_row.cpp | 18 +++++++++--------- .../test_suite/join/t/join_merge.test | 2 ++ 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/sql/code_generator/ob_static_engine_expr_cg.cpp b/src/sql/code_generator/ob_static_engine_expr_cg.cpp index 361094966b..c008c46662 100644 --- a/src/sql/code_generator/ob_static_engine_expr_cg.cpp +++ b/src/sql/code_generator/ob_static_engine_expr_cg.cpp @@ -401,22 +401,18 @@ int ObStaticEngineExprCG::cg_expr_by_operator(const ObIArray &raw_e || OB_ISNULL(rt_expr = get_rt_expr(*raw_expr))) { ret = OB_ERR_UNEXPECTED; LOG_WARN("arg is null", K(raw_expr), K(rt_expr), K(ret)); - } else if (T_QUESTIONMARK == rt_expr->type_ && rt_question_mark_eval_) { + } else if (T_QUESTIONMARK == rt_expr->type_ && + (raw_expr->has_flag(IS_TABLE_ASSIGN) || rt_question_mark_eval_)) { // generate question mark expr for get param from param store directly + // if the questionmark is from TABLE_ASSIGN, use eval_assign_question_mark_func ObConstRawExpr *c_expr = static_cast(raw_expr); int64_t param_idx = 0; OZ(c_expr->get_value().get_unknown(param_idx)); if (OB_SUCC(ret)) { rt_expr->extra_ = param_idx; - rt_expr->eval_func_ = &eval_question_mark_func; - } - } else if (T_QUESTIONMARK == rt_expr->type_ && raw_expr->has_flag(IS_TABLE_ASSIGN)) { - ObConstRawExpr *c_expr = static_cast(raw_expr); - int64_t param_idx = 0; - OZ(c_expr->get_value().get_unknown(param_idx)); - if (OB_SUCC(ret)) { - rt_expr->extra_ = param_idx; - rt_expr->eval_func_ = &eval_assign_question_mark_func; + rt_expr->eval_func_ = raw_expr->has_flag(IS_TABLE_ASSIGN) ? + &eval_assign_question_mark_func: + &eval_question_mark_func; } } else if (!IS_EXPR_OP(rt_expr->type_) || IS_AGGR_FUN(rt_expr->type_)) { // do nothing diff --git a/src/sql/engine/expr/ob_expr_to_outfile_row.cpp b/src/sql/engine/expr/ob_expr_to_outfile_row.cpp index 492019ecdc..eb6741f055 100644 --- a/src/sql/engine/expr/ob_expr_to_outfile_row.cpp +++ b/src/sql/engine/expr/ob_expr_to_outfile_row.cpp @@ -31,9 +31,9 @@ ObExprToOutfileRow::ObExprToOutfileRow(ObIAllocator &alloc) { need_charset_convert_ = false; } - -ObExprToOutfileRow::~ObExprToOutfileRow() -{ + +ObExprToOutfileRow::~ObExprToOutfileRow() +{ } int ObExprToOutfileRow::calc_result_typeN(ObExprResType &type, @@ -102,9 +102,9 @@ int ObExprToOutfileRow::extend_buffer(ObExprOutFileInfo &out_info, LOG_WARN("fail to allocate memory", K(ret), K(old_len), K(new_len)); } else if (OB_ISNULL(out_info.tmp_buf_ = static_cast(allocator.alloc(new_len)))) { ret = OB_ALLOCATE_MEMORY_FAILED; - LOG_WARN("fail to allocate memory", K(ret), K(old_len), K(new_len)); - } else { - out_info.buf_len_ = new_len; + LOG_WARN("fail to allocate memory", K(ret), K(old_len), K(new_len)); + } else { + out_info.buf_len_ = new_len; out_info.tmp_buf_len_ = new_len; } return ret; @@ -148,9 +148,9 @@ int ObExprToOutfileRow::calc_outfile_info(const ObExpr &expr, OZ(extract_fisrt_wchar_from_varhcar(out_info.escape_, out_info.wchar_escape_)); OZ(extend_buffer(out_info, allocator)); return ret; -} - -int ObExprToOutfileRow::to_outfile_str(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_datum) +} + +int ObExprToOutfileRow::to_outfile_str(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_datum) { int ret = OB_SUCCESS; if (OB_UNLIKELY(expr.arg_cnt_ <= PARAM_SELECT_ITEM)) { diff --git a/tools/deploy/mysql_test/test_suite/join/t/join_merge.test b/tools/deploy/mysql_test/test_suite/join/t/join_merge.test index fc3ad7ae5e..e89fbb4ab3 100644 --- a/tools/deploy/mysql_test/test_suite/join/t/join_merge.test +++ b/tools/deploy/mysql_test/test_suite/join/t/join_merge.test @@ -1,3 +1,4 @@ +--source mysql_test/include/explain_init.inc --disable_query_log set @@session.explicit_defaults_for_timestamp=off; --enable_query_log @@ -346,3 +347,4 @@ drop table t2; --disable_warnings drop table if exists t2, t7, t8, t9, BB, CC; --enable_warnings +--source mysql_test/include/explain_end.inc