[FEAT MERGE] Support float/double(m, d) in mysql mode
This commit is contained in:
@ -17,6 +17,7 @@
|
||||
#include "sql/session/ob_sql_session_info.h"
|
||||
#include "sql/engine/ob_exec_context.h"
|
||||
#include "sql/engine/expr/ob_batch_eval_util.h"
|
||||
#include "share/object/ob_obj_cast_util.h"
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
@ -56,7 +57,7 @@ int ObExprDiv::calc_result_type2(ObExprResType &type,
|
||||
OC( (ObArithExprOperator::calc_result_type2)(type, type1, type2, type_ctx));
|
||||
if (OB_SUCC(ret)) {
|
||||
const ObObjTypeClass result_tc = type.get_type_class();
|
||||
if (ObNumberTC == result_tc || ObDoubleTC == result_tc || ObFloatTC == result_tc) {
|
||||
if (ObNumberTC == result_tc) {
|
||||
if (is_oracle_mode()) {
|
||||
type.set_scale(ORA_NUMBER_SCALE_UNKNOWN_YET);
|
||||
type.set_precision(PRECISION_UNKNOWN_YET);
|
||||
@ -92,6 +93,34 @@ int ObExprDiv::calc_result_type2(ObExprResType &type,
|
||||
"new_scale1", ROUND_UP(scale1), "new_scale2", ROUND_UP(scale2),
|
||||
K(div_precision_increment));
|
||||
}
|
||||
} else if (ObDoubleTC == result_tc || ObFloatTC == result_tc) {
|
||||
if (is_oracle_mode()) {
|
||||
type.set_scale(ORA_NUMBER_SCALE_UNKNOWN_YET);
|
||||
type.set_precision(PRECISION_UNKNOWN_YET);
|
||||
} else {
|
||||
ObScale scale = SCALE_UNKNOWN_YET;
|
||||
ObPrecision precision = PRECISION_UNKNOWN_YET;
|
||||
if (SCALE_UNKNOWN_YET != type1.get_scale() && SCALE_UNKNOWN_YET != type2.get_scale()) {
|
||||
ObScale scale1 = static_cast<ObScale>(MAX(type1.get_scale(), 0));
|
||||
ObScale scale2 = static_cast<ObScale>(MAX(type2.get_scale(), 0));
|
||||
scale = MAX(scale1, scale2) + div_precision_increment;
|
||||
if (scale > OB_MAX_DOUBLE_FLOAT_SCALE) {
|
||||
scale = SCALE_UNKNOWN_YET;
|
||||
}
|
||||
}
|
||||
if (PRECISION_UNKNOWN_YET != type1.get_precision() &&
|
||||
PRECISION_UNKNOWN_YET != type2.get_precision() &&
|
||||
SCALE_UNKNOWN_YET != scale) {
|
||||
ObPrecision p1 = ObMySQLUtil::float_length(scale);
|
||||
ObPrecision p2 = type1.get_precision() - type1.get_scale() + scale;
|
||||
if (ObNumberTC == type1.get_type_class()) {
|
||||
p2 += decimal_to_double_precision_inc(type1.get_type(), type1.get_scale());
|
||||
}
|
||||
precision = MIN(p1, p2);
|
||||
}
|
||||
type.set_scale(scale);
|
||||
type.set_precision(precision);
|
||||
}
|
||||
} else if (ObIntervalTC == type.get_type_class()) {
|
||||
type.set_scale(ObAccuracy::MAX_ACCURACY2[ORACLE_MODE][type.get_type()].get_scale());
|
||||
type.set_precision(ObAccuracy::MAX_ACCURACY2[ORACLE_MODE][type.get_type()].get_precision());
|
||||
|
||||
Reference in New Issue
Block a user