mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fix for bug #12956: cast make differ rounding.
sql/item_func.cc: Fix for bug #12956: cast make differ rounding. - call rint() as we do in the Field_*int*::store(double)
This commit is contained in:
@ -337,7 +337,7 @@ set @precision=10000000000;
|
|||||||
select rand(),
|
select rand(),
|
||||||
cast(rand(10)*@precision as unsigned integer) from t1;
|
cast(rand(10)*@precision as unsigned integer) from t1;
|
||||||
rand() cast(rand(10)*@precision as unsigned integer)
|
rand() cast(rand(10)*@precision as unsigned integer)
|
||||||
- 6570515219
|
- 6570515220
|
||||||
- 1282061302
|
- 1282061302
|
||||||
- 6698761160
|
- 6698761160
|
||||||
- 9647622201
|
- 9647622201
|
||||||
@ -348,23 +348,23 @@ prepare stmt from
|
|||||||
set @var=1;
|
set @var=1;
|
||||||
execute stmt using @var;
|
execute stmt using @var;
|
||||||
rand() cast(rand(10)*@precision as unsigned integer) cast(rand(?)*@precision as unsigned integer)
|
rand() cast(rand(10)*@precision as unsigned integer) cast(rand(?)*@precision as unsigned integer)
|
||||||
- 6570515219 -
|
- 6570515220 -
|
||||||
- 1282061302 -
|
- 1282061302 -
|
||||||
- 6698761160 -
|
- 6698761160 -
|
||||||
- 9647622201 -
|
- 9647622201 -
|
||||||
set @var=2;
|
set @var=2;
|
||||||
execute stmt using @var;
|
execute stmt using @var;
|
||||||
rand() cast(rand(10)*@precision as unsigned integer) cast(rand(?)*@precision as unsigned integer)
|
rand() cast(rand(10)*@precision as unsigned integer) cast(rand(?)*@precision as unsigned integer)
|
||||||
- 6570515219 6555866465
|
- 6570515220 6555866465
|
||||||
- 1282061302 1223466192
|
- 1282061302 1223466193
|
||||||
- 6698761160 6449731873
|
- 6698761160 6449731874
|
||||||
- 9647622201 8578261098
|
- 9647622201 8578261098
|
||||||
set @var=3;
|
set @var=3;
|
||||||
execute stmt using @var;
|
execute stmt using @var;
|
||||||
rand() cast(rand(10)*@precision as unsigned integer) cast(rand(?)*@precision as unsigned integer)
|
rand() cast(rand(10)*@precision as unsigned integer) cast(rand(?)*@precision as unsigned integer)
|
||||||
- 6570515219 9057697559
|
- 6570515220 9057697560
|
||||||
- 1282061302 3730790581
|
- 1282061302 3730790581
|
||||||
- 6698761160 1480860534
|
- 6698761160 1480860535
|
||||||
- 9647622201 6211931236
|
- 9647622201 6211931236
|
||||||
drop table t1;
|
drop table t1;
|
||||||
deallocate prepare stmt;
|
deallocate prepare stmt;
|
||||||
|
@ -17,7 +17,7 @@ while ($1)
|
|||||||
SET @rnd= RAND();
|
SET @rnd= RAND();
|
||||||
SET @id = CAST(@rnd * @rnd_max AS UNSIGNED);
|
SET @id = CAST(@rnd * @rnd_max AS UNSIGNED);
|
||||||
SET @id_rev= @rnd_max - @id;
|
SET @id_rev= @rnd_max - @id;
|
||||||
SET @grp= CAST(128.0 * @rnd AS UNSIGNED);
|
SET @grp= CAST(127.0 * @rnd AS UNSIGNED);
|
||||||
INSERT INTO t1 (id, grp, id_rev) VALUES (@id, @grp, @id_rev);
|
INSERT INTO t1 (id, grp, id_rev) VALUES (@id, @grp, @id_rev);
|
||||||
dec $1;
|
dec $1;
|
||||||
}
|
}
|
||||||
|
@ -735,7 +735,7 @@ longlong Item_func_numhybrid::val_int()
|
|||||||
case INT_RESULT:
|
case INT_RESULT:
|
||||||
return int_op();
|
return int_op();
|
||||||
case REAL_RESULT:
|
case REAL_RESULT:
|
||||||
return (longlong)real_op();
|
return (longlong) rint(real_op());
|
||||||
case STRING_RESULT:
|
case STRING_RESULT:
|
||||||
{
|
{
|
||||||
int err_not_used;
|
int err_not_used;
|
||||||
|
Reference in New Issue
Block a user