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


Public Member Functions | |
| Item_func_repeat (Item *arg1, Item *arg2) | |
| String * | val_str (String *) |
| void | fix_length_and_dec () |
| const char * | func_name () const |
Private Attributes | |
| String | tmp_value |
Definition at line 534 of file item_strfunc.h.
| void Item_func_repeat::fix_length_and_dec | ( | ) | [virtual] |
Implements Item_result_field.
Definition at line 2116 of file item_strfunc.cc.
References Item_func::args, Item::collation, Item_func::const_item(), MAX_BLOB_WIDTH, Item::max_length, Item::maybe_null, DTCollation::set(), and Item_str_func::val_int().
02117 { 02118 collation.set(args[0]->collation); 02119 if (args[1]->const_item()) 02120 { 02121 ulonglong max_result_length= ((ulonglong) args[0]->max_length * 02122 args[1]->val_int()); 02123 if (max_result_length >= MAX_BLOB_WIDTH) 02124 { 02125 max_result_length= MAX_BLOB_WIDTH; 02126 maybe_null= 1; 02127 } 02128 max_length= (ulong) max_result_length; 02129 } 02130 else 02131 { 02132 max_length= MAX_BLOB_WIDTH; 02133 maybe_null= 1; 02134 } 02135 }
Here is the call graph for this function:

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

Implements Item.
Definition at line 2142 of file item_strfunc.cc.
References alloc_buffer(), Item_func::args, count, current_thd, DBUG_ASSERT, ER, ER_WARN_ALLOWED_PACKET_OVERFLOWED, err, Item::fixed, func_name(), String::length(), memcpy, my_empty_string(), Item::null_value, String::ptr(), push_warning_printf(), tmp_value, to, Item_str_func::val_int(), Item::val_str(), and MYSQL_ERROR::WARN_LEVEL_WARN.
02143 { 02144 DBUG_ASSERT(fixed == 1); 02145 uint length,tot_length; 02146 char *to; 02147 long count= (long) args[1]->val_int(); 02148 String *res =args[0]->val_str(str); 02149 02150 if (args[0]->null_value || args[1]->null_value) 02151 goto err; // string and/or delim are null 02152 null_value=0; 02153 if (count <= 0) // For nicer SQL code 02154 return &my_empty_string; 02155 if (count == 1) // To avoid reallocs 02156 return res; 02157 length=res->length(); 02158 // Safe length check 02159 if (length > current_thd->variables.max_allowed_packet/count) 02160 { 02161 push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, 02162 ER_WARN_ALLOWED_PACKET_OVERFLOWED, 02163 ER(ER_WARN_ALLOWED_PACKET_OVERFLOWED), 02164 func_name(), current_thd->variables.max_allowed_packet); 02165 goto err; 02166 } 02167 tot_length= length*(uint) count; 02168 if (!(res= alloc_buffer(res,str,&tmp_value,tot_length))) 02169 goto err; 02170 02171 to=(char*) res->ptr()+length; 02172 while (--count) 02173 { 02174 memcpy(to,res->ptr(),length); 02175 to+=length; 02176 } 02177 return (res); 02178 02179 err: 02180 null_value=1; 02181 return 0; 02182 }
Here is the call graph for this function:

String Item_func_repeat::tmp_value [private] |
1.4.7

