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(). sql/item_func.cc: For some platforms we need special handling of LONGLONG_MIN to guarantee overflow.
This commit is contained in:
parent
a265914018
commit
73b99f055e
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#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 @@ public:
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user