diff options
author | unknown <igor@olga.mysql.com> | 2006-07-06 13:40:08 -0700 |
---|---|---|
committer | unknown <igor@olga.mysql.com> | 2006-07-06 13:40:08 -0700 |
commit | cba001b77a3875b437a7b9f58e0ae081ba1d60c4 (patch) | |
tree | e627c269131cbb540c25419b17b0e62991ac3825 /sql | |
parent | 665d46e1b66b0ebfae69993ad2b43400bda784db (diff) | |
parent | 8cb368bcc37bb31fa7a2a2e1231801dcfbcf2385 (diff) | |
download | mariadb-git-cba001b77a3875b437a7b9f58e0ae081ba1d60c4.tar.gz |
Merge olga.mysql.com:/home/igor/mysql-4.1-opt
into olga.mysql.com:/home/igor/mysql-5.0-opt
mysql-test/r/func_str.result:
Auto merged
mysql-test/t/func_str.test:
Auto merged
sql/item.h:
Auto merged
sql/item_strfunc.cc:
Auto merged
sql/item_strfunc.h:
Auto merged
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item.h | 11 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 39 | ||||
-rw-r--r-- | sql/item_strfunc.h | 1 |
3 files changed, 31 insertions, 20 deletions
diff --git a/sql/item.h b/sql/item.h index 2cadfda6895..23849226c2f 100644 --- a/sql/item.h +++ b/sql/item.h @@ -697,9 +697,16 @@ public: Any new item which can be NULL must implement this call. */ virtual bool is_null() { return 0; } + /* - it is "top level" item of WHERE clause and we do not need correct NULL - handling + Inform the item that there will be no distinction between its result + being FALSE or NULL. + + NOTE + This function will be called for eg. Items that are top-level AND-parts + of the WHERE clause. Items implementing this function (currently + Item_cond_and and subquery-related item) enable special optimizations + when they are "top level". */ virtual void top_level_item() {} /* diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 7a35dedc08a..91b07eca652 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; } diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index af59b8d740b..ee5dd0b5c69 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -102,6 +102,7 @@ public: class Item_func_reverse :public Item_str_func { + String tmp_value; public: Item_func_reverse(Item *a) :Item_str_func(a) {} String *val_str(String *); |