Commit 2434be61 authored by bar@bar.mysql.r18.ru's avatar bar@bar.mysql.r18.ru

String->copy() now has a charset arg

parent 86b63337
......@@ -4302,7 +4302,7 @@ int Field_blob::store(const char *from,uint len,CHARSET_INFO *cs)
}
}
#endif /* USE_TIS620 */
value.copy(from,len);
value.copy(from,len,charset());
from=value.ptr();
#ifdef USE_TIS620
my_free(th_ptr,MYF(MY_ALLOW_ZERO_PTR));
......
......@@ -887,7 +887,7 @@ class Field_blob :public Field_str {
inline bool copy()
{ char *tmp;
get_ptr(&tmp);
if (value.copy(tmp,get_length()))
if (value.copy(tmp,get_length(),charset()))
{
Field_blob::reset();
return 1;
......
......@@ -1568,7 +1568,7 @@ void item_user_lock_release(ULL *ull)
char buf[256];
const char *command="DO RELEASE_LOCK(\"";
String tmp(buf,sizeof(buf), system_charset_info);
tmp.copy(command, strlen(command));
tmp.copy(command, strlen(command), tmp.charset());
tmp.append(ull->key,ull->key_length);
tmp.append("\")");
Query_log_event qev(current_thd,tmp.ptr(), tmp.length());
......@@ -2040,12 +2040,11 @@ Item_func_get_user_var::val_str(String *str)
str->set(*(longlong*) entry->value,thd_charset());
break;
case STRING_RESULT:
if (str->copy(entry->value, entry->length-1))
if (str->copy(entry->value, entry->length-1, entry->var_charset))
{
null_value=1;
return NULL;
}
str->set_charset(entry->var_charset);
break;
}
return str;
......
......@@ -1373,7 +1373,7 @@ String *Item_func_database::val_str(String *str)
String *Item_func_user::val_str(String *str)
{
THD *thd=current_thd;
if (str->copy((const char*) thd->user,(uint) strlen(thd->user)) ||
if (str->copy((const char*) thd->user,(uint) strlen(thd->user), system_charset_info) ||
str->append('@') ||
str->append(thd->host ? thd->host : thd->ip ? thd->ip : ""))
return &empty_string;
......@@ -1899,7 +1899,7 @@ String *Item_func_conv::val_str(String *str)
else
dec= (longlong) strtoull(res->c_ptr(),&endptr,from_base);
ptr= longlong2str(dec,ans,to_base);
if (str->copy(ans,(uint32) (ptr-ans)))
if (str->copy(ans,(uint32) (ptr-ans), thd_charset()))
return &empty_string;
return str;
}
......@@ -2120,7 +2120,7 @@ String *Item_func_charset::val_str(String *str)
if ((null_value=(args[0]->null_value || !res->charset())))
return 0;
str->copy(res->charset()->name,strlen(res->charset()->name));
str->copy(res->charset()->name,strlen(res->charset()->name),default_charset_info);
return str;
}
......@@ -2135,7 +2135,7 @@ String *Item_func_hex::val_str(String *str)
if ((null_value= args[0]->null_value))
return 0;
ptr= longlong2str(dec,ans,16);
if (str->copy(ans,(uint32) (ptr-ans)))
if (str->copy(ans,(uint32) (ptr-ans),default_charset_info))
return &empty_string; // End of memory
return str;
}
......@@ -2454,7 +2454,9 @@ String *Item_func_geometry_type::val_str(String *str)
if ((null_value=(args[0]->null_value ||
geom.create_from_wkb(wkt->ptr(),wkt->length()))))
return 0;
str->copy(geom.get_class_info()->m_name,strlen(geom.get_class_info()->m_name));
str->copy(geom.get_class_info()->m_name,
strlen(geom.get_class_info()->m_name),
default_charset_info);
return str;
}
......
......@@ -106,7 +106,7 @@ Item_sum_int::val_str(String *str)
return 0;
char buff[21];
uint length= (uint) (longlong10_to_str(nr,buff,-10)-buff);
str->copy(buff,length);
str->copy(buff,length,thd_charset());
return str;
}
......
......@@ -396,7 +396,7 @@ String *Item_date::val_str(String *str)
return (String*) 0;
if (!value) // zero daynr
{
str->copy("0000-00-00",10);
str->copy("0000-00-00",10,my_charset_latin1);
return str;
}
if (str->alloc(11))
......@@ -547,7 +547,7 @@ String *Item_func_sec_to_time::val_str(String *str)
uint sec= (uint) ((ulonglong) seconds % 3600);
length= my_sprintf(buff,(buff,"%s%02lu:%02u:%02u",sign,(long) (seconds/3600),
sec/60, sec % 60));
str->copy(buff, length);
str->copy(buff, length, my_charset_latin1);
return str;
}
......
......@@ -94,7 +94,7 @@ class Item_proc_string :public Item_proc
enum_field_types field_type() const { return FIELD_TYPE_STRING; }
void set(double nr) { str_value.set(nr, 2, my_thd_charset); }
void set(longlong nr) { str_value.set(nr, my_thd_charset); }
void set(const char *str, uint length) { str_value.copy(str,length); }
void set(const char *str, uint length) { str_value.copy(str,length, my_thd_charset); }
double val() { return atof(str_value.ptr()); }
longlong val_int() { return strtoll(str_value.ptr(),NULL,10); }
String *val_str(String*)
......
......@@ -117,7 +117,7 @@ bool String::set(double num,uint decimals, CHARSET_INFO *cs)
if (decimals >= NOT_FIXED_DEC)
{
sprintf(buff,"%.14g",num); // Enough for a DATETIME
return copy(buff, (uint32) strlen(buff));
return copy(buff, (uint32) strlen(buff), my_charset_latin1);
}
#ifdef HAVE_FCONVERT
int decpt,sign;
......@@ -182,7 +182,7 @@ bool String::set(double num,uint decimals, CHARSET_INFO *cs)
#else
sprintf(buff,"%.*f",(int) decimals,num);
#endif
return copy(buff,(uint32) strlen(buff));
return copy(buff,(uint32) strlen(buff), my_charset_latin1);
#endif
}
......@@ -208,13 +208,14 @@ bool String::copy(const String &str)
return FALSE;
}
bool String::copy(const char *str,uint32 arg_length)
bool String::copy(const char *str,uint32 arg_length, CHARSET_INFO *cs)
{
if (alloc(arg_length))
return TRUE;
if ((str_length=arg_length))
memcpy(Ptr,str,arg_length);
Ptr[arg_length]=0;
str_charset=cs;
return FALSE;
}
......
......@@ -178,7 +178,7 @@ class String
bool copy(); // Alloc string if not alloced
bool copy(const String &s); // Allocate new string
bool copy(const char *s,uint32 arg_length); // Allocate new string
bool copy(const char *s,uint32 arg_length, CHARSET_INFO *cs); // Allocate new string
bool append(const String &s);
bool append(const char *s,uint32 arg_length=0);
bool append(IO_CACHE* file, uint32 arg_length);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment