diff options
author | Alexander Barkov <bar@mariadb.com> | 2018-09-21 18:17:32 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2018-09-21 18:17:32 +0400 |
commit | a4131c51f55bf0c0ee7bf5a72d877d2ecc46872e (patch) | |
tree | 28bb4656c8d4d9134322be0dc18036a78d3a8604 /sql | |
parent | acc97298e5605174b6891d6439555069f95089d9 (diff) | |
parent | fc70f21e0a874a535cd640695a60ecc76fb9aef2 (diff) | |
download | mariadb-git-a4131c51f55bf0c0ee7bf5a72d877d2ecc46872e.tar.gz |
Merge remote-tracking branch 'origin/5.5' into bb-10.0-barbb-10.0-bar
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item.h | 2 | ||||
-rw-r--r-- | sql/sql_type_int.h | 6 |
2 files changed, 6 insertions, 2 deletions
diff --git a/sql/item.h b/sql/item.h index 1d580280196..5bcdc45ce23 100644 --- a/sql/item.h +++ b/sql/item.h @@ -4027,7 +4027,7 @@ public: Base class to implement typed value caching Item classes Item_copy_ classes are very similar to the corresponding Item_ - classes (e.g. Item_copy_int is similar to Item_int) but they add + classes (e.g. Item_copy_string is similar to Item_string) but they add the following additional functionality to Item_ : 1. Nullability 2. Possibility to store the value not only on instantiation time, diff --git a/sql/sql_type_int.h b/sql/sql_type_int.h index 055790ba431..1eda5651df5 100644 --- a/sql/sql_type_int.h +++ b/sql/sql_type_int.h @@ -33,7 +33,11 @@ public: bool neg() const { return m_value < 0 && !m_unsigned; } ulonglong abs() const { - return neg() ? (ulonglong) -m_value : (ulonglong) m_value; + if (m_unsigned) + return (ulonglong) m_value; + if (m_value == LONGLONG_MIN) // avoid undefined behavior + return ((ulonglong) LONGLONG_MAX) + 1; + return m_value < 0 ? -m_value : m_value; } }; |