Commit 48cdd978 authored by bar@bar.mysql.r18.ru's avatar bar@bar.mysql.r18.ru

Strings which appear without charset context,

like number-to-string-convertion-result, now 
takes current database character set, instead of
thread character set. This makes it easy to be
SQL99 conformant and 4.0 compatible.

Item->thd_charset() is renamed to Item->default_charset()
as old name doesn't describe its nature anymore.
parent b381cb04
...@@ -163,9 +163,9 @@ bool Item::get_time(TIME *ltime) ...@@ -163,9 +163,9 @@ bool Item::get_time(TIME *ltime)
return 0; return 0;
} }
CHARSET_INFO * Item::thd_charset() const CHARSET_INFO * Item::default_charset() const
{ {
return current_thd->variables.thd_charset; return current_thd->db_charset;
} }
Item_field::Item_field(Field *f) :Item_ident(NullS,f->table_name,f->field_name) Item_field::Item_field(Field *f) :Item_ident(NullS,f->table_name,f->field_name)
...@@ -303,7 +303,7 @@ Item *Item_field::get_tmp_table_item(THD *thd) ...@@ -303,7 +303,7 @@ Item *Item_field::get_tmp_table_item(THD *thd)
String *Item_int::val_str(String *str) String *Item_int::val_str(String *str)
{ {
str->set(value, thd_charset()); str->set(value, default_charset());
return str; return str;
} }
...@@ -311,7 +311,7 @@ void Item_int::print(String *str) ...@@ -311,7 +311,7 @@ void Item_int::print(String *str)
{ {
if (!name) if (!name)
{ {
str_value.set(value, thd_charset()); str_value.set(value, default_charset());
name=str_value.c_ptr(); name=str_value.c_ptr();
} }
str->append(name); str->append(name);
...@@ -319,7 +319,7 @@ void Item_int::print(String *str) ...@@ -319,7 +319,7 @@ void Item_int::print(String *str)
String *Item_uint::val_str(String *str) String *Item_uint::val_str(String *str)
{ {
str->set((ulonglong) value, thd_charset()); str->set((ulonglong) value, default_charset());
return str; return str;
} }
...@@ -327,7 +327,7 @@ void Item_uint::print(String *str) ...@@ -327,7 +327,7 @@ void Item_uint::print(String *str)
{ {
if (!name) if (!name)
{ {
str_value.set((ulonglong) value, thd_charset()); str_value.set((ulonglong) value, default_charset());
name=str_value.c_ptr(); name=str_value.c_ptr();
} }
str->append(name); str->append(name);
...@@ -336,7 +336,7 @@ void Item_uint::print(String *str) ...@@ -336,7 +336,7 @@ void Item_uint::print(String *str)
String *Item_real::val_str(String *str) String *Item_real::val_str(String *str)
{ {
str->set(value,decimals,thd_charset()); str->set(value,decimals,default_charset());
return str; return str;
} }
...@@ -377,7 +377,7 @@ void Item_param::set_double(double value) ...@@ -377,7 +377,7 @@ void Item_param::set_double(double value)
void Item_param::set_value(const char *str, uint length) void Item_param::set_value(const char *str, uint length)
{ {
str_value.set(str,length,thd_charset()); str_value.set(str,length,default_charset());
item_type = STRING_ITEM; item_type = STRING_ITEM;
} }
...@@ -474,10 +474,10 @@ String *Item_param::val_str(String* str) ...@@ -474,10 +474,10 @@ String *Item_param::val_str(String* str)
{ {
switch (item_result_type) { switch (item_result_type) {
case INT_RESULT: case INT_RESULT:
str->set(int_value, thd_charset()); str->set(int_value, default_charset());
return str; return str;
case REAL_RESULT: case REAL_RESULT:
str->set(real_value, 2, thd_charset()); str->set(real_value, 2, default_charset());
return str; return str;
default: default:
return (String*) &str_value; return (String*) &str_value;
......
...@@ -110,7 +110,7 @@ public: ...@@ -110,7 +110,7 @@ public:
virtual bool binary() const virtual bool binary() const
{ return str_value.charset()->state & MY_CS_BINSORT ? 1 : 0 ; } { return str_value.charset()->state & MY_CS_BINSORT ? 1 : 0 ; }
CHARSET_INFO *thd_charset() const; CHARSET_INFO *default_charset() const;
CHARSET_INFO *charset() const { return str_value.charset(); }; CHARSET_INFO *charset() const { return str_value.charset(); };
void set_charset(CHARSET_INFO *cs) { str_value.set_charset(cs); } void set_charset(CHARSET_INFO *cs) { str_value.set_charset(cs); }
virtual void set_outer_resolving() {} virtual void set_outer_resolving() {}
...@@ -773,7 +773,7 @@ public: ...@@ -773,7 +773,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) { str->set(value, thd_charset()); return str; } String* val_str(String *str) { str->set(value, default_charset()); return str; }
enum Item_result result_type() const { return INT_RESULT; } enum Item_result result_type() const { return INT_RESULT; }
}; };
...@@ -792,7 +792,7 @@ public: ...@@ -792,7 +792,7 @@ public:
longlong val_int() { return (longlong) (value+(value > 0 ? 0.5 : -0.5)); } longlong val_int() { return (longlong) (value+(value > 0 ? 0.5 : -0.5)); }
String* val_str(String *str) String* val_str(String *str)
{ {
str->set(value, decimals, thd_charset()); str->set(value, decimals, default_charset());
return str; return str;
} }
enum Item_result result_type() const { return REAL_RESULT; } enum Item_result result_type() const { return REAL_RESULT; }
......
...@@ -873,7 +873,7 @@ String *Item_func_case::val_str(String *str) ...@@ -873,7 +873,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),thd_charset()); String dummy_str(buff,sizeof(buff),default_charset());
Item *item=find_item(&dummy_str); Item *item=find_item(&dummy_str);
longlong res; longlong res;
...@@ -890,7 +890,7 @@ longlong Item_func_case::val_int() ...@@ -890,7 +890,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),thd_charset()); String dummy_str(buff,sizeof(buff),default_charset());
Item *item=find_item(&dummy_str); Item *item=find_item(&dummy_str);
double res; double res;
......
...@@ -286,7 +286,7 @@ String *Item_real_func::val_str(String *str) ...@@ -286,7 +286,7 @@ String *Item_real_func::val_str(String *str)
if (null_value) if (null_value)
return 0; /* purecov: inspected */ return 0; /* purecov: inspected */
else else
str->set(nr,decimals,thd_charset()); str->set(nr,decimals,default_charset());
return str; return str;
} }
...@@ -299,9 +299,9 @@ String *Item_num_func::val_str(String *str) ...@@ -299,9 +299,9 @@ String *Item_num_func::val_str(String *str)
if (null_value) if (null_value)
return 0; /* purecov: inspected */ return 0; /* purecov: inspected */
else if (!unsigned_flag) else if (!unsigned_flag)
str->set(nr,thd_charset()); str->set(nr,default_charset());
else else
str->set((ulonglong) nr,thd_charset()); str->set((ulonglong) nr,default_charset());
} }
else else
{ {
...@@ -309,7 +309,7 @@ String *Item_num_func::val_str(String *str) ...@@ -309,7 +309,7 @@ String *Item_num_func::val_str(String *str)
if (null_value) if (null_value)
return 0; /* purecov: inspected */ return 0; /* purecov: inspected */
else else
str->set(nr,decimals,thd_charset()); str->set(nr,decimals,default_charset());
} }
return str; return str;
} }
...@@ -336,9 +336,9 @@ String *Item_int_func::val_str(String *str) ...@@ -336,9 +336,9 @@ String *Item_int_func::val_str(String *str)
if (null_value) if (null_value)
return 0; return 0;
else if (!unsigned_flag) else if (!unsigned_flag)
str->set(nr,thd_charset()); str->set(nr,default_charset());
else else
str->set((ulonglong) nr,thd_charset()); str->set((ulonglong) nr,default_charset());
return str; return str;
} }
...@@ -365,9 +365,9 @@ String *Item_num_op::val_str(String *str) ...@@ -365,9 +365,9 @@ String *Item_num_op::val_str(String *str)
if (null_value) if (null_value)
return 0; /* purecov: inspected */ return 0; /* purecov: inspected */
else if (!unsigned_flag) else if (!unsigned_flag)
str->set(nr,thd_charset()); str->set(nr,default_charset());
else else
str->set((ulonglong) nr,thd_charset()); str->set((ulonglong) nr,default_charset());
} }
else else
{ {
...@@ -375,7 +375,7 @@ String *Item_num_op::val_str(String *str) ...@@ -375,7 +375,7 @@ String *Item_num_op::val_str(String *str)
if (null_value) if (null_value)
return 0; /* purecov: inspected */ return 0; /* purecov: inspected */
else else
str->set(nr,decimals,thd_charset()); str->set(nr,decimals,default_charset());
} }
return str; return str;
} }
...@@ -890,9 +890,9 @@ String *Item_func_min_max::val_str(String *str) ...@@ -890,9 +890,9 @@ String *Item_func_min_max::val_str(String *str)
if (null_value) if (null_value)
return 0; return 0;
else if (!unsigned_flag) else if (!unsigned_flag)
str->set(nr,thd_charset()); str->set(nr,default_charset());
else else
str->set((ulonglong) nr,thd_charset()); str->set((ulonglong) nr,default_charset());
return str; return str;
} }
case REAL_RESULT: case REAL_RESULT:
...@@ -901,7 +901,7 @@ String *Item_func_min_max::val_str(String *str) ...@@ -901,7 +901,7 @@ String *Item_func_min_max::val_str(String *str)
if (null_value) if (null_value)
return 0; /* purecov: inspected */ return 0; /* purecov: inspected */
else else
str->set(nr,decimals,thd_charset()); str->set(nr,decimals,default_charset());
return str; return str;
} }
case STRING_RESULT: case STRING_RESULT:
...@@ -1563,7 +1563,7 @@ String *Item_func_udf_float::val_str(String *str) ...@@ -1563,7 +1563,7 @@ String *Item_func_udf_float::val_str(String *str)
if (null_value) if (null_value)
return 0; /* purecov: inspected */ return 0; /* purecov: inspected */
else else
str->set(nr,decimals,thd_charset()); str->set(nr,decimals,default_charset());
return str; return str;
} }
...@@ -1584,9 +1584,9 @@ String *Item_func_udf_int::val_str(String *str) ...@@ -1584,9 +1584,9 @@ String *Item_func_udf_int::val_str(String *str)
if (null_value) if (null_value)
return 0; return 0;
else if (!unsigned_flag) else if (!unsigned_flag)
str->set(nr,thd_charset()); str->set(nr,default_charset());
else else
str->set((ulonglong) nr,thd_charset()); str->set((ulonglong) nr,default_charset());
return str; return str;
} }
......
...@@ -1429,14 +1429,14 @@ String *Item_func_database::val_str(String *str) ...@@ -1429,14 +1429,14 @@ String *Item_func_database::val_str(String *str)
str->length(0); str->length(0);
else else
str->copy((const char*) thd->db,(uint) strlen(thd->db), str->copy((const char*) thd->db,(uint) strlen(thd->db),
system_charset_info, thd->variables.thd_charset); system_charset_info, default_charset());
return str; return str;
} }
String *Item_func_user::val_str(String *str) String *Item_func_user::val_str(String *str)
{ {
THD *thd=current_thd; THD *thd=current_thd;
CHARSET_INFO *cs=thd->variables.thd_charset; CHARSET_INFO *cs= default_charset();
const char *host=thd->host ? thd->host : thd->ip ? thd->ip : ""; const char *host=thd->host ? thd->host : thd->ip ? thd->ip : "";
uint32 res_length=(strlen(thd->user)+strlen(host)+10) * cs->mbmaxlen; uint32 res_length=(strlen(thd->user)+strlen(host)+10) * cs->mbmaxlen;
...@@ -1543,7 +1543,7 @@ String *Item_func_format::val_str(String *str) ...@@ -1543,7 +1543,7 @@ String *Item_func_format::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 */
dec= decimals ? decimals+1 : 0; dec= decimals ? decimals+1 : 0;
str->set(nr,decimals,thd_charset()); str->set(nr,decimals,default_charset());
str_length=str->length(); str_length=str->length();
if (nr < 0) if (nr < 0)
str_length--; // Don't count sign str_length--; // Don't count sign
...@@ -2007,7 +2007,7 @@ String *Item_func_conv::val_str(String *str) ...@@ -2007,7 +2007,7 @@ String *Item_func_conv::val_str(String *str)
else else
dec= (longlong) my_strntoull(res->charset(),res->ptr(),res->length(),from_base,&endptr,&err); dec= (longlong) my_strntoull(res->charset(),res->ptr(),res->length(),from_base,&endptr,&err);
ptr= longlong2str(dec,ans,to_base); ptr= longlong2str(dec,ans,to_base);
if (str->copy(ans,(uint32) (ptr-ans), thd_charset())) if (str->copy(ans,(uint32) (ptr-ans), default_charset()))
return &empty_string; return &empty_string;
return str; return str;
} }
...@@ -2242,7 +2242,7 @@ String *Item_func_charset::val_str(String *str) ...@@ -2242,7 +2242,7 @@ String *Item_func_charset::val_str(String *str)
if ((null_value=(args[0]->null_value || !res->charset()))) if ((null_value=(args[0]->null_value || !res->charset())))
return 0; return 0;
str->copy(res->charset()->csname,strlen(res->charset()->csname), str->copy(res->charset()->csname,strlen(res->charset()->csname),
&my_charset_latin1, thd_charset()); &my_charset_latin1, default_charset());
return str; return str;
} }
...@@ -2253,7 +2253,7 @@ String *Item_func_collation::val_str(String *str) ...@@ -2253,7 +2253,7 @@ String *Item_func_collation::val_str(String *str)
if ((null_value=(args[0]->null_value || !res->charset()))) if ((null_value=(args[0]->null_value || !res->charset())))
return 0; return 0;
str->copy(res->charset()->name,strlen(res->charset()->name), str->copy(res->charset()->name,strlen(res->charset()->name),
&my_charset_latin1, thd_charset()); &my_charset_latin1, default_charset());
return str; return str;
} }
......
...@@ -333,8 +333,8 @@ public: ...@@ -333,8 +333,8 @@ public:
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec() void fix_length_and_dec()
{ {
max_length= MAX_FIELD_NAME * thd_charset()->mbmaxlen; max_length= MAX_FIELD_NAME * default_charset()->mbmaxlen;
set_charset(thd_charset()); set_charset(default_charset());
} }
const char *func_name() const { return "database"; } const char *func_name() const { return "database"; }
}; };
...@@ -346,8 +346,8 @@ public: ...@@ -346,8 +346,8 @@ public:
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec() void fix_length_and_dec()
{ {
max_length= (USERNAME_LENGTH+HOSTNAME_LENGTH+1)*thd_charset()->mbmaxlen; max_length= (USERNAME_LENGTH+HOSTNAME_LENGTH+1)*default_charset()->mbmaxlen;
set_charset(thd_charset()); set_charset(default_charset());
} }
const char *func_name() const { return "user"; } const char *func_name() const { return "user"; }
}; };
...@@ -612,7 +612,7 @@ public: ...@@ -612,7 +612,7 @@ public:
void fix_length_and_dec() void fix_length_and_dec()
{ {
max_length=40; // should be enough max_length=40; // should be enough
set_charset(thd_charset()); set_charset(default_charset());
}; };
}; };
...@@ -625,7 +625,7 @@ public: ...@@ -625,7 +625,7 @@ public:
void fix_length_and_dec() void fix_length_and_dec()
{ {
max_length=40; // should be enough max_length=40; // should be enough
set_charset(thd_charset()); set_charset(default_charset());
}; };
}; };
......
...@@ -372,7 +372,7 @@ String *Item_exists_subselect::val_str(String *str) ...@@ -372,7 +372,7 @@ String *Item_exists_subselect::val_str(String *str)
reset(); reset();
return 0; return 0;
} }
str->set(value,thd_charset()); str->set(value,default_charset());
return str; return str;
} }
...@@ -415,7 +415,7 @@ String *Item_in_subselect::val_str(String *str) ...@@ -415,7 +415,7 @@ String *Item_in_subselect::val_str(String *str)
null_value= 1; null_value= 1;
return 0; return 0;
} }
str->set(value,thd_charset()); str->set(value,default_charset());
return str; return str;
} }
......
...@@ -124,7 +124,7 @@ Item_sum_num::val_str(String *str) ...@@ -124,7 +124,7 @@ Item_sum_num::val_str(String *str)
double nr=val(); double nr=val();
if (null_value) if (null_value)
return 0; return 0;
str->set(nr,decimals,thd_charset()); str->set(nr,decimals,default_charset());
return str; return str;
} }
...@@ -135,7 +135,7 @@ Item_sum_int::val_str(String *str) ...@@ -135,7 +135,7 @@ Item_sum_int::val_str(String *str)
longlong nr=val_int(); longlong nr=val_int();
if (null_value) if (null_value)
return 0; return 0;
str->set(nr,thd_charset()); str->set(nr,default_charset());
return str; return str;
} }
...@@ -416,13 +416,13 @@ Item_sum_hybrid::val_str(String *str) ...@@ -416,13 +416,13 @@ Item_sum_hybrid::val_str(String *str)
case STRING_RESULT: case STRING_RESULT:
return &value; return &value;
case REAL_RESULT: case REAL_RESULT:
str->set(sum,decimals,thd_charset()); str->set(sum,decimals,default_charset());
break; break;
case INT_RESULT: case INT_RESULT:
if (unsigned_flag) if (unsigned_flag)
str->set((ulonglong) sum_int,thd_charset()); str->set((ulonglong) sum_int,default_charset());
else else
str->set((longlong) sum_int,thd_charset()); str->set((longlong) sum_int,default_charset());
break; break;
case ROW_RESULT: case ROW_RESULT:
default: default:
...@@ -879,7 +879,7 @@ String *Item_avg_field::val_str(String *str) ...@@ -879,7 +879,7 @@ String *Item_avg_field::val_str(String *str)
double nr=Item_avg_field::val(); double nr=Item_avg_field::val();
if (null_value) if (null_value)
return 0; return 0;
str->set(nr,decimals,thd_charset()); str->set(nr,decimals,default_charset());
return str; return str;
} }
...@@ -927,7 +927,7 @@ String *Item_variance_field::val_str(String *str) ...@@ -927,7 +927,7 @@ String *Item_variance_field::val_str(String *str)
double nr=val(); double nr=val();
if (null_value) if (null_value)
return 0; return 0;
str->set(nr,decimals,thd_charset()); str->set(nr,decimals,default_charset());
return str; return str;
} }
...@@ -1281,7 +1281,7 @@ String *Item_sum_udf_float::val_str(String *str) ...@@ -1281,7 +1281,7 @@ String *Item_sum_udf_float::val_str(String *str)
if (null_value) if (null_value)
return 0; /* purecov: inspected */ return 0; /* purecov: inspected */
else else
str->set(nr,decimals,thd_charset()); str->set(nr,decimals,default_charset());
return str; return str;
} }
...@@ -1300,7 +1300,7 @@ String *Item_sum_udf_int::val_str(String *str) ...@@ -1300,7 +1300,7 @@ String *Item_sum_udf_int::val_str(String *str)
if (null_value) if (null_value)
return 0; return 0;
else else
str->set(nr,thd_charset()); str->set(nr,default_charset());
return str; return str;
} }
......
...@@ -162,7 +162,7 @@ String* Item_func_monthname::val_str(String* str) ...@@ -162,7 +162,7 @@ String* Item_func_monthname::val_str(String* str)
null_value=0; null_value=0;
String *m=&month_names[month-1]; String *m=&month_names[month-1];
str->copy(m->ptr(), m->length(), m->charset(), thd_charset()); str->copy(m->ptr(), m->length(), m->charset(), default_charset());
return str; return str;
} }
...@@ -252,7 +252,7 @@ String* Item_func_dayname::val_str(String* str) ...@@ -252,7 +252,7 @@ String* Item_func_dayname::val_str(String* str)
return (String*) 0; return (String*) 0;
String *d=&day_names[weekday]; String *d=&day_names[weekday];
str->copy(d->ptr(), d->length(), d->charset(), thd_charset()); str->copy(d->ptr(), d->length(), d->charset(), default_charset());
return str; return str;
} }
...@@ -416,7 +416,7 @@ String *Item_date::val_str(String *str) ...@@ -416,7 +416,7 @@ String *Item_date::val_str(String *str)
return (String*) 0; return (String*) 0;
if (!value) // zero daynr if (!value) // zero daynr
{ {
str->copy("0000-00-00",10,&my_charset_latin1,thd_charset()); str->copy("0000-00-00",10,&my_charset_latin1,default_charset());
return str; return str;
} }
...@@ -425,7 +425,7 @@ String *Item_date::val_str(String *str) ...@@ -425,7 +425,7 @@ String *Item_date::val_str(String *str)
(int) (value/10000L) % 10000, (int) (value/10000L) % 10000,
(int) (value/100)%100, (int) (value/100)%100,
(int) (value%100)); (int) (value%100));
str->copy(tmpbuff,10,&my_charset_latin1,thd_charset()); str->copy(tmpbuff,10,&my_charset_latin1,default_charset());
return str; return str;
} }
...@@ -463,9 +463,9 @@ void Item_func_curdate::fix_length_and_dec() ...@@ -463,9 +463,9 @@ void Item_func_curdate::fix_length_and_dec()
struct tm tm_tmp,*start; struct tm tm_tmp,*start;
time_t query_start=current_thd->query_start(); time_t query_start=current_thd->query_start();
set_charset(thd_charset()); set_charset(default_charset());
decimals=0; decimals=0;
max_length=10*thd_charset()->mbmaxlen; max_length=10*default_charset()->mbmaxlen;
localtime_r(&query_start,&tm_tmp); localtime_r(&query_start,&tm_tmp);
start=&tm_tmp; start=&tm_tmp;
value=(longlong) ((ulong) ((uint) start->tm_year+1900)*10000L+ value=(longlong) ((ulong) ((uint) start->tm_year+1900)*10000L+
...@@ -492,7 +492,7 @@ bool Item_func_curdate::get_date(TIME *res, ...@@ -492,7 +492,7 @@ bool Item_func_curdate::get_date(TIME *res,
String *Item_func_curtime::val_str(String *str) String *Item_func_curtime::val_str(String *str)
{ {
str_value.set(buff,buff_length,thd_charset()); str_value.set(buff,buff_length,default_charset());
return &str_value; return &str_value;
} }
...@@ -500,7 +500,7 @@ void Item_func_curtime::fix_length_and_dec() ...@@ -500,7 +500,7 @@ void Item_func_curtime::fix_length_and_dec()
{ {
struct tm tm_tmp,*start; struct tm tm_tmp,*start;
time_t query_start=current_thd->query_start(); time_t query_start=current_thd->query_start();
CHARSET_INFO *cs=thd_charset(); CHARSET_INFO *cs=default_charset();
decimals=0; decimals=0;
max_length=8*cs->mbmaxlen; max_length=8*cs->mbmaxlen;
...@@ -520,7 +520,7 @@ void Item_func_curtime::fix_length_and_dec() ...@@ -520,7 +520,7 @@ void Item_func_curtime::fix_length_and_dec()
String *Item_func_now::val_str(String *str) String *Item_func_now::val_str(String *str)
{ {
str_value.set(buff,buff_length,thd_charset()); str_value.set(buff,buff_length,default_charset());
return &str_value; return &str_value;
} }
...@@ -595,7 +595,7 @@ String *Item_func_sec_to_time::val_str(String *str) ...@@ -595,7 +595,7 @@ String *Item_func_sec_to_time::val_str(String *str)
uint sec= (uint) ((ulonglong) seconds % 3600); uint sec= (uint) ((ulonglong) seconds % 3600);
length= my_sprintf(buff,(buff,"%s%02lu:%02u:%02u",sign,(long) (seconds/3600), length= my_sprintf(buff,(buff,"%s%02lu:%02u:%02u",sign,(long) (seconds/3600),
sec/60, sec % 60)); sec/60, sec % 60));
str->copy(buff, length, &my_charset_latin1, thd_charset()); str->copy(buff, length, &my_charset_latin1, default_charset());
return str; return str;
} }
...@@ -940,7 +940,7 @@ String *Item_func_from_unixtime::val_str(String *str) ...@@ -940,7 +940,7 @@ String *Item_func_from_unixtime::val_str(String *str)
struct tm tm_tmp,*start; struct tm tm_tmp,*start;
time_t tmp=(time_t) args[0]->val_int(); time_t tmp=(time_t) args[0]->val_int();
uint32 l; uint32 l;
CHARSET_INFO *cs=thd_charset(); CHARSET_INFO *cs=default_charset();
if ((null_value=args[0]->null_value)) if ((null_value=args[0]->null_value))
return 0; return 0;
...@@ -1003,9 +1003,9 @@ bool Item_func_from_unixtime::get_date(TIME *ltime, ...@@ -1003,9 +1003,9 @@ bool Item_func_from_unixtime::get_date(TIME *ltime,
void Item_date_add_interval::fix_length_and_dec() void Item_date_add_interval::fix_length_and_dec()
{ {
enum_field_types arg0_field_type; enum_field_types arg0_field_type;
set_charset(thd_charset()); set_charset(default_charset());
maybe_null=1; maybe_null=1;
max_length=19*thd_charset()->mbmaxlen; max_length=19*default_charset()->mbmaxlen;
value.alloc(32); value.alloc(32);
/* /*
...@@ -1124,7 +1124,7 @@ bool Item_date_add_interval::get_date(TIME *ltime, bool fuzzy_date) ...@@ -1124,7 +1124,7 @@ bool Item_date_add_interval::get_date(TIME *ltime, bool fuzzy_date)
String *Item_date_add_interval::val_str(String *str) String *Item_date_add_interval::val_str(String *str)
{ {
TIME ltime; TIME ltime;
CHARSET_INFO *cs=thd_charset(); CHARSET_INFO *cs=default_charset();
uint32 l; uint32 l;
if (Item_date_add_interval::get_date(&ltime,0)) if (Item_date_add_interval::get_date(&ltime,0))
......
...@@ -29,7 +29,7 @@ public: ...@@ -29,7 +29,7 @@ public:
const char *func_name() const { return "period_add"; } const char *func_name() const { return "period_add"; }
void fix_length_and_dec() void fix_length_and_dec()
{ {
max_length=6*thd_charset()->mbmaxlen; max_length=6*default_charset()->mbmaxlen;
} }
}; };
...@@ -43,7 +43,7 @@ public: ...@@ -43,7 +43,7 @@ public:
void fix_length_and_dec() void fix_length_and_dec()
{ {
decimals=0; decimals=0;
max_length=6*thd_charset()->mbmaxlen; max_length=6*default_charset()->mbmaxlen;
} }
}; };
...@@ -57,7 +57,7 @@ public: ...@@ -57,7 +57,7 @@ public:
void fix_length_and_dec() void fix_length_and_dec()
{ {
decimals=0; decimals=0;
max_length=6*thd_charset()->mbmaxlen; max_length=6*default_charset()->mbmaxlen;
maybe_null=1; maybe_null=1;
} }
}; };
...@@ -72,7 +72,7 @@ public: ...@@ -72,7 +72,7 @@ public:
void fix_length_and_dec() void fix_length_and_dec()
{ {
decimals=0; decimals=0;
max_length=2*thd_charset()->mbmaxlen; max_length=2*default_charset()->mbmaxlen;
maybe_null=1; maybe_null=1;
} }
}; };
...@@ -86,16 +86,16 @@ public: ...@@ -86,16 +86,16 @@ public:
double val() { return (double) Item_func_month::val_int(); } double val() { return (double) Item_func_month::val_int(); }
String *val_str(String *str) String *val_str(String *str)
{ {
str->set(val_int(), thd_charset()); str->set(val_int(), default_charset());
return null_value ? 0 : str; return null_value ? 0 : str;
} }
const char *func_name() const { return "month"; } const char *func_name() const { return "month"; }
enum Item_result result_type () const { return INT_RESULT; } enum Item_result result_type () const { return INT_RESULT; }
void fix_length_and_dec() void fix_length_and_dec()
{ {
set_charset(thd_charset()); set_charset(default_charset());
decimals=0; decimals=0;
max_length=2*thd_charset()->mbmaxlen; max_length=2*default_charset()->mbmaxlen;
maybe_null=1; maybe_null=1;
} }
}; };
...@@ -110,9 +110,9 @@ public: ...@@ -110,9 +110,9 @@ public:
enum Item_result result_type () const { return STRING_RESULT; } enum Item_result result_type () const { return STRING_RESULT; }
void fix_length_and_dec() void fix_length_and_dec()
{ {
set_charset(thd_charset()); set_charset(default_charset());
decimals=0; decimals=0;
max_length=10*thd_charset()->mbmaxlen; max_length=10*default_charset()->mbmaxlen;
maybe_null=1; maybe_null=1;
} }
}; };
...@@ -127,7 +127,7 @@ public: ...@@ -127,7 +127,7 @@ public:
void fix_length_and_dec() void fix_length_and_dec()
{ {
decimals=0; decimals=0;
max_length=3*thd_charset()->mbmaxlen; max_length=3*default_charset()->mbmaxlen;
maybe_null=1; maybe_null=1;
} }
}; };
...@@ -142,7 +142,7 @@ public: ...@@ -142,7 +142,7 @@ public:
void fix_length_and_dec() void fix_length_and_dec()
{ {
decimals=0; decimals=0;
max_length=2*thd_charset()->mbmaxlen; max_length=2*default_charset()->mbmaxlen;
maybe_null=1; maybe_null=1;
} }
}; };
...@@ -157,7 +157,7 @@ public: ...@@ -157,7 +157,7 @@ public:
void fix_length_and_dec() void fix_length_and_dec()
{ {
decimals=0; decimals=0;
max_length=2*thd_charset()->mbmaxlen; max_length=2*default_charset()->mbmaxlen;
maybe_null=1; maybe_null=1;
} }
}; };
...@@ -172,7 +172,7 @@ public: ...@@ -172,7 +172,7 @@ public:
void fix_length_and_dec() void fix_length_and_dec()
{ {
decimals=0; decimals=0;
max_length=1*thd_charset()->mbmaxlen; max_length=1*default_charset()->mbmaxlen;
maybe_null=1; maybe_null=1;
} }
}; };
...@@ -187,7 +187,7 @@ public: ...@@ -187,7 +187,7 @@ public:
void fix_length_and_dec() void fix_length_and_dec()
{ {
decimals=0; decimals=0;
max_length=2*thd_charset()->mbmaxlen; max_length=2*default_charset()->mbmaxlen;
maybe_null=1; maybe_null=1;
} }
}; };
...@@ -202,7 +202,7 @@ public: ...@@ -202,7 +202,7 @@ public:
void fix_length_and_dec() void fix_length_and_dec()
{ {
decimals=0; decimals=0;
max_length=2*thd_charset()->mbmaxlen; max_length=2*default_charset()->mbmaxlen;
maybe_null=1; maybe_null=1;
} }
}; };
...@@ -216,7 +216,7 @@ public: ...@@ -216,7 +216,7 @@ public:
void fix_length_and_dec() void fix_length_and_dec()
{ {
decimals=0; decimals=0;
max_length=6*thd_charset()->mbmaxlen; max_length=6*default_charset()->mbmaxlen;
maybe_null=1; maybe_null=1;
} }
}; };
...@@ -231,7 +231,7 @@ public: ...@@ -231,7 +231,7 @@ public:
void fix_length_and_dec() void fix_length_and_dec()
{ {
decimals=0; decimals=0;
max_length=4*thd_charset()->mbmaxlen; max_length=4*default_charset()->mbmaxlen;
maybe_null=1; maybe_null=1;
} }
}; };
...@@ -247,16 +247,16 @@ public: ...@@ -247,16 +247,16 @@ public:
double val() { return (double) val_int(); } double val() { return (double) val_int(); }
String *val_str(String *str) String *val_str(String *str)
{ {
str->set(val_int(), thd_charset()); str->set(val_int(), default_charset());
return null_value ? 0 : str; return null_value ? 0 : str;
} }
const char *func_name() const { return "weekday"; } const char *func_name() const { return "weekday"; }
enum Item_result result_type () const { return INT_RESULT; } enum Item_result result_type () const { return INT_RESULT; }
void fix_length_and_dec() void fix_length_and_dec()
{ {
set_charset(thd_charset()); set_charset(default_charset());
decimals=0; decimals=0;
max_length=1*thd_charset()->mbmaxlen; max_length=1*default_charset()->mbmaxlen;
maybe_null=1; maybe_null=1;
} }
}; };
...@@ -270,9 +270,9 @@ class Item_func_dayname :public Item_func_weekday ...@@ -270,9 +270,9 @@ class Item_func_dayname :public Item_func_weekday
enum Item_result result_type () const { return STRING_RESULT; } enum Item_result result_type () const { return STRING_RESULT; }
void fix_length_and_dec() void fix_length_and_dec()
{ {
set_charset(thd_charset()); set_charset(default_charset());
decimals=0; decimals=0;
max_length=9*thd_charset()->mbmaxlen; max_length=9*default_charset()->mbmaxlen;
maybe_null=1; maybe_null=1;
} }
}; };
...@@ -289,7 +289,7 @@ public: ...@@ -289,7 +289,7 @@ public:
void fix_length_and_dec() void fix_length_and_dec()
{ {
decimals=0; decimals=0;
max_length=10*thd_charset()->mbmaxlen; max_length=10*default_charset()->mbmaxlen;
} }
}; };
...@@ -303,7 +303,7 @@ public: ...@@ -303,7 +303,7 @@ public:
void fix_length_and_dec() void fix_length_and_dec()
{ {
decimals=0; decimals=0;
max_length=10*thd_charset()->mbmaxlen; max_length=10*default_charset()->mbmaxlen;
} }
}; };
...@@ -322,15 +322,15 @@ public: ...@@ -322,15 +322,15 @@ public:
const char *func_name() const { return "date"; } const char *func_name() const { return "date"; }
void fix_length_and_dec() void fix_length_and_dec()
{ {
set_charset(thd_charset()); set_charset(default_charset());
decimals=0; decimals=0;
max_length=10*thd_charset()->mbmaxlen; max_length=10*default_charset()->mbmaxlen;
} }
int save_in_field(Field *to, bool no_conversions); int save_in_field(Field *to, bool no_conversions);
Field *tmp_table_field() { return result_field; } Field *tmp_table_field() { return result_field; }
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
return (new Field_date(maybe_null, name, t_arg, thd_charset())); return (new Field_date(maybe_null, name, t_arg, default_charset()));
} }
}; };
...@@ -345,7 +345,7 @@ public: ...@@ -345,7 +345,7 @@ public:
Field *tmp_table_field() { return result_field; } Field *tmp_table_field() { return result_field; }
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
return (new Field_datetime(maybe_null, name, t_arg, thd_charset())); return (new Field_datetime(maybe_null, name, t_arg, default_charset()));
} }
}; };
...@@ -368,7 +368,7 @@ public: ...@@ -368,7 +368,7 @@ public:
Field *tmp_table_field() { return result_field; } Field *tmp_table_field() { return result_field; }
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
return (new Field_time(maybe_null, name, t_arg, thd_charset())); return (new Field_time(maybe_null, name, t_arg, default_charset()));
} }
}; };
...@@ -440,9 +440,9 @@ class Item_func_from_unixtime :public Item_date_func ...@@ -440,9 +440,9 @@ class Item_func_from_unixtime :public Item_date_func
const char *func_name() const { return "from_unixtime"; } const char *func_name() const { return "from_unixtime"; }
void fix_length_and_dec() void fix_length_and_dec()
{ {
set_charset(thd_charset()); set_charset(default_charset());
decimals=0; decimals=0;
max_length=19*thd_charset()->mbmaxlen; max_length=19*default_charset()->mbmaxlen;
} }
bool get_date(TIME *res,bool fuzzy_date); bool get_date(TIME *res,bool fuzzy_date);
}; };
...@@ -457,16 +457,16 @@ public: ...@@ -457,16 +457,16 @@ public:
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec() void fix_length_and_dec()
{ {
set_charset(thd_charset()); set_charset(default_charset());
maybe_null=1; maybe_null=1;
max_length=13*thd_charset()->mbmaxlen; max_length=13*default_charset()->mbmaxlen;
} }
enum_field_types field_type() const { return MYSQL_TYPE_TIME; } enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
const char *func_name() const { return "sec_to_time"; } const char *func_name() const { return "sec_to_time"; }
Field *tmp_table_field() { return result_field; } Field *tmp_table_field() { return result_field; }
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
return (new Field_time(maybe_null, name, t_arg, thd_charset())); return (new Field_time(maybe_null, name, t_arg, default_charset()));
} }
}; };
...@@ -532,7 +532,7 @@ public: ...@@ -532,7 +532,7 @@ public:
} }
void fix_length_and_dec() void fix_length_and_dec()
{ {
set_charset(thd_charset()); set_charset(default_charset());
max_length=args[0]->max_length; max_length=args[0]->max_length;
} }
void print(String *str); void print(String *str);
...@@ -545,7 +545,7 @@ public: ...@@ -545,7 +545,7 @@ public:
Item_char_typecast(Item *a) :Item_typecast(a) {} Item_char_typecast(Item *a) :Item_typecast(a) {}
void fix_length_and_dec() void fix_length_and_dec()
{ {
set_charset(thd_charset()); set_charset(default_charset());
max_length=args[0]->max_length; max_length=args[0]->max_length;
} }
}; };
...@@ -560,7 +560,7 @@ public: ...@@ -560,7 +560,7 @@ public:
Field *tmp_table_field() { return result_field; } Field *tmp_table_field() { return result_field; }
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
return (new Field_date(maybe_null, name, t_arg, thd_charset())); return (new Field_date(maybe_null, name, t_arg, default_charset()));
} }
}; };
...@@ -574,7 +574,7 @@ public: ...@@ -574,7 +574,7 @@ public:
Field *tmp_table_field() { return result_field; } Field *tmp_table_field() { return result_field; }
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
return (new Field_time(maybe_null, name, t_arg, thd_charset())); return (new Field_time(maybe_null, name, t_arg, default_charset()));
} }
}; };
...@@ -588,6 +588,6 @@ public: ...@@ -588,6 +588,6 @@ public:
Field *tmp_table_field() { return result_field; } Field *tmp_table_field() { return result_field; }
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
return (new Field_datetime(maybe_null, name, t_arg, thd_charset())); return (new Field_datetime(maybe_null, name, t_arg, default_charset()));
} }
}; };
...@@ -38,7 +38,7 @@ public: ...@@ -38,7 +38,7 @@ public:
virtual void set(const char *str,uint length,CHARSET_INFO *cs)=0; virtual void set(const char *str,uint length,CHARSET_INFO *cs)=0;
virtual void set(longlong nr)=0; virtual void set(longlong nr)=0;
virtual enum_field_types field_type() const=0; virtual enum_field_types field_type() const=0;
void set(const char *str) { set(str,(uint) strlen(str), thd_charset()); } void set(const char *str) { set(str,(uint) strlen(str), default_charset()); }
void make_field(Send_field *tmp_field) void make_field(Send_field *tmp_field)
{ {
init_make_field(tmp_field,field_type()); init_make_field(tmp_field,field_type());
...@@ -62,7 +62,7 @@ public: ...@@ -62,7 +62,7 @@ public:
{ int err; value=my_strntod(cs,(char*) str,length,(char**)0,&err); } { int err; value=my_strntod(cs,(char*) str,length,(char**)0,&err); }
double val() { return value; } double val() { return value; }
longlong val_int() { return (longlong) value; } longlong val_int() { return (longlong) value; }
String *val_str(String *s) { s->set(value,decimals,thd_charset()); return s; } String *val_str(String *s) { s->set(value,decimals,default_charset()); return s; }
unsigned int size_of() { return sizeof(*this);} unsigned int size_of() { return sizeof(*this);}
}; };
...@@ -80,7 +80,7 @@ public: ...@@ -80,7 +80,7 @@ public:
{ int err; value=my_strntoll(cs,str,length,10,NULL,&err); } { int err; value=my_strntoll(cs,str,length,10,NULL,&err); }
double val() { return (double) value; } double val() { return (double) value; }
longlong val_int() { return value; } longlong val_int() { return value; }
String *val_str(String *s) { s->set(value, thd_charset()); return s; } String *val_str(String *s) { s->set(value, default_charset()); return s; }
unsigned int size_of() { return sizeof(*this);} unsigned int size_of() { return sizeof(*this);}
}; };
...@@ -92,8 +92,8 @@ public: ...@@ -92,8 +92,8 @@ public:
{ this->max_length=length; } { this->max_length=length; }
enum Item_result result_type () const { return STRING_RESULT; } enum Item_result result_type () const { return STRING_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_STRING; } enum_field_types field_type() const { return MYSQL_TYPE_STRING; }
void set(double nr) { str_value.set(nr, 2, thd_charset()); } void set(double nr) { str_value.set(nr, 2, default_charset()); }
void set(longlong nr) { str_value.set(nr, thd_charset()); } void set(longlong nr) { str_value.set(nr, default_charset()); }
void set(const char *str, uint length, CHARSET_INFO *cs) void set(const char *str, uint length, CHARSET_INFO *cs)
{ str_value.copy(str,length,cs); } { str_value.copy(str,length,cs); }
double val() double val()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment