summaryrefslogtreecommitdiff
path: root/sql/item_strfunc.cc
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2006-07-13 18:16:16 +0400
committerunknown <evgen@moonbone.local>2006-07-13 18:16:16 +0400
commit805c33a5e161864c5eee91f02335eb59000c77b2 (patch)
tree7f6569df935d07558c6602029f0648e288a95f84 /sql/item_strfunc.cc
parenta7dddd3b67e70292c0813e80ad255f1dc2f3a867 (diff)
parentf783a15aada23772e9aae11f9732dd6e9ed095de (diff)
downloadmariadb-git-805c33a5e161864c5eee91f02335eb59000c77b2.tar.gz
Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0
into moonbone.local:/work/tmp_merge-5.0-opt-mysql mysql-test/r/rpl_insert_id.result: Auto merged mysql-test/t/rpl_insert_id.test: Auto merged sql/item_strfunc.cc: Auto merged sql/item_strfunc.h: Auto merged sql/sql_class.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_insert.cc: Auto merged sql/sql_select.cc: Auto merged
Diffstat (limited to 'sql/item_strfunc.cc')
-rw-r--r--sql/item_strfunc.cc39
1 files changed, 21 insertions, 18 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 8bc1bfaf7dd..c03f360271f 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -752,44 +752,47 @@ String *Item_func_reverse::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
String *res = args[0]->val_str(str);
- char *ptr,*end;
+ char *ptr, *end, *tmp;
if ((null_value=args[0]->null_value))
return 0;
/* An empty string is a special case as the string pointer may be null */
if (!res->length())
return &my_empty_string;
- res=copy_if_not_alloced(str,res,res->length());
- ptr = (char *) res->ptr();
- end=ptr+res->length();
+ if (tmp_value.alloced_length() < res->length() &&
+ tmp_value.realloc(res->length()))
+ {
+ null_value= 1;
+ return 0;
+ }
+ tmp_value.length(res->length());
+ tmp_value.set_charset(res->charset());
+ ptr= (char *) res->ptr();
+ end= ptr + res->length();
+ tmp= (char *) tmp_value.ptr() + tmp_value.length();
#ifdef USE_MB
if (use_mb(res->charset()))
{
- String tmpstr;
- tmpstr.copy(*res);
- char *tmp = (char *) tmpstr.ptr() + tmpstr.length();
register uint32 l;
while (ptr < end)
{
- if ((l=my_ismbchar(res->charset(), ptr,end)))
- tmp-=l, memcpy(tmp,ptr,l), ptr+=l;
+ if ((l= my_ismbchar(res->charset(),ptr,end)))
+ {
+ tmp-= l;
+ memcpy(tmp,ptr,l);
+ ptr+= l;
+ }
else
- *--tmp=*ptr++;
+ *--tmp= *ptr++;
}
- memcpy((char *) res->ptr(),(char *) tmpstr.ptr(), res->length());
}
else
#endif /* USE_MB */
{
- char tmp;
while (ptr < end)
- {
- tmp=*ptr;
- *ptr++=*--end;
- *end=tmp;
- }
+ *--tmp= *ptr++;
}
- return res;
+ return &tmp_value;
}