#include <item_strfunc.h>
Inheritance diagram for Item_func_trim:


Public Member Functions | |
| Item_func_trim (Item *a, Item *b) | |
| Item_func_trim (Item *a) | |
| String * | val_str (String *) |
| void | fix_length_and_dec () |
| const char * | func_name () const |
| void | print (String *str) |
| virtual const char * | mode_name () const |
| bool | check_partition_func_processor (byte *bool_arg) |
Protected Attributes | |
| String | tmp_value |
| String | remove |
Definition at line 232 of file item_strfunc.h.
| Item_func_trim::Item_func_trim | ( | Item * | a | ) | [inline] |
| void Item_func_trim::fix_length_and_dec | ( | ) | [virtual] |
Implements Item_result_field.
Definition at line 1488 of file item_strfunc.cc.
References Item_func::agg_arg_charsets(), Item_func::arg_count, Item_func::args, DTCollation::collation, Item::collation, Item::max_length, MY_COLL_CMP_CONV, remove, DTCollation::set(), String::set_ascii(), and String::set_charset().
01489 { 01490 max_length= args[0]->max_length; 01491 if (arg_count == 1) 01492 { 01493 collation.set(args[0]->collation); 01494 remove.set_charset(collation.collation); 01495 remove.set_ascii(" ",1); 01496 } 01497 else 01498 { 01499 // Handle character set for args[1] and args[0]. 01500 // Note that we pass args[1] as the first item, and args[0] as the second. 01501 if (agg_arg_charsets(collation, &args[1], 2, MY_COLL_CMP_CONV, -1)) 01502 return; 01503 } 01504 }
Here is the call graph for this function:

| const char* Item_func_trim::func_name | ( | ) | const [inline, virtual] |
Implements Item_func.
Reimplemented in Item_func_ltrim, and Item_func_rtrim.
Definition at line 242 of file item_strfunc.h.
Referenced by print().
Here is the caller graph for this function:

| virtual const char* Item_func_trim::mode_name | ( | ) | const [inline, virtual] |
Reimplemented in Item_func_ltrim, and Item_func_rtrim.
Definition at line 244 of file item_strfunc.h.
Referenced by print().
Here is the caller graph for this function:

| void Item_func_trim::print | ( | String * | str | ) | [virtual] |
Reimplemented from Item_func.
Definition at line 1506 of file item_strfunc.cc.
References String::append(), Item_func::arg_count, Item_func::args, func_name(), mode_name(), Item::print(), Item_func::print(), and STRING_WITH_LEN.
01507 { 01508 if (arg_count == 1) 01509 { 01510 Item_func::print(str); 01511 return; 01512 } 01513 str->append(Item_func_trim::func_name()); 01514 str->append('('); 01515 str->append(mode_name()); 01516 str->append(' '); 01517 args[1]->print(str); 01518 str->append(STRING_WITH_LEN(" from ")); 01519 args[0]->print(str); 01520 str->append(')'); 01521 }
Here is the call graph for this function:

Implements Item.
Reimplemented in Item_func_ltrim, and Item_func_rtrim.
Definition at line 1426 of file item_strfunc.cc.
References Item_func::arg_count, Item_func::args, String::charset(), DBUG_ASSERT, Item::fixed, String::length(), LINT_INIT, MAX_FIELD_WIDTH, memcmp(), my_ismbchar, Item::null_value, p, String::ptr(), remove, String::set(), system_charset_info, tmp_value, use_mb, and Item::val_str().
01427 { 01428 DBUG_ASSERT(fixed == 1); 01429 char buff[MAX_FIELD_WIDTH], *ptr, *end; 01430 const char *r_ptr; 01431 String tmp(buff, sizeof(buff), system_charset_info); 01432 String *res, *remove_str; 01433 uint remove_length; 01434 LINT_INIT(remove_length); 01435 01436 res= args[0]->val_str(str); 01437 if ((null_value=args[0]->null_value)) 01438 return 0; 01439 remove_str= &remove; /* Default value. */ 01440 if (arg_count == 2) 01441 { 01442 remove_str= args[1]->val_str(&tmp); 01443 if ((null_value= args[1]->null_value)) 01444 return 0; 01445 } 01446 01447 if ((remove_length= remove_str->length()) == 0 || 01448 remove_length > res->length()) 01449 return res; 01450 01451 ptr= (char*) res->ptr(); 01452 end= ptr+res->length(); 01453 r_ptr= remove_str->ptr(); 01454 while (ptr+remove_length <= end && !memcmp(ptr,r_ptr,remove_length)) 01455 ptr+=remove_length; 01456 #ifdef USE_MB 01457 if (use_mb(res->charset())) 01458 { 01459 char *p=ptr; 01460 register uint32 l; 01461 loop: 01462 while (ptr + remove_length < end) 01463 { 01464 if ((l=my_ismbchar(res->charset(), ptr,end))) ptr+=l; 01465 else ++ptr; 01466 } 01467 if (ptr + remove_length == end && !memcmp(ptr,r_ptr,remove_length)) 01468 { 01469 end-=remove_length; 01470 ptr=p; 01471 goto loop; 01472 } 01473 ptr=p; 01474 } 01475 else 01476 #endif /* USE_MB */ 01477 { 01478 while (ptr + remove_length <= end && 01479 !memcmp(end-remove_length,r_ptr,remove_length)) 01480 end-=remove_length; 01481 } 01482 if (ptr == res->ptr() && end == ptr+res->length()) 01483 return res; 01484 tmp_value.set(*res,(uint) (ptr - res->ptr()),(uint) (end-ptr)); 01485 return &tmp_value; 01486 }
Here is the call graph for this function:

String Item_func_trim::remove [protected] |
Definition at line 236 of file item_strfunc.h.
Referenced by fix_length_and_dec(), val_str(), Item_func_rtrim::val_str(), and Item_func_ltrim::val_str().
String Item_func_trim::tmp_value [protected] |
Definition at line 235 of file item_strfunc.h.
Referenced by val_str(), Item_func_rtrim::val_str(), and Item_func_ltrim::val_str().
1.4.7

