Fix decimal int related bugs

This commit is contained in:
hezuojiao
2024-02-07 01:49:15 +00:00
committed by ob-robot
parent be77c63e7f
commit 03d27e8033
3 changed files with 19 additions and 13 deletions

View File

@ -62,7 +62,10 @@ int ObExprMod::calc_result_type2(ObExprResType &type,
// In mysql mode, precision of int(255) is 255, more than OB_MAX_DECIMAL_POSSIBLE_PRECISION
// So precision deduced just now may be larger than 81 while res type is decimal_int
// TODO:@xiaofeng.lby, use a more generic method to solve this problem
type.set_precision(MIN(type.get_precision(), OB_MAX_DECIMAL_POSSIBLE_PRECISION));
const int64_t int_part1 = type1.get_precision() - type1.get_scale();
const int64_t int_part2 = type2.get_precision() - type2.get_scale();
const int64_t precision = MAX(int_part1, int_part2) + type.get_scale();
type.set_precision(MIN(precision, OB_MAX_DECIMAL_POSSIBLE_PRECISION));
type1.set_calc_accuracy(type.get_accuracy());
type2.set_calc_accuracy(type.get_accuracy());
}

View File

@ -879,8 +879,8 @@ static ObObjType RELATIONAL_CMP_TYPE[ObMaxType][ObMaxType] =
ObNumberType, /*MediumTextType*/
ObNumberType, /*LongTextType*/
ObNumberType, /*BitType*/
ObNumberType, /*EnumType*/
ObNumberType, /*SetType*/
ObDoubleType, /*EnumType*/
ObDoubleType, /*SetType*/
ObNumberType, /*EnumInnerType*/
ObNumberType, /*SetInnerType*/
ObTimestampTZType, /* ObTimestampTZType */
@ -934,8 +934,8 @@ static ObObjType RELATIONAL_CMP_TYPE[ObMaxType][ObMaxType] =
ObNumberType, /*MediumTextType*/
ObNumberType, /*LongTextType*/
ObUNumberType, /*BitType*/
ObUNumberType, /*EnumType*/
ObUNumberType, /*SetType*/
ObDoubleType, /*EnumType*/
ObDoubleType, /*SetType*/
ObUNumberType, /*EnumInnerType*/
ObUNumberType, /*SetInnerType*/
ObTimestampTZType, /* ObTimestampTZType */
@ -1792,8 +1792,8 @@ static ObObjType RELATIONAL_CMP_TYPE[ObMaxType][ObMaxType] =
ObDoubleType, /* DoubleType */
ObDoubleType, /* UFloatType */
ObDoubleType, /* UDoubleType */
ObNumberType, /* NumberType */
ObNumberType, /* UNumberType */
ObDoubleType, /* NumberType */
ObDoubleType, /* UNumberType */
ObDateTimeType, /* DateTimeType */
ObTimestampType, /* TimestampType */
ObDateTimeType, /* DateType */
@ -1827,7 +1827,7 @@ static ObObjType RELATIONAL_CMP_TYPE[ObMaxType][ObMaxType] =
ObNumberType, /* ObJsonType */
ObMaxType, /* ObGeometryType */
ObMaxType, /* UDT */
ObDecimalIntType, /* ObDecimalIntType */
ObDoubleType, /* ObDecimalIntType */
},
/*SetType*/
{
@ -1846,8 +1846,8 @@ static ObObjType RELATIONAL_CMP_TYPE[ObMaxType][ObMaxType] =
ObDoubleType, /* DoubleType */
ObDoubleType, /* UFloatType */
ObDoubleType, /* UDoubleType */
ObNumberType, /* NumberType */
ObNumberType, /* UNumberType */
ObDoubleType, /* NumberType */
ObDoubleType, /* UNumberType */
ObDateTimeType, /* DateTimeType */
ObTimestampType, /* TimestampType */
ObDateTimeType, /* DateType */
@ -1881,7 +1881,7 @@ static ObObjType RELATIONAL_CMP_TYPE[ObMaxType][ObMaxType] =
ObNumberType, /* ObJsonType */
ObMaxType, /* ObGeometryType */
ObMaxType, /* UDT */
ObDecimalIntType, /* ObDecimalIntType */
ObDoubleType, /* ObDecimalIntType */
},
/*EnumInnerType*/
{
@ -2782,8 +2782,8 @@ static ObObjType RELATIONAL_CMP_TYPE[ObMaxType][ObMaxType] =
ObDecimalIntType, /*MediumTextType*/
ObDecimalIntType, /*LongTextType*/
ObDecimalIntType, /*BitType*/
ObDecimalIntType, /*EnumType*/
ObDecimalIntType, /*SetType*/
ObDoubleType, /*EnumType*/
ObDoubleType, /*SetType*/
ObDecimalIntType, /*EnumInnerType*/
ObDecimalIntType, /*SetInnerType*/
ObTimestampTZType, /* ObTimestampTZType */