Commit bf56f26c authored by unknown's avatar unknown

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 4c71ecf9
......@@ -163,9 +163,9 @@ bool Item::get_time(TIME *ltime)
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)
......@@ -303,7 +303,7 @@ Item *Item_field::get_tmp_table_item(THD *thd)
String *Item_int::val_str(String *str)
{
str->set(value, thd_charset());
str->set(value, default_charset());
return str;
}
......@@ -311,7 +311,7 @@ void Item_int::print(String *str)
{
if (!name)
{
str_value.set(value, thd_charset());
str_value.set(value, default_charset());
name=str_value.c_ptr();
}
str->append(name);
......@@ -319,7 +319,7 @@ void Item_int::print(String *str)
String *Item_uint::val_str(String *str)
{
str->set((ulonglong) value, thd_charset());
str->set((ulonglong) value, default_charset());
return str;
}
......@@ -327,7 +327,7 @@ void Item_uint::print(String *str)
{
if (!name)
{
str_value.set((ulonglong) value, thd_charset());
str_value.set((ulonglong) value, default_charset());
name=str_value.c_ptr();
}
str->append(name);
......@@ -336,7 +336,7 @@ void Item_uint::print(String *str)
String *Item_real::val_str(String *str)
{
str->set(value,decimals,thd_charset());
str->set(value,decimals,default_charset());
return str;
}
......@@ -377,7 +377,7 @@ void Item_param::set_double(double value)
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;
}
......@@ -474,10 +474,10 @@ String *Item_param::val_str(String* str)
{
switch (item_result_type) {
case INT_RESULT:
str->set(int_value, thd_charset());
str->set(int_value, default_charset());
return str;
case REAL_RESULT:
str->set(real_value, 2, thd_charset());
str->set(real_value, 2, default_charset());
return str;
default:
return (String*) &str_value;
......
......@@ -110,7 +110,7 @@ class Item {
virtual bool binary() const
{ 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(); };
void set_charset(CHARSET_INFO *cs) { str_value.set_charset(cs); }
virtual void set_outer_resolving() {}
......@@ -773,7 +773,7 @@ class Item_cache_int: public Item_cache
}
double val() { return (double) 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; }
};
......@@ -792,7 +792,7 @@ class Item_cache_real: public Item_cache
longlong val_int() { return (longlong) (value+(value > 0 ? 0.5 : -0.5)); }
String* val_str(String *str)
{
str->set(value, decimals, thd_charset());
str->set(value, decimals, default_charset());
return str;
}
enum Item_result result_type() const { return REAL_RESULT; }
......
......@@ -873,7 +873,7 @@ String *Item_func_case::val_str(String *str)
longlong Item_func_case::val_int()
{
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);
longlong res;
......@@ -890,7 +890,7 @@ longlong Item_func_case::val_int()
double Item_func_case::val()
{
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);
double res;
......
......@@ -286,7 +286,7 @@ String *Item_real_func::val_str(String *str)
if (null_value)
return 0; /* purecov: inspected */
else
str->set(nr,decimals,thd_charset());
str->set(nr,decimals,default_charset());
return str;
}
......@@ -299,9 +299,9 @@ String *Item_num_func::val_str(String *str)
if (null_value)
return 0; /* purecov: inspected */
else if (!unsigned_flag)
str->set(nr,thd_charset());
str->set(nr,default_charset());
else
str->set((ulonglong) nr,thd_charset());
str->set((ulonglong) nr,default_charset());
}
else
{
......@@ -309,7 +309,7 @@ String *Item_num_func::val_str(String *str)
if (null_value)
return 0; /* purecov: inspected */
else
str->set(nr,decimals,thd_charset());
str->set(nr,decimals,default_charset());
}
return str;
}
......@@ -336,9 +336,9 @@ String *Item_int_func::val_str(String *str)
if (null_value)
return 0;
else if (!unsigned_flag)
str->set(nr,thd_charset());
str->set(nr,default_charset());
else
str->set((ulonglong) nr,thd_charset());
str->set((ulonglong) nr,default_charset());
return str;
}
......@@ -365,9 +365,9 @@ String *Item_num_op::val_str(String *str)
if (null_value)
return 0; /* purecov: inspected */
else if (!unsigned_flag)
str->set(nr,thd_charset());
str->set(nr,default_charset());
else
str->set((ulonglong) nr,thd_charset());
str->set((ulonglong) nr,default_charset());
}
else
{
......@@ -375,7 +375,7 @@ String *Item_num_op::val_str(String *str)
if (null_value)
return 0; /* purecov: inspected */
else
str->set(nr,decimals,thd_charset());
str->set(nr,decimals,default_charset());
}
return str;
}
......@@ -890,9 +890,9 @@ String *Item_func_min_max::val_str(String *str)
if (null_value)
return 0;
else if (!unsigned_flag)
str->set(nr,thd_charset());
str->set(nr,default_charset());
else
str->set((ulonglong) nr,thd_charset());
str->set((ulonglong) nr,default_charset());
return str;
}
case REAL_RESULT:
......@@ -901,7 +901,7 @@ String *Item_func_min_max::val_str(String *str)
if (null_value)
return 0; /* purecov: inspected */
else
str->set(nr,decimals,thd_charset());
str->set(nr,decimals,default_charset());
return str;
}
case STRING_RESULT:
......@@ -1563,7 +1563,7 @@ String *Item_func_udf_float::val_str(String *str)
if (null_value)
return 0; /* purecov: inspected */
else
str->set(nr,decimals,thd_charset());
str->set(nr,decimals,default_charset());
return str;
}
......@@ -1584,9 +1584,9 @@ String *Item_func_udf_int::val_str(String *str)
if (null_value)
return 0;
else if (!unsigned_flag)
str->set(nr,thd_charset());
str->set(nr,default_charset());
else
str->set((ulonglong) nr,thd_charset());
str->set((ulonglong) nr,default_charset());
return str;
}
......
......@@ -1429,14 +1429,14 @@ String *Item_func_database::val_str(String *str)
str->length(0);
else
str->copy((const char*) thd->db,(uint) strlen(thd->db),
system_charset_info, thd->variables.thd_charset);
system_charset_info, default_charset());
return str;
}
String *Item_func_user::val_str(String *str)
{
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 : "";
uint32 res_length=(strlen(thd->user)+strlen(host)+10) * cs->mbmaxlen;
......@@ -1543,7 +1543,7 @@ String *Item_func_format::val_str(String *str)
if ((null_value=args[0]->null_value))
return 0; /* purecov: inspected */
dec= decimals ? decimals+1 : 0;
str->set(nr,decimals,thd_charset());
str->set(nr,decimals,default_charset());
str_length=str->length();
if (nr < 0)
str_length--; // Don't count sign
......@@ -2007,7 +2007,7 @@ String *Item_func_conv::val_str(String *str)
else
dec= (longlong) my_strntoull(res->charset(),res->ptr(),res->length(),from_base,&endptr,&err);
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 str;
}
......@@ -2242,7 +2242,7 @@ String *Item_func_charset::val_str(String *str)
if ((null_value=(args[0]->null_value || !res->charset())))
return 0;
str->copy(res->charset()->csname,strlen(res->charset()->csname),
&my_charset_latin1, thd_charset());
&my_charset_latin1, default_charset());
return str;
}
......@@ -2253,7 +2253,7 @@ String *Item_func_collation::val_str(String *str)
if ((null_value=(args[0]->null_value || !res->charset())))
return 0;
str->copy(res->charset()->name,strlen(res->charset()->name),
&my_charset_latin1, thd_charset());
&my_charset_latin1, default_charset());
return str;
}
......
......@@ -333,8 +333,8 @@ class Item_func_database :public Item_str_func
String *val_str(String *);
void fix_length_and_dec()
{
max_length= MAX_FIELD_NAME * thd_charset()->mbmaxlen;
set_charset(thd_charset());
max_length= MAX_FIELD_NAME * default_charset()->mbmaxlen;
set_charset(default_charset());
}
const char *func_name() const { return "database"; }
};
......@@ -346,8 +346,8 @@ class Item_func_user :public Item_str_func
String *val_str(String *);
void fix_length_and_dec()
{
max_length= (USERNAME_LENGTH+HOSTNAME_LENGTH+1)*thd_charset()->mbmaxlen;
set_charset(thd_charset());
max_length= (USERNAME_LENGTH+HOSTNAME_LENGTH+1)*default_charset()->mbmaxlen;
set_charset(default_charset());
}
const char *func_name() const { return "user"; }
};
......@@ -612,7 +612,7 @@ class Item_func_charset :public Item_str_func
void fix_length_and_dec()
{
max_length=40; // should be enough
set_charset(thd_charset());
set_charset(default_charset());
};
};
......@@ -625,7 +625,7 @@ class Item_func_collation :public Item_str_func
void fix_length_and_dec()
{
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)
reset();
return 0;
}
str->set(value,thd_charset());
str->set(value,default_charset());
return str;
}
......@@ -415,7 +415,7 @@ String *Item_in_subselect::val_str(String *str)
null_value= 1;
return 0;
}
str->set(value,thd_charset());
str->set(value,default_charset());
return str;
}
......
......@@ -124,7 +124,7 @@ Item_sum_num::val_str(String *str)
double nr=val();
if (null_value)
return 0;
str->set(nr,decimals,thd_charset());
str->set(nr,decimals,default_charset());
return str;
}
......@@ -135,7 +135,7 @@ Item_sum_int::val_str(String *str)
longlong nr=val_int();
if (null_value)
return 0;
str->set(nr,thd_charset());
str->set(nr,default_charset());
return str;
}
......@@ -416,13 +416,13 @@ Item_sum_hybrid::val_str(String *str)
case STRING_RESULT:
return &value;
case REAL_RESULT:
str->set(sum,decimals,thd_charset());
str->set(sum,decimals,default_charset());
break;
case INT_RESULT:
if (unsigned_flag)
str->set((ulonglong) sum_int,thd_charset());
str->set((ulonglong) sum_int,default_charset());
else
str->set((longlong) sum_int,thd_charset());
str->set((longlong) sum_int,default_charset());
break;
case ROW_RESULT:
default:
......@@ -879,7 +879,7 @@ String *Item_avg_field::val_str(String *str)
double nr=Item_avg_field::val();
if (null_value)
return 0;
str->set(nr,decimals,thd_charset());
str->set(nr,decimals,default_charset());
return str;
}
......@@ -927,7 +927,7 @@ String *Item_variance_field::val_str(String *str)
double nr=val();
if (null_value)
return 0;
str->set(nr,decimals,thd_charset());
str->set(nr,decimals,default_charset());
return str;
}
......@@ -1281,7 +1281,7 @@ String *Item_sum_udf_float::val_str(String *str)
if (null_value)
return 0; /* purecov: inspected */
else
str->set(nr,decimals,thd_charset());
str->set(nr,decimals,default_charset());
return str;
}
......@@ -1300,7 +1300,7 @@ String *Item_sum_udf_int::val_str(String *str)
if (null_value)
return 0;
else
str->set(nr,thd_charset());
str->set(nr,default_charset());
return str;
}
......
......@@ -162,7 +162,7 @@ String* Item_func_monthname::val_str(String* str)
null_value=0;
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;
}
......@@ -252,7 +252,7 @@ String* Item_func_dayname::val_str(String* str)
return (String*) 0;
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;
}
......@@ -416,7 +416,7 @@ String *Item_date::val_str(String *str)
return (String*) 0;
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;
}
......@@ -425,7 +425,7 @@ String *Item_date::val_str(String *str)
(int) (value/10000L) % 10000,
(int) (value/100)%100,
(int) (value%100));
str->copy(tmpbuff,10,&my_charset_latin1,thd_charset());
str->copy(tmpbuff,10,&my_charset_latin1,default_charset());
return str;
}
......@@ -463,9 +463,9 @@ void Item_func_curdate::fix_length_and_dec()
struct tm tm_tmp,*start;
time_t query_start=current_thd->query_start();
set_charset(thd_charset());
set_charset(default_charset());
decimals=0;
max_length=10*thd_charset()->mbmaxlen;
max_length=10*default_charset()->mbmaxlen;
localtime_r(&query_start,&tm_tmp);
start=&tm_tmp;
value=(longlong) ((ulong) ((uint) start->tm_year+1900)*10000L+
......@@ -492,7 +492,7 @@ bool Item_func_curdate::get_date(TIME *res,
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;
}
......@@ -500,7 +500,7 @@ void Item_func_curtime::fix_length_and_dec()
{
struct tm tm_tmp,*start;
time_t query_start=current_thd->query_start();
CHARSET_INFO *cs=thd_charset();
CHARSET_INFO *cs=default_charset();
decimals=0;
max_length=8*cs->mbmaxlen;
......@@ -520,7 +520,7 @@ void Item_func_curtime::fix_length_and_dec()
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;
}
......@@ -595,7 +595,7 @@ String *Item_func_sec_to_time::val_str(String *str)
uint sec= (uint) ((ulonglong) seconds % 3600);
length= my_sprintf(buff,(buff,"%s%02lu:%02u:%02u",sign,(long) (seconds/3600),
sec/60, sec % 60));
str->copy(buff, length, &my_charset_latin1, thd_charset());
str->copy(buff, length, &my_charset_latin1, default_charset());
return str;
}
......@@ -940,7 +940,7 @@ String *Item_func_from_unixtime::val_str(String *str)
struct tm tm_tmp,*start;
time_t tmp=(time_t) args[0]->val_int();
uint32 l;
CHARSET_INFO *cs=thd_charset();
CHARSET_INFO *cs=default_charset();
if ((null_value=args[0]->null_value))
return 0;
......@@ -1003,9 +1003,9 @@ bool Item_func_from_unixtime::get_date(TIME *ltime,
void Item_date_add_interval::fix_length_and_dec()
{
enum_field_types arg0_field_type;
set_charset(thd_charset());
set_charset(default_charset());
maybe_null=1;
max_length=19*thd_charset()->mbmaxlen;
max_length=19*default_charset()->mbmaxlen;
value.alloc(32);
/*
......@@ -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)
{
TIME ltime;
CHARSET_INFO *cs=thd_charset();
CHARSET_INFO *cs=default_charset();
uint32 l;
if (Item_date_add_interval::get_date(&ltime,0))
......
......@@ -29,7 +29,7 @@ class Item_func_period_add :public Item_int_func
const char *func_name() const { return "period_add"; }
void fix_length_and_dec()
{
max_length=6*thd_charset()->mbmaxlen;
max_length=6*default_charset()->mbmaxlen;
}
};
......@@ -43,7 +43,7 @@ class Item_func_period_diff :public Item_int_func
void fix_length_and_dec()
{
decimals=0;
max_length=6*thd_charset()->mbmaxlen;
max_length=6*default_charset()->mbmaxlen;
}
};
......@@ -57,7 +57,7 @@ class Item_func_to_days :public Item_int_func
void fix_length_and_dec()
{
decimals=0;
max_length=6*thd_charset()->mbmaxlen;
max_length=6*default_charset()->mbmaxlen;
maybe_null=1;
}
};
......@@ -72,7 +72,7 @@ class Item_func_dayofmonth :public Item_int_func
void fix_length_and_dec()
{
decimals=0;
max_length=2*thd_charset()->mbmaxlen;
max_length=2*default_charset()->mbmaxlen;
maybe_null=1;
}
};
......@@ -86,16 +86,16 @@ class Item_func_month :public Item_func
double val() { return (double) Item_func_month::val_int(); }
String *val_str(String *str)
{
str->set(val_int(), thd_charset());
str->set(val_int(), default_charset());
return null_value ? 0 : str;
}
const char *func_name() const { return "month"; }
enum Item_result result_type () const { return INT_RESULT; }
void fix_length_and_dec()
{
set_charset(thd_charset());
set_charset(default_charset());
decimals=0;
max_length=2*thd_charset()->mbmaxlen;
max_length=2*default_charset()->mbmaxlen;
maybe_null=1;
}
};
......@@ -110,9 +110,9 @@ class Item_func_monthname :public Item_func_month
enum Item_result result_type () const { return STRING_RESULT; }
void fix_length_and_dec()
{
set_charset(thd_charset());
set_charset(default_charset());
decimals=0;
max_length=10*thd_charset()->mbmaxlen;
max_length=10*default_charset()->mbmaxlen;
maybe_null=1;
}
};
......@@ -127,7 +127,7 @@ class Item_func_dayofyear :public Item_int_func
void fix_length_and_dec()
{
decimals=0;
max_length=3*thd_charset()->mbmaxlen;
max_length=3*default_charset()->mbmaxlen;
maybe_null=1;
}
};
......@@ -142,7 +142,7 @@ class Item_func_hour :public Item_int_func
void fix_length_and_dec()
{
decimals=0;
max_length=2*thd_charset()->mbmaxlen;
max_length=2*default_charset()->mbmaxlen;
maybe_null=1;
}
};
......@@ -157,7 +157,7 @@ class Item_func_minute :public Item_int_func
void fix_length_and_dec()
{
decimals=0;
max_length=2*thd_charset()->mbmaxlen;
max_length=2*default_charset()->mbmaxlen;
maybe_null=1;
}
};
......@@ -172,7 +172,7 @@ class Item_func_quarter :public Item_int_func
void fix_length_and_dec()
{
decimals=0;
max_length=1*thd_charset()->mbmaxlen;
max_length=1*default_charset()->mbmaxlen;
maybe_null=1;
}
};
......@@ -187,7 +187,7 @@ class Item_func_second :public Item_int_func
void fix_length_and_dec()
{
decimals=0;
max_length=2*thd_charset()->mbmaxlen;
max_length=2*default_charset()->mbmaxlen;
maybe_null=1;
}
};
......@@ -202,7 +202,7 @@ class Item_func_week :public Item_int_func
void fix_length_and_dec()
{
decimals=0;
max_length=2*thd_charset()->mbmaxlen;
max_length=2*default_charset()->mbmaxlen;
maybe_null=1;
}
};
......@@ -216,7 +216,7 @@ class Item_func_yearweek :public Item_int_func
void fix_length_and_dec()
{
decimals=0;
max_length=6*thd_charset()->mbmaxlen;
max_length=6*default_charset()->mbmaxlen;
maybe_null=1;
}
};
......@@ -231,7 +231,7 @@ class Item_func_year :public Item_int_func
void fix_length_and_dec()
{
decimals=0;
max_length=4*thd_charset()->mbmaxlen;
max_length=4*default_charset()->mbmaxlen;
maybe_null=1;
}
};
......@@ -247,16 +247,16 @@ class Item_func_weekday :public Item_func
double val() { return (double) val_int(); }
String *val_str(String *str)
{
str->set(val_int(), thd_charset());
str->set(val_int(), default_charset());
return null_value ? 0 : str;
}
const char *func_name() const { return "weekday"; }
enum Item_result result_type () const { return INT_RESULT; }
void fix_length_and_dec()
{
set_charset(thd_charset());
set_charset(default_charset());
decimals=0;
max_length=1*thd_charset()->mbmaxlen;
max_length=1*default_charset()->mbmaxlen;
maybe_null=1;
}
};
......@@ -270,9 +270,9 @@ class Item_func_dayname :public Item_func_weekday
enum Item_result result_type () const { return STRING_RESULT; }
void fix_length_and_dec()
{
set_charset(thd_charset());
set_charset(default_charset());
decimals=0;
max_length=9*thd_charset()->mbmaxlen;
max_length=9*default_charset()->mbmaxlen;
maybe_null=1;
}
};
......@@ -289,7 +289,7 @@ class Item_func_unix_timestamp :public Item_int_func
void fix_length_and_dec()
{
decimals=0;
max_length=10*thd_charset()->mbmaxlen;
max_length=10*default_charset()->mbmaxlen;
}
};
......@@ -303,7 +303,7 @@ class Item_func_time_to_sec :public Item_int_func
void fix_length_and_dec()
{
decimals=0;
max_length=10*thd_charset()->mbmaxlen;
max_length=10*default_charset()->mbmaxlen;
}
};
......@@ -322,15 +322,15 @@ class Item_date :public Item_func
const char *func_name() const { return "date"; }
void fix_length_and_dec()
{
set_charset(thd_charset());
set_charset(default_charset());
decimals=0;
max_length=10*thd_charset()->mbmaxlen;
max_length=10*default_charset()->mbmaxlen;
}
int save_in_field(Field *to, bool no_conversions);
Field *tmp_table_field() { return result_field; }
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 @@ class Item_date_func :public Item_str_func
Field *tmp_table_field() { return result_field; }
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 @@ class Item_func_curtime :public Item_func
Field *tmp_table_field() { return result_field; }
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
const char *func_name() const { return "from_unixtime"; }
void fix_length_and_dec()
{
set_charset(thd_charset());
set_charset(default_charset());
decimals=0;
max_length=19*thd_charset()->mbmaxlen;
max_length=19*default_charset()->mbmaxlen;
}
bool get_date(TIME *res,bool fuzzy_date);
};
......@@ -457,16 +457,16 @@ class Item_func_sec_to_time :public Item_str_func
String *val_str(String *);
void fix_length_and_dec()
{
set_charset(thd_charset());
set_charset(default_charset());
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; }
const char *func_name() const { return "sec_to_time"; }
Field *tmp_table_field() { return result_field; }
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 @@ class Item_typecast :public Item_str_func
}
void fix_length_and_dec()
{
set_charset(thd_charset());
set_charset(default_charset());
max_length=args[0]->max_length;
}
void print(String *str);
......@@ -545,7 +545,7 @@ class Item_char_typecast :public Item_typecast
Item_char_typecast(Item *a) :Item_typecast(a) {}
void fix_length_and_dec()
{
set_charset(thd_charset());
set_charset(default_charset());
max_length=args[0]->max_length;
}
};
......@@ -560,7 +560,7 @@ class Item_date_typecast :public Item_typecast
Field *tmp_table_field() { return result_field; }
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 @@ class Item_time_typecast :public Item_typecast
Field *tmp_table_field() { return result_field; }
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 @@ class Item_datetime_typecast :public Item_typecast
Field *tmp_table_field() { return result_field; }
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 @@ class Item_proc :public Item
virtual void set(const char *str,uint length,CHARSET_INFO *cs)=0;
virtual void set(longlong nr)=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)
{
init_make_field(tmp_field,field_type());
......@@ -62,7 +62,7 @@ class Item_proc_real :public Item_proc
{ int err; value=my_strntod(cs,(char*) str,length,(char**)0,&err); }
double val() { return 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);}
};
......@@ -80,7 +80,7 @@ class Item_proc_int :public Item_proc
{ int err; value=my_strntoll(cs,str,length,10,NULL,&err); }
double val() { return (double) 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);}
};
......@@ -92,8 +92,8 @@ class Item_proc_string :public Item_proc
{ this->max_length=length; }
enum Item_result result_type () const { return STRING_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_STRING; }
void set(double nr) { str_value.set(nr, 2, thd_charset()); }
void set(longlong nr) { str_value.set(nr, thd_charset()); }
void set(double nr) { str_value.set(nr, 2, default_charset()); }
void set(longlong nr) { str_value.set(nr, default_charset()); }
void set(const char *str, uint length, CHARSET_INFO *cs)
{ str_value.copy(str,length,cs); }
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