summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc23
1 files changed, 13 insertions, 10 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index fb2f361f676..f14091b4592 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -1520,16 +1520,20 @@ void Item_func_neg::fix_length_and_dec()
Use val() to get value as arg_type doesn't mean that item is
Item_int or Item_real due to existence of Item_param.
*/
- if (hybrid_type == INT_RESULT &&
- args[0]->type() == INT_ITEM &&
- ((ulonglong) args[0]->val_int() > (ulonglong) LONGLONG_MIN))
+ if (hybrid_type == INT_RESULT && args[0]->const_item())
{
- /*
- Ensure that result is converted to DECIMAL, as longlong can't hold
- the negated number
- */
- hybrid_type= DECIMAL_RESULT;
- DBUG_PRINT("info", ("Type changed: DECIMAL_RESULT"));
+ longlong val= args[0]->val_int();
+ if ((ulonglong) val >= (ulonglong) LONGLONG_MIN &&
+ ((ulonglong) val != (ulonglong) LONGLONG_MIN ||
+ args[0]->type() != INT_ITEM))
+ {
+ /*
+ Ensure that result is converted to DECIMAL, as longlong can't hold
+ the negated number
+ */
+ hybrid_type= DECIMAL_RESULT;
+ DBUG_PRINT("info", ("Type changed: DECIMAL_RESULT"));
+ }
}
unsigned_flag= 0;
DBUG_VOID_RETURN;
@@ -2499,7 +2503,6 @@ longlong Item_func_coercibility::val_int()
void Item_func_locate::fix_length_and_dec()
{
- maybe_null= 0;
max_length= MY_INT32_NUM_DECIMAL_DIGITS;
agg_arg_charsets(cmp_collation, args, 2, MY_COLL_CMP_CONV, 1);
}