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


Public Member Functions | |
| Item_func_lpad (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 | lpad_str |
Definition at line 558 of file item_strfunc.h.
| void Item_func_lpad::fix_length_and_dec | ( | ) | [virtual] |
Implements Item_result_field.
Definition at line 2267 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().
02268 { 02269 // Handle character set for args[0] and args[2]. 02270 if (agg_arg_charsets(collation, &args[0], 2, MY_COLL_ALLOW_CONV, 2)) 02271 return; 02272 02273 if (args[1]->const_item()) 02274 { 02275 ulonglong length= ((ulonglong) args[1]->val_int() * 02276 collation.collation->mbmaxlen); 02277 if (length >= MAX_BLOB_WIDTH) 02278 { 02279 length= MAX_BLOB_WIDTH; 02280 maybe_null= 1; 02281 } 02282 max_length= (ulong) length; 02283 } 02284 else 02285 { 02286 max_length= MAX_BLOB_WIDTH; 02287 maybe_null= 1; 02288 } 02289 }
Here is the call graph for this function:

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

Implements Item.
Definition at line 2292 of file item_strfunc.cc.
References String::alloc(), String::append(), 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(), lpad_str, charset_info_st::mbmaxlen, Item::null_value, String::numchars(), TaoCrypt::pad, push_warning_printf(), String::set_charset(), tmp_value, Item_str_func::val_int(), Item::val_str(), and MYSQL_ERROR::WARN_LEVEL_WARN.
02293 { 02294 DBUG_ASSERT(fixed == 1); 02295 uint32 res_char_length,pad_char_length; 02296 ulong count= (long) args[1]->val_int(), byte_count; 02297 String *res= args[0]->val_str(&tmp_value); 02298 String *pad= args[2]->val_str(&lpad_str); 02299 02300 if (!res || args[1]->null_value || !pad) 02301 goto err; 02302 02303 null_value=0; 02304 res_char_length= res->numchars(); 02305 02306 if (count <= res_char_length) 02307 { 02308 res->length(res->charpos(count)); 02309 return res; 02310 } 02311 02312 pad_char_length= pad->numchars(); 02313 byte_count= count * collation.collation->mbmaxlen; 02314 02315 if (byte_count > current_thd->variables.max_allowed_packet) 02316 { 02317 push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, 02318 ER_WARN_ALLOWED_PACKET_OVERFLOWED, 02319 ER(ER_WARN_ALLOWED_PACKET_OVERFLOWED), 02320 func_name(), current_thd->variables.max_allowed_packet); 02321 goto err; 02322 } 02323 02324 if (args[2]->null_value || !pad_char_length || str->alloc(byte_count)) 02325 goto err; 02326 02327 str->length(0); 02328 str->set_charset(collation.collation); 02329 count-= res_char_length; 02330 while (count >= pad_char_length) 02331 { 02332 str->append(*pad); 02333 count-= pad_char_length; 02334 } 02335 if (count > 0) 02336 str->append(pad->ptr(), pad->charpos(count), collation.collation); 02337 02338 str->append(*res); 02339 null_value= 0; 02340 return str; 02341 02342 err: 02343 null_value= 1; 02344 return 0; 02345 }
Here is the call graph for this function:

String Item_func_lpad::lpad_str [private] |
String Item_func_lpad::tmp_value [private] |
1.4.7

