summaryrefslogtreecommitdiff
path: root/sql/item_strfunc.cc
diff options
context:
space:
mode:
authorunknown <bar@bar.mysql.r18.ru>2002-11-11 18:43:33 +0400
committerunknown <bar@bar.mysql.r18.ru>2002-11-11 18:43:33 +0400
commit84b95682cf6dd1444ebcf6de6521dd78877d5b18 (patch)
tree010f897b6190ff4efdeb8321d6e36e87f47fc592 /sql/item_strfunc.cc
parent50b32edc76d476a812a14727ccdfece3f85c7c72 (diff)
downloadmariadb-git-84b95682cf6dd1444ebcf6de6521dd78877d5b18.tar.gz
USER(), DATABASE() and CHARSET() functions are now UCS2 compatible
Bug fix in ctype-utf8.c sql/item_strfunc.cc: USER(), DATABASE() and CHARSET() functions are now UCS2 compatible sql/item_strfunc.h: USER(), DATABASE() and CHARSET() functions are now UCS2 compatible sql/procedure.h: USER(), DATABASE() and CHARSET() functions are now UCS2 compatible strings/ctype-utf8.c: Bug fix
Diffstat (limited to 'sql/item_strfunc.cc')
-rw-r--r--sql/item_strfunc.cc22
1 files changed, 15 insertions, 7 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 83b94ea145b..1a561c9eb34 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1366,17 +1366,25 @@ String *Item_func_database::val_str(String *str)
if (!current_thd->db)
str->length(0);
else
- str->set((const char*) current_thd->db,(uint) strlen(current_thd->db), default_charset_info);
+ str->copy((const char*) current_thd->db,(uint) strlen(current_thd->db), system_charset_info, thd_charset());
return str;
}
String *Item_func_user::val_str(String *str)
{
- THD *thd=current_thd;
- if (str->copy((const char*) thd->user,(uint) strlen(thd->user), system_charset_info) ||
- str->append('@') ||
- str->append(thd->host ? thd->host : thd->ip ? thd->ip : ""))
- return &empty_string;
+ THD *thd=current_thd;
+ CHARSET_INFO *cs=thd_charset();
+ const char *host=thd->host ? thd->host : thd->ip ? thd->ip : "";
+ uint32 res_length=(strlen(thd->user)+strlen(host)+10) * cs->mbmaxlen;
+
+ if (str->alloc(res_length))
+ {
+ null_value=1;
+ return 0;
+ }
+ res_length=cs->snprintf(cs, (char*)str->ptr(), res_length, "%s@%s",thd->user,host);
+ str->length(res_length);
+ str->set_charset(cs);
return str;
}
@@ -2120,7 +2128,7 @@ String *Item_func_charset::val_str(String *str)
if ((null_value=(args[0]->null_value || !res->charset())))
return 0;
- str->copy(res->charset()->name,strlen(res->charset()->name),default_charset_info);
+ str->copy(res->charset()->name,strlen(res->charset()->name),my_charset_latin1,thd_charset());
return str;
}