diff options
author | unknown <cmiller@maint1.mysql.com> | 2006-09-13 15:01:19 +0200 |
---|---|---|
committer | unknown <cmiller@maint1.mysql.com> | 2006-09-13 15:01:19 +0200 |
commit | 76862eaf6071c83d329801b8674798ffcf637aad (patch) | |
tree | fdb81bb15796c9cc261fbb5e511349a22c2f28cc /sql/item_strfunc.cc | |
parent | eef51cd83d952b786def92fccde44b41a007c989 (diff) | |
parent | 629a4b1ae1fce674275354f3811a23eb67692c42 (diff) | |
download | mariadb-git-76862eaf6071c83d329801b8674798ffcf637aad.tar.gz |
Merge maint1.mysql.com:/data/localhome/cmiller/bug15583/my50-bug15583
into maint1.mysql.com:/data/localhome/cmiller/bug15583/my51-bug15583
mysql-test/r/type_bit.result:
Auto merged
sql/item_strfunc.cc:
Auto merged
Diffstat (limited to 'sql/item_strfunc.cc')
-rw-r--r-- | sql/item_strfunc.cc | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index dee7f408733..2bfe7e8e81b 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2359,17 +2359,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; } |