Commit 626c8a1c authored by jimw@mysql.com's avatar jimw@mysql.com

Merge mysql.com:/home/jimw/my/mysql-4.1-13344

into  mysql.com:/home/jimw/my/mysql-4.1-clean
parents 6a19058c 3bfe3579
...@@ -264,3 +264,6 @@ cast(repeat('1',20) as signed) ...@@ -264,3 +264,6 @@ cast(repeat('1',20) as signed)
-7335632962598440505 -7335632962598440505
Warnings: Warnings:
Warning 1105 Cast to signed converted positive out-of-range integer to it's negative complement Warning 1105 Cast to signed converted positive out-of-range integer to it's negative complement
select cast(1.0e+300 as signed int);
cast(1.0e+300 as signed int)
9223372036854775807
...@@ -147,4 +147,9 @@ select cast(concat('184467440','73709551615') as signed); ...@@ -147,4 +147,9 @@ select cast(concat('184467440','73709551615') as signed);
select cast(repeat('1',20) as unsigned); select cast(repeat('1',20) as unsigned);
select cast(repeat('1',20) as signed); select cast(repeat('1',20) as signed);
#
# Bug #13344: cast of large decimal to signed int not handled correctly
#
select cast(1.0e+300 as signed int);
# End of 4.1 tests # End of 4.1 tests
...@@ -703,6 +703,14 @@ public: ...@@ -703,6 +703,14 @@ public:
longlong val_int() longlong val_int()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
if (value <= (double) LONGLONG_MIN)
{
return LONGLONG_MIN;
}
else if (value >= (double) (ulonglong) LONGLONG_MAX)
{
return LONGLONG_MAX;
}
return (longlong) (value+(value > 0 ? 0.5 : -0.5)); return (longlong) (value+(value > 0 ? 0.5 : -0.5));
} }
String *val_str(String*); String *val_str(String*);
......
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