From 1225f5f0cee5cf9b8a7d018bd6a93ce86fc8c2fc Mon Sep 17 00:00:00 2001 From: obdev Date: Tue, 14 Feb 2023 11:15:13 +0000 Subject: [PATCH] revert 'fix avg scale is not compat with MySQL' --- src/sql/dtl/ob_dtl_flow_control.cpp | 2 +- src/sql/engine/expr/ob_expr_div.cpp | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/sql/dtl/ob_dtl_flow_control.cpp b/src/sql/dtl/ob_dtl_flow_control.cpp index dbeea85627..e849e6de06 100644 --- a/src/sql/dtl/ob_dtl_flow_control.cpp +++ b/src/sql/dtl/ob_dtl_flow_control.cpp @@ -158,7 +158,7 @@ int ObDtlFlowControl::unregister_all_channel() } } if (is_receive() && (0 != get_blocked_cnt() || 0 != get_total_buffer_cnt() || 0 != get_used())) { - LOG_ERROR("unexpected dfc status", K(chans_.count()), K(ret), K(get_blocked_cnt()), K(get_total_buffer_cnt()), K(get_used()), K(get_accumulated_blocked_cnt())); + LOG_WARN("unexpected dfc status", K(chans_.count()), K(ret), K(get_blocked_cnt()), K(get_total_buffer_cnt()), K(get_used()), K(get_accumulated_blocked_cnt())); } LOG_TRACE("unregister all channel", K(chans_.count()), K(ret), K(get_blocked_cnt()), K(get_total_buffer_cnt()), K(get_used()), K(get_accumulated_blocked_cnt())); return ret; diff --git a/src/sql/engine/expr/ob_expr_div.cpp b/src/sql/engine/expr/ob_expr_div.cpp index 155d2d3b71..66295ce869 100644 --- a/src/sql/engine/expr/ob_expr_div.cpp +++ b/src/sql/engine/expr/ob_expr_div.cpp @@ -609,16 +609,11 @@ struct ObNumberDivFunc // const int64_t new_scale2 = ROUND_UP(scale2); // const int64_t calc_scale = ROUND_UP(new_scale1 + new_scale2 + div_pi); const int64_t calc_scale = expr.div_calc_scale_; - if (calc_scale > 0) { - if (T_OP_AGG_DIV == expr.type_) { - if (OB_FAIL(result_num.round(expr.datum_meta_.scale_))) { - LOG_WARN("failed to round result number", K(ret), K(result_num), K(calc_scale)); - } - } else if (OB_FAIL(result_num.trunc(calc_scale))) { - LOG_WARN("failed to round result number", K(ret), K(result_num), K(calc_scale)); - } - } - if (OB_SUCC(ret)) { + if (calc_scale > 0 && OB_FAIL(result_num.trunc(calc_scale))) { + //calc_scale is calc_scale ,not res_scale. + //trunc with calc_scale and round with res_scale + LOG_WARN("failed to trunc result number", K(ret), K(result_num), K(calc_scale)); + } else { res.set_number(result_num); } LOG_DEBUG("finish div", K(ret), K(calc_scale), -- GitLab