FIx type deduction for decimal int division
This commit is contained in:
parent
2f74f70567
commit
9d62ee876f
@ -142,8 +142,12 @@ int ObExprDiv::calc_result_type2(ObExprResType &type,
|
||||
ObPrecision calc_prec1 = type1_acc.get_precision() + type2_acc.get_precision()
|
||||
+ div_precision_increment + extra_scale_for_decint_div;
|
||||
ObScale calc_scale1 = type1_acc.get_scale() + calc_prec1 - type1_acc.get_precision();
|
||||
if (calc_prec1 > OB_MAX_DECIMAL_POSSIBLE_PRECISION) {
|
||||
if (calc_prec1 > OB_MAX_DECIMAL_POSSIBLE_PRECISION || calc_scale1 > number::ObNumber::FLOATING_SCALE) {
|
||||
// to large precision, use number as calc type instead
|
||||
|
||||
// if we have a decimal int with (P, S) = (81, 73)
|
||||
// sizeof(floating digits) = 9, sizeof(integer digits) = 1, however ObNumber can only store 9 digits as maximum
|
||||
// thus, fall back to ObNumber instead.
|
||||
type1.set_calc_type(ObNumberType);
|
||||
type2.set_calc_type(ObNumberType);
|
||||
} else {
|
||||
|
@ -253,11 +253,14 @@ int ObExprResultTypeUtil::get_div_result_type(ObObjType &result_type,
|
||||
}
|
||||
} else {
|
||||
result_type = DIV_RESULT_TYPE[type1][type2];
|
||||
omt::ObTenantConfigGuard tenant_config(TENANT_CONF(MTL_ID()));
|
||||
// FIXME: @zuojiao.hzj : remove this after we can keep high division calc scale
|
||||
// using decimal int as division calc types
|
||||
bool can_use_decint_div = (ob_is_decimal_int(type1) || ob_is_integer_type(type1))
|
||||
&& (ob_is_decimal_int(type2) || ob_is_integer_type(type2))
|
||||
&& GET_MIN_CLUSTER_VERSION() >= CLUSTER_VERSION_4_3_5_0;
|
||||
&& GET_MIN_CLUSTER_VERSION() >= CLUSTER_VERSION_4_3_5_0
|
||||
&& tenant_config.is_valid()
|
||||
&& tenant_config->_enable_decimal_int_type;
|
||||
if (ob_is_decimal_int(result_type)) {
|
||||
result_type = ObNumberType;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user