mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug#8663 cant use bgint unsigned as input to cast
Problem: cast to unsigned limited result to max signed bigint 9223372036854775808, instead of max unsigned bigint 18446744073709551615. Fix: don't use args[0]->val_int() when casting from a floating point number, use val() instead, with range checkings, special to unsigned data type. item_func.cc: Special handling of cast from REAL_RESULT to unsigned int: we cannot execute args[0]->val_int() because it cuts max allowed value to LONGLONG_INT, instead of ULONGLONG_INT required. count_distinct3.test: Getting rid of "Data truncated; out of range ..." warnings. cast.test, cast.result: Adding test case. ps.result: Fixing that cast from 6570515219.6535 to unsigned didn't round to 6570515220, and returned 6570515219 instead. mysql-test/r/cast.result: Adding test case. mysql-test/r/ps.result: Fixing that cast from 6570515219.6535 to unsigned didn't round to 6570515220, and returned 6570515219 instead. mysql-test/t/cast.test: Adding test case. mysql-test/t/count_distinct3.test: Get rid of "wring unsigned value" warnings. sql/item_func.cc: Special handling of cast from REAL)RESULT to unsigned int: we cannot execute args[0]->val_int() because it cuts max allowed value to LONGLONG_INT, instead of ULONGLONG_INT required.
This commit is contained in:
@ -340,7 +340,7 @@ set @precision=10000000000;
|
||||
select rand(),
|
||||
cast(rand(10)*@precision as unsigned integer) from t1;
|
||||
rand() cast(rand(10)*@precision as unsigned integer)
|
||||
- 6570515219
|
||||
- 6570515220
|
||||
- 1282061302
|
||||
- 6698761160
|
||||
- 9647622201
|
||||
@ -351,23 +351,23 @@ prepare stmt from
|
||||
set @var=1;
|
||||
execute stmt using @var;
|
||||
rand() cast(rand(10)*@precision as unsigned integer) cast(rand(?)*@precision as unsigned integer)
|
||||
- 6570515219 -
|
||||
- 6570515220 -
|
||||
- 1282061302 -
|
||||
- 6698761160 -
|
||||
- 9647622201 -
|
||||
set @var=2;
|
||||
execute stmt using @var;
|
||||
rand() cast(rand(10)*@precision as unsigned integer) cast(rand(?)*@precision as unsigned integer)
|
||||
- 6570515219 6555866465
|
||||
- 1282061302 1223466192
|
||||
- 6698761160 6449731873
|
||||
- 6570515220 6555866465
|
||||
- 1282061302 1223466193
|
||||
- 6698761160 6449731874
|
||||
- 9647622201 8578261098
|
||||
set @var=3;
|
||||
execute stmt using @var;
|
||||
rand() cast(rand(10)*@precision as unsigned integer) cast(rand(?)*@precision as unsigned integer)
|
||||
- 6570515219 9057697559
|
||||
- 6570515220 9057697560
|
||||
- 1282061302 3730790581
|
||||
- 6698761160 1480860534
|
||||
- 6698761160 1480860535
|
||||
- 9647622201 6211931236
|
||||
drop table t1;
|
||||
deallocate prepare stmt;
|
||||
|
Reference in New Issue
Block a user