Skip to content

Commit c5dfdec

Browse files
committed
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().
1 parent ff906f0 commit c5dfdec

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

sql/item_func.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1760,7 +1760,13 @@ longlong Item_func_neg::int_op()
17601760
if ((null_value= args[0]->null_value))
17611761
return 0;
17621762
if (args[0]->unsigned_flag &&
1763-
(ulonglong) value > (ulonglong) LONGLONG_MAX + 1)
1763+
(ulonglong) value > (ulonglong) LONGLONG_MAX + 1ULL)
1764+
return raise_integer_overflow();
1765+
// For some platforms we need special handling of LONGLONG_MIN to
1766+
// guarantee overflow.
1767+
if (value == LONGLONG_MIN &&
1768+
!args[0]->unsigned_flag &&
1769+
!unsigned_flag)
17641770
return raise_integer_overflow();
17651771
return check_integer_overflow(-value, !args[0]->unsigned_flag && value < 0);
17661772
}

sql/item_func.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef ITEM_FUNC_INCLUDED
22
#define ITEM_FUNC_INCLUDED
33

4-
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
4+
/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
55
66
This program is free software; you can redistribute it and/or modify
77
it under the terms of the GNU General Public License as published by
@@ -251,7 +251,8 @@ class Item_func :public Item_result_field
251251
inline longlong check_integer_overflow(longlong value, bool val_unsigned)
252252
{
253253
if ((unsigned_flag && !val_unsigned && value < 0) ||
254-
(!unsigned_flag && val_unsigned && (ulonglong) value > LONGLONG_MAX))
254+
(!unsigned_flag && val_unsigned &&
255+
(ulonglong) value > (ulonglong) LONGLONG_MAX))
255256
return raise_integer_overflow();
256257
return value;
257258
}

0 commit comments

Comments
 (0)