Commit 6a9273fa authored by venu@myvenu.com's avatar venu@myvenu.com

Merge work.mysql.com:/home/bk/mysql-4.1

into myvenu.com:/home/venu/work/sql/dev-4.1
parents 64f0e428 b4c6a208
......@@ -47,8 +47,11 @@ __os_rename(dbenv, oldname, newname, flags)
* There is no MoveFileEx for Win9x/Me, so we have to
* do the best we can.
*/
if (!GetLongPathName(oldname, oldbuf, sizeof oldbuf) ||
!GetLongPathName(newname, newbuf, sizeof newbuf)) {
LPTSTR FilePath;
if (!GetFullPathName(oldname, sizeof(oldbuf), oldbuf,
&FilePath) ||
!GetFullPathName(newname, sizeof(newbuf), newbuf,
&FilePath)) {
ret = __os_win32_errno();
goto done;
}
......
......@@ -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;
......
......@@ -39,8 +39,8 @@ class Item {
SUBSELECT_ITEM, ROW_ITEM, CACHE_ITEM};
enum cond_result { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE };
enum coercion { COER_NOCOLL=0, COER_COERCIBLE=1,
COER_IMPLICIT=2, COER_EXPLICIT=3 };
enum coercion { COER_NOCOLL=3, COER_COERCIBLE=2,
COER_IMPLICIT=1, COER_EXPLICIT=0 };
String str_value; /* used to store value */
my_string name; /* Name from select */
......@@ -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;
......
......@@ -132,7 +132,7 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
coercibility= (*arg)->coercibility;
set_charset((*arg)->charset());
}
else if ((*arg)->coercibility > coercibility)
else if ((*arg)->coercibility < coercibility)
{
if (strcmp(charset()->csname,(*arg)->charset()->csname))
{
......@@ -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;
}
......@@ -2007,6 +2007,7 @@ static user_var_entry *get_variable(HASH *hash, LEX_STRING &name,
}
bool Item_func_set_user_var::fix_fields(THD *thd, TABLE_LIST *tables,
Item **ref)
{
......@@ -2030,7 +2031,8 @@ Item_func_set_user_var::fix_length_and_dec()
void Item_func_set_user_var::update_hash(void *ptr, uint length,
Item_result type,
CHARSET_INFO *cs)
CHARSET_INFO *cs,
enum coercion coercibility)
{
if ((null_value=args[0]->null_value))
{
......@@ -2040,6 +2042,7 @@ void Item_func_set_user_var::update_hash(void *ptr, uint length,
entry->value=0;
entry->length=0;
entry->var_charset=cs;
entry->var_coercibility= coercibility;
}
else
{
......@@ -2071,6 +2074,7 @@ void Item_func_set_user_var::update_hash(void *ptr, uint length,
entry->length= length;
entry->type=type;
entry->var_charset=cs;
entry->var_coercibility= coercibility;
}
return;
......@@ -2112,7 +2116,8 @@ double
Item_func_set_user_var::val()
{
double value=args[0]->val();
update_hash((void*) &value,sizeof(value), REAL_RESULT, default_charset_info);
update_hash((void*) &value,sizeof(value), REAL_RESULT,
&my_charset_bin, COER_NOCOLL);
return value;
}
......@@ -2121,7 +2126,7 @@ Item_func_set_user_var::val_int()
{
longlong value=args[0]->val_int();
update_hash((void*) &value, sizeof(longlong), INT_RESULT,
default_charset_info);
&my_charset_bin, COER_NOCOLL);
return value;
}
......@@ -2130,10 +2135,10 @@ Item_func_set_user_var::val_str(String *str)
{
String *res=args[0]->val_str(str);
if (!res) // Null value
update_hash((void*) 0, 0, STRING_RESULT, &my_charset_bin);
update_hash((void*) 0, 0, STRING_RESULT, &my_charset_bin, COER_NOCOLL);
else
update_hash((void*) res->ptr(), res->length(), STRING_RESULT,
res->charset());
res->charset(), args[0]->coercibility);
return res;
}
......
......@@ -934,7 +934,8 @@ class Item_func_set_user_var :public Item_func
double val();
longlong val_int();
String *val_str(String *str);
void update_hash(void *ptr, uint length, enum Item_result type, CHARSET_INFO *cs);
void update_hash(void *ptr, uint length, enum Item_result type,
CHARSET_INFO *cs, enum coercion coercibility);
bool update();
enum Item_result result_type () const { return cached_result_type; }
bool fix_fields(THD *thd, struct st_table_list *tables, Item **ref);
......
......@@ -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()));
}
};
......@@ -2177,7 +2177,7 @@ int User_var_log_event::exec_event(struct st_relay_log_info* rli)
}
Item_func_set_user_var e(user_var_name, it);
e.fix_fields(thd, 0, 0);
e.update_hash(val, val_len, type, charset);
e.update_hash(val, val_len, type, charset, Item::COER_NOCOLL);
free_root(&thd->mem_root,0);
rli->inc_pending(get_event_len());
......
......@@ -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()
......
......@@ -935,6 +935,7 @@ class user_var_entry
ulong length, update_query_id, used_query_id;
Item_result type;
CHARSET_INFO *var_charset;
enum Item::coercion var_coercibility;
};
/* Class for unique (removing of duplicates) */
......
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