Commit c5dfdec5 authored by mithun's avatar mithun

Bug #19372926 : 5.5.38 FAILS FUNC_MATH MTR TEST.

Issue :
-------
This seems for some platform -(LONGLONG_MIN) is
not flagged as out of range.

Fix:
----
Fix is backported from mysql-5.6 bug 14314156.
Fixed by adding an explicit test for this value in
Item_func_neg::int_op().
parent ff906f03
...@@ -1760,7 +1760,13 @@ longlong Item_func_neg::int_op() ...@@ -1760,7 +1760,13 @@ longlong Item_func_neg::int_op()
if ((null_value= args[0]->null_value)) if ((null_value= args[0]->null_value))
return 0; return 0;
if (args[0]->unsigned_flag && if (args[0]->unsigned_flag &&
(ulonglong) value > (ulonglong) LONGLONG_MAX + 1) (ulonglong) value > (ulonglong) LONGLONG_MAX + 1ULL)
return raise_integer_overflow();
// For some platforms we need special handling of LONGLONG_MIN to
// guarantee overflow.
if (value == LONGLONG_MIN &&
!args[0]->unsigned_flag &&
!unsigned_flag)
return raise_integer_overflow(); return raise_integer_overflow();
return check_integer_overflow(-value, !args[0]->unsigned_flag && value < 0); return check_integer_overflow(-value, !args[0]->unsigned_flag && value < 0);
} }
......
#ifndef ITEM_FUNC_INCLUDED #ifndef ITEM_FUNC_INCLUDED
#define ITEM_FUNC_INCLUDED #define ITEM_FUNC_INCLUDED
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. /* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -251,7 +251,8 @@ class Item_func :public Item_result_field ...@@ -251,7 +251,8 @@ class Item_func :public Item_result_field
inline longlong check_integer_overflow(longlong value, bool val_unsigned) inline longlong check_integer_overflow(longlong value, bool val_unsigned)
{ {
if ((unsigned_flag && !val_unsigned && value < 0) || if ((unsigned_flag && !val_unsigned && value < 0) ||
(!unsigned_flag && val_unsigned && (ulonglong) value > LONGLONG_MAX)) (!unsigned_flag && val_unsigned &&
(ulonglong) value > (ulonglong) LONGLONG_MAX))
return raise_integer_overflow(); return raise_integer_overflow();
return value; return value;
} }
......
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