mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
String->copy() now has a charset arg
This commit is contained in:
@ -4302,7 +4302,7 @@ int Field_blob::store(const char *from,uint len,CHARSET_INFO *cs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* USE_TIS620 */
|
#endif /* USE_TIS620 */
|
||||||
value.copy(from,len);
|
value.copy(from,len,charset());
|
||||||
from=value.ptr();
|
from=value.ptr();
|
||||||
#ifdef USE_TIS620
|
#ifdef USE_TIS620
|
||||||
my_free(th_ptr,MYF(MY_ALLOW_ZERO_PTR));
|
my_free(th_ptr,MYF(MY_ALLOW_ZERO_PTR));
|
||||||
|
@ -887,7 +887,7 @@ public:
|
|||||||
inline bool copy()
|
inline bool copy()
|
||||||
{ char *tmp;
|
{ char *tmp;
|
||||||
get_ptr(&tmp);
|
get_ptr(&tmp);
|
||||||
if (value.copy(tmp,get_length()))
|
if (value.copy(tmp,get_length(),charset()))
|
||||||
{
|
{
|
||||||
Field_blob::reset();
|
Field_blob::reset();
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1568,7 +1568,7 @@ void item_user_lock_release(ULL *ull)
|
|||||||
char buf[256];
|
char buf[256];
|
||||||
const char *command="DO RELEASE_LOCK(\"";
|
const char *command="DO RELEASE_LOCK(\"";
|
||||||
String tmp(buf,sizeof(buf), system_charset_info);
|
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(ull->key,ull->key_length);
|
||||||
tmp.append("\")");
|
tmp.append("\")");
|
||||||
Query_log_event qev(current_thd,tmp.ptr(), tmp.length());
|
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());
|
str->set(*(longlong*) entry->value,thd_charset());
|
||||||
break;
|
break;
|
||||||
case STRING_RESULT:
|
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;
|
null_value=1;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
str->set_charset(entry->var_charset);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
|
@ -1373,7 +1373,7 @@ String *Item_func_database::val_str(String *str)
|
|||||||
String *Item_func_user::val_str(String *str)
|
String *Item_func_user::val_str(String *str)
|
||||||
{
|
{
|
||||||
THD *thd=current_thd;
|
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('@') ||
|
||||||
str->append(thd->host ? thd->host : thd->ip ? thd->ip : ""))
|
str->append(thd->host ? thd->host : thd->ip ? thd->ip : ""))
|
||||||
return &empty_string;
|
return &empty_string;
|
||||||
@ -1899,7 +1899,7 @@ String *Item_func_conv::val_str(String *str)
|
|||||||
else
|
else
|
||||||
dec= (longlong) strtoull(res->c_ptr(),&endptr,from_base);
|
dec= (longlong) strtoull(res->c_ptr(),&endptr,from_base);
|
||||||
ptr= longlong2str(dec,ans,to_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 &empty_string;
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
@ -2120,7 +2120,7 @@ String *Item_func_charset::val_str(String *str)
|
|||||||
|
|
||||||
if ((null_value=(args[0]->null_value || !res->charset())))
|
if ((null_value=(args[0]->null_value || !res->charset())))
|
||||||
return 0;
|
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;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2135,7 +2135,7 @@ String *Item_func_hex::val_str(String *str)
|
|||||||
if ((null_value= args[0]->null_value))
|
if ((null_value= args[0]->null_value))
|
||||||
return 0;
|
return 0;
|
||||||
ptr= longlong2str(dec,ans,16);
|
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 &empty_string; // End of memory
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
@ -2454,7 +2454,9 @@ String *Item_func_geometry_type::val_str(String *str)
|
|||||||
if ((null_value=(args[0]->null_value ||
|
if ((null_value=(args[0]->null_value ||
|
||||||
geom.create_from_wkb(wkt->ptr(),wkt->length()))))
|
geom.create_from_wkb(wkt->ptr(),wkt->length()))))
|
||||||
return 0;
|
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;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ Item_sum_int::val_str(String *str)
|
|||||||
return 0;
|
return 0;
|
||||||
char buff[21];
|
char buff[21];
|
||||||
uint length= (uint) (longlong10_to_str(nr,buff,-10)-buff);
|
uint length= (uint) (longlong10_to_str(nr,buff,-10)-buff);
|
||||||
str->copy(buff,length);
|
str->copy(buff,length,thd_charset());
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,7 +396,7 @@ String *Item_date::val_str(String *str)
|
|||||||
return (String*) 0;
|
return (String*) 0;
|
||||||
if (!value) // zero daynr
|
if (!value) // zero daynr
|
||||||
{
|
{
|
||||||
str->copy("0000-00-00",10);
|
str->copy("0000-00-00",10,my_charset_latin1);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
if (str->alloc(11))
|
if (str->alloc(11))
|
||||||
@ -547,7 +547,7 @@ String *Item_func_sec_to_time::val_str(String *str)
|
|||||||
uint sec= (uint) ((ulonglong) seconds % 3600);
|
uint sec= (uint) ((ulonglong) seconds % 3600);
|
||||||
length= my_sprintf(buff,(buff,"%s%02lu:%02u:%02u",sign,(long) (seconds/3600),
|
length= my_sprintf(buff,(buff,"%s%02lu:%02u:%02u",sign,(long) (seconds/3600),
|
||||||
sec/60, sec % 60));
|
sec/60, sec % 60));
|
||||||
str->copy(buff, length);
|
str->copy(buff, length, my_charset_latin1);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ public:
|
|||||||
enum_field_types field_type() const { return FIELD_TYPE_STRING; }
|
enum_field_types field_type() const { return FIELD_TYPE_STRING; }
|
||||||
void set(double nr) { str_value.set(nr, 2, my_thd_charset); }
|
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(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()); }
|
double val() { return atof(str_value.ptr()); }
|
||||||
longlong val_int() { return strtoll(str_value.ptr(),NULL,10); }
|
longlong val_int() { return strtoll(str_value.ptr(),NULL,10); }
|
||||||
String *val_str(String*)
|
String *val_str(String*)
|
||||||
|
@ -117,7 +117,7 @@ bool String::set(double num,uint decimals, CHARSET_INFO *cs)
|
|||||||
if (decimals >= NOT_FIXED_DEC)
|
if (decimals >= NOT_FIXED_DEC)
|
||||||
{
|
{
|
||||||
sprintf(buff,"%.14g",num); // Enough for a DATETIME
|
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
|
#ifdef HAVE_FCONVERT
|
||||||
int decpt,sign;
|
int decpt,sign;
|
||||||
@ -182,7 +182,7 @@ end:
|
|||||||
#else
|
#else
|
||||||
sprintf(buff,"%.*f",(int) decimals,num);
|
sprintf(buff,"%.*f",(int) decimals,num);
|
||||||
#endif
|
#endif
|
||||||
return copy(buff,(uint32) strlen(buff));
|
return copy(buff,(uint32) strlen(buff), my_charset_latin1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,13 +208,14 @@ bool String::copy(const String &str)
|
|||||||
return FALSE;
|
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))
|
if (alloc(arg_length))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
if ((str_length=arg_length))
|
if ((str_length=arg_length))
|
||||||
memcpy(Ptr,str,arg_length);
|
memcpy(Ptr,str,arg_length);
|
||||||
Ptr[arg_length]=0;
|
Ptr[arg_length]=0;
|
||||||
|
str_charset=cs;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ public:
|
|||||||
|
|
||||||
bool copy(); // Alloc string if not alloced
|
bool copy(); // Alloc string if not alloced
|
||||||
bool copy(const String &s); // Allocate new string
|
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 String &s);
|
||||||
bool append(const char *s,uint32 arg_length=0);
|
bool append(const char *s,uint32 arg_length=0);
|
||||||
bool append(IO_CACHE* file, uint32 arg_length);
|
bool append(IO_CACHE* file, uint32 arg_length);
|
||||||
|
Reference in New Issue
Block a user