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


Public Member Functions | |
| Item_func_rpad (Item *arg1, Item *arg2, Item *arg3) | |
| String * | val_str (String *) |
| void | fix_length_and_dec () |
| const char * | func_name () const |
| bool | check_partition_func_processor (byte *bool_arg) |
Private Attributes | |
| String | tmp_value |
| String | rpad_str |
Definition at line 545 of file item_strfunc.h.
| void Item_func_rpad::fix_length_and_dec | ( | ) | [virtual] |
Implements Item_result_field.
Definition at line 2185 of file item_strfunc.cc.
References Item_func::agg_arg_charsets(), Item_func::args, DTCollation::collation, Item::collation, Item_func::const_item(), MAX_BLOB_WIDTH, Item::max_length, Item::maybe_null, charset_info_st::mbmaxlen, MY_COLL_ALLOW_CONV, and Item_str_func::val_int().
02186 { 02187 // Handle character set for args[0] and args[2]. 02188 if (agg_arg_charsets(collation, &args[0], 2, MY_COLL_ALLOW_CONV, 2)) 02189 return; 02190 if (args[1]->const_item()) 02191 { 02192 ulonglong length= ((ulonglong) args[1]->val_int() * 02193 collation.collation->mbmaxlen); 02194 if (length >= MAX_BLOB_WIDTH) 02195 { 02196 length= MAX_BLOB_WIDTH; 02197 maybe_null= 1; 02198 } 02199 max_length= (ulong) length; 02200 } 02201 else 02202 { 02203 max_length= MAX_BLOB_WIDTH; 02204 maybe_null= 1; 02205 } 02206 }
Here is the call graph for this function:

| const char* Item_func_rpad::func_name | ( | ) | const [inline, virtual] |
Implements Item_func.
Definition at line 553 of file item_strfunc.h.
Referenced by val_str().
Here is the caller graph for this function:

Implements Item.
Definition at line 2209 of file item_strfunc.cc.
References alloc_buffer(), Item_func::args, String::charpos(), DTCollation::collation, Item::collation, count, current_thd, DBUG_ASSERT, ER, ER_WARN_ALLOWED_PACKET_OVERFLOWED, err, Item::fixed, func_name(), String::length(), charset_info_st::mbmaxlen, memcpy, Item::null_value, String::numchars(), String::ptr(), push_warning_printf(), rpad_str, tmp_value, to, Item_str_func::val_int(), Item::val_str(), and MYSQL_ERROR::WARN_LEVEL_WARN.
02210 { 02211 DBUG_ASSERT(fixed == 1); 02212 uint32 res_byte_length,res_char_length,pad_char_length,pad_byte_length; 02213 char *to; 02214 const char *ptr_pad; 02215 int32 count= (int32) args[1]->val_int(); 02216 int32 byte_count= count * collation.collation->mbmaxlen; 02217 String *res =args[0]->val_str(str); 02218 String *rpad = args[2]->val_str(&rpad_str); 02219 02220 if (!res || args[1]->null_value || !rpad || count < 0) 02221 goto err; 02222 null_value=0; 02223 if (count <= (int32) (res_char_length=res->numchars())) 02224 { // String to pad is big enough 02225 res->length(res->charpos(count)); // Shorten result if longer 02226 return (res); 02227 } 02228 pad_char_length= rpad->numchars(); 02229 if ((ulong) byte_count > current_thd->variables.max_allowed_packet) 02230 { 02231 push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, 02232 ER_WARN_ALLOWED_PACKET_OVERFLOWED, 02233 ER(ER_WARN_ALLOWED_PACKET_OVERFLOWED), 02234 func_name(), current_thd->variables.max_allowed_packet); 02235 goto err; 02236 } 02237 if (args[2]->null_value || !pad_char_length) 02238 goto err; 02239 res_byte_length= res->length(); /* Must be done before alloc_buffer */ 02240 if (!(res= alloc_buffer(res,str,&tmp_value,byte_count))) 02241 goto err; 02242 02243 to= (char*) res->ptr()+res_byte_length; 02244 ptr_pad=rpad->ptr(); 02245 pad_byte_length= rpad->length(); 02246 count-= res_char_length; 02247 for ( ; (uint32) count > pad_char_length; count-= pad_char_length) 02248 { 02249 memcpy(to,ptr_pad,pad_byte_length); 02250 to+= pad_byte_length; 02251 } 02252 if (count) 02253 { 02254 pad_byte_length= rpad->charpos(count); 02255 memcpy(to,ptr_pad,(size_t) pad_byte_length); 02256 to+= pad_byte_length; 02257 } 02258 res->length(to- (char*) res->ptr()); 02259 return (res); 02260 02261 err: 02262 null_value=1; 02263 return 0; 02264 }
Here is the call graph for this function:

String Item_func_rpad::rpad_str [private] |
String Item_func_rpad::tmp_value [private] |
1.4.7

