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

@ -528,6 +528,9 @@ int ObMPBase::response_row(ObSQLSessionInfo &session,
// need at ps mode // need at ps mode
if (!is_packed && value.get_type() != fields->at(i).type_.get_type()) { if (!is_packed && value.get_type() != fields->at(i).type_.get_type()) {
ObCastCtx cast_ctx(&allocator, NULL, CM_WARN_ON_FAIL, fields->at(i).type_.get_collation_type()); ObCastCtx cast_ctx(&allocator, NULL, CM_WARN_ON_FAIL, fields->at(i).type_.get_collation_type());
if (ObDecimalIntType == fields->at(i).type_.get_type()) {
cast_ctx.res_accuracy_ = const_cast<ObAccuracy*>(&fields->at(i).accuracy_);
}
if (OB_FAIL(common::ObObjCaster::to_type(fields->at(i).type_.get_type(), if (OB_FAIL(common::ObObjCaster::to_type(fields->at(i).type_.get_type(),
cast_ctx, cast_ctx,
value, value,

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 // 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 // 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 // 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()); type1.set_calc_accuracy(type.get_accuracy());
type2.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, /*MediumTextType*/
ObNumberType, /*LongTextType*/ ObNumberType, /*LongTextType*/
ObNumberType, /*BitType*/ ObNumberType, /*BitType*/
ObNumberType, /*EnumType*/ ObDoubleType, /*EnumType*/
ObNumberType, /*SetType*/ ObDoubleType, /*SetType*/
ObNumberType, /*EnumInnerType*/ ObNumberType, /*EnumInnerType*/
ObNumberType, /*SetInnerType*/ ObNumberType, /*SetInnerType*/
ObTimestampTZType, /* ObTimestampTZType */ ObTimestampTZType, /* ObTimestampTZType */
@ -934,8 +934,8 @@ static ObObjType RELATIONAL_CMP_TYPE[ObMaxType][ObMaxType] =
ObNumberType, /*MediumTextType*/ ObNumberType, /*MediumTextType*/
ObNumberType, /*LongTextType*/ ObNumberType, /*LongTextType*/
ObUNumberType, /*BitType*/ ObUNumberType, /*BitType*/
ObUNumberType, /*EnumType*/ ObDoubleType, /*EnumType*/
ObUNumberType, /*SetType*/ ObDoubleType, /*SetType*/
ObUNumberType, /*EnumInnerType*/ ObUNumberType, /*EnumInnerType*/
ObUNumberType, /*SetInnerType*/ ObUNumberType, /*SetInnerType*/
ObTimestampTZType, /* ObTimestampTZType */ ObTimestampTZType, /* ObTimestampTZType */
@ -1792,8 +1792,8 @@ static ObObjType RELATIONAL_CMP_TYPE[ObMaxType][ObMaxType] =
ObDoubleType, /* DoubleType */ ObDoubleType, /* DoubleType */
ObDoubleType, /* UFloatType */ ObDoubleType, /* UFloatType */
ObDoubleType, /* UDoubleType */ ObDoubleType, /* UDoubleType */
ObNumberType, /* NumberType */ ObDoubleType, /* NumberType */
ObNumberType, /* UNumberType */ ObDoubleType, /* UNumberType */
ObDateTimeType, /* DateTimeType */ ObDateTimeType, /* DateTimeType */
ObTimestampType, /* TimestampType */ ObTimestampType, /* TimestampType */
ObDateTimeType, /* DateType */ ObDateTimeType, /* DateType */
@ -1827,7 +1827,7 @@ static ObObjType RELATIONAL_CMP_TYPE[ObMaxType][ObMaxType] =
ObNumberType, /* ObJsonType */ ObNumberType, /* ObJsonType */
ObMaxType, /* ObGeometryType */ ObMaxType, /* ObGeometryType */
ObMaxType, /* UDT */ ObMaxType, /* UDT */
ObDecimalIntType, /* ObDecimalIntType */ ObDoubleType, /* ObDecimalIntType */
}, },
/*SetType*/ /*SetType*/
{ {
@ -1846,8 +1846,8 @@ static ObObjType RELATIONAL_CMP_TYPE[ObMaxType][ObMaxType] =
ObDoubleType, /* DoubleType */ ObDoubleType, /* DoubleType */
ObDoubleType, /* UFloatType */ ObDoubleType, /* UFloatType */
ObDoubleType, /* UDoubleType */ ObDoubleType, /* UDoubleType */
ObNumberType, /* NumberType */ ObDoubleType, /* NumberType */
ObNumberType, /* UNumberType */ ObDoubleType, /* UNumberType */
ObDateTimeType, /* DateTimeType */ ObDateTimeType, /* DateTimeType */
ObTimestampType, /* TimestampType */ ObTimestampType, /* TimestampType */
ObDateTimeType, /* DateType */ ObDateTimeType, /* DateType */
@ -1881,7 +1881,7 @@ static ObObjType RELATIONAL_CMP_TYPE[ObMaxType][ObMaxType] =
ObNumberType, /* ObJsonType */ ObNumberType, /* ObJsonType */
ObMaxType, /* ObGeometryType */ ObMaxType, /* ObGeometryType */
ObMaxType, /* UDT */ ObMaxType, /* UDT */
ObDecimalIntType, /* ObDecimalIntType */ ObDoubleType, /* ObDecimalIntType */
}, },
/*EnumInnerType*/ /*EnumInnerType*/
{ {
@ -2782,8 +2782,8 @@ static ObObjType RELATIONAL_CMP_TYPE[ObMaxType][ObMaxType] =
ObDecimalIntType, /*MediumTextType*/ ObDecimalIntType, /*MediumTextType*/
ObDecimalIntType, /*LongTextType*/ ObDecimalIntType, /*LongTextType*/
ObDecimalIntType, /*BitType*/ ObDecimalIntType, /*BitType*/
ObDecimalIntType, /*EnumType*/ ObDoubleType, /*EnumType*/
ObDecimalIntType, /*SetType*/ ObDoubleType, /*SetType*/
ObDecimalIntType, /*EnumInnerType*/ ObDecimalIntType, /*EnumInnerType*/
ObDecimalIntType, /*SetInnerType*/ ObDecimalIntType, /*SetInnerType*/
ObTimestampTZType, /* ObTimestampTZType */ ObTimestampTZType, /* ObTimestampTZType */