Merge maint1.mysql.com:/data/localhome/cmiller/bug15583/my51-bug15583

into  maint1.mysql.com:/data/localhome/cmiller/mysql-5.1-maint


sql/item_strfunc.cc:
  Auto merged
This commit is contained in:
unknown 2006-09-13 15:13:52 +02:00
commit 28502300f0
3 changed files with 69 additions and 8 deletions

View file

@ -2381,17 +2381,33 @@ String *Item_func_conv::val_str(String *str)
abs(to_base) > 36 || abs(to_base) < 2 ||
abs(from_base) > 36 || abs(from_base) < 2 || !(res->length()))
{
null_value=1;
return 0;
null_value= 1;
return NULL;
}
null_value=0;
null_value= 0;
unsigned_flag= !(from_base < 0);
if (from_base < 0)
dec= my_strntoll(res->charset(),res->ptr(),res->length(),-from_base,&endptr,&err);
if (args[0]->field_type() == MYSQL_TYPE_BIT)
{
/*
Special case: The string representation of BIT doesn't resemble the
decimal representation, so we shouldn't change it to string and then to
decimal.
*/
dec= args[0]->val_int();
}
else
dec= (longlong) my_strntoull(res->charset(),res->ptr(),res->length(),from_base,&endptr,&err);
ptr= longlong2str(dec,ans,to_base);
if (str->copy(ans,(uint32) (ptr-ans), default_charset()))
{
if (from_base < 0)
dec= my_strntoll(res->charset(), res->ptr(), res->length(),
-from_base, &endptr, &err);
else
dec= (longlong) my_strntoull(res->charset(), res->ptr(), res->length(),
from_base, &endptr, &err);
}
ptr= longlong2str(dec, ans, to_base);
if (str->copy(ans, (uint32) (ptr-ans), default_charset()))
return &my_empty_string;
return str;
}