diff options
author | acurtis@xiphis.org <> | 2005-04-21 13:34:39 +0100 |
---|---|---|
committer | acurtis@xiphis.org <> | 2005-04-21 13:34:39 +0100 |
commit | c5d94db336f74dc120c0b90bfba324bc53077813 (patch) | |
tree | f0a079db183be6001e94610cc2739ebd61a810b2 /sql/sp_head.cc | |
parent | 564eb3dc98336663b6d414a347fe90dc6d2cb042 (diff) | |
parent | f67507588fc58b86a05ea494f669e2909b08bc72 (diff) | |
download | mariadb-git-c5d94db336f74dc120c0b90bfba324bc53077813.tar.gz |
Merge
Diffstat (limited to 'sql/sp_head.cc')
-rw-r--r-- | sql/sp_head.cc | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc index c505ef05b57..2d9cad61cd6 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -370,6 +370,7 @@ TYPELIB * sp_head::create_typelib(List<String> *src) { TYPELIB *result= NULL; + CHARSET_INFO *cs= m_returns_cs; DBUG_ENTER("sp_head::clone_typelib"); if (src->elements) { @@ -377,12 +378,39 @@ sp_head::create_typelib(List<String> *src) result->count= src->elements; result->name= ""; if (!(result->type_names=(const char **) - alloc_root(mem_root,sizeof(char *)*(result->count+1)))) + alloc_root(mem_root,(sizeof(char *)+sizeof(int))*(result->count+1)))) return 0; + result->type_lengths= (unsigned int *)(result->type_names + result->count+1); List_iterator<String> it(*src); + String conv, *tmp; + uint32 dummy; for (uint i=0; i<result->count; i++) - result->type_names[i]= strdup_root(mem_root, (it++)->c_ptr()); + { + tmp = it++; + if (String::needs_conversion(tmp->length(), tmp->charset(), + cs, &dummy)) + { + uint cnv_errs; + conv.copy(tmp->ptr(), tmp->length(), tmp->charset(), cs, &cnv_errs); + char *buf= (char*) alloc_root(mem_root,conv.length()+1); + memcpy(buf, conv.ptr(), conv.length()); + buf[conv.length()]= '\0'; + result->type_names[i]= buf; + result->type_lengths[i]= conv.length(); + } + else { + result->type_names[i]= strdup_root(mem_root, tmp->c_ptr()); + result->type_lengths[i]= tmp->length(); + } + + // Strip trailing spaces. + uint lengthsp= cs->cset->lengthsp(cs, result->type_names[i], + result->type_lengths[i]); + result->type_lengths[i]= lengthsp; + ((uchar *)result->type_names[i])[lengthsp]= '\0'; + } result->type_names[result->count]= 0; + result->type_lengths[result->count]= 0; } return result; } |