fix sign result not cpmpat with mysql
This commit is contained in:
@ -66,7 +66,7 @@ int ObExprSign::calc_result_type1(ObExprResType& type, ObExprResType& text, comm
|
|||||||
|
|
||||||
int ObExprSign::calc(ObObj& result, double val)
|
int ObExprSign::calc(ObObj& result, double val)
|
||||||
{
|
{
|
||||||
if (fabs(val) < FLOAT_EPS) {
|
if (0 == val) {
|
||||||
result.set_int(0);
|
result.set_int(0);
|
||||||
} else {
|
} else {
|
||||||
result.set_int(val < 0 ? -1 : 1);
|
result.set_int(val < 0 ? -1 : 1);
|
||||||
@ -193,7 +193,7 @@ int calc_sign_expr(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& res_datum)
|
|||||||
}
|
}
|
||||||
case ObFloatTC: {
|
case ObFloatTC: {
|
||||||
float v = arg_datum->get_float();
|
float v = arg_datum->get_float();
|
||||||
if (is_mysql_mode() && fabsf(v) < FLOAT_EPS) {
|
if (is_mysql_mode() && 0 == v) {
|
||||||
res_int = 0;
|
res_int = 0;
|
||||||
} else {
|
} else {
|
||||||
res_int = v < 0 ? -1 : 1;
|
res_int = v < 0 ? -1 : 1;
|
||||||
@ -202,7 +202,7 @@ int calc_sign_expr(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& res_datum)
|
|||||||
}
|
}
|
||||||
case ObDoubleTC: {
|
case ObDoubleTC: {
|
||||||
double v = arg_datum->get_double();
|
double v = arg_datum->get_double();
|
||||||
if (is_mysql_mode() && fabs(v) < DOUBLE_EPS) {
|
if (is_mysql_mode() && 0 == v) {
|
||||||
res_int = 0;
|
res_int = 0;
|
||||||
} else {
|
} else {
|
||||||
res_int = v < 0 ? -1 : 1;
|
res_int = v < 0 ? -1 : 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user