Now string values are created and filled with charset field

SELECT func(charset2) FROM t ORDER BY 1 works in correct charset
This commit is contained in:
bar@gw.udmsearch.izhnet.ru 2002-05-17 16:29:52 +05:00
parent 7fce07d52d
commit 196aa19cf6
37 changed files with 366 additions and 325 deletions

View File

@ -257,7 +257,7 @@ bool Field::send(THD *thd, String *packet)
if (is_null()) if (is_null())
return net_store_null(packet); return net_store_null(packet);
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String tmp(buff,sizeof(buff)); String tmp(buff,sizeof(buff),default_charset_info);
val_str(&tmp,&tmp); val_str(&tmp,&tmp);
CONVERT *convert; CONVERT *convert;
if ((convert=thd->convert_set)) if ((convert=thd->convert_set))
@ -320,7 +320,7 @@ uint Field::fill_cache_field(CACHE_FIELD *copy)
bool Field::get_date(TIME *ltime,bool fuzzydate) bool Field::get_date(TIME *ltime,bool fuzzydate)
{ {
char buff[40]; char buff[40];
String tmp(buff,sizeof(buff)),tmp2,*res; String tmp(buff,sizeof(buff),default_charset_info),tmp2,*res;
if (!(res=val_str(&tmp,&tmp2)) || if (!(res=val_str(&tmp,&tmp2)) ||
str_to_TIME(res->ptr(),res->length(),ltime,fuzzydate) == TIMESTAMP_NONE) str_to_TIME(res->ptr(),res->length(),ltime,fuzzydate) == TIMESTAMP_NONE)
return 1; return 1;
@ -330,7 +330,7 @@ bool Field::get_date(TIME *ltime,bool fuzzydate)
bool Field::get_time(TIME *ltime) bool Field::get_time(TIME *ltime)
{ {
char buff[40]; char buff[40];
String tmp(buff,sizeof(buff)),tmp2,*res; String tmp(buff,sizeof(buff),default_charset_info),tmp2,*res;
if (!(res=val_str(&tmp,&tmp2)) || if (!(res=val_str(&tmp,&tmp2)) ||
str_to_time(res->ptr(),res->length(),ltime)) str_to_time(res->ptr(),res->length(),ltime))
return 1; return 1;
@ -344,22 +344,22 @@ void Field::store_time(TIME *ltime,timestamp_type type)
char buff[25]; char buff[25];
switch (type) { switch (type) {
case TIMESTAMP_NONE: case TIMESTAMP_NONE:
store("",0); // Probably an error store("",0,default_charset_info); // Probably an error
break; break;
case TIMESTAMP_DATE: case TIMESTAMP_DATE:
sprintf(buff,"%04d-%02d-%02d", ltime->year,ltime->month,ltime->day); sprintf(buff,"%04d-%02d-%02d", ltime->year,ltime->month,ltime->day);
store(buff,10); store(buff,10,default_charset_info);
break; break;
case TIMESTAMP_FULL: case TIMESTAMP_FULL:
sprintf(buff,"%04d-%02d-%02d %02d:%02d:%02d", sprintf(buff,"%04d-%02d-%02d %02d:%02d:%02d",
ltime->year,ltime->month,ltime->day, ltime->year,ltime->month,ltime->day,
ltime->hour,ltime->minute,ltime->second); ltime->hour,ltime->minute,ltime->second);
store(buff,19); store(buff,19,default_charset_info);
break; break;
case TIMESTAMP_TIME: case TIMESTAMP_TIME:
sprintf(buff, "%02d:%02d:%02d", sprintf(buff, "%02d:%02d:%02d",
ltime->hour,ltime->minute,ltime->second); ltime->hour,ltime->minute,ltime->second);
store(buff,(uint) strlen(buff)); store(buff,(uint) strlen(buff),default_charset_info);
break; break;
} }
} }
@ -378,7 +378,7 @@ bool Field::optimize_range(uint idx)
void void
Field_decimal::reset(void) Field_decimal::reset(void)
{ {
Field_decimal::store("0",1); Field_decimal::store("0",1,default_charset_info);
} }
void Field_decimal::overflow(bool negative) void Field_decimal::overflow(bool negative)
@ -397,7 +397,7 @@ void Field_decimal::overflow(bool negative)
} }
void Field_decimal::store(const char *from,uint len) void Field_decimal::store(const char *from,uint len,CHARSET_INFO *cs)
{ {
reg3 int i; reg3 int i;
uint tmp_dec; uint tmp_dec;
@ -589,7 +589,7 @@ String *Field_decimal::val_str(String *val_buffer __attribute__((unused)),
if (field_length < tmp_length) // Error in data if (field_length < tmp_length) // Error in data
val_ptr->length(0); val_ptr->length(0);
else else
val_ptr->set((const char*) str,field_length-tmp_length); val_ptr->set((const char*) str,field_length-tmp_length,default_charset_info);
return val_ptr; return val_ptr;
} }
@ -672,9 +672,9 @@ void Field_decimal::sql_type(String &res) const
** tiny int ** tiny int
****************************************************************************/ ****************************************************************************/
void Field_tiny::store(const char *from,uint len) void Field_tiny::store(const char *from,uint len,CHARSET_INFO *cs)
{ {
String tmp_str(from,len); String tmp_str(from,len,default_charset_info);
long tmp= strtol(tmp_str.c_ptr(),NULL,10); long tmp= strtol(tmp_str.c_ptr(),NULL,10);
if (unsigned_flag) if (unsigned_flag)
@ -843,9 +843,9 @@ void Field_tiny::sql_type(String &res) const
// Note: Sometimes this should be fixed to use one strtol() to use // Note: Sometimes this should be fixed to use one strtol() to use
// len and check for garbage after number. // len and check for garbage after number.
void Field_short::store(const char *from,uint len) void Field_short::store(const char *from,uint len,CHARSET_INFO *cs)
{ {
String tmp_str(from,len); String tmp_str(from,len,default_charset_info);
long tmp= strtol(tmp_str.c_ptr(),NULL,10); long tmp= strtol(tmp_str.c_ptr(),NULL,10);
if (unsigned_flag) if (unsigned_flag)
{ {
@ -1083,9 +1083,9 @@ void Field_short::sql_type(String &res) const
// Note: Sometimes this should be fixed to use one strtol() to use // Note: Sometimes this should be fixed to use one strtol() to use
// len and check for garbage after number. // len and check for garbage after number.
void Field_medium::store(const char *from,uint len) void Field_medium::store(const char *from,uint len,CHARSET_INFO *cs)
{ {
String tmp_str(from,len); String tmp_str(from,len,default_charset_info);
long tmp= strtol(tmp_str.c_ptr(),NULL,10); long tmp= strtol(tmp_str.c_ptr(),NULL,10);
if (unsigned_flag) if (unsigned_flag)
@ -1268,14 +1268,14 @@ void Field_medium::sql_type(String &res) const
// Note: Sometimes this should be fixed to use one strtol() to use // Note: Sometimes this should be fixed to use one strtol() to use
// len and check for garbage after number. // len and check for garbage after number.
void Field_long::store(const char *from,uint len) void Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
{ {
while (len && my_isspace(system_charset_info,*from)) while (len && my_isspace(system_charset_info,*from))
{ {
len--; from++; len--; from++;
} }
long tmp; long tmp;
String tmp_str(from,len); String tmp_str(from,len,default_charset_info);
errno=0; errno=0;
if (unsigned_flag) if (unsigned_flag)
{ {
@ -1496,14 +1496,14 @@ void Field_long::sql_type(String &res) const
** longlong int ** longlong int
****************************************************************************/ ****************************************************************************/
void Field_longlong::store(const char *from,uint len) void Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs)
{ {
while (len && my_isspace(system_charset_info,*from)) while (len && my_isspace(system_charset_info,*from))
{ // For easy error check { // For easy error check
len--; from++; len--; from++;
} }
longlong tmp; longlong tmp;
String tmp_str(from,len); String tmp_str(from,len,default_charset_info);
errno=0; errno=0;
if (unsigned_flag) if (unsigned_flag)
{ {
@ -1703,9 +1703,9 @@ void Field_longlong::sql_type(String &res) const
** single precision float ** single precision float
****************************************************************************/ ****************************************************************************/
void Field_float::store(const char *from,uint len) void Field_float::store(const char *from,uint len,CHARSET_INFO *cs)
{ {
String tmp_str(from,len); String tmp_str(from,len,default_charset_info);
errno=0; errno=0;
Field_float::store(atof(tmp_str.c_ptr())); Field_float::store(atof(tmp_str.c_ptr()));
if (errno || current_thd->count_cuted_fields && !test_if_real(from,len)) if (errno || current_thd->count_cuted_fields && !test_if_real(from,len))
@ -1953,9 +1953,9 @@ void Field_float::sql_type(String &res) const
** double precision floating point numbers ** double precision floating point numbers
****************************************************************************/ ****************************************************************************/
void Field_double::store(const char *from,uint len) void Field_double::store(const char *from,uint len,CHARSET_INFO *cs)
{ {
String tmp_str(from,len); String tmp_str(from,len,default_charset_info);
errno=0; errno=0;
double j= atof(tmp_str.c_ptr()); double j= atof(tmp_str.c_ptr());
if (errno || current_thd->count_cuted_fields && !test_if_real(from,len)) if (errno || current_thd->count_cuted_fields && !test_if_real(from,len))
@ -2209,7 +2209,7 @@ Field_timestamp::Field_timestamp(char *ptr_arg, uint32 len_arg,
} }
void Field_timestamp::store(const char *from,uint len) void Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs)
{ {
long tmp=(long) str_to_timestamp(from,len); long tmp=(long) str_to_timestamp(from,len);
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
@ -2548,7 +2548,7 @@ void Field_timestamp::set_time()
** Stored as a 3 byte unsigned int ** Stored as a 3 byte unsigned int
****************************************************************************/ ****************************************************************************/
void Field_time::store(const char *from,uint len) void Field_time::store(const char *from,uint len,CHARSET_INFO *cs)
{ {
TIME ltime; TIME ltime;
long tmp; long tmp;
@ -2688,7 +2688,7 @@ void Field_time::sort_string(char *to,uint length __attribute__((unused)))
void Field_time::sql_type(String &res) const void Field_time::sql_type(String &res) const
{ {
res.set("time",4); res.set("time",4,default_charset_info);
} }
/**************************************************************************** /****************************************************************************
@ -2697,9 +2697,9 @@ void Field_time::sql_type(String &res) const
** Can handle 2 byte or 4 byte years! ** Can handle 2 byte or 4 byte years!
****************************************************************************/ ****************************************************************************/
void Field_year::store(const char *from, uint len) void Field_year::store(const char *from, uint len,CHARSET_INFO *cs)
{ {
String tmp_str(from,len); String tmp_str(from,len,default_charset_info);
long nr= strtol(tmp_str.c_ptr(),NULL,10); long nr= strtol(tmp_str.c_ptr(),NULL,10);
if (nr < 0 || nr >= 100 && nr <= 1900 || nr > 2155) if (nr < 0 || nr >= 100 && nr <= 1900 || nr > 2155)
@ -2786,7 +2786,7 @@ void Field_year::sql_type(String &res) const
** Stored as a 4 byte unsigned int ** Stored as a 4 byte unsigned int
****************************************************************************/ ****************************************************************************/
void Field_date::store(const char *from, uint len) void Field_date::store(const char *from, uint len,CHARSET_INFO *cs)
{ {
TIME l_time; TIME l_time;
uint32 tmp; uint32 tmp;
@ -2934,7 +2934,7 @@ void Field_date::sort_string(char *to,uint length __attribute__((unused)))
void Field_date::sql_type(String &res) const void Field_date::sql_type(String &res) const
{ {
res.set("date",4); res.set("date",4,default_charset_info);
} }
/**************************************************************************** /****************************************************************************
@ -2943,7 +2943,7 @@ void Field_date::sql_type(String &res) const
** In number context: YYYYMMDD ** In number context: YYYYMMDD
****************************************************************************/ ****************************************************************************/
void Field_newdate::store(const char *from,uint len) void Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs)
{ {
TIME l_time; TIME l_time;
long tmp; long tmp;
@ -3085,7 +3085,7 @@ void Field_newdate::sort_string(char *to,uint length __attribute__((unused)))
void Field_newdate::sql_type(String &res) const void Field_newdate::sql_type(String &res) const
{ {
res.set("date",4); res.set("date",4,default_charset_info);
} }
@ -3096,7 +3096,7 @@ void Field_newdate::sql_type(String &res) const
** Stored as a 8 byte unsigned int. Should sometimes be change to a 6 byte int. ** Stored as a 8 byte unsigned int. Should sometimes be change to a 6 byte int.
****************************************************************************/ ****************************************************************************/
void Field_datetime::store(const char *from,uint len) void Field_datetime::store(const char *from,uint len,CHARSET_INFO *cs)
{ {
longlong tmp=str_to_datetime(from,len,1); longlong tmp=str_to_datetime(from,len,1);
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
@ -3302,7 +3302,7 @@ void Field_datetime::sort_string(char *to,uint length __attribute__((unused)))
void Field_datetime::sql_type(String &res) const void Field_datetime::sql_type(String &res) const
{ {
res.set("datetime",8); res.set("datetime",8,default_charset_info);
} }
/**************************************************************************** /****************************************************************************
@ -3312,8 +3312,9 @@ void Field_datetime::sql_type(String &res) const
/* Copy a string and fill with space */ /* Copy a string and fill with space */
void Field_string::store(const char *from,uint length) void Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
{ {
field_charset=cs;
#ifdef USE_TIS620 #ifdef USE_TIS620
if(!binary_flag) { if(!binary_flag) {
ThNormalize((uchar *)ptr, field_length, (uchar *)from, length); ThNormalize((uchar *)ptr, field_length, (uchar *)from, length);
@ -3354,7 +3355,7 @@ void Field_string::store(double nr)
int width=min(field_length,DBL_DIG+5); int width=min(field_length,DBL_DIG+5);
sprintf(buff,"%-*.*g",width,max(width-5,0),nr); sprintf(buff,"%-*.*g",width,max(width-5,0),nr);
end=strcend(buff,' '); end=strcend(buff,' ');
Field_string::store(buff,(uint) (end - buff)); Field_string::store(buff,(uint) (end - buff), default_charset_info);
} }
@ -3362,7 +3363,7 @@ void Field_string::store(longlong nr)
{ {
char buff[22]; char buff[22];
char *end=longlong10_to_str(nr,buff,-10); char *end=longlong10_to_str(nr,buff,-10);
Field_string::store(buff,(uint) (end-buff)); Field_string::store(buff,(uint) (end-buff), default_charset_info);
} }
@ -3397,7 +3398,7 @@ String *Field_string::val_str(String *val_buffer __attribute__((unused)),
#endif #endif
while (end > ptr && end[-1] == ' ') while (end > ptr && end[-1] == ' ')
end--; end--;
val_ptr->set((const char*) ptr,(uint) (end - ptr)); val_ptr->set((const char*) ptr,(uint) (end - ptr),field_charset);
return val_ptr; return val_ptr;
} }
@ -3516,8 +3517,9 @@ uint Field_string::max_packed_col_length(uint max_length)
****************************************************************************/ ****************************************************************************/
void Field_varstring::store(const char *from,uint length) void Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
{ {
field_charset=cs;
#ifdef USE_TIS620 #ifdef USE_TIS620
if(!binary_flag) if(!binary_flag)
{ {
@ -3545,7 +3547,7 @@ void Field_varstring::store(double nr)
int width=min(field_length,DBL_DIG+5); int width=min(field_length,DBL_DIG+5);
sprintf(buff,"%-*.*g",width,max(width-5,0),nr); sprintf(buff,"%-*.*g",width,max(width-5,0),nr);
end=strcend(buff,' '); end=strcend(buff,' ');
Field_varstring::store(buff,(uint) (end - buff)); Field_varstring::store(buff,(uint) (end - buff), default_charset_info);
} }
@ -3553,7 +3555,7 @@ void Field_varstring::store(longlong nr)
{ {
char buff[22]; char buff[22];
char *end=longlong10_to_str(nr,buff,-10); char *end=longlong10_to_str(nr,buff,-10);
Field_varstring::store(buff,(uint) (end-buff)); Field_varstring::store(buff,(uint) (end-buff), default_charset_info);
} }
@ -3585,7 +3587,7 @@ String *Field_varstring::val_str(String *val_buffer __attribute__((unused)),
String *val_ptr) String *val_ptr)
{ {
uint length=uint2korr(ptr); uint length=uint2korr(ptr);
val_ptr->set((const char*) ptr+2,length); val_ptr->set((const char*) ptr+2,length,field_charset);
return val_ptr; return val_ptr;
} }
@ -3741,7 +3743,7 @@ Field_blob::Field_blob(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
bool binary_arg) bool binary_arg)
:Field_str(ptr_arg, (1L << min(blob_pack_length,3)*8)-1L, :Field_str(ptr_arg, (1L << min(blob_pack_length,3)*8)-1L,
null_ptr_arg, null_bit_arg, unireg_check_arg, field_name_arg, null_ptr_arg, null_bit_arg, unireg_check_arg, field_name_arg,
table_arg), table_arg, default_charset_info),
packlength(blob_pack_length),binary_flag(binary_arg), geom_flag(true) packlength(blob_pack_length),binary_flag(binary_arg), geom_flag(true)
{ {
flags|= BLOB_FLAG; flags|= BLOB_FLAG;
@ -3833,8 +3835,9 @@ uint32 Field_blob::get_length(const char *pos)
} }
void Field_blob::store(const char *from,uint len) void Field_blob::store(const char *from,uint len,CHARSET_INFO *cs)
{ {
field_charset=cs;
if (!len) if (!len)
{ {
bzero(ptr,Field_blob::pack_length()); bzero(ptr,Field_blob::pack_length());
@ -3872,14 +3875,14 @@ void Field_blob::store(const char *from,uint len)
void Field_blob::store(double nr) void Field_blob::store(double nr)
{ {
value.set(nr); value.set(nr);
Field_blob::store(value.ptr(),(uint) value.length()); Field_blob::store(value.ptr(),(uint) value.length(), default_charset_info);
} }
void Field_blob::store(longlong nr) void Field_blob::store(longlong nr)
{ {
value.set(nr); value.set(nr);
Field_blob::store(value.ptr(), (uint) value.length()); Field_blob::store(value.ptr(), (uint) value.length(), default_charset_info);
} }
@ -3922,9 +3925,9 @@ String *Field_blob::val_str(String *val_buffer __attribute__((unused)),
char *blob; char *blob;
memcpy_fixed(&blob,ptr+packlength,sizeof(char*)); memcpy_fixed(&blob,ptr+packlength,sizeof(char*));
if (!blob) if (!blob)
val_ptr->set("",0); // A bit safer than ->length(0) val_ptr->set("",0,default_charset_info); // A bit safer than ->length(0)
else else
val_ptr->set((const char*) blob,get_length(ptr)); val_ptr->set((const char*) blob,get_length(ptr),default_charset_info);
return val_ptr; return val_ptr;
} }
@ -4026,7 +4029,7 @@ void Field_blob::get_key_image(char *buff,uint length, imagetype type)
void Field_blob::set_key_image(char *buff,uint length) void Field_blob::set_key_image(char *buff,uint length)
{ {
length=uint2korr(buff); length=uint2korr(buff);
Field_blob::store(buff+2,length); Field_blob::store(buff+2,length, default_charset_info);
} }
void Field_geom::get_key_image(char *buff,uint length, imagetype type) void Field_geom::get_key_image(char *buff,uint length, imagetype type)
@ -4121,7 +4124,7 @@ void Field_blob::sql_type(String &res) const
case 3: str="medium"; break; case 3: str="medium"; break;
case 4: str="long"; break; case 4: str="long"; break;
} }
res.set(str,(uint) strlen(str)); res.set(str,(uint) strlen(str),default_charset_info);
res.append(binary_flag ? "blob" : "text"); res.append(binary_flag ? "blob" : "text");
} }
@ -4342,7 +4345,7 @@ uint find_enum(TYPELIB *lib,const char *x, uint length)
** (if there isn't a empty value in the enum) ** (if there isn't a empty value in the enum)
*/ */
void Field_enum::store(const char *from,uint length) void Field_enum::store(const char *from,uint length,CHARSET_INFO *cs)
{ {
uint tmp=find_enum(typelib,from,length); uint tmp=find_enum(typelib,from,length);
if (!tmp) if (!tmp)
@ -4448,7 +4451,8 @@ String *Field_enum::val_str(String *val_buffer __attribute__((unused)),
val_ptr->length(0); val_ptr->length(0);
else else
val_ptr->set((const char*) typelib->type_names[tmp-1], val_ptr->set((const char*) typelib->type_names[tmp-1],
(uint) strlen(typelib->type_names[tmp-1])); (uint) strlen(typelib->type_names[tmp-1]),
default_charset_info);
return val_ptr; return val_ptr;
} }
@ -4534,7 +4538,7 @@ ulonglong find_set(TYPELIB *lib,const char *x,uint length)
} }
void Field_set::store(const char *from,uint length) void Field_set::store(const char *from,uint length,CHARSET_INFO *cs)
{ {
ulonglong tmp=find_set(typelib,from,length); ulonglong tmp=find_set(typelib,from,length);
if (!tmp && length && length < 22) if (!tmp && length && length < 22)
@ -4585,7 +4589,8 @@ String *Field_set::val_str(String *val_buffer,
if (val_buffer->length()) if (val_buffer->length())
val_buffer->append(field_separator); val_buffer->append(field_separator);
String str(typelib->type_names[bitnr], String str(typelib->type_names[bitnr],
(uint) strlen(typelib->type_names[bitnr])); (uint) strlen(typelib->type_names[bitnr]),
default_charset_info);
val_buffer->append(str); val_buffer->append(str);
} }
tmp>>=1; tmp>>=1;
@ -4723,7 +4728,7 @@ Field *make_field(char *ptr, uint32 field_length,
if (!f_is_packed(pack_flag)) if (!f_is_packed(pack_flag))
return new Field_string(ptr,field_length,null_pos,null_bit, return new Field_string(ptr,field_length,null_pos,null_bit,
unireg_check, field_name, table, unireg_check, field_name, table,
f_is_binary(pack_flag) != 0); f_is_binary(pack_flag) != 0, default_charset_info);
uint pack_length=calc_pack_length((enum_field_types) uint pack_length=calc_pack_length((enum_field_types)
f_packtype(pack_flag), f_packtype(pack_flag),
@ -4853,7 +4858,7 @@ create_field::create_field(Field *old_field,Field *orig_field)
orig_field) orig_field)
{ {
char buff[MAX_FIELD_WIDTH],*pos; char buff[MAX_FIELD_WIDTH],*pos;
String tmp(buff,sizeof(buff)); String tmp(buff,sizeof(buff),default_charset_info);
/* Get the value from record[2] (the default value row) */ /* Get the value from record[2] (the default value row) */
my_ptrdiff_t diff= (my_ptrdiff_t) (orig_field->table->rec_buff_length*2); my_ptrdiff_t diff= (my_ptrdiff_t) (orig_field->table->rec_buff_length*2);
@ -4865,7 +4870,7 @@ create_field::create_field(Field *old_field,Field *orig_field)
{ {
pos= (char*) sql_memdup(tmp.ptr(),tmp.length()+1); pos= (char*) sql_memdup(tmp.ptr(),tmp.length()+1);
pos[tmp.length()]=0; pos[tmp.length()]=0;
def=new Item_string(pos,tmp.length()); def=new Item_string(pos,tmp.length(),default_charset_info);
} }
} }
} }

View File

@ -59,7 +59,7 @@ public:
utype unireg_check_arg, const char *field_name_arg, utype unireg_check_arg, const char *field_name_arg,
struct st_table *table_arg); struct st_table *table_arg);
virtual ~Field() {} virtual ~Field() {}
virtual void store(const char *to,uint length)=0; virtual void store(const char *to,uint length,CHARSET_INFO *cs)=0;
virtual void store(double nr)=0; virtual void store(double nr)=0;
virtual void store(longlong nr)=0; virtual void store(longlong nr)=0;
virtual void store_time(TIME *ltime,timestamp_type t_type); virtual void store_time(TIME *ltime,timestamp_type t_type);
@ -242,10 +242,10 @@ public:
Field_str(char *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, Field_str(char *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg, uchar null_bit_arg, utype unireg_check_arg,
const char *field_name_arg, const char *field_name_arg,
struct st_table *table_arg) struct st_table *table_arg,CHARSET_INFO *charset)
:Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, :Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, table_arg) unireg_check_arg, field_name_arg, table_arg)
{ field_charset=default_charset_info; } { field_charset=charset; }
Item_result result_type () const { return STRING_RESULT; } Item_result result_type () const { return STRING_RESULT; }
uint decimals() const { return NOT_FIXED_DEC; } uint decimals() const { return NOT_FIXED_DEC; }
friend class create_field; friend class create_field;
@ -279,7 +279,7 @@ public:
enum ha_base_keytype key_type() const enum ha_base_keytype key_type() const
{ return zerofill ? HA_KEYTYPE_BINARY : HA_KEYTYPE_NUM; } { return zerofill ? HA_KEYTYPE_BINARY : HA_KEYTYPE_NUM; }
void reset(void); void reset(void);
void store(const char *to,uint length); void store(const char *to,uint length,CHARSET_INFO *charset);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
double val_real(void); double val_real(void);
@ -308,7 +308,7 @@ public:
enum_field_types type() const { return FIELD_TYPE_TINY;} enum_field_types type() const { return FIELD_TYPE_TINY;}
enum ha_base_keytype key_type() const enum ha_base_keytype key_type() const
{ return unsigned_flag ? HA_KEYTYPE_BINARY : HA_KEYTYPE_INT8; } { return unsigned_flag ? HA_KEYTYPE_BINARY : HA_KEYTYPE_INT8; }
void store(const char *to,uint length); void store(const char *to,uint length,CHARSET_INFO *charset);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void reset(void) { ptr[0]=0; } void reset(void) { ptr[0]=0; }
@ -337,7 +337,7 @@ public:
enum_field_types type() const { return FIELD_TYPE_SHORT;} enum_field_types type() const { return FIELD_TYPE_SHORT;}
enum ha_base_keytype key_type() const enum ha_base_keytype key_type() const
{ return unsigned_flag ? HA_KEYTYPE_USHORT_INT : HA_KEYTYPE_SHORT_INT;} { return unsigned_flag ? HA_KEYTYPE_USHORT_INT : HA_KEYTYPE_SHORT_INT;}
void store(const char *to,uint length); void store(const char *to,uint length,CHARSET_INFO *charset);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void reset(void) { ptr[0]=ptr[1]=0; } void reset(void) { ptr[0]=ptr[1]=0; }
@ -366,7 +366,7 @@ public:
enum_field_types type() const { return FIELD_TYPE_INT24;} enum_field_types type() const { return FIELD_TYPE_INT24;}
enum ha_base_keytype key_type() const enum ha_base_keytype key_type() const
{ return unsigned_flag ? HA_KEYTYPE_UINT24 : HA_KEYTYPE_INT24; } { return unsigned_flag ? HA_KEYTYPE_UINT24 : HA_KEYTYPE_INT24; }
void store(const char *to,uint length); void store(const char *to,uint length,CHARSET_INFO *charset);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=0; } void reset(void) { ptr[0]=ptr[1]=ptr[2]=0; }
@ -400,7 +400,7 @@ public:
enum_field_types type() const { return FIELD_TYPE_LONG;} enum_field_types type() const { return FIELD_TYPE_LONG;}
enum ha_base_keytype key_type() const enum ha_base_keytype key_type() const
{ return unsigned_flag ? HA_KEYTYPE_ULONG_INT : HA_KEYTYPE_LONG_INT; } { return unsigned_flag ? HA_KEYTYPE_ULONG_INT : HA_KEYTYPE_LONG_INT; }
void store(const char *to,uint length); void store(const char *to,uint length,CHARSET_INFO *charset);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; } void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; }
@ -436,7 +436,7 @@ public:
enum_field_types type() const { return FIELD_TYPE_LONGLONG;} enum_field_types type() const { return FIELD_TYPE_LONGLONG;}
enum ha_base_keytype key_type() const enum ha_base_keytype key_type() const
{ return unsigned_flag ? HA_KEYTYPE_ULONGLONG : HA_KEYTYPE_LONGLONG; } { return unsigned_flag ? HA_KEYTYPE_ULONGLONG : HA_KEYTYPE_LONGLONG; }
void store(const char *to,uint length); void store(const char *to,uint length,CHARSET_INFO *charset);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0; } void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0; }
@ -463,7 +463,7 @@ public:
{} {}
enum_field_types type() const { return FIELD_TYPE_FLOAT;} enum_field_types type() const { return FIELD_TYPE_FLOAT;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_FLOAT; } enum ha_base_keytype key_type() const { return HA_KEYTYPE_FLOAT; }
void store(const char *to,uint length); void store(const char *to,uint length,CHARSET_INFO *charset);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void reset(void) { bzero(ptr,sizeof(float)); } void reset(void) { bzero(ptr,sizeof(float)); }
@ -495,7 +495,7 @@ public:
{} {}
enum_field_types type() const { return FIELD_TYPE_DOUBLE;} enum_field_types type() const { return FIELD_TYPE_DOUBLE;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_DOUBLE; } enum ha_base_keytype key_type() const { return HA_KEYTYPE_DOUBLE; }
void store(const char *to,uint length); void store(const char *to,uint length,CHARSET_INFO *charset);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void reset(void) { bzero(ptr,sizeof(double)); } void reset(void) { bzero(ptr,sizeof(double)); }
@ -518,10 +518,10 @@ public:
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const char *field_name_arg,
struct st_table *table_arg) struct st_table *table_arg)
:Field_str(ptr_arg, len_arg, null, 1, :Field_str(ptr_arg, len_arg, null, 1,
unireg_check_arg, field_name_arg, table_arg) unireg_check_arg, field_name_arg, table_arg, default_charset_info)
{} {}
enum_field_types type() const { return FIELD_TYPE_NULL;} enum_field_types type() const { return FIELD_TYPE_NULL;}
void store(const char *to, uint length) { null[0]=1; } void store(const char *to, uint length, CHARSET_INFO *cs) { null[0]=1; }
void store(double nr) { null[0]=1; } void store(double nr) { null[0]=1; }
void store(longlong nr) { null[0]=1; } void store(longlong nr) { null[0]=1; }
void reset(void) {} void reset(void) {}
@ -532,7 +532,7 @@ public:
int cmp(const char *a, const char *b) { return 0;} int cmp(const char *a, const char *b) { return 0;}
void sort_string(char *buff, uint length) {} void sort_string(char *buff, uint length) {}
uint32 pack_length() const { return 0; } uint32 pack_length() const { return 0; }
void sql_type(String &str) const { str.set("null",4); } void sql_type(String &str) const { str.set("null",4,default_charset_info); }
uint size_of() const { return sizeof(*this); } uint size_of() const { return sizeof(*this); }
}; };
@ -545,7 +545,7 @@ public:
enum Item_result result_type () const { return field_length == 8 || field_length == 14 ? INT_RESULT : STRING_RESULT; } enum Item_result result_type () const { return field_length == 8 || field_length == 14 ? INT_RESULT : STRING_RESULT; }
enum_field_types type() const { return FIELD_TYPE_TIMESTAMP;} enum_field_types type() const { return FIELD_TYPE_TIMESTAMP;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; } enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
void store(const char *to,uint length); void store(const char *to,uint length,CHARSET_INFO *charset);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; } void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; }
@ -585,7 +585,7 @@ public:
unireg_check_arg, field_name_arg, table_arg, 1, 1) unireg_check_arg, field_name_arg, table_arg, 1, 1)
{} {}
enum_field_types type() const { return FIELD_TYPE_YEAR;} enum_field_types type() const { return FIELD_TYPE_YEAR;}
void store(const char *to,uint length); void store(const char *to,uint length,CHARSET_INFO *charset);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
double val_real(void); double val_real(void);
@ -601,16 +601,16 @@ public:
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const char *field_name_arg,
struct st_table *table_arg) struct st_table *table_arg)
:Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg, :Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, table_arg) unireg_check_arg, field_name_arg, table_arg, default_charset_info)
{} {}
Field_date(bool maybe_null_arg, const char *field_name_arg, Field_date(bool maybe_null_arg, const char *field_name_arg,
struct st_table *table_arg) struct st_table *table_arg)
:Field_str((char*) 0,10, maybe_null_arg ? (uchar*) "": 0,0, :Field_str((char*) 0,10, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg, table_arg) {} NONE, field_name_arg, table_arg, default_charset_info) {}
enum_field_types type() const { return FIELD_TYPE_DATE;} enum_field_types type() const { return FIELD_TYPE_DATE;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; } enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
enum Item_result cmp_type () const { return INT_RESULT; } enum Item_result cmp_type () const { return INT_RESULT; }
void store(const char *to,uint length); void store(const char *to,uint length,CHARSET_INFO *charset);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; } void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; }
@ -631,13 +631,13 @@ public:
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const char *field_name_arg,
struct st_table *table_arg) struct st_table *table_arg)
:Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg, :Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, table_arg) unireg_check_arg, field_name_arg, table_arg, default_charset_info)
{} {}
enum_field_types type() const { return FIELD_TYPE_DATE;} enum_field_types type() const { return FIELD_TYPE_DATE;}
enum_field_types real_type() const { return FIELD_TYPE_NEWDATE; } enum_field_types real_type() const { return FIELD_TYPE_NEWDATE; }
enum ha_base_keytype key_type() const { return HA_KEYTYPE_UINT24; } enum ha_base_keytype key_type() const { return HA_KEYTYPE_UINT24; }
enum Item_result cmp_type () const { return INT_RESULT; } enum Item_result cmp_type () const { return INT_RESULT; }
void store(const char *to,uint length); void store(const char *to,uint length,CHARSET_INFO *charset);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void store_time(TIME *ltime,timestamp_type type); void store_time(TIME *ltime,timestamp_type type);
@ -662,16 +662,16 @@ public:
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const char *field_name_arg,
struct st_table *table_arg) struct st_table *table_arg)
:Field_str(ptr_arg, 8, null_ptr_arg, null_bit_arg, :Field_str(ptr_arg, 8, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, table_arg) unireg_check_arg, field_name_arg, table_arg, default_charset_info)
{} {}
Field_time(bool maybe_null_arg, const char *field_name_arg, Field_time(bool maybe_null_arg, const char *field_name_arg,
struct st_table *table_arg) struct st_table *table_arg)
:Field_str((char*) 0,8, maybe_null_arg ? (uchar*) "": 0,0, :Field_str((char*) 0,8, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg, table_arg) {} NONE, field_name_arg, table_arg, default_charset_info) {}
enum_field_types type() const { return FIELD_TYPE_TIME;} enum_field_types type() const { return FIELD_TYPE_TIME;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_INT24; } enum ha_base_keytype key_type() const { return HA_KEYTYPE_INT24; }
enum Item_result cmp_type () const { return INT_RESULT; } enum Item_result cmp_type () const { return INT_RESULT; }
void store(const char *to,uint length); void store(const char *to,uint length,CHARSET_INFO *charset);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void reset(void) { ptr[0]=ptr[1]=ptr[2]=0; } void reset(void) { ptr[0]=ptr[1]=ptr[2]=0; }
@ -694,18 +694,18 @@ public:
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const char *field_name_arg,
struct st_table *table_arg) struct st_table *table_arg)
:Field_str(ptr_arg, 19, null_ptr_arg, null_bit_arg, :Field_str(ptr_arg, 19, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, table_arg) unireg_check_arg, field_name_arg, table_arg, default_charset_info)
{} {}
Field_datetime(bool maybe_null_arg, const char *field_name_arg, Field_datetime(bool maybe_null_arg, const char *field_name_arg,
struct st_table *table_arg) struct st_table *table_arg)
:Field_str((char*) 0,19, maybe_null_arg ? (uchar*) "": 0,0, :Field_str((char*) 0,19, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg, table_arg) {} NONE, field_name_arg, table_arg, default_charset_info) {}
enum_field_types type() const { return FIELD_TYPE_DATETIME;} enum_field_types type() const { return FIELD_TYPE_DATETIME;}
#ifdef HAVE_LONG_LONG #ifdef HAVE_LONG_LONG
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONGLONG; } enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONGLONG; }
#endif #endif
enum Item_result cmp_type () const { return INT_RESULT; } enum Item_result cmp_type () const { return INT_RESULT; }
void store(const char *to,uint length); void store(const char *to,uint length,CHARSET_INFO *charset);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void store_time(TIME *ltime,timestamp_type type); void store_time(TIME *ltime,timestamp_type type);
@ -730,18 +730,18 @@ public:
Field_string(char *ptr_arg, uint32 len_arg,uchar *null_ptr_arg, Field_string(char *ptr_arg, uint32 len_arg,uchar *null_ptr_arg,
uchar null_bit_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const char *field_name_arg,
struct st_table *table_arg,bool binary_arg) struct st_table *table_arg,bool binary_arg, CHARSET_INFO *cs)
:Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, :Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, table_arg), unireg_check_arg, field_name_arg, table_arg,cs),
binary_flag(binary_arg) binary_flag(binary_arg)
{ {
if (binary_arg) if (binary_arg)
flags|=BINARY_FLAG; flags|=BINARY_FLAG;
} }
Field_string(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg, Field_string(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
struct st_table *table_arg, bool binary_arg) struct st_table *table_arg, bool binary_arg, CHARSET_INFO *cs)
:Field_str((char*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0,0, :Field_str((char*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg, table_arg), NONE, field_name_arg, table_arg, cs),
binary_flag(binary_arg) binary_flag(binary_arg)
{ {
if (binary_arg) if (binary_arg)
@ -759,7 +759,7 @@ public:
bool zero_pack() const { return 0; } bool zero_pack() const { return 0; }
bool binary() const { return binary_flag; } bool binary() const { return binary_flag; }
void reset(void) { bfill(ptr,field_length,' '); } void reset(void) { bfill(ptr,field_length,' '); }
void store(const char *to,uint length); void store(const char *to,uint length,CHARSET_INFO *charset);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
double val_real(void); double val_real(void);
@ -785,18 +785,18 @@ public:
Field_varstring(char *ptr_arg, uint32 len_arg,uchar *null_ptr_arg, Field_varstring(char *ptr_arg, uint32 len_arg,uchar *null_ptr_arg,
uchar null_bit_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const char *field_name_arg,
struct st_table *table_arg,bool binary_arg) struct st_table *table_arg,bool binary_arg, CHARSET_INFO *cs)
:Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, :Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, table_arg), unireg_check_arg, field_name_arg, table_arg, cs),
binary_flag(binary_arg) binary_flag(binary_arg)
{ {
if (binary_arg) if (binary_arg)
flags|=BINARY_FLAG; flags|=BINARY_FLAG;
} }
Field_varstring(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg, Field_varstring(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
struct st_table *table_arg, bool binary_arg) struct st_table *table_arg, bool binary_arg, CHARSET_INFO *cs)
:Field_str((char*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0,0, :Field_str((char*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg, table_arg), NONE, field_name_arg, table_arg, cs),
binary_flag(binary_arg) binary_flag(binary_arg)
{ {
if (binary_arg) if (binary_arg)
@ -811,7 +811,7 @@ public:
void reset(void) { bzero(ptr,field_length+2); } void reset(void) { bzero(ptr,field_length+2); }
uint32 pack_length() const { return (uint32) field_length+2; } uint32 pack_length() const { return (uint32) field_length+2; }
uint32 key_length() const { return (uint32) field_length; } uint32 key_length() const { return (uint32) field_length; }
void store(const char *to,uint length); void store(const char *to,uint length,CHARSET_INFO *charset);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
double val_real(void); double val_real(void);
@ -844,7 +844,7 @@ public:
Field_blob(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg, Field_blob(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
struct st_table *table_arg, bool binary_arg) struct st_table *table_arg, bool binary_arg)
:Field_str((char*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0,0, :Field_str((char*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg, table_arg), NONE, field_name_arg, table_arg, default_charset_info),
packlength(3),binary_flag(binary_arg), geom_flag(true) packlength(3),binary_flag(binary_arg), geom_flag(true)
{ {
flags|= BLOB_FLAG; flags|= BLOB_FLAG;
@ -854,7 +854,7 @@ public:
enum_field_types type() const { return FIELD_TYPE_BLOB;} enum_field_types type() const { return FIELD_TYPE_BLOB;}
enum ha_base_keytype key_type() const enum ha_base_keytype key_type() const
{ return binary_flag ? HA_KEYTYPE_VARBINARY : HA_KEYTYPE_VARTEXT; } { return binary_flag ? HA_KEYTYPE_VARBINARY : HA_KEYTYPE_VARTEXT; }
void store(const char *to,uint length); void store(const char *to,uint length,CHARSET_INFO *charset);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
double val_real(void); double val_real(void);
@ -951,7 +951,7 @@ public:
struct st_table *table_arg,uint packlength_arg, struct st_table *table_arg,uint packlength_arg,
TYPELIB *typelib_arg) TYPELIB *typelib_arg)
:Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, :Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, table_arg), unireg_check_arg, field_name_arg, table_arg, default_charset_info),
packlength(packlength_arg),typelib(typelib_arg) packlength(packlength_arg),typelib(typelib_arg)
{ {
flags|=ENUM_FLAG; flags|=ENUM_FLAG;
@ -959,7 +959,7 @@ public:
enum_field_types type() const { return FIELD_TYPE_STRING; } enum_field_types type() const { return FIELD_TYPE_STRING; }
enum Item_result cmp_type () const { return INT_RESULT; } enum Item_result cmp_type () const { return INT_RESULT; }
enum ha_base_keytype key_type() const; enum ha_base_keytype key_type() const;
void store(const char *to,uint length); void store(const char *to,uint length,CHARSET_INFO *charset);
void store(double nr); void store(double nr);
void store(longlong nr); void store(longlong nr);
void reset() { bzero(ptr,packlength); } void reset() { bzero(ptr,packlength); }
@ -994,7 +994,7 @@ public:
{ {
flags=(flags & ~ENUM_FLAG) | SET_FLAG; flags=(flags & ~ENUM_FLAG) | SET_FLAG;
} }
void store(const char *to,uint length); void store(const char *to,uint length,CHARSET_INFO *charset);
void store(double nr) { Field_set::store((longlong) nr); } void store(double nr) { Field_set::store((longlong) nr); }
void store(longlong nr); void store(longlong nr);
virtual bool zero_pack() const { return 1; } virtual bool zero_pack() const { return 1; }

View File

@ -228,7 +228,7 @@ static void do_conv_blob(Copy_field *copy)
{ {
copy->from_field->val_str(&copy->tmp,&copy->tmp); copy->from_field->val_str(&copy->tmp,&copy->tmp);
((Field_blob *) copy->to_field)->store(copy->tmp.ptr(), ((Field_blob *) copy->to_field)->store(copy->tmp.ptr(),
copy->tmp.length()); copy->tmp.length(),default_charset_info);
} }
/* Save blob in copy->tmp for GROUP BY */ /* Save blob in copy->tmp for GROUP BY */
@ -236,20 +236,20 @@ static void do_conv_blob(Copy_field *copy)
static void do_save_blob(Copy_field *copy) static void do_save_blob(Copy_field *copy)
{ {
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String res(buff,sizeof(buff)); String res(buff,sizeof(buff),default_charset_info);
copy->from_field->val_str(&res,&res); copy->from_field->val_str(&res,&res);
copy->tmp.copy(res); copy->tmp.copy(res);
((Field_blob *) copy->to_field)->store(copy->tmp.ptr(), ((Field_blob *) copy->to_field)->store(copy->tmp.ptr(),
copy->tmp.length()); copy->tmp.length(),default_charset_info);
} }
static void do_field_string(Copy_field *copy) static void do_field_string(Copy_field *copy)
{ {
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
copy->tmp.set_quick(buff,sizeof(buff)); copy->tmp.set_quick(buff,sizeof(buff),default_charset_info);
copy->from_field->val_str(&copy->tmp,&copy->tmp); copy->from_field->val_str(&copy->tmp,&copy->tmp);
copy->to_field->store(copy->tmp.c_ptr_quick(),copy->tmp.length()); copy->to_field->store(copy->tmp.c_ptr_quick(),copy->tmp.length(),default_charset_info);
} }
@ -508,7 +508,7 @@ void field_conv(Field *to,Field *from)
if (!blob->value.is_alloced() && if (!blob->value.is_alloced() &&
from->real_type() != FIELD_TYPE_STRING) from->real_type() != FIELD_TYPE_STRING)
blob->value.copy(); blob->value.copy();
blob->store(blob->value.ptr(),blob->value.length()); blob->store(blob->value.ptr(),blob->value.length(),default_charset_info);
return; return;
} }
if ((from->result_type() == STRING_RESULT && if ((from->result_type() == STRING_RESULT &&
@ -518,9 +518,9 @@ void field_conv(Field *to,Field *from)
to->type() == FIELD_TYPE_DECIMAL) to->type() == FIELD_TYPE_DECIMAL)
{ {
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String result(buff,sizeof(buff)); String result(buff,sizeof(buff),default_charset_info);
from->val_str(&result,&result); from->val_str(&result,&result);
to->store(result.c_ptr_quick(),result.length()); to->store(result.c_ptr_quick(),result.length(),default_charset_info);
} }
else if (from->result_type() == REAL_RESULT) else if (from->result_type() == REAL_RESULT)
to->store(from->val_real()); to->store(from->val_real());

View File

@ -475,12 +475,10 @@ static void make_sortkey(register SORTPARAM *param,
switch (sort_field->result_type) { switch (sort_field->result_type) {
case STRING_RESULT: case STRING_RESULT:
{ {
CHARSET_INFO *cs=item->str_value.charset();
if (item->maybe_null) if (item->maybe_null)
*to++=1; *to++=1;
/* All item->str() to use some extra byte for end null.. */ /* All item->str() to use some extra byte for end null.. */
String tmp((char*) to,sort_field->length+4); String tmp((char*) to,sort_field->length+4,default_charset_info);
String *res=item->val_str(&tmp); String *res=item->val_str(&tmp);
if (!res) if (!res)
{ {
@ -495,6 +493,7 @@ static void make_sortkey(register SORTPARAM *param,
break; break;
} }
length=res->length(); length=res->length();
CHARSET_INFO *cs=res->charset();
int diff=(int) (sort_field->length-length); int diff=(int) (sort_field->length-length);
if (diff < 0) if (diff < 0)
{ {

View File

@ -665,7 +665,7 @@ void handler::print_error(int error, myf errflag)
{ {
/* Write the dupplicated key in the error message */ /* Write the dupplicated key in the error message */
char key[MAX_KEY_LENGTH]; char key[MAX_KEY_LENGTH];
String str(key,sizeof(key)); String str(key,sizeof(key),default_charset_info);
key_unpack(&str,table,(uint) key_nr); key_unpack(&str,table,(uint) key_nr);
uint max_length=MYSQL_ERRMSG_SIZE-(uint) strlen(ER(ER_DUP_ENTRY)); uint max_length=MYSQL_ERRMSG_SIZE-(uint) strlen(ER(ER_DUP_ENTRY));
if (str.length() >= max_length) if (str.length() >= max_length)

View File

@ -89,7 +89,7 @@ bool Item_string::eq(const Item *item, bool binary_cmp) const
bool Item::get_date(TIME *ltime,bool fuzzydate) bool Item::get_date(TIME *ltime,bool fuzzydate)
{ {
char buff[40]; char buff[40];
String tmp(buff,sizeof(buff)),*res; String tmp(buff,sizeof(buff),default_charset_info),*res;
if (!(res=val_str(&tmp)) || if (!(res=val_str(&tmp)) ||
str_to_TIME(res->ptr(),res->length(),ltime,fuzzydate) == TIMESTAMP_NONE) str_to_TIME(res->ptr(),res->length(),ltime,fuzzydate) == TIMESTAMP_NONE)
{ {
@ -107,7 +107,7 @@ bool Item::get_date(TIME *ltime,bool fuzzydate)
bool Item::get_time(TIME *ltime) bool Item::get_time(TIME *ltime)
{ {
char buff[40]; char buff[40];
String tmp(buff,sizeof(buff)),*res; String tmp(buff,sizeof(buff),default_charset_info),*res;
if (!(res=val_str(&tmp)) || if (!(res=val_str(&tmp)) ||
str_to_time(res->ptr(),res->length(),ltime)) str_to_time(res->ptr(),res->length(),ltime))
{ {
@ -457,14 +457,15 @@ bool Item::save_in_field(Field *field)
field->result_type() == STRING_RESULT) field->result_type() == STRING_RESULT)
{ {
String *result; String *result;
CHARSET_INFO *cs=field->binary()?default_charset_info:((Field_str*)field)->charset();
char buff[MAX_FIELD_WIDTH]; // Alloc buffer for small columns char buff[MAX_FIELD_WIDTH]; // Alloc buffer for small columns
str_value.set_quick(buff,sizeof(buff)); str_value.set_quick(buff,sizeof(buff),cs);
result=val_str(&str_value); result=val_str(&str_value);
if (null_value) if (null_value)
return set_field_to_null(field); return set_field_to_null(field);
field->set_notnull(); field->set_notnull();
field->store(result->ptr(),result->length()); field->store(result->ptr(),result->length(),cs);
str_value.set_quick(0, 0); str_value.set_quick(0, 0, cs);
} }
else if (result_type() == REAL_RESULT) else if (result_type() == REAL_RESULT)
{ {
@ -488,11 +489,12 @@ bool Item::save_in_field(Field *field)
bool Item_string::save_in_field(Field *field) bool Item_string::save_in_field(Field *field)
{ {
String *result; String *result;
CHARSET_INFO *cs=field->binary()?default_charset_info:((Field_str*)field)->charset();
result=val_str(&str_value); result=val_str(&str_value);
if (null_value) if (null_value)
return set_field_to_null(field); return set_field_to_null(field);
field->set_notnull(); field->set_notnull();
field->store(result->ptr(),result->length()); field->store(result->ptr(),result->length(),cs);
return 0; return 0;
} }
@ -529,14 +531,14 @@ inline uint char_val(char X)
X-'a'+10); X-'a'+10);
} }
Item_varbinary::Item_varbinary(const char *str, uint str_length) Item_varbinary::Item_varbinary(const char *str, uint str_length, CHARSET_INFO *cs)
{ {
name=(char*) str-2; // Lex makes this start with 0x name=(char*) str-2; // Lex makes this start with 0x
max_length=(str_length+1)/2; max_length=(str_length+1)/2;
char *ptr=(char*) sql_alloc(max_length+1); char *ptr=(char*) sql_alloc(max_length+1);
if (!ptr) if (!ptr)
return; return;
str_value.set(ptr,max_length); str_value.set(ptr,max_length,cs);
char *end=ptr+max_length; char *end=ptr+max_length;
if (max_length*2 != str_length) if (max_length*2 != str_length)
*ptr++=char_val(*str++); // Not even, assume 0 prefix *ptr++=char_val(*str++); // Not even, assume 0 prefix
@ -563,10 +565,11 @@ longlong Item_varbinary::val_int()
bool Item_varbinary::save_in_field(Field *field) bool Item_varbinary::save_in_field(Field *field)
{ {
CHARSET_INFO *cs=field->binary()?default_charset_info:((Field_str*)field)->charset();
field->set_notnull(); field->set_notnull();
if (field->result_type() == STRING_RESULT) if (field->result_type() == STRING_RESULT)
{ {
field->store(str_value.ptr(),str_value.length()); field->store(str_value.ptr(),str_value.length(),cs);
} }
else else
{ {
@ -590,7 +593,7 @@ bool Item::send(THD *thd, String *packet)
{ {
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
CONVERT *convert; CONVERT *convert;
String s(buff,sizeof(buff)),*res; String s(buff,sizeof(buff),packet->charset()),*res;
if (!(res=val_str(&s))) if (!(res=val_str(&s)))
return net_store_null(packet); return net_store_null(packet);
if ((convert=thd->convert_set)) if ((convert=thd->convert_set))
@ -649,7 +652,7 @@ Item *resolve_const_item(Item *item,Item *comp_item)
if (res_type == STRING_RESULT) if (res_type == STRING_RESULT)
{ {
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String tmp(buff,sizeof(buff)),*result; String tmp(buff,sizeof(buff),default_charset_info),*result;
result=item->val_str(&tmp); result=item->val_str(&tmp);
if (item->null_value) if (item->null_value)
{ {
@ -663,7 +666,7 @@ Item *resolve_const_item(Item *item,Item *comp_item)
#ifdef DELETE_ITEMS #ifdef DELETE_ITEMS
delete item; delete item;
#endif #endif
return new Item_string(name,tmp_str,length); return new Item_string(name,tmp_str,length,default_charset_info);
} }
if (res_type == INT_RESULT) if (res_type == INT_RESULT)
{ {
@ -704,8 +707,8 @@ bool field_is_equal_to_item(Field *field,Item *item)
{ {
char item_buff[MAX_FIELD_WIDTH]; char item_buff[MAX_FIELD_WIDTH];
char field_buff[MAX_FIELD_WIDTH]; char field_buff[MAX_FIELD_WIDTH];
String item_tmp(item_buff,sizeof(item_buff)),*item_result; String item_tmp(item_buff,sizeof(item_buff),default_charset_info),*item_result;
String field_tmp(field_buff,sizeof(field_buff)); String field_tmp(field_buff,sizeof(field_buff),default_charset_info);
item_result=item->val_str(&item_tmp); item_result=item->val_str(&item_tmp);
if (item->null_value) if (item->null_value)
return 1; // This must be true return 1; // This must be true

View File

@ -241,16 +241,16 @@ public:
class Item_string :public Item class Item_string :public Item
{ {
public: public:
Item_string(const char *str,uint length) Item_string(const char *str,uint length,CHARSET_INFO *cs)
{ {
str_value.set(str,length); str_value.set(str,length,cs);
max_length=length; max_length=length;
name=(char*) str_value.ptr(); name=(char*) str_value.ptr();
decimals=NOT_FIXED_DEC; decimals=NOT_FIXED_DEC;
} }
Item_string(const char *name_par,const char *str,uint length) Item_string(const char *name_par,const char *str,uint length,CHARSET_INFO *cs)
{ {
str_value.set(str,length); str_value.set(str,length,cs);
max_length=length; max_length=length;
name=(char*) name_par; name=(char*) name_par;
decimals=NOT_FIXED_DEC; decimals=NOT_FIXED_DEC;
@ -265,7 +265,7 @@ public:
enum Item_result result_type () const { return STRING_RESULT; } enum Item_result result_type () const { return STRING_RESULT; }
bool basic_const_item() const { return 1; } bool basic_const_item() const { return 1; }
bool eq(const Item *item, bool binary_cmp) const; bool eq(const Item *item, bool binary_cmp) const;
Item *new_item() { return new Item_string(name,str_value.ptr(),max_length); } Item *new_item() { return new Item_string(name,str_value.ptr(),max_length,default_charset_info); }
String *const_string() { return &str_value; } String *const_string() { return &str_value; }
inline void append(char *str,uint length) { str_value.append(str,length); } inline void append(char *str,uint length) { str_value.append(str,length); }
void print(String *str); void print(String *str);
@ -276,7 +276,7 @@ public:
class Item_datetime :public Item_string class Item_datetime :public Item_string
{ {
public: public:
Item_datetime(const char *item_name): Item_string(item_name,"",0) Item_datetime(const char *item_name): Item_string(item_name,"",0,default_charset_info)
{ max_length=19;} { max_length=19;}
void make_field(Send_field *field); void make_field(Send_field *field);
}; };
@ -284,14 +284,14 @@ public:
class Item_empty_string :public Item_string class Item_empty_string :public Item_string
{ {
public: public:
Item_empty_string(const char *header,uint length) :Item_string("",0) Item_empty_string(const char *header,uint length) :Item_string("",0,default_charset_info)
{ name=(char*) header; max_length=length;} { name=(char*) header; max_length=length;}
}; };
class Item_varbinary :public Item class Item_varbinary :public Item
{ {
public: public:
Item_varbinary(const char *str,uint str_length); Item_varbinary(const char *str,uint str_length,CHARSET_INFO *cs);
~Item_varbinary() {} ~Item_varbinary() {}
enum Type type() const { return VARBIN_ITEM; } enum Type type() const { return VARBIN_ITEM; }
double val() { return (double) Item_varbinary::val_int(); } double val() { return (double) Item_varbinary::val_int(); }

View File

@ -687,7 +687,7 @@ String *Item_func_case::val_str(String *str)
longlong Item_func_case::val_int() longlong Item_func_case::val_int()
{ {
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String dummy_str(buff,sizeof(buff)); String dummy_str(buff,sizeof(buff),default_charset_info);
Item *item=find_item(&dummy_str); Item *item=find_item(&dummy_str);
longlong res; longlong res;
@ -704,7 +704,7 @@ longlong Item_func_case::val_int()
double Item_func_case::val() double Item_func_case::val()
{ {
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String dummy_str(buff,sizeof(buff)); String dummy_str(buff,sizeof(buff),default_charset_info);
Item *item=find_item(&dummy_str); Item *item=find_item(&dummy_str);
double res; double res;
@ -876,7 +876,7 @@ int in_vector::find(Item *item)
in_string::in_string(uint elements,qsort_cmp cmp_func) in_string::in_string(uint elements,qsort_cmp cmp_func)
:in_vector(elements,sizeof(String),cmp_func),tmp(buff,sizeof(buff)) :in_vector(elements,sizeof(String),cmp_func),tmp(buff,sizeof(buff),default_charset_info)
{} {}
in_string::~in_string() in_string::~in_string()
@ -1272,7 +1272,7 @@ Item_func_regex::fix_fields(THD *thd,TABLE_LIST *tables)
if (!regex_compiled && args[1]->const_item()) if (!regex_compiled && args[1]->const_item())
{ {
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String tmp(buff,sizeof(buff)); String tmp(buff,sizeof(buff),default_charset_info);
String *res=args[1]->val_str(&tmp); String *res=args[1]->val_str(&tmp);
if (args[1]->null_value) if (args[1]->null_value)
{ // Will always return NULL { // Will always return NULL
@ -1301,7 +1301,7 @@ Item_func_regex::fix_fields(THD *thd,TABLE_LIST *tables)
longlong Item_func_regex::val_int() longlong Item_func_regex::val_int()
{ {
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String *res, tmp(buff,sizeof(buff)); String *res, tmp(buff,sizeof(buff),default_charset_info);
res=args[0]->val_str(&tmp); res=args[0]->val_str(&tmp);
if (args[0]->null_value) if (args[0]->null_value)
@ -1312,7 +1312,7 @@ longlong Item_func_regex::val_int()
if (!regex_is_const) if (!regex_is_const)
{ {
char buff2[MAX_FIELD_WIDTH]; char buff2[MAX_FIELD_WIDTH];
String *res2, tmp2(buff2,sizeof(buff2)); String *res2, tmp2(buff2,sizeof(buff2),default_charset_info);
res2= args[1]->val_str(&tmp2); res2= args[1]->val_str(&tmp2);
if (args[1]->null_value) if (args[1]->null_value)

View File

@ -341,7 +341,7 @@ class cmp_item_sort_string :public cmp_item {
char value_buff[80]; char value_buff[80];
String value,*value_res; String value,*value_res;
public: public:
cmp_item_sort_string() :value(value_buff,sizeof(value_buff)) {} cmp_item_sort_string() :value(value_buff,sizeof(value_buff),default_charset_info) {}
void store_value(Item *item) void store_value(Item *item)
{ {
value_res=item->val_str(&value); value_res=item->val_str(&value);
@ -349,7 +349,7 @@ public:
int cmp(Item *arg) int cmp(Item *arg)
{ {
char buff[80]; char buff[80];
String tmp(buff,sizeof(buff)),*res; String tmp(buff,sizeof(buff),default_charset_info),*res;
if (!(res=arg->val_str(&tmp))) if (!(res=arg->val_str(&tmp)))
return 1; /* Can't be right */ return 1; /* Can't be right */
return sortcmp(value_res,res); return sortcmp(value_res,res);
@ -362,7 +362,7 @@ public:
int cmp(Item *arg) int cmp(Item *arg)
{ {
char buff[80]; char buff[80];
String tmp(buff,sizeof(buff)),*res; String tmp(buff,sizeof(buff),default_charset_info),*res;
if (!(res=arg->val_str(&tmp))) if (!(res=arg->val_str(&tmp)))
return 1; /* Can't be right */ return 1; /* Can't be right */
return stringcmp(value_res,res); return stringcmp(value_res,res);

View File

@ -227,7 +227,7 @@ Item *create_func_lpad(Item* a, Item *b, Item *c)
Item *create_func_ltrim(Item* a) Item *create_func_ltrim(Item* a)
{ {
return new Item_func_ltrim(a,new Item_string(" ",1)); return new Item_func_ltrim(a,new Item_string(" ",1,default_charset_info));
} }
Item *create_func_md5(Item* a) Item *create_func_md5(Item* a)
@ -309,7 +309,7 @@ Item *create_func_rpad(Item* a, Item *b, Item *c)
Item *create_func_rtrim(Item* a) Item *create_func_rtrim(Item* a)
{ {
return new Item_func_rtrim(a,new Item_string(" ",1)); return new Item_func_rtrim(a,new Item_string(" ",1,default_charset_info));
} }
Item *create_func_sec_to_time(Item* a) Item *create_func_sec_to_time(Item* a)
@ -329,7 +329,7 @@ Item *create_func_sin(Item* a)
Item *create_func_space(Item *a) Item *create_func_space(Item *a)
{ {
return new Item_func_repeat(new Item_string(" ",1),a); return new Item_func_repeat(new Item_string(" ",1,default_charset_info),a);
} }
Item *create_func_soundex(Item* a) Item *create_func_soundex(Item* a)
@ -374,7 +374,9 @@ Item *create_func_ucase(Item* a)
Item *create_func_version(void) Item *create_func_version(void)
{ {
return new Item_string(NullS,server_version, (uint) strlen(server_version)); return new Item_string(NullS,server_version,
(uint) strlen(server_version),
default_charset_info);
} }
Item *create_func_weekday(Item* a) Item *create_func_weekday(Item* a)

View File

@ -1296,7 +1296,7 @@ String *udf_handler::val_str(String *str,String *save_str)
str->length(res_length); str->length(res_length);
return str; return str;
} }
save_str->set(res, res_length); save_str->set(res, res_length, default_charset_info);
return save_str; return save_str;
} }
@ -1438,7 +1438,7 @@ void item_user_lock_release(ULL *ull)
THD *thd = current_thd; THD *thd = current_thd;
uint save_query_length; uint save_query_length;
char buf[256]; char buf[256];
String tmp(buf,sizeof(buf)); String tmp(buf,sizeof(buf), default_charset_info);
tmp.length(0); tmp.length(0);
tmp.append("DO RELEASE_LOCK(\""); tmp.append("DO RELEASE_LOCK(\"");
tmp.append(ull->key,ull->key_length); tmp.append(ull->key,ull->key_length);
@ -1695,7 +1695,7 @@ longlong Item_func_set_last_insert_id::val_int()
longlong Item_func_benchmark::val_int() longlong Item_func_benchmark::val_int()
{ {
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String tmp(buff,sizeof(buff)); String tmp(buff,sizeof(buff), default_charset_info);
THD *thd=current_thd; THD *thd=current_thd;
for (ulong loop=0 ; loop < loop_count && !thd->killed; loop++) for (ulong loop=0 ; loop < loop_count && !thd->killed; loop++)
@ -1832,7 +1832,7 @@ Item_func_set_user_var::update()
break; break;
case STRING_RESULT: case STRING_RESULT:
char buffer[MAX_FIELD_WIDTH]; char buffer[MAX_FIELD_WIDTH];
String tmp(buffer,sizeof(buffer)); String tmp(buffer,sizeof(buffer),default_charset_info);
(void) val_str(&tmp); (void) val_str(&tmp);
break; break;
} }
@ -2006,7 +2006,7 @@ longlong Item_func_inet_aton::val_int()
char c = '.'; // we mark c to indicate invalid IP in case length is 0 char c = '.'; // we mark c to indicate invalid IP in case length is 0
char buff[36]; char buff[36];
String *s,tmp(buff,sizeof(buff)); String *s,tmp(buff,sizeof(buff),default_charset_info);
if (!(s = args[0]->val_str(&tmp))) // If null value if (!(s = args[0]->val_str(&tmp))) // If null value
goto err; goto err;
null_value=0; null_value=0;
@ -2052,17 +2052,17 @@ void Item_func_match::init_search(bool no_order)
} }
if (key == NO_SUCH_KEY) if (key == NO_SUCH_KEY)
concat=new Item_func_concat_ws (new Item_string(" ",1), fields); concat=new Item_func_concat_ws (new Item_string(" ",1,default_charset_info), fields);
String *ft_tmp=0; String *ft_tmp=0;
char tmp1[FT_QUERY_MAXLEN]; char tmp1[FT_QUERY_MAXLEN];
String tmp2(tmp1,sizeof(tmp1)); String tmp2(tmp1,sizeof(tmp1),default_charset_info);
// MATCH ... AGAINST (NULL) is meaningless, but possible // MATCH ... AGAINST (NULL) is meaningless, but possible
if (!(ft_tmp=key_item()->val_str(&tmp2))) if (!(ft_tmp=key_item()->val_str(&tmp2)))
{ {
ft_tmp=&tmp2; ft_tmp=&tmp2;
tmp2.set("",0); tmp2.set("",0,default_charset_info);
} }
ft_handler=table->file->ft_init_ext(mode, key, ft_handler=table->file->ft_init_ext(mode, key,

View File

@ -35,7 +35,7 @@
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
#include "md5.h" #include "md5.h"
String empty_string(""); String empty_string("",default_charset_info);
uint nr_of_decimals(const char *str) uint nr_of_decimals(const char *str)
{ {
@ -371,7 +371,7 @@ error:
String *Item_func_concat_ws::val_str(String *str) String *Item_func_concat_ws::val_str(String *str)
{ {
char tmp_str_buff[10]; char tmp_str_buff[10];
String tmp_sep_str(tmp_str_buff, sizeof(tmp_str_buff)), String tmp_sep_str(tmp_str_buff, sizeof(tmp_str_buff),default_charset_info),
*sep_str, *res, *res2,*use_as_buff; *sep_str, *res, *res2,*use_as_buff;
uint i; uint i;
@ -989,7 +989,7 @@ String *Item_func_ltrim::val_str(String *str)
if ((null_value=args[0]->null_value)) if ((null_value=args[0]->null_value))
return 0; /* purecov: inspected */ return 0; /* purecov: inspected */
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String tmp(buff,sizeof(buff)); String tmp(buff,sizeof(buff),res->charset());
String *remove_str=args[1]->val_str(&tmp); String *remove_str=args[1]->val_str(&tmp);
uint remove_length; uint remove_length;
LINT_INIT(remove_length); LINT_INIT(remove_length);
@ -1027,7 +1027,7 @@ String *Item_func_rtrim::val_str(String *str)
if ((null_value=args[0]->null_value)) if ((null_value=args[0]->null_value))
return 0; /* purecov: inspected */ return 0; /* purecov: inspected */
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String tmp(buff,sizeof(buff)); String tmp(buff,sizeof(buff),res->charset());
String *remove_str=args[1]->val_str(&tmp); String *remove_str=args[1]->val_str(&tmp);
uint remove_length; uint remove_length;
LINT_INIT(remove_length); LINT_INIT(remove_length);
@ -1099,7 +1099,7 @@ String *Item_func_trim::val_str(String *str)
if ((null_value=args[0]->null_value)) if ((null_value=args[0]->null_value))
return 0; /* purecov: inspected */ return 0; /* purecov: inspected */
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String tmp(buff,sizeof(buff)); String tmp(buff,sizeof(buff),res->charset());
String *remove_str=args[1]->val_str(&tmp); String *remove_str=args[1]->val_str(&tmp);
uint remove_length; uint remove_length;
LINT_INIT(remove_length); LINT_INIT(remove_length);
@ -1154,7 +1154,7 @@ String *Item_func_password::val_str(String *str)
if (res->length() == 0) if (res->length() == 0)
return &empty_string; return &empty_string;
make_scrambled_password(tmp_value,res->c_ptr()); make_scrambled_password(tmp_value,res->c_ptr());
str->set(tmp_value,16); str->set(tmp_value,16,res->charset());
return str; return str;
} }
@ -1188,7 +1188,7 @@ String *Item_func_encrypt::val_str(String *str)
} }
pthread_mutex_lock(&LOCK_crypt); pthread_mutex_lock(&LOCK_crypt);
char *tmp=crypt(res->c_ptr(),salt_ptr); char *tmp=crypt(res->c_ptr(),salt_ptr);
str->set(tmp,(uint) strlen(tmp)); str->set(tmp,(uint) strlen(tmp),res->charset());
str->copy(); str->copy();
pthread_mutex_unlock(&LOCK_crypt); pthread_mutex_unlock(&LOCK_crypt);
return str; return str;
@ -1240,7 +1240,7 @@ String *Item_func_database::val_str(String *str)
if (!current_thd->db) if (!current_thd->db)
str->length(0); str->length(0);
else else
str->set((const char*) current_thd->db,(uint) strlen(current_thd->db)); str->set((const char*) current_thd->db,(uint) strlen(current_thd->db), default_charset_info);
return str; return str;
} }
@ -2035,7 +2035,7 @@ String* Item_func_export_set::val_str(String* str)
} }
break; break;
case 3: case 3:
sep_buf.set(",", 1); sep_buf.set(",", 1, default_charset_info);
sep = &sep_buf; sep = &sep_buf;
} }
null_value=0; null_value=0;
@ -2154,7 +2154,7 @@ 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); str->copy(geom.get_class_info()->m_name,strlen(geom.get_class_info()->m_name));
return str; return str;
} }

View File

@ -38,7 +38,7 @@ public:
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
if (!t_arg) return result_field; if (!t_arg) return result_field;
return (max_length > 255) ? (Field *)new Field_blob(max_length,maybe_null, name,t_arg, binary) : (Field *) new Field_string(max_length,maybe_null, name,t_arg, binary); return (max_length > 255) ? (Field *)new Field_blob(max_length,maybe_null, name,t_arg, binary) : (Field *) new Field_string(max_length,maybe_null, name,t_arg, binary, default_charset_info);
} }
}; };

View File

@ -513,7 +513,7 @@ void Item_sum_hybrid::reset_field()
if (hybrid_type == STRING_RESULT) if (hybrid_type == STRING_RESULT)
{ {
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String tmp(buff,sizeof(buff)),*res; String tmp(buff,sizeof(buff),default_charset_info),*res;
res=args[0]->val_str(&tmp); res=args[0]->val_str(&tmp);
if (args[0]->null_value) if (args[0]->null_value)
@ -524,7 +524,7 @@ void Item_sum_hybrid::reset_field()
else else
{ {
result_field->set_notnull(); result_field->set_notnull();
result_field->store(res->ptr(),res->length()); result_field->store(res->ptr(),res->length(),tmp.charset());
} }
} }
else if (hybrid_type == INT_RESULT) else if (hybrid_type == INT_RESULT)
@ -694,7 +694,7 @@ Item_sum_hybrid::min_max_update_str_field(int offset)
if (result_field->is_null() || if (result_field->is_null() ||
(cmp_sign * (binary ? stringcmp(res_str,&tmp_value) : (cmp_sign * (binary ? stringcmp(res_str,&tmp_value) :
sortcmp(res_str,&tmp_value)) < 0)) sortcmp(res_str,&tmp_value)) < 0))
result_field->store(res_str->ptr(),res_str->length()); result_field->store(res_str->ptr(),res_str->length(),res_str->charset());
else else
{ // Use old value { // Use old value
char *res=result_field->ptr; char *res=result_field->ptr;

View File

@ -29,11 +29,31 @@
** Todo: Move month and days to language files ** Todo: Move month and days to language files
*/ */
static String month_names[] = { "January", "February", "March", "April", static String month_names[] =
"May", "June", "July", "August", {
"September", "October", "November", "December" }; String("January", default_charset_info),
static String day_names[] = { "Monday", "Tuesday", "Wednesday", String("February", default_charset_info),
"Thursday", "Friday", "Saturday" ,"Sunday" }; String("March", default_charset_info),
String("April", default_charset_info),
String("May", default_charset_info),
String("June", default_charset_info),
String("July", default_charset_info),
String("August", default_charset_info),
String("September", default_charset_info),
String("October", default_charset_info),
String("November", default_charset_info),
String("December", default_charset_info)
};
static String day_names[] =
{
String("Monday", default_charset_info),
String("Tuesday", default_charset_info),
String("Wednesday", default_charset_info),
String("Thursday", default_charset_info),
String("Friday", default_charset_info),
String("Saturday", default_charset_info),
String("Sunday", default_charset_info)
};
/* /*
** Get a array of positive numbers from a string object. ** Get a array of positive numbers from a string object.
@ -376,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"); str->copy("0000-00-00",10);
return str; return str;
} }
if (str->alloc(11)) if (str->alloc(11))

View File

@ -271,7 +271,7 @@ public:
double val() { return (double) value; } double val() { return (double) value; }
longlong val_int() { return value; } longlong val_int() { return value; }
String *val_str(String *str) String *val_str(String *str)
{ str_value.set(buff,buff_length); return &str_value; } { str_value.set(buff,buff_length,default_charset_info); return &str_value; }
const char *func_name() const { return "curtime"; } const char *func_name() const { return "curtime"; }
void fix_length_and_dec(); void fix_length_and_dec();
void make_field(Send_field *tmp_field) void make_field(Send_field *tmp_field)
@ -313,7 +313,7 @@ public:
longlong val_int() { return value; } longlong val_int() { return value; }
bool save_in_field(Field *to); bool save_in_field(Field *to);
String *val_str(String *str) String *val_str(String *str)
{ str_value.set(buff,buff_length); return &str_value; } { str_value.set(buff,buff_length,default_charset_info); return &str_value; }
const char *func_name() const { return "now"; } const char *func_name() const { return "now"; }
void fix_length_and_dec(); void fix_length_and_dec();
bool get_date(TIME *res,bool fuzzy_date); bool get_date(TIME *res,bool fuzzy_date);

View File

@ -213,7 +213,7 @@ void Log_event::pack_info(String* packet)
void Query_log_event::pack_info(String* packet) void Query_log_event::pack_info(String* packet)
{ {
char buf[256]; char buf[256];
String tmp(buf, sizeof(buf)); String tmp(buf, sizeof(buf), system_charset_info);
tmp.length(0); tmp.length(0);
if (db && db_len) if (db && db_len)
{ {
@ -230,7 +230,7 @@ void Query_log_event::pack_info(String* packet)
void Start_log_event::pack_info(String* packet) void Start_log_event::pack_info(String* packet)
{ {
char buf1[256]; char buf1[256];
String tmp(buf1, sizeof(buf1)); String tmp(buf1, sizeof(buf1), system_charset_info);
tmp.length(0); tmp.length(0);
char buf[22]; char buf[22];
@ -244,7 +244,7 @@ void Start_log_event::pack_info(String* packet)
void Load_log_event::pack_info(String* packet) void Load_log_event::pack_info(String* packet)
{ {
char buf[256]; char buf[256];
String tmp(buf, sizeof(buf)); String tmp(buf, sizeof(buf), system_charset_info);
tmp.length(0); tmp.length(0);
if(db && db_len) if(db && db_len)
{ {
@ -320,7 +320,7 @@ void Load_log_event::pack_info(String* packet)
void Rotate_log_event::pack_info(String* packet) void Rotate_log_event::pack_info(String* packet)
{ {
char buf1[256]; char buf1[256];
String tmp(buf1, sizeof(buf1)); String tmp(buf1, sizeof(buf1), system_charset_info);
tmp.length(0); tmp.length(0);
char buf[22]; char buf[22];
tmp.append(new_log_ident, ident_len); tmp.append(new_log_ident, ident_len);
@ -334,7 +334,7 @@ void Rotate_log_event::pack_info(String* packet)
void Intvar_log_event::pack_info(String* packet) void Intvar_log_event::pack_info(String* packet)
{ {
char buf1[256]; char buf1[256];
String tmp(buf1, sizeof(buf1)); String tmp(buf1, sizeof(buf1), system_charset_info);
tmp.length(0); tmp.length(0);
char buf[22]; char buf[22];
tmp.append(get_var_type_name()); tmp.append(get_var_type_name());
@ -346,7 +346,7 @@ void Intvar_log_event::pack_info(String* packet)
void Slave_log_event::pack_info(String* packet) void Slave_log_event::pack_info(String* packet)
{ {
char buf1[256]; char buf1[256];
String tmp(buf1, sizeof(buf1)); String tmp(buf1, sizeof(buf1), system_charset_info);
tmp.length(0); tmp.length(0);
char buf[22]; char buf[22];
tmp.append("host="); tmp.append("host=");
@ -1417,7 +1417,7 @@ void Create_file_log_event::print(FILE* file, bool short_form,
void Create_file_log_event::pack_info(String* packet) void Create_file_log_event::pack_info(String* packet)
{ {
char buf1[256]; char buf1[256];
String tmp(buf1, sizeof(buf1)); String tmp(buf1, sizeof(buf1), system_charset_info);
tmp.length(0); tmp.length(0);
char buf[22]; char buf[22];
tmp.append("db="); tmp.append("db=");
@ -1475,7 +1475,7 @@ void Append_block_log_event::print(FILE* file, bool short_form,
void Append_block_log_event::pack_info(String* packet) void Append_block_log_event::pack_info(String* packet)
{ {
char buf1[256]; char buf1[256];
String tmp(buf1, sizeof(buf1)); String tmp(buf1, sizeof(buf1), system_charset_info);
tmp.length(0); tmp.length(0);
char buf[22]; char buf[22];
tmp.append(";file_id="); tmp.append(";file_id=");
@ -1524,7 +1524,7 @@ void Delete_file_log_event::print(FILE* file, bool short_form,
void Delete_file_log_event::pack_info(String* packet) void Delete_file_log_event::pack_info(String* packet)
{ {
char buf1[256]; char buf1[256];
String tmp(buf1, sizeof(buf1)); String tmp(buf1, sizeof(buf1), system_charset_info);
tmp.length(0); tmp.length(0);
char buf[22]; char buf[22];
tmp.append(";file_id="); tmp.append(";file_id=");
@ -1571,7 +1571,7 @@ void Execute_load_log_event::print(FILE* file, bool short_form,
void Execute_load_log_event::pack_info(String* packet) void Execute_load_log_event::pack_info(String* packet)
{ {
char buf1[256]; char buf1[256];
String tmp(buf1, sizeof(buf1)); String tmp(buf1, sizeof(buf1), system_charset_info);
tmp.length(0); tmp.length(0);
char buf[22]; char buf[22];
tmp.append(";file_id="); tmp.append(";file_id=");
@ -1690,12 +1690,12 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli)
handle_dup = DUP_REPLACE; handle_dup = DUP_REPLACE;
sql_exchange ex((char*)fname, sql_ex.opt_flags && sql_exchange ex((char*)fname, sql_ex.opt_flags &&
DUMPFILE_FLAG ); DUMPFILE_FLAG );
String field_term(sql_ex.field_term,sql_ex.field_term_len); String field_term(sql_ex.field_term,sql_ex.field_term_len, system_charset_info);
String enclosed(sql_ex.enclosed,sql_ex.enclosed_len); String enclosed(sql_ex.enclosed,sql_ex.enclosed_len, system_charset_info);
String line_term(sql_ex.line_term,sql_ex.line_term_len); String line_term(sql_ex.line_term,sql_ex.line_term_len, system_charset_info);
String line_start(sql_ex.line_start,sql_ex.line_start_len); String line_start(sql_ex.line_start,sql_ex.line_start_len, system_charset_info);
String escaped(sql_ex.escaped,sql_ex.escaped_len); String escaped(sql_ex.escaped,sql_ex.escaped_len, system_charset_info);
ex.opt_enclosed = (sql_ex.opt_flags & OPT_ENCLOSED_FLAG); ex.opt_enclosed = (sql_ex.opt_flags & OPT_ENCLOSED_FLAG);
if (sql_ex.empty_flags & FIELD_TERM_EMPTY) if (sql_ex.empty_flags & FIELD_TERM_EMPTY)
ex.field_term->length(0); ex.field_term->length(0);

View File

@ -334,7 +334,7 @@ net_store_data(String *packet,struct tm *tmp)
bool net_store_data(String* packet, I_List<i_string>* str_list) bool net_store_data(String* packet, I_List<i_string>* str_list)
{ {
char buf[256]; char buf[256];
String tmp(buf, sizeof(buf)); String tmp(buf, sizeof(buf), default_charset_info);
tmp.length(0); tmp.length(0);
I_List_iterator<i_string> it(*str_list); I_List_iterator<i_string> it(*str_list);
i_string* s; i_string* s;

View File

@ -930,7 +930,7 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part,
{ {
bool like_error; bool like_error;
char buff1[MAX_FIELD_WIDTH],*min_str,*max_str; char buff1[MAX_FIELD_WIDTH],*min_str,*max_str;
String tmp(buff1,sizeof(buff1)),*res; String tmp(buff1,sizeof(buff1),default_charset_info),*res;
uint length,offset,min_length,max_length; uint length,offset,min_length,max_length;
if (!field->optimize_range((uint) key_part->key)) if (!field->optimize_range((uint) key_part->key))
@ -2836,7 +2836,7 @@ static void
print_key(KEY_PART *key_part,const char *key,uint used_length) print_key(KEY_PART *key_part,const char *key,uint used_length)
{ {
char buff[1024]; char buff[1024];
String tmp(buff,sizeof(buff)); String tmp(buff,sizeof(buff),default_charset_info);
for (uint length=0; for (uint length=0;
length < used_length ; length < used_length ;

View File

@ -377,7 +377,7 @@ static uint get_access(TABLE *form,uint fieldnr)
{ {
uint access_bits=0,bit; uint access_bits=0,bit;
char buff[2]; char buff[2];
String res(buff,sizeof(buff)); String res(buff,sizeof(buff),default_charset_info);
Field **pos; Field **pos;
for (pos=form->field+fieldnr,bit=1 ; *pos ; pos++ , bit<<=1) for (pos=form->field+fieldnr,bit=1 ; *pos ; pos++ , bit<<=1)
@ -1091,8 +1091,8 @@ static bool update_user_table(THD *thd, const char *host, const char *user,
tables.db=(char*) "mysql"; tables.db=(char*) "mysql";
if (!(table=open_ltable(thd,&tables,TL_WRITE))) if (!(table=open_ltable(thd,&tables,TL_WRITE)))
DBUG_RETURN(1); /* purecov: deadcode */ DBUG_RETURN(1); /* purecov: deadcode */
table->field[0]->store(host,(uint) strlen(host)); table->field[0]->store(host,(uint) strlen(host), system_charset_info);
table->field[1]->store(user,(uint) strlen(user)); table->field[1]->store(user,(uint) strlen(user), system_charset_info);
if (table->file->index_read_idx(table->record[0],0, if (table->file->index_read_idx(table->record[0],0,
(byte*) table->field[0]->ptr,0, (byte*) table->field[0]->ptr,0,
@ -1102,7 +1102,7 @@ static bool update_user_table(THD *thd, const char *host, const char *user,
DBUG_RETURN(1); /* purecov: deadcode */ DBUG_RETURN(1); /* purecov: deadcode */
} }
store_record(table,1); store_record(table,1);
table->field[2]->store(new_password,(uint) strlen(new_password)); table->field[2]->store(new_password,(uint) strlen(new_password), system_charset_info);
if ((error=table->file->update_row(table->record[1],table->record[0]))) if ((error=table->file->update_row(table->record[1],table->record[0])))
{ {
table->file->print_error(error,MYF(0)); /* purecov: deadcode */ table->file->print_error(error,MYF(0)); /* purecov: deadcode */
@ -1161,8 +1161,8 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
empty_string[0]=0; empty_string[0]=0;
} }
table->field[0]->store(combo.host.str,combo.host.length); table->field[0]->store(combo.host.str,combo.host.length, system_charset_info);
table->field[1]->store(combo.user.str,combo.user.length); table->field[1]->store(combo.user.str,combo.user.length, system_charset_info);
table->file->index_init(0); table->file->index_init(0);
if (table->file->index_read(table->record[0], if (table->file->index_read(table->record[0],
(byte*) table->field[0]->ptr,0, (byte*) table->field[0]->ptr,0,
@ -1183,17 +1183,17 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
goto end; goto end;
} }
old_row_exists = 0; old_row_exists = 0;
restore_record(table,2); // cp empty row from record[2] restore_record(table,2); // cp empty row from record[2]
table->field[0]->store(combo.host.str,combo.host.length); table->field[0]->store(combo.host.str,combo.host.length, system_charset_info);
table->field[1]->store(combo.user.str,combo.user.length); table->field[1]->store(combo.user.str,combo.user.length, system_charset_info);
table->field[2]->store(password,(uint) strlen(password)); table->field[2]->store(password,(uint) strlen(password), system_charset_info);
} }
else else
{ {
old_row_exists = 1; old_row_exists = 1;
store_record(table,1); // Save copy for update store_record(table,1); // Save copy for update
if (combo.password.str) // If password given if (combo.password.str) // If password given
table->field[2]->store(password,(uint) strlen(password)); table->field[2]->store(password,(uint) strlen(password), system_charset_info);
} }
for (i = 3, j = SELECT_ACL; // starting from reload for (i = 3, j = SELECT_ACL; // starting from reload
@ -1201,7 +1201,7 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
i++, j <<= 1) i++, j <<= 1)
{ {
if (j & rights) // set requested privileges if (j & rights) // set requested privileges
table->field[i]->store(&what,1); table->field[i]->store(&what,1, system_charset_info);
} }
rights=get_access(table,3); rights=get_access(table,3);
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
@ -1209,30 +1209,30 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
DBUG_PRINT("info",("table->fields=%d",table->fields)); DBUG_PRINT("info",("table->fields=%d",table->fields));
if (table->fields >= 21) /* From 4.0.0 we have more fields */ if (table->fields >= 21) /* From 4.0.0 we have more fields */
{ {
table->field[18]->store("",0); table->field[18]->store("",0, system_charset_info);
table->field[19]->store("",0); table->field[19]->store("",0, system_charset_info);
table->field[20]->store("",0); table->field[20]->store("",0, system_charset_info);
switch (thd->lex.ssl_type) { switch (thd->lex.ssl_type) {
case SSL_TYPE_ANY: case SSL_TYPE_ANY:
table->field[17]->store("ANY",3); table->field[17]->store("ANY",3, system_charset_info);
break; break;
case SSL_TYPE_X509: case SSL_TYPE_X509:
table->field[17]->store("X509",4); table->field[17]->store("X509",4, system_charset_info);
break; break;
case SSL_TYPE_SPECIFIED: case SSL_TYPE_SPECIFIED:
table->field[17]->store("SPECIFIED",9); table->field[17]->store("SPECIFIED",9, system_charset_info);
if (thd->lex.ssl_cipher) if (thd->lex.ssl_cipher)
table->field[18]->store(thd->lex.ssl_cipher, table->field[18]->store(thd->lex.ssl_cipher,
strlen(thd->lex.ssl_cipher)); strlen(thd->lex.ssl_cipher), system_charset_info);
if (thd->lex.x509_issuer) if (thd->lex.x509_issuer)
table->field[19]->store(thd->lex.x509_issuer, table->field[19]->store(thd->lex.x509_issuer,
strlen(thd->lex.x509_issuer)); strlen(thd->lex.x509_issuer), system_charset_info);
if (thd->lex.x509_subject) if (thd->lex.x509_subject)
table->field[20]->store(thd->lex.x509_subject, table->field[20]->store(thd->lex.x509_subject,
strlen(thd->lex.x509_subject)); strlen(thd->lex.x509_subject), system_charset_info);
break; break;
default: default:
table->field[17]->store("NONE",4); table->field[17]->store("NONE",4, system_charset_info);
} }
} }
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
@ -1315,9 +1315,9 @@ static int replace_db_table(TABLE *table, const char *db,
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
table->field[0]->store(combo.host.str,combo.host.length); table->field[0]->store(combo.host.str,combo.host.length, system_charset_info);
table->field[1]->store(db,(uint) strlen(db)); table->field[1]->store(db,(uint) strlen(db), system_charset_info);
table->field[2]->store(combo.user.str,combo.user.length); table->field[2]->store(combo.user.str,combo.user.length, system_charset_info);
table->file->index_init(0); table->file->index_init(0);
if (table->file->index_read(table->record[0],(byte*) table->field[0]->ptr,0, if (table->file->index_read(table->record[0],(byte*) table->field[0]->ptr,0,
HA_READ_KEY_EXACT)) HA_READ_KEY_EXACT))
@ -1330,9 +1330,9 @@ static int replace_db_table(TABLE *table, const char *db,
} }
old_row_exists = 0; old_row_exists = 0;
restore_record(table,2); // cp empty row from record[2] restore_record(table,2); // cp empty row from record[2]
table->field[0]->store(combo.host.str,combo.host.length); table->field[0]->store(combo.host.str,combo.host.length, system_charset_info);
table->field[1]->store(db,(uint) strlen(db)); table->field[1]->store(db,(uint) strlen(db), system_charset_info);
table->field[2]->store(combo.user.str,combo.user.length); table->field[2]->store(combo.user.str,combo.user.length, system_charset_info);
} }
else else
{ {
@ -1344,7 +1344,7 @@ static int replace_db_table(TABLE *table, const char *db,
for (i = 3, j = 1; i < table->fields; i++, j <<= 1) for (i = 3, j = 1; i < table->fields; i++, j <<= 1)
{ {
if (j & store_rights) // do it if priv is chosen if (j & store_rights) // do it if priv is chosen
table->field [i]->store(&what,1); // set requested privileges table->field [i]->store(&what,1, system_charset_info);// set requested privileges
} }
rights=get_access(table,3); rights=get_access(table,3);
rights=fix_rights_for_db(rights); rights=fix_rights_for_db(rights);
@ -1466,16 +1466,16 @@ public:
if (cols) if (cols)
{ {
int key_len; int key_len;
col_privs->field[0]->store(host,(uint) strlen(host)); col_privs->field[0]->store(host,(uint) strlen(host), system_charset_info);
col_privs->field[1]->store(db,(uint) strlen(db)); col_privs->field[1]->store(db,(uint) strlen(db), system_charset_info);
col_privs->field[2]->store(user,(uint) strlen(user)); col_privs->field[2]->store(user,(uint) strlen(user), system_charset_info);
col_privs->field[3]->store(tname,(uint) strlen(tname)); col_privs->field[3]->store(tname,(uint) strlen(tname), system_charset_info);
key_len=(col_privs->field[0]->pack_length()+ key_len=(col_privs->field[0]->pack_length()+
col_privs->field[1]->pack_length()+ col_privs->field[1]->pack_length()+
col_privs->field[2]->pack_length()+ col_privs->field[2]->pack_length()+
col_privs->field[3]->pack_length()); col_privs->field[3]->pack_length());
key_copy(key,col_privs,0,key_len); key_copy(key,col_privs,0,key_len);
col_privs->field[4]->store("",0); col_privs->field[4]->store("",0, system_charset_info);
col_privs->file->index_init(0); col_privs->file->index_init(0);
if (col_privs->file->index_read(col_privs->record[0], if (col_privs->file->index_read(col_privs->record[0],
(byte*) col_privs->field[0]->ptr, (byte*) col_privs->field[0]->ptr,
@ -1574,10 +1574,10 @@ static int replace_column_table(GRANT_TABLE *g_t,
byte key[MAX_KEY_LENGTH]; byte key[MAX_KEY_LENGTH];
DBUG_ENTER("replace_column_table"); DBUG_ENTER("replace_column_table");
table->field[0]->store(combo.host.str,combo.host.length); table->field[0]->store(combo.host.str,combo.host.length, system_charset_info);
table->field[1]->store(db,(uint) strlen(db)); table->field[1]->store(db,(uint) strlen(db), system_charset_info);
table->field[2]->store(combo.user.str,combo.user.length); table->field[2]->store(combo.user.str,combo.user.length, system_charset_info);
table->field[3]->store(table_name,(uint) strlen(table_name)); table->field[3]->store(table_name,(uint) strlen(table_name), system_charset_info);
key_length=(table->field[0]->pack_length()+ table->field[1]->pack_length()+ key_length=(table->field[0]->pack_length()+ table->field[1]->pack_length()+
table->field[2]->pack_length()+ table->field[3]->pack_length()); table->field[2]->pack_length()+ table->field[3]->pack_length());
key_copy(key,table,0,key_length); key_copy(key,table,0,key_length);
@ -1594,7 +1594,7 @@ static int replace_column_table(GRANT_TABLE *g_t,
uint privileges = xx->rights; uint privileges = xx->rights;
bool old_row_exists=0; bool old_row_exists=0;
key_restore(table,key,0,key_length); key_restore(table,key,0,key_length);
table->field[4]->store(xx->column.ptr(),xx->column.length()); table->field[4]->store(xx->column.ptr(),xx->column.length(),system_charset_info);
if (table->file->index_read(table->record[0],(byte*) table->field[0]->ptr, if (table->file->index_read(table->record[0],(byte*) table->field[0]->ptr,
0, HA_READ_KEY_EXACT)) 0, HA_READ_KEY_EXACT))
@ -1608,9 +1608,9 @@ static int replace_column_table(GRANT_TABLE *g_t,
continue; /* purecov: inspected */ continue; /* purecov: inspected */
} }
old_row_exists = 0; old_row_exists = 0;
restore_record(table,2); // Get empty record restore_record(table,2); // Get empty record
key_restore(table,key,0,key_length); key_restore(table,key,0,key_length);
table->field[4]->store(xx->column.ptr(),xx->column.length()); table->field[4]->store(xx->column.ptr(),xx->column.length(), system_charset_info);
} }
else else
{ {
@ -1682,7 +1682,7 @@ static int replace_column_table(GRANT_TABLE *g_t,
{ {
GRANT_COLUMN *grant_column = NULL; GRANT_COLUMN *grant_column = NULL;
char colum_name_buf[HOSTNAME_LENGTH+1]; char colum_name_buf[HOSTNAME_LENGTH+1];
String column_name(colum_name_buf,sizeof(colum_name_buf)); String column_name(colum_name_buf,sizeof(colum_name_buf),system_charset_info);
privileges&= ~rights; privileges&= ~rights;
table->field[6]->store((longlong) table->field[6]->store((longlong)
@ -1749,10 +1749,10 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table,
} }
restore_record(table,2); // Get empty record restore_record(table,2); // Get empty record
table->field[0]->store(combo.host.str,combo.host.length); table->field[0]->store(combo.host.str,combo.host.length, system_charset_info);
table->field[1]->store(db,(uint) strlen(db)); table->field[1]->store(db,(uint) strlen(db), system_charset_info);
table->field[2]->store(combo.user.str,combo.user.length); table->field[2]->store(combo.user.str,combo.user.length, system_charset_info);
table->field[3]->store(table_name,(uint) strlen(table_name)); table->field[3]->store(table_name,(uint) strlen(table_name), system_charset_info);
store_record(table,1); // store at pos 1 store_record(table,1); // store at pos 1
if (table->file->index_read_idx(table->record[0],0, if (table->file->index_read_idx(table->record[0],0,
@ -1797,7 +1797,7 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table,
} }
} }
table->field[4]->store(grantor,(uint) strlen(grantor)); table->field[4]->store(grantor,(uint) strlen(grantor), system_charset_info);
table->field[6]->store((longlong) store_table_rights); table->field[6]->store((longlong) store_table_rights);
table->field[7]->store((longlong) store_col_rights); table->field[7]->store((longlong) store_col_rights);
rights=fix_rights_for_table(store_table_rights); rights=fix_rights_for_table(store_table_rights);
@ -2612,7 +2612,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
Item_string *field=new Item_string("",0); Item_string *field=new Item_string("",0,system_charset_info);
List<Item> field_list; List<Item> field_list;
field->name=buff; field->name=buff;
field->max_length=1024; field->max_length=1024;
@ -2628,7 +2628,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
if (acl_user->access || acl_user->password) if (acl_user->access || acl_user->password)
{ {
want_access=acl_user->access; want_access=acl_user->access;
String global(buff,sizeof(buff)); String global(buff,sizeof(buff),system_charset_info);
global.length(0); global.length(0);
global.append("GRANT ",6); global.append("GRANT ",6);
@ -2734,7 +2734,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
want_access=acl_db->access; want_access=acl_db->access;
if (want_access) if (want_access)
{ {
String db(buff,sizeof(buff)); String db(buff,sizeof(buff),system_charset_info);
db.length(0); db.length(0);
db.append("GRANT ",6); db.append("GRANT ",6);
@ -2793,7 +2793,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
want_access=grant_table->privs; want_access=grant_table->privs;
if ((want_access | grant_table->cols) != 0) if ((want_access | grant_table->cols) != 0)
{ {
String global(buff,sizeof(buff)); String global(buff,sizeof(buff),system_charset_info);
global.length(0); global.length(0);
global.append("GRANT ",6); global.append("GRANT ",6);

View File

@ -270,7 +270,7 @@ void free_string(String *s)
void field_str::add() void field_str::add()
{ {
char buff[MAX_FIELD_WIDTH], *ptr; char buff[MAX_FIELD_WIDTH], *ptr;
String s(buff, sizeof(buff)), *res; String s(buff, sizeof(buff),default_charset_info), *res;
ulong length; ulong length;
if (!(res = item->val_str(&s))) if (!(res = item->val_str(&s)))
@ -573,8 +573,9 @@ bool analyse::end_of_records()
{ {
field_info **f = f_info; field_info **f = f_info;
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String *res, s_min(buff, sizeof(buff)), s_max(buff, sizeof(buff)), String *res, s_min(buff, sizeof(buff),default_charset_info),
ans(buff, sizeof(buff)); s_max(buff, sizeof(buff),default_charset_info),
ans(buff, sizeof(buff),default_charset_info);
for (; f != f_end; f++) for (; f != f_end; f++)
{ {
@ -620,14 +621,14 @@ bool analyse::end_of_records()
((*f)->tree.elements_in_tree * 3 - 1 + 6)))) ((*f)->tree.elements_in_tree * 3 - 1 + 6))))
{ {
char tmp[331]; //331, because one double prec. num. can be this long char tmp[331]; //331, because one double prec. num. can be this long
String tmp_str(tmp, sizeof(tmp)); String tmp_str(tmp, sizeof(tmp),default_charset_info);
TREE_INFO tree_info; TREE_INFO tree_info;
tree_info.str = &tmp_str; tree_info.str = &tmp_str;
tree_info.found = 0; tree_info.found = 0;
tree_info.item = (*f)->item; tree_info.item = (*f)->item;
tmp_str.set("ENUM(", 5); tmp_str.set("ENUM(", 5,default_charset_info);
tree_walk(&(*f)->tree, (*f)->collect_enum(), (char*) &tree_info, tree_walk(&(*f)->tree, (*f)->collect_enum(), (char*) &tree_info,
left_root_right); left_root_right);
tmp_str.append(')'); tmp_str.append(')');
@ -891,7 +892,7 @@ int collect_real(double *element, element_count count __attribute__((unused)),
TREE_INFO *info) TREE_INFO *info)
{ {
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String s(buff, sizeof(buff)); String s(buff, sizeof(buff),default_charset_info);
if (info->found) if (info->found)
info->str->append(','); info->str->append(',');
@ -910,7 +911,7 @@ int collect_longlong(longlong *element,
TREE_INFO *info) TREE_INFO *info)
{ {
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String s(buff, sizeof(buff)); String s(buff, sizeof(buff),default_charset_info);
if (info->found) if (info->found)
info->str->append(','); info->str->append(',');
@ -929,7 +930,7 @@ int collect_ulonglong(ulonglong *element,
TREE_INFO *info) TREE_INFO *info)
{ {
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String s(buff, sizeof(buff)); String s(buff, sizeof(buff),default_charset_info);
if (info->found) if (info->found)
info->str->append(','); info->str->append(',');

View File

@ -110,8 +110,9 @@ class field_str :public field_info
EV_NUM_INFO ev_num_info; EV_NUM_INFO ev_num_info;
public: public:
field_str(Item* a, analyse* b) :field_info(a,b), min_arg(""), field_str(Item* a, analyse* b) :field_info(a,b),
max_arg(""), sum(0), min_arg("",default_charset_info),
max_arg("",default_charset_info), sum(0),
must_be_blob(0), was_zero_fill(0), must_be_blob(0), was_zero_fill(0),
was_maybe_zerofill(0), can_be_still_num(1) was_maybe_zerofill(0), can_be_still_num(1)
{ init_tree(&tree, 0, 0, sizeof(String), a->binary ? { init_tree(&tree, 0, 0, sizeof(String), a->binary ?

View File

@ -197,7 +197,8 @@ send_fields(THD *thd,List<Item> &list,uint flag)
char buff[80]; char buff[80];
CONVERT *convert= (flag & 4) ? (CONVERT*) 0 : thd->convert_set; CONVERT *convert= (flag & 4) ? (CONVERT*) 0 : thd->convert_set;
String tmp((char*) buff,sizeof(buff)),*res,*packet= &thd->packet; String tmp((char*) buff,sizeof(buff),default_charset_info);
String *res,*packet= &thd->packet;
if (thd->fatal_error) // We have got an error if (thd->fatal_error) // We have got an error
goto err; goto err;

View File

@ -363,8 +363,10 @@ select_result::select_result()
thd=current_thd; thd=current_thd;
} }
static String default_line_term("\n"),default_escaped("\\"), static String
default_field_term("\t"); default_line_term("\n",default_charset_info),
default_escaped("\\",default_charset_info),
default_field_term("\t",default_charset_info);
sql_exchange::sql_exchange(char *name,bool flag) sql_exchange::sql_exchange(char *name,bool flag)
:file_name(name), opt_enclosed(0), dumpfile(flag), skip_lines(0) :file_name(name), opt_enclosed(0), dumpfile(flag), skip_lines(0)
@ -507,7 +509,7 @@ bool select_export::send_data(List<Item> &items)
DBUG_ENTER("send_data"); DBUG_ENTER("send_data");
char buff[MAX_FIELD_WIDTH],null_buff[2],space[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH],null_buff[2],space[MAX_FIELD_WIDTH];
bool space_inited=0; bool space_inited=0;
String tmp(buff,sizeof(buff)),*res; String tmp(buff,sizeof(buff),default_charset_info),*res;
tmp.length(0); tmp.length(0);
if (thd->offset_limit) if (thd->offset_limit)
@ -714,7 +716,7 @@ bool select_dump::send_data(List<Item> &items)
{ {
List_iterator_fast<Item> li(items); List_iterator_fast<Item> li(items);
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String tmp(buff,sizeof(buff)),*res; String tmp(buff,sizeof(buff),default_charset_info),*res;
tmp.length(0); tmp.length(0);
Item *item; Item *item;
DBUG_ENTER("send_data"); DBUG_ENTER("send_data");

View File

@ -358,7 +358,7 @@ read_fixed_length(THD *thd,COPY_INFO &info,TABLE *table,List<Item> &fields,
field->field_length) field->field_length)
length=field->field_length; length=field->field_length;
save_chr=pos[length]; pos[length]='\0'; // Safeguard aganst malloc save_chr=pos[length]; pos[length]='\0'; // Safeguard aganst malloc
field->store((char*) pos,length); field->store((char*) pos,length,default_charset_info);
pos[length]=save_chr; pos[length]=save_chr;
if ((pos+=length) > read_info.row_end) if ((pos+=length) > read_info.row_end)
pos= read_info.row_end; /* Fills rest with space */ pos= read_info.row_end; /* Fills rest with space */
@ -427,7 +427,7 @@ read_sep_field(THD *thd,COPY_INFO &info,TABLE *table,
} }
field->set_notnull(); field->set_notnull();
read_info.row_end[0]=0; // Safe to change end marker read_info.row_end[0]=0; // Safe to change end marker
field->store((char*) read_info.row_start,length); field->store((char*) read_info.row_start,length,default_charset_info);
} }
if (read_info.error) if (read_info.error)
break; break;

View File

@ -3377,14 +3377,14 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
case Item_sum::AVG_FUNC: /* Place for sum & count */ case Item_sum::AVG_FUNC: /* Place for sum & count */
if (group) if (group)
return new Field_string(sizeof(double)+sizeof(longlong), return new Field_string(sizeof(double)+sizeof(longlong),
maybe_null, item->name,table,1); maybe_null, item->name,table,1,default_charset_info);
else else
return new Field_double(item_sum->max_length,maybe_null, return new Field_double(item_sum->max_length,maybe_null,
item->name, table, item_sum->decimals); item->name, table, item_sum->decimals);
case Item_sum::STD_FUNC: /* Place for sum & count */ case Item_sum::STD_FUNC: /* Place for sum & count */
if (group) if (group)
return new Field_string(sizeof(double)*2+sizeof(longlong), return new Field_string(sizeof(double)*2+sizeof(longlong),
maybe_null, item->name,table,1); maybe_null, item->name,table,1,default_charset_info);
else else
return new Field_double(item_sum->max_length, maybe_null, return new Field_double(item_sum->max_length, maybe_null,
item->name,table,item_sum->decimals); item->name,table,item_sum->decimals);
@ -3403,7 +3403,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
return new Field_blob(item_sum->max_length,maybe_null, return new Field_blob(item_sum->max_length,maybe_null,
item->name,table,item->binary); item->name,table,item->binary);
return new Field_string(item_sum->max_length,maybe_null, return new Field_string(item_sum->max_length,maybe_null,
item->name,table,item->binary); item->name,table,item->binary,default_charset_info);
} }
} }
thd->fatal_error=1; thd->fatal_error=1;
@ -3457,7 +3457,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
item->name,table,item->binary); item->name,table,item->binary);
else else
new_field= new Field_string(item->max_length,maybe_null, new_field= new Field_string(item->max_length,maybe_null,
item->name,table,item->binary); item->name,table,item->binary,default_charset_info);
break; break;
} }
if (copy_func) if (copy_func)
@ -3876,7 +3876,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
(uchar*) 0, (uchar*) 0,
(uint) 0, (uint) 0,
Field::NONE, Field::NONE,
NullS, table, (bool) 1); NullS, table, (bool) 1, default_charset_info);
key_part_info->key_type=FIELDFLAG_BINARY; key_part_info->key_type=FIELDFLAG_BINARY;
key_part_info->type= HA_KEYTYPE_BINARY; key_part_info->type= HA_KEYTYPE_BINARY;
key_part_info++; key_part_info++;
@ -6790,7 +6790,7 @@ change_to_use_tmp_fields(List<Item> &items)
if (_db_on_ && !item_field->name) if (_db_on_ && !item_field->name)
{ {
char buff[256]; char buff[256];
String str(buff,sizeof(buff)); String str(buff,sizeof(buff),default_charset_info);
str.length(0); str.length(0);
item->print(&str); item->print(&str);
item_field->name=sql_strmake(str.ptr(),str.length()); item_field->name=sql_strmake(str.ptr(),str.length());
@ -7021,7 +7021,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
item_list.push_back(new Item_empty_string("",0)); item_list.push_back(new Item_empty_string("",0));
item_list.push_back(new Item_empty_string("",0)); item_list.push_back(new Item_empty_string("",0));
item_list.push_back(new Item_empty_string("",0)); item_list.push_back(new Item_empty_string("",0));
item_list.push_back(new Item_string(message,strlen(message))); item_list.push_back(new Item_string(message,strlen(message),default_charset_info));
if (result->send_data(item_list)) if (result->send_data(item_list))
result->send_error(0,NullS); result->send_error(0,NullS);
} }
@ -7034,13 +7034,13 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
TABLE *table=tab->table; TABLE *table=tab->table;
char buff[512],*buff_ptr=buff; char buff[512],*buff_ptr=buff;
char buff1[512], buff2[512], bufff[512]; char buff1[512], buff2[512], bufff[512];
String tmp1(buff1,sizeof(buff1)); String tmp1(buff1,sizeof(buff1),default_charset_info);
String tmp2(buff2,sizeof(buff2)); String tmp2(buff2,sizeof(buff2),default_charset_info);
item_list.empty(); item_list.empty();
if (tab->type == JT_ALL && tab->select && tab->select->quick) if (tab->type == JT_ALL && tab->select && tab->select->quick)
tab->type= JT_RANGE; tab->type= JT_RANGE;
item_list.push_back(new Item_string(table->table_name,strlen(table->table_name))); item_list.push_back(new Item_string(table->table_name,strlen(table->table_name),default_charset_info));
item_list.push_back(new Item_string(join_type_str[tab->type],strlen(join_type_str[tab->type]))); item_list.push_back(new Item_string(join_type_str[tab->type],strlen(join_type_str[tab->type]),default_charset_info));
tmp1.length(0); tmp2.length(0); tmp1.length(0); tmp2.length(0);
key_map bits; key_map bits;
uint j; uint j;
@ -7054,12 +7054,12 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
} }
} }
if (tmp1.length()) if (tmp1.length())
item_list.push_back(new Item_string(tmp1.ptr(),tmp1.length())); item_list.push_back(new Item_string(tmp1.ptr(),tmp1.length(),default_charset_info));
else else
item_list.push_back(new Item_null()); item_list.push_back(new Item_null());
if (tab->ref.key_parts) if (tab->ref.key_parts)
{ {
item_list.push_back(new Item_string(table->key_info[tab->ref.key].name,strlen(table->key_info[tab->ref.key].name))); item_list.push_back(new Item_string(table->key_info[tab->ref.key].name,strlen(table->key_info[tab->ref.key].name),default_charset_info));
item_list.push_back(new Item_int((int) tab->ref.key_length)); item_list.push_back(new Item_int((int) tab->ref.key_length));
for (store_key **ref=tab->ref.key_copy ; *ref ; ref++) for (store_key **ref=tab->ref.key_copy ; *ref ; ref++)
{ {
@ -7067,17 +7067,17 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
tmp2.append(','); tmp2.append(',');
tmp2.append((*ref)->name()); tmp2.append((*ref)->name());
} }
item_list.push_back(new Item_string(tmp2.ptr(),tmp2.length())); item_list.push_back(new Item_string(tmp2.ptr(),tmp2.length(),default_charset_info));
} }
else if (tab->type == JT_NEXT) else if (tab->type == JT_NEXT)
{ {
item_list.push_back(new Item_string(table->key_info[tab->index].name,strlen(table->key_info[tab->index].name))); item_list.push_back(new Item_string(table->key_info[tab->index].name,strlen(table->key_info[tab->index].name),default_charset_info));
item_list.push_back(new Item_int((int) table->key_info[tab->index].key_length)); item_list.push_back(new Item_int((int) table->key_info[tab->index].key_length));
item_list.push_back(new Item_null()); item_list.push_back(new Item_null());
} }
else if (tab->select && tab->select->quick) else if (tab->select && tab->select->quick)
{ {
item_list.push_back(new Item_string(table->key_info[tab->select->quick->index].name,strlen(table->key_info[tab->select->quick->index].name))); item_list.push_back(new Item_string(table->key_info[tab->select->quick->index].name,strlen(table->key_info[tab->select->quick->index].name),default_charset_info));
item_list.push_back(new Item_int((int) tab->select->quick->max_used_key_length)); item_list.push_back(new Item_int((int) tab->select->quick->max_used_key_length));
item_list.push_back(new Item_null()); item_list.push_back(new Item_null());
} }
@ -7088,14 +7088,14 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
item_list.push_back(new Item_null()); item_list.push_back(new Item_null());
} }
sprintf(bufff,"%.0f",join->best_positions[i].records_read); sprintf(bufff,"%.0f",join->best_positions[i].records_read);
item_list.push_back(new Item_string(bufff,strlen(bufff))); item_list.push_back(new Item_string(bufff,strlen(bufff),default_charset_info));
my_bool key_read=table->key_read; my_bool key_read=table->key_read;
if (tab->type == JT_NEXT && if (tab->type == JT_NEXT &&
((table->used_keys & ((key_map) 1 << tab->index)))) ((table->used_keys & ((key_map) 1 << tab->index))))
key_read=1; key_read=1;
if (tab->info) if (tab->info)
item_list.push_back(new Item_string(tab->info,strlen(tab->info))); item_list.push_back(new Item_string(tab->info,strlen(tab->info),default_charset_info));
else if (tab->select) else if (tab->select)
{ {
if (tab->use_quick == 2) if (tab->use_quick == 2)
@ -7149,7 +7149,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
} }
buff_ptr=strmov(buff_ptr,"Distinct"); buff_ptr=strmov(buff_ptr,"Distinct");
} }
item_list.push_back(new Item_string(buff,(uint) (buff_ptr - buff))); item_list.push_back(new Item_string(buff,(uint) (buff_ptr - buff),default_charset_info));
// For next iteration // For next iteration
used_tables|=table->map; used_tables|=table->map;
if (result->send_data(item_list)) if (result->send_data(item_list))

View File

@ -217,7 +217,7 @@ class store_key :public Sql_alloc
if (field_arg->type() == FIELD_TYPE_BLOB) if (field_arg->type() == FIELD_TYPE_BLOB)
to_field=new Field_varstring(ptr, length, (uchar*) null, 1, to_field=new Field_varstring(ptr, length, (uchar*) null, 1,
Field::NONE, field_arg->field_name, Field::NONE, field_arg->field_name,
field_arg->table, field_arg->binary()); field_arg->table, field_arg->binary(), default_charset_info);
else else
{ {
to_field=field_arg->new_field(&thd->mem_root,field_arg->table); to_field=field_arg->new_field(&thd->mem_root,field_arg->table);

View File

@ -57,7 +57,7 @@ extern struct st_VioSSLAcceptorFd * ssl_acceptor_fd;
int int
mysqld_show_dbs(THD *thd,const char *wild) mysqld_show_dbs(THD *thd,const char *wild)
{ {
Item_string *field=new Item_string("",0); Item_string *field=new Item_string("",0,default_charset_info);
List<Item> field_list; List<Item> field_list;
char *end; char *end;
List<char> files; List<char> files;
@ -138,7 +138,7 @@ int mysqld_show_open_tables(THD *thd,const char *wild)
int mysqld_show_tables(THD *thd,const char *db,const char *wild) int mysqld_show_tables(THD *thd,const char *db,const char *wild)
{ {
Item_string *field=new Item_string("",0); Item_string *field=new Item_string("",0,default_charset_info);
List<Item> field_list; List<Item> field_list;
char path[FN_LEN],*end; char path[FN_LEN],*end;
List<char> files; List<char> files;
@ -262,7 +262,7 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild)
(void) sprintf(path,"%s/%s",mysql_data_home,db); (void) sprintf(path,"%s/%s",mysql_data_home,db);
(void) unpack_dirname(path,path); (void) unpack_dirname(path,path);
//,default_charset_info
field_list.push_back(item=new Item_empty_string("Name",NAME_LEN)); field_list.push_back(item=new Item_empty_string("Name",NAME_LEN));
item->maybe_null=1; item->maybe_null=1;
field_list.push_back(item=new Item_empty_string("Type",10)); field_list.push_back(item=new Item_empty_string("Type",10));
@ -483,7 +483,7 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
{ {
byte *pos; byte *pos;
uint flags=field->flags; uint flags=field->flags;
String type(tmp,sizeof(tmp)); String type(tmp,sizeof(tmp),default_charset_info);
uint col_access; uint col_access;
bool null_default_value=0; bool null_default_value=0;
@ -506,7 +506,7 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
null_default_value=1; null_default_value=1;
if (!null_default_value && !field->is_null()) if (!null_default_value && !field->is_null())
{ // Not null by default { // Not null by default
type.set(tmp,sizeof(tmp)); type.set(tmp,sizeof(tmp),default_charset_info);
field->val_str(&type,&type); field->val_str(&type,&type);
net_store_data(packet,convert,type.ptr(),type.length()); net_store_data(packet,convert,type.ptr(),type.length());
} }
@ -810,7 +810,7 @@ store_create_info(THD *thd, TABLE *table, String *packet)
List<Item> field_list; List<Item> field_list;
char tmp[MAX_FIELD_WIDTH]; char tmp[MAX_FIELD_WIDTH];
String type(tmp, sizeof(tmp)); String type(tmp, sizeof(tmp),default_charset_info);
if (table->tmp_table) if (table->tmp_table)
packet->append("CREATE TEMPORARY TABLE ", 23); packet->append("CREATE TEMPORARY TABLE ", 23);
else else
@ -830,7 +830,7 @@ store_create_info(THD *thd, TABLE *table, String *packet)
packet->append(' '); packet->append(' ');
// check for surprises from the previous call to Field::sql_type() // check for surprises from the previous call to Field::sql_type()
if (type.ptr() != tmp) if (type.ptr() != tmp)
type.set(tmp, sizeof(tmp)); type.set(tmp, sizeof(tmp),default_charset_info);
field->sql_type(type); field->sql_type(type);
packet->append(type.ptr(),type.length()); packet->append(type.ptr(),type.length());
@ -846,7 +846,7 @@ store_create_info(THD *thd, TABLE *table, String *packet)
packet->append(" default ", 9); packet->append(" default ", 9);
if (!field->is_null()) if (!field->is_null())
{ // Not null by default { // Not null by default
type.set(tmp,sizeof(tmp)); type.set(tmp,sizeof(tmp),default_charset_info);
field->val_str(&type,&type); field->val_str(&type,&type);
packet->append('\''); packet->append('\'');
if (type.length()) if (type.length())
@ -1143,7 +1143,7 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables)
{ {
uint i; uint i;
char buff[8192]; char buff[8192];
String packet2(buff,sizeof(buff)); String packet2(buff,sizeof(buff),default_charset_info);
List<Item> field_list; List<Item> field_list;
CONVERT *convert=thd->convert_set; CONVERT *convert=thd->convert_set;
DBUG_ENTER("mysqld_show"); DBUG_ENTER("mysqld_show");

View File

@ -586,6 +586,7 @@ String *copy_if_not_alloced(String *to,String *from,uint32 from_length)
return from; // Actually an error return from; // Actually an error
if ((to->str_length=min(from->str_length,from_length))) if ((to->str_length=min(from->str_length,from_length)))
memcpy(to->Ptr,from->Ptr,to->str_length); memcpy(to->Ptr,from->Ptr,to->str_length);
to->str_charset=from->str_charset;
return to; return to;
} }

View File

@ -46,22 +46,21 @@ public:
String(uint32 length_arg) String(uint32 length_arg)
{ {
alloced=0; Alloced_length=0; (void) real_alloc(length_arg); alloced=0; Alloced_length=0; (void) real_alloc(length_arg);
str_charset=default_charset_info;
} }
String(const char *str) String(const char *str, CHARSET_INFO *cs)
{ {
Ptr=(char*) str; str_length=(uint) strlen(str); Alloced_length=0; alloced=0; Ptr=(char*) str; str_length=(uint) strlen(str); Alloced_length=0; alloced=0;
str_charset=default_charset_info; str_charset=cs;
} }
String(const char *str,uint32 len) String(const char *str,uint32 len, CHARSET_INFO *cs)
{ {
Ptr=(char*) str; str_length=len; Alloced_length=0; alloced=0; Ptr=(char*) str; str_length=len; Alloced_length=0; alloced=0;
str_charset=default_charset_info; str_charset=cs;
} }
String(char *str,uint32 len) String(char *str,uint32 len, CHARSET_INFO *cs)
{ {
Ptr=(char*) str; Alloced_length=str_length=len; alloced=0; Ptr=(char*) str; Alloced_length=str_length=len; alloced=0;
str_charset=default_charset_info; str_charset=cs;
} }
String(const String &str) String(const String &str)
{ {
@ -103,23 +102,27 @@ public:
Alloced_length=str.Alloced_length-offset; Alloced_length=str.Alloced_length-offset;
else else
Alloced_length=0; Alloced_length=0;
str_charset=str.str_charset;
} }
inline void set(char *str,uint32 arg_length) inline void set(char *str,uint32 arg_length, CHARSET_INFO *cs)
{ {
free(); free();
Ptr=(char*) str; str_length=Alloced_length=arg_length ; alloced=0; Ptr=(char*) str; str_length=Alloced_length=arg_length ; alloced=0;
str_charset=cs;
} }
inline void set(const char *str,uint32 arg_length) inline void set(const char *str,uint32 arg_length, CHARSET_INFO *cs)
{ {
free(); free();
Ptr=(char*) str; str_length=arg_length; Alloced_length=0 ; alloced=0; Ptr=(char*) str; str_length=arg_length; Alloced_length=0 ; alloced=0;
str_charset=cs;
} }
inline void set_quick(char *str,uint32 arg_length) inline void set_quick(char *str,uint32 arg_length, CHARSET_INFO *cs)
{ {
if (!alloced) if (!alloced)
{ {
Ptr=(char*) str; str_length=Alloced_length=arg_length; Ptr=(char*) str; str_length=Alloced_length=arg_length;
} }
str_charset=cs;
} }
bool set(longlong num); bool set(longlong num);
/* bool set(long num); */ /* bool set(long num); */

View File

@ -156,7 +156,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
{ {
if (wrong_tables.length()) if (wrong_tables.length())
wrong_tables.append(','); wrong_tables.append(',');
wrong_tables.append(String(table->real_name)); wrong_tables.append(String(table->real_name,default_charset_info));
} }
} }
if (some_tables_deleted) if (some_tables_deleted)

View File

@ -33,7 +33,7 @@ print_where(COND *cond,const char *info)
if (cond) if (cond)
{ {
char buff[256]; char buff[256];
String str(buff,(uint32) sizeof(buff)); String str(buff,(uint32) sizeof(buff), default_charset_info);
str.length(0); str.length(0);
cond->print(&str); cond->print(&str);
str.append('\0'); str.append('\0');
@ -99,7 +99,8 @@ void print_cached_tables(void)
void TEST_filesort(SORT_FIELD *sortorder,uint s_length, ha_rows special) void TEST_filesort(SORT_FIELD *sortorder,uint s_length, ha_rows special)
{ {
char buff[256],buff2[256]; char buff[256],buff2[256];
String str(buff,sizeof(buff)),out(buff2,sizeof(buff2)); String str(buff,sizeof(buff),default_charset_info);
String out(buff2,sizeof(buff2),default_charset_info);
const char *sep; const char *sep;
DBUG_ENTER("TEST_filesort"); DBUG_ENTER("TEST_filesort");

View File

@ -412,9 +412,9 @@ int mysql_create_function(THD *thd,udf_func *udf)
goto err; goto err;
restore_record(table,2); // Get default values for fields restore_record(table,2); // Get default values for fields
table->field[0]->store(u_d->name, u_d->name_length); table->field[0]->store(u_d->name, u_d->name_length, default_charset_info);
table->field[1]->store((longlong) u_d->returns); table->field[1]->store((longlong) u_d->returns);
table->field[2]->store(u_d->dl,(uint) strlen(u_d->dl)); table->field[2]->store(u_d->dl,(uint) strlen(u_d->dl), default_charset_info);
if (table->fields >= 4) // If not old func format if (table->fields >= 4) // If not old func format
table->field[3]->store((longlong) u_d->type); table->field[3]->store((longlong) u_d->type);
error = table->file->write_row(table->record[0]); error = table->file->write_row(table->record[0]);

View File

@ -466,7 +466,7 @@ multi_update::prepare(List<Item> &values)
} }
if (counter) if (counter)
{ {
Field_string offset(table_ref->table->file->ref_length,false,"offset",table_ref->table,true); Field_string offset(table_ref->table->file->ref_length,false,"offset",table_ref->table,true,default_charset_info);
temp_fields->push_front(new Item_field(((Field *)&offset))); temp_fields->push_front(new Item_field(((Field *)&offset)));
// Here I make tmp tables // Here I make tmp tables
int cnt=counter-1; int cnt=counter-1;
@ -616,7 +616,8 @@ bool multi_update::send_data(List<Item> &values)
{ {
// Here we insert into each temporary table // Here we insert into each temporary table
values_by_table.push_front(new Item_string((char*) table->file->ref, values_by_table.push_front(new Item_string((char*) table->file->ref,
table->file->ref_length)); table->file->ref_length,
system_charset_info));
fill_record(tmp_tables[secure_counter]->field,values_by_table); fill_record(tmp_tables[secure_counter]->field,values_by_table);
error= write_record(tmp_tables[secure_counter], error= write_record(tmp_tables[secure_counter],
&(infos[secure_counter])); &(infos[secure_counter]));

View File

@ -1904,7 +1904,7 @@ simple_expr:
| SUBSTRING_INDEX '(' expr ',' expr ',' expr ')' | SUBSTRING_INDEX '(' expr ',' expr ',' expr ')'
{ $$= new Item_func_substr_index($3,$5,$7); } { $$= new Item_func_substr_index($3,$5,$7); }
| TRIM '(' expr ')' | TRIM '(' expr ')'
{ $$= new Item_func_trim($3,new Item_string(" ",1)); } { $$= new Item_func_trim($3,new Item_string(" ",1,default_charset_info)); }
| TRIM '(' LEADING opt_pad FROM expr ')' | TRIM '(' LEADING opt_pad FROM expr ')'
{ $$= new Item_func_ltrim($6,$4); } { $$= new Item_func_ltrim($6,$4); }
| TRIM '(' TRAILING opt_pad FROM expr ')' | TRIM '(' TRAILING opt_pad FROM expr ')'
@ -2089,7 +2089,7 @@ when_list2:
} }
opt_pad: opt_pad:
/* empty */ { $$=new Item_string(" ",1); } /* empty */ { $$=new Item_string(" ",1,default_charset_info); }
| expr { $$=$1; } | expr { $$=$1; }
join_table_list: join_table_list:
@ -2204,11 +2204,11 @@ key_usage_list:
key_usage_list2: key_usage_list2:
key_usage_list2 ',' ident key_usage_list2 ',' ident
{ Select->interval_list.push_back(new String((const char*) $3.str,$3.length)); } { Select->interval_list.push_back(new String((const char*) $3.str,$3.length,default_charset_info)); }
| ident | ident
{ Select->interval_list.push_back(new String((const char*) $1.str,$1.length)); } { Select->interval_list.push_back(new String((const char*) $1.str,$1.length,default_charset_info)); }
| PRIMARY_SYM | PRIMARY_SYM
{ Select->interval_list.push_back(new String("PRIMARY",7)); } { Select->interval_list.push_back(new String("PRIMARY",7,default_charset_info)); }
using_list: using_list:
ident ident
@ -2815,7 +2815,7 @@ describe_command:
opt_describe_column: opt_describe_column:
/* empty */ {} /* empty */ {}
| text_string { Lex->wild= $1; } | text_string { Lex->wild= $1; }
| ident { Lex->wild= new String((const char*) $1.str,$1.length); } | ident { Lex->wild= new String((const char*) $1.str,$1.length,default_charset_info); }
/* flush things */ /* flush things */
@ -2983,15 +2983,15 @@ opt_ignore_lines:
/* Common definitions */ /* Common definitions */
text_literal: text_literal:
TEXT_STRING { $$ = new Item_string($1.str,$1.length); } TEXT_STRING { $$ = new Item_string($1.str,$1.length,default_charset_info); }
| text_literal TEXT_STRING | text_literal TEXT_STRING
{ ((Item_string*) $1)->append($2.str,$2.length); } { ((Item_string*) $1)->append($2.str,$2.length); }
text_string: text_string:
TEXT_STRING { $$= new String($1.str,$1.length); } TEXT_STRING { $$= new String($1.str,$1.length,default_charset_info); }
| HEX_NUM | HEX_NUM
{ {
Item *tmp = new Item_varbinary($1.str,$1.length); Item *tmp = new Item_varbinary($1.str,$1.length,default_charset_info);
$$= tmp ? tmp->val_str((String*) 0) : (String*) 0; $$= tmp ? tmp->val_str((String*) 0) : (String*) 0;
} }
@ -3004,7 +3004,7 @@ literal:
| FLOAT_NUM { $$ = new Item_float($1.str, $1.length); } | FLOAT_NUM { $$ = new Item_float($1.str, $1.length); }
| NULL_SYM { $$ = new Item_null(); | NULL_SYM { $$ = new Item_null();
Lex->next_state=STATE_OPERATOR_OR_IDENT;} Lex->next_state=STATE_OPERATOR_OR_IDENT;}
| HEX_NUM { $$ = new Item_varbinary($1.str,$1.length);} | HEX_NUM { $$ = new Item_varbinary($1.str,$1.length,default_charset_info);}
| DATE_SYM text_literal { $$ = $2; } | DATE_SYM text_literal { $$ = $2; }
| TIME_SYM text_literal { $$ = $2; } | TIME_SYM text_literal { $$ = $2; }
| TIMESTAMP text_literal { $$ = $2; } | TIMESTAMP text_literal { $$ = $2; }
@ -3731,7 +3731,7 @@ column_list:
column_list_id: column_list_id:
ident ident
{ {
String *new_str = new String((const char*) $1.str,$1.length); String *new_str = new String((const char*) $1.str,$1.length,default_charset_info);
List_iterator <LEX_COLUMN> iter(Lex->columns); List_iterator <LEX_COLUMN> iter(Lex->columns);
class LEX_COLUMN *point; class LEX_COLUMN *point;
LEX *lex=Lex; LEX *lex=Lex;

View File

@ -1072,7 +1072,7 @@ char *get_field(MEM_ROOT *mem, TABLE *table, uint fieldnr)
{ {
Field *field=table->field[fieldnr]; Field *field=table->field[fieldnr];
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String str(buff,sizeof(buff)); String str(buff,sizeof(buff),table->table_charset);
field->val_str(&str,&str); field->val_str(&str,&str);
uint length=str.length(); uint length=str.length();
if (!length) if (!length)

View File

@ -484,7 +484,7 @@ static bool pack_fields(File file,List<create_field> &create_fields)
/* Write intervals */ /* Write intervals */
if (int_count) if (int_count)
{ {
String tmp((char*) buff,sizeof(buff)); String tmp((char*) buff,sizeof(buff), default_charset_info);
tmp.length(0); tmp.length(0);
it.rewind(); it.rewind();
int_count=0; int_count=0;
@ -561,6 +561,7 @@ static bool make_empty_rec(File file,enum db_type table_type,
field->interval, field->interval,
field->field_name, field->field_name,
&table); &table);
if (!(field->flags & NOT_NULL_FLAG)) if (!(field->flags & NOT_NULL_FLAG))
null_count++; null_count++;
@ -581,9 +582,9 @@ static bool make_empty_rec(File file,enum db_type table_type,
regfield->store((longlong) 1); regfield->store((longlong) 1);
} }
else if (type == Field::YES) // Old unireg type else if (type == Field::YES) // Old unireg type
regfield->store(ER(ER_YES),(uint) strlen(ER(ER_YES))); regfield->store(ER(ER_YES),(uint) strlen(ER(ER_YES)),default_charset_info);
else if (type == Field::NO) // Old unireg type else if (type == Field::NO) // Old unireg type
regfield->store(ER(ER_NO), (uint) strlen(ER(ER_NO))); regfield->store(ER(ER_NO), (uint) strlen(ER(ER_NO)),default_charset_info);
else else
regfield->reset(); regfield->reset();
delete regfield; delete regfield;