Commit 1fa7b95d authored by jimw@mysql.com's avatar jimw@mysql.com

Fix multiplication of abs() by a negative value. (Bug #11402)

parent 53761ce0
...@@ -137,3 +137,6 @@ select * from t1; ...@@ -137,3 +137,6 @@ select * from t1;
round(1, 6) round(1, 6)
1.000000 1.000000
drop table t1; drop table t1;
select abs(-2) * -2;
abs(-2) * -2
-4
...@@ -71,3 +71,8 @@ create table t1 select round(1, 6); ...@@ -71,3 +71,8 @@ create table t1 select round(1, 6);
show create table t1; show create table t1;
select * from t1; select * from t1;
drop table t1; drop table t1;
#
# Bug #11402: abs() forces rest of calculation to unsigned
#
select abs(-2) * -2;
...@@ -914,10 +914,7 @@ void Item_func_abs::fix_length_and_dec() ...@@ -914,10 +914,7 @@ void Item_func_abs::fix_length_and_dec()
max_length=args[0]->max_length; max_length=args[0]->max_length;
hybrid_type= REAL_RESULT; hybrid_type= REAL_RESULT;
if (args[0]->result_type() == INT_RESULT) if (args[0]->result_type() == INT_RESULT)
{
hybrid_type= INT_RESULT; hybrid_type= INT_RESULT;
unsigned_flag= 1;
}
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment