Commit 7c1748a1 authored by unknown's avatar unknown

cleanup String::set(integer)

parent 98b03424
......@@ -7125,10 +7125,7 @@ int Field_blob::store(double nr)
int Field_blob::store(longlong nr, bool unsigned_val)
{
CHARSET_INFO *cs=charset();
if (unsigned_val)
value.set((ulonglong) nr, cs);
else
value.set(nr, cs);
value.set(nr, unsigned_val, cs);
return Field_blob::store(value.ptr(), (uint) value.length(), cs);
}
......
......@@ -212,10 +212,7 @@ String *Item::val_string_from_int(String *str)
longlong nr= val_int();
if (null_value)
return 0;
if (unsigned_flag)
str->set((ulonglong) nr, &my_charset_bin);
else
str->set(nr, &my_charset_bin);
str->set(nr, unsigned_flag, &my_charset_bin);
return str;
}
......
......@@ -556,10 +556,7 @@ String *Item_int_func::val_str(String *str)
longlong nr=val_int();
if (null_value)
return 0;
if (!unsigned_flag)
str->set(nr,&my_charset_bin);
else
str->set((ulonglong) nr,&my_charset_bin);
str->set(nr, unsigned_flag, &my_charset_bin);
return str;
}
......@@ -701,10 +698,7 @@ String *Item_func_numhybrid::val_str(String *str)
longlong nr= int_op();
if (null_value)
return 0; /* purecov: inspected */
if (!unsigned_flag)
str->set(nr,&my_charset_bin);
else
str->set((ulonglong) nr,&my_charset_bin);
str->set(nr, unsigned_flag, &my_charset_bin);
break;
}
case REAL_RESULT:
......@@ -2058,10 +2052,7 @@ String *Item_func_min_max::val_str(String *str)
longlong nr=val_int();
if (null_value)
return 0;
if (!unsigned_flag)
str->set(nr,&my_charset_bin);
else
str->set((ulonglong) nr,&my_charset_bin);
str->set(nr, unsigned_flag, &my_charset_bin);
return str;
}
case DECIMAL_RESULT:
......@@ -2847,10 +2838,7 @@ String *Item_func_udf_int::val_str(String *str)
longlong nr=val_int();
if (null_value)
return 0;
if (!unsigned_flag)
str->set(nr,&my_charset_bin);
else
str->set((ulonglong) nr,&my_charset_bin);
str->set(nr, unsigned_flag, &my_charset_bin);
return str;
}
......
......@@ -1584,10 +1584,7 @@ Item_sum_hybrid::val_str(String *str)
my_decimal2string(E_DEC_FATAL_ERROR, &sum_dec, 0, 0, 0, str);
return str;
case INT_RESULT:
if (unsigned_flag)
str->set((ulonglong) sum_int, &my_charset_bin);
else
str->set((longlong) sum_int, &my_charset_bin);
str->set(sum_int, unsigned_flag, &my_charset_bin);
break;
case ROW_RESULT:
default:
......
......@@ -96,24 +96,14 @@ bool String::realloc(uint32 alloc_length)
return FALSE;
}
bool String::set(longlong num, CHARSET_INFO *cs)
bool String::set(longlong num, bool unsigned_flag, CHARSET_INFO *cs)
{
uint l=20*cs->mbmaxlen+1;
int base= unsigned_flag ? 10 : -10;
if (alloc(l))
return TRUE;
str_length=(uint32) (cs->cset->longlong10_to_str)(cs,Ptr,l,-10,num);
str_charset=cs;
return FALSE;
}
bool String::set(ulonglong num, CHARSET_INFO *cs)
{
uint l=20*cs->mbmaxlen+1;
if (alloc(l))
return TRUE;
str_length=(uint32) (cs->cset->longlong10_to_str)(cs,Ptr,l,10,num);
str_length=(uint32) (cs->cset->longlong10_to_str)(cs,Ptr,l,base,num);
str_charset=cs;
return FALSE;
}
......
......@@ -139,8 +139,11 @@ class String
}
str_charset=cs;
}
bool set(longlong num, CHARSET_INFO *cs);
bool set(ulonglong num, CHARSET_INFO *cs);
bool set(longlong num, bool unsigned_flag, CHARSET_INFO *cs);
bool set(longlong num, CHARSET_INFO *cs)
{ return set(num, false, cs); }
bool set(ulonglong num, CHARSET_INFO *cs)
{ return set((longlong)num, true, cs); }
bool set(double num,uint decimals, CHARSET_INFO *cs);
/*
......
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