Commit 99fd8f72 authored by serg@serg.mylan's avatar serg@serg.mylan

cleanup String::set(integer)

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