Below is the list of changes that have just been committed into a local
4.1 repository of bar. When bar does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2491 06/06/14 13:40:21 bar@stripped +5 -0
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.
sql/item_func.cc
1.262 06/06/14 13:32:02 bar@stripped +20 -0
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.
mysql-test/t/count_distinct3.test
1.5 06/06/14 13:31:30 bar@stripped +2 -0
Get rid of "wring unsigned value"
warnings.
mysql-test/t/cast.test
1.22 06/06/14 13:31:00 bar@stripped +6 -0
Adding test case.
mysql-test/r/ps.result
1.50 06/06/14 13:29:51 bar@stripped +7 -7
Fixing that cast from 6570515219.6535
to unsigned didn't round to 6570515220,
and returned 6570515219 instead.
mysql-test/r/cast.result
1.26 06/06/14 13:29:30 bar@stripped +3 -0
Adding test case.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: bar
# Host: bar.intranet.mysql.r18.ru
# Root: /usr/home/bar/mysql-4.1.b8663
--- 1.261/sql/item_func.cc 2006-05-07 13:43:22 +05:00
+++ 1.262/sql/item_func.cc 2006-06-14 13:32:02 +05:00
@@ -508,6 +508,26 @@ longlong Item_func_unsigned::val_int()
longlong value;
int error;
+ if (args[0]->result_type() == REAL_RESULT)
+ {
+ double dvalue= args[0]->val();
+ if ((null_value= args[0]->null_value))
+ return 0;
+ if (dvalue <= (double) LONGLONG_MIN)
+ {
+ return LONGLONG_MIN;
+ }
+ if (dvalue >= (double) (ulonglong) ULONGLONG_MAX)
+ {
+ return (longlong) ULONGLONG_MAX;
+ }
+ if (dvalue >= (double) (ulonglong) LONGLONG_MAX)
+ {
+ return (ulonglong) (dvalue + (dvalue > 0 ? 0.5 : -0.5));
+ }
+ return (longlong) (dvalue + (dvalue > 0 ? 0.5 : -0.5));
+ }
+
if (args[0]->cast_to_int_type() != STRING_RESULT)
{
value= args[0]->val_int();
--- 1.4/mysql-test/t/count_distinct3.test 2005-07-28 05:21:39 +05:00
+++ 1.5/mysql-test/t/count_distinct3.test 2006-06-14 13:31:30 +05:00
@@ -9,6 +9,7 @@ DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (id INTEGER, grp TINYINT, id_rev INTEGER);
+--disable_warnings
--disable_query_log
SET @rnd_max= 2147483647;
let $1 = 1000;
@@ -43,6 +44,7 @@ INSERT INTO t1 (id, grp, id_rev) SELECT
INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
DROP TABLE t2;
--enable_query_log
+--enable_warnings
SELECT COUNT(*) FROM t1;
--- 1.25/mysql-test/r/cast.result 2005-12-06 16:51:12 +04:00
+++ 1.26/mysql-test/r/cast.result 2006-06-14 13:29:30 +05:00
@@ -264,6 +264,9 @@ cast(repeat('1',20) as signed)
-7335632962598440505
Warnings:
Warning 1105 Cast to signed converted positive out-of-range integer to it's negative
complement
+select cast(19999999999999999999 as unsigned);
+cast(19999999999999999999 as unsigned)
+18446744073709551615
select cast(1.0e+300 as signed int);
cast(1.0e+300 as signed int)
9223372036854775807
--- 1.21/mysql-test/t/cast.test 2005-12-06 16:51:00 +04:00
+++ 1.22/mysql-test/t/cast.test 2006-06-14 13:31:00 +05:00
@@ -148,6 +148,12 @@ select cast(repeat('1',20) as unsigned);
select cast(repeat('1',20) as signed);
#
+# Bug#8663 cant use bgint unsigned as input to cast
+#
+select cast(19999999999999999999 as unsigned);
+
+
+#
# Bug #13344: cast of large decimal to signed int not handled correctly
#
select cast(1.0e+300 as signed int);
--- 1.49/mysql-test/r/ps.result 2006-04-08 00:50:37 +05:00
+++ 1.50/mysql-test/r/ps.result 2006-06-14 13:29:51 +05:00
@@ -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;
| Thread |
|---|
| • bk commit into 4.1 tree (bar:1.2491) BUG#8663 | bar | 14 Jun |