mirror of
https://github.com/MariaDB/server.git
synced 2026-05-03 13:45:34 +02:00
Fix multiplication of abs() by a negative value. (Bug #11402)
mysql-test/r/func_math.result: Add new results mysql-test/t/func_math.test: Add new regression test sql/item_func.cc: Don't set result of abs() to unsigned. Result should still be a signed value, even if always positive.
This commit is contained in:
parent
31d0786687
commit
5841d70af8
3 changed files with 8 additions and 3 deletions
|
|
@ -137,3 +137,6 @@ select * from t1;
|
|||
round(1, 6)
|
||||
1.000000
|
||||
drop table t1;
|
||||
select abs(-2) * -2;
|
||||
abs(-2) * -2
|
||||
-4
|
||||
|
|
|
|||
|
|
@ -71,3 +71,8 @@ create table t1 select round(1, 6);
|
|||
show create table t1;
|
||||
select * from 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()
|
|||
max_length=args[0]->max_length;
|
||||
hybrid_type= REAL_RESULT;
|
||||
if (args[0]->result_type() == INT_RESULT)
|
||||
{
|
||||
hybrid_type= INT_RESULT;
|
||||
unsigned_flag= 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue