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


Public Member Functions | |
| Item_func_concat (List< Item > &list) | |
| Item_func_concat (Item *a, Item *b) | |
| 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 |
Definition at line 83 of file item_strfunc.h.
| void Item_func_concat::fix_length_and_dec | ( | ) | [virtual] |
Implements Item_result_field.
Definition at line 404 of file item_strfunc.cc.
References Item_func::agg_arg_charsets(), Item_func::arg_count, Item_func::args, DTCollation::collation, Item::collation, MAX_BLOB_WIDTH, Item::max_length, Item::maybe_null, charset_info_st::mbmaxlen, and MY_COLL_ALLOW_CONV.
00405 { 00406 ulonglong max_result_length= 0; 00407 00408 if (agg_arg_charsets(collation, args, arg_count, MY_COLL_ALLOW_CONV, 1)) 00409 return; 00410 00411 for (uint i=0 ; i < arg_count ; i++) 00412 { 00413 if (args[i]->collation.collation->mbmaxlen != collation.collation->mbmaxlen) 00414 max_result_length+= (args[i]->max_length / 00415 args[i]->collation.collation->mbmaxlen) * 00416 collation.collation->mbmaxlen; 00417 else 00418 max_result_length+= args[i]->max_length; 00419 } 00420 00421 if (max_result_length >= MAX_BLOB_WIDTH) 00422 { 00423 max_result_length= MAX_BLOB_WIDTH; 00424 maybe_null= 1; 00425 } 00426 max_length= (ulong) max_result_length; 00427 }
Here is the call graph for this function:

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

Implements Item.
Definition at line 302 of file item_strfunc.cc.
References String::alloc(), String::alloced_length(), String::append(), Item_func::arg_count, Item_func::args, DTCollation::collation, Item::collation, Item::const_item(), String::copy(), current_thd, DBUG_ASSERT, ER, ER_WARN_ALLOWED_PACKET_OVERFLOWED, Item::fixed, func_name(), String::is_alloced(), String::length(), Item::max_length, Item::null_value, String::ptr(), push_warning_printf(), String::replace(), String::set_charset(), tmp_value, Item::used_tables(), and MYSQL_ERROR::WARN_LEVEL_WARN.
00303 { 00304 DBUG_ASSERT(fixed == 1); 00305 String *res,*res2,*use_as_buff; 00306 uint i; 00307 bool is_const= 0; 00308 00309 null_value=0; 00310 if (!(res=args[0]->val_str(str))) 00311 goto null; 00312 use_as_buff= &tmp_value; 00313 /* Item_subselect in --ps-protocol mode will state it as a non-const */ 00314 is_const= args[0]->const_item() || !args[0]->used_tables(); 00315 for (i=1 ; i < arg_count ; i++) 00316 { 00317 if (res->length() == 0) 00318 { 00319 if (!(res=args[i]->val_str(str))) 00320 goto null; 00321 } 00322 else 00323 { 00324 if (!(res2=args[i]->val_str(use_as_buff))) 00325 goto null; 00326 if (res2->length() == 0) 00327 continue; 00328 if (res->length()+res2->length() > 00329 current_thd->variables.max_allowed_packet) 00330 { 00331 push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, 00332 ER_WARN_ALLOWED_PACKET_OVERFLOWED, 00333 ER(ER_WARN_ALLOWED_PACKET_OVERFLOWED), func_name(), 00334 current_thd->variables.max_allowed_packet); 00335 goto null; 00336 } 00337 if (!is_const && res->alloced_length() >= res->length()+res2->length()) 00338 { // Use old buffer 00339 res->append(*res2); 00340 } 00341 else if (str->alloced_length() >= res->length()+res2->length()) 00342 { 00343 if (str == res2) 00344 str->replace(0,0,*res); 00345 else 00346 { 00347 str->copy(*res); 00348 str->append(*res2); 00349 } 00350 res= str; 00351 use_as_buff= &tmp_value; 00352 } 00353 else if (res == &tmp_value) 00354 { 00355 if (res->append(*res2)) // Must be a blob 00356 goto null; 00357 } 00358 else if (res2 == &tmp_value) 00359 { // This can happend only 1 time 00360 if (tmp_value.replace(0,0,*res)) 00361 goto null; 00362 res= &tmp_value; 00363 use_as_buff=str; // Put next arg here 00364 } 00365 else if (tmp_value.is_alloced() && res2->ptr() >= tmp_value.ptr() && 00366 res2->ptr() <= tmp_value.ptr() + tmp_value.alloced_length()) 00367 { 00368 /* 00369 This happens really seldom: 00370 In this case res2 is sub string of tmp_value. We will 00371 now work in place in tmp_value to set it to res | res2 00372 */ 00373 /* Chop the last characters in tmp_value that isn't in res2 */ 00374 tmp_value.length((uint32) (res2->ptr() - tmp_value.ptr()) + 00375 res2->length()); 00376 /* Place res2 at start of tmp_value, remove chars before res2 */ 00377 if (tmp_value.replace(0,(uint32) (res2->ptr() - tmp_value.ptr()), 00378 *res)) 00379 goto null; 00380 res= &tmp_value; 00381 use_as_buff=str; // Put next arg here 00382 } 00383 else 00384 { // Two big const strings 00385 if (tmp_value.alloc(max_length) || 00386 tmp_value.copy(*res) || 00387 tmp_value.append(*res2)) 00388 goto null; 00389 res= &tmp_value; 00390 use_as_buff=str; 00391 } 00392 is_const= 0; 00393 } 00394 } 00395 res->set_charset(collation.collation); 00396 return res; 00397 00398 null: 00399 null_value=1; 00400 return 0; 00401 }
Here is the call graph for this function:

String Item_func_concat::tmp_value [private] |
1.4.7

