[CP] fix bug for opensouce

This commit is contained in:
obdev
2022-07-04 10:09:14 +08:00
committed by linzhigang.lzg
parent 649f70dfa7
commit 1eaee03522
5 changed files with 120 additions and 75 deletions

View File

@ -698,11 +698,16 @@ int ObExprDiv::div_number(
// 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 && 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 {
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)) {
result.set_number(result_num);
}
LOG_DEBUG("finish div",