Commit 1cf19581 authored by unknown's avatar unknown

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

into bar.mysql.r18.ru:/usr/home/bar/mysql-4.1.wrk
parents 6df2be8f 66404afb
...@@ -4316,14 +4316,14 @@ int Field_blob::store(const char *from,uint len,CHARSET_INFO *cs) ...@@ -4316,14 +4316,14 @@ int Field_blob::store(const char *from,uint len,CHARSET_INFO *cs)
int Field_blob::store(double nr) int Field_blob::store(double nr)
{ {
value.set(nr,2,my_thd_charset); value.set(nr,2,current_thd->thd_charset);
return Field_blob::store(value.ptr(),(uint) value.length(), value.charset()); return Field_blob::store(value.ptr(),(uint) value.length(), value.charset());
} }
int Field_blob::store(longlong nr) int Field_blob::store(longlong nr)
{ {
value.set(nr,my_thd_charset); value.set(nr,current_thd->thd_charset);
return Field_blob::store(value.ptr(), (uint) value.length(), value.charset()); return Field_blob::store(value.ptr(), (uint) value.length(), value.charset());
} }
......
...@@ -117,6 +117,11 @@ bool Item::get_time(TIME *ltime) ...@@ -117,6 +117,11 @@ bool Item::get_time(TIME *ltime)
return 0; return 0;
} }
CHARSET_INFO * Item::thd_charset() const
{
return current_thd->thd_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)
{ {
set_field(f); set_field(f);
...@@ -234,7 +239,7 @@ table_map Item_field::used_tables() const ...@@ -234,7 +239,7 @@ table_map Item_field::used_tables() const
String *Item_int::val_str(String *str) String *Item_int::val_str(String *str)
{ {
str->set(value, my_thd_charset); str->set(value, thd_charset());
return str; return str;
} }
...@@ -242,7 +247,7 @@ void Item_int::print(String *str) ...@@ -242,7 +247,7 @@ void Item_int::print(String *str)
{ {
if (!name) if (!name)
{ {
str_value.set(value, my_thd_charset); str_value.set(value, thd_charset());
name=str_value.c_ptr(); name=str_value.c_ptr();
} }
str->append(name); str->append(name);
...@@ -250,7 +255,7 @@ void Item_int::print(String *str) ...@@ -250,7 +255,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, my_thd_charset); str->set((ulonglong) value, thd_charset());
return str; return str;
} }
...@@ -258,7 +263,7 @@ void Item_uint::print(String *str) ...@@ -258,7 +263,7 @@ void Item_uint::print(String *str)
{ {
if (!name) if (!name)
{ {
str_value.set((ulonglong) value, my_thd_charset); str_value.set((ulonglong) value, thd_charset());
name=str_value.c_ptr(); name=str_value.c_ptr();
} }
str->append(name); str->append(name);
...@@ -267,7 +272,7 @@ void Item_uint::print(String *str) ...@@ -267,7 +272,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,my_thd_charset); str->set(value,decimals,thd_charset());
return str; return str;
} }
...@@ -384,10 +389,10 @@ String *Item_param::val_str(String* str) ...@@ -384,10 +389,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, my_thd_charset); str->set(int_value, thd_charset());
return str; return str;
case REAL_RESULT: case REAL_RESULT:
str->set(real_value, 2, my_thd_charset); str->set(real_value, 2, thd_charset());
return str; return str;
default: default:
return (String*) &str_value; return (String*) &str_value;
......
...@@ -84,6 +84,7 @@ class Item { ...@@ -84,6 +84,7 @@ class Item {
virtual bool get_date(TIME *ltime,bool fuzzydate); virtual bool get_date(TIME *ltime,bool fuzzydate);
virtual bool get_time(TIME *ltime); virtual bool get_time(TIME *ltime);
virtual bool is_null() { return 0; }; virtual bool is_null() { return 0; };
virtual CHARSET_INFO *thd_charset() const;
virtual CHARSET_INFO *charset() const { return str_value.charset(); }; virtual CHARSET_INFO *charset() const { return str_value.charset(); };
virtual bool binary() const { return str_value.charset()->state & MY_CS_BINSORT ? 1 : 0 ; } virtual bool binary() const { return str_value.charset()->state & MY_CS_BINSORT ? 1 : 0 ; }
virtual void set_charset(CHARSET_INFO *cs) { str_value.set_charset(cs); } virtual void set_charset(CHARSET_INFO *cs) { str_value.set_charset(cs); }
......
...@@ -243,7 +243,7 @@ String *Item_real_func::val_str(String *str) ...@@ -243,7 +243,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,my_thd_charset); str->set(nr,decimals,thd_charset());
return str; return str;
} }
...@@ -256,9 +256,9 @@ String *Item_num_func::val_str(String *str) ...@@ -256,9 +256,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,my_thd_charset); str->set(nr,thd_charset());
else else
str->set((ulonglong) nr,my_thd_charset); str->set((ulonglong) nr,thd_charset());
} }
else else
{ {
...@@ -266,7 +266,7 @@ String *Item_num_func::val_str(String *str) ...@@ -266,7 +266,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,my_thd_charset); str->set(nr,decimals,thd_charset());
} }
return str; return str;
} }
...@@ -286,9 +286,9 @@ String *Item_int_func::val_str(String *str) ...@@ -286,9 +286,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,my_thd_charset); str->set(nr,thd_charset());
else else
str->set((ulonglong) nr,my_thd_charset); str->set((ulonglong) nr,thd_charset());
return str; return str;
} }
...@@ -315,9 +315,9 @@ String *Item_num_op::val_str(String *str) ...@@ -315,9 +315,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,my_thd_charset); str->set(nr,thd_charset());
else else
str->set((ulonglong) nr,my_thd_charset); str->set((ulonglong) nr,thd_charset());
} }
else else
{ {
...@@ -325,7 +325,7 @@ String *Item_num_op::val_str(String *str) ...@@ -325,7 +325,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,my_thd_charset); str->set(nr,decimals,thd_charset());
} }
return str; return str;
} }
...@@ -813,9 +813,9 @@ String *Item_func_min_max::val_str(String *str) ...@@ -813,9 +813,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,my_thd_charset); str->set(nr,thd_charset());
else else
str->set((ulonglong) nr,my_thd_charset); str->set((ulonglong) nr,thd_charset());
return str; return str;
} }
case REAL_RESULT: case REAL_RESULT:
...@@ -824,7 +824,7 @@ String *Item_func_min_max::val_str(String *str) ...@@ -824,7 +824,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,my_thd_charset); str->set(nr,decimals,thd_charset());
return str; return str;
} }
case STRING_RESULT: case STRING_RESULT:
...@@ -1447,7 +1447,7 @@ String *Item_func_udf_float::val_str(String *str) ...@@ -1447,7 +1447,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,my_thd_charset); str->set(nr,decimals,thd_charset());
return str; return str;
} }
...@@ -1468,9 +1468,9 @@ String *Item_func_udf_int::val_str(String *str) ...@@ -1468,9 +1468,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,my_thd_charset); str->set(nr,thd_charset());
else else
str->set((ulonglong) nr,my_thd_charset); str->set((ulonglong) nr,thd_charset());
return str; return str;
} }
...@@ -2034,10 +2034,10 @@ Item_func_get_user_var::val_str(String *str) ...@@ -2034,10 +2034,10 @@ Item_func_get_user_var::val_str(String *str)
return NULL; return NULL;
switch (entry->type) { switch (entry->type) {
case REAL_RESULT: case REAL_RESULT:
str->set(*(double*) entry->value,decimals,my_thd_charset); str->set(*(double*) entry->value,decimals,thd_charset());
break; break;
case INT_RESULT: case INT_RESULT:
str->set(*(longlong*) entry->value,my_thd_charset); str->set(*(longlong*) entry->value,thd_charset());
break; break;
case STRING_RESULT: case STRING_RESULT:
if (str->copy(entry->value, entry->length-1)) if (str->copy(entry->value, entry->length-1))
......
...@@ -1469,7 +1469,7 @@ String *Item_func_format::val_str(String *str) ...@@ -1469,7 +1469,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,my_thd_charset); str->set(nr,decimals,thd_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
......
...@@ -200,7 +200,7 @@ String *Item_exists_subselect::val_str(String *str) ...@@ -200,7 +200,7 @@ String *Item_exists_subselect::val_str(String *str)
assign_null(); assign_null();
return 0; return 0;
} }
str->set(value,my_thd_charset); str->set(value,thd_charset());
return str; return str;
} }
......
...@@ -93,7 +93,7 @@ Item_sum_num::val_str(String *str) ...@@ -93,7 +93,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,my_thd_charset); str->set(nr,decimals,thd_charset());
return str; return str;
} }
...@@ -359,13 +359,13 @@ Item_sum_hybrid::val_str(String *str) ...@@ -359,13 +359,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,my_thd_charset); str->set(sum,decimals,thd_charset());
break; break;
case INT_RESULT: case INT_RESULT:
if (unsigned_flag) if (unsigned_flag)
str->set((ulonglong) sum_int,my_thd_charset); str->set((ulonglong) sum_int,thd_charset());
else else
str->set((longlong) sum_int,my_thd_charset); str->set((longlong) sum_int,thd_charset());
break; break;
} }
return str; // Keep compiler happy return str; // Keep compiler happy
...@@ -810,7 +810,7 @@ String *Item_avg_field::val_str(String *str) ...@@ -810,7 +810,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,my_thd_charset); str->set(nr,decimals,thd_charset());
return str; return str;
} }
...@@ -847,7 +847,7 @@ String *Item_std_field::val_str(String *str) ...@@ -847,7 +847,7 @@ String *Item_std_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,my_thd_charset); str->set(nr,decimals,thd_charset());
return str; return str;
} }
...@@ -1177,7 +1177,7 @@ String *Item_sum_udf_float::val_str(String *str) ...@@ -1177,7 +1177,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,my_thd_charset); str->set(nr,decimals,thd_charset());
return str; return str;
} }
...@@ -1196,7 +1196,7 @@ String *Item_sum_udf_int::val_str(String *str) ...@@ -1196,7 +1196,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,my_thd_charset); str->set(nr,thd_charset());
return str; return str;
} }
......
...@@ -69,7 +69,7 @@ class Item_func_month :public Item_func ...@@ -69,7 +69,7 @@ class Item_func_month :public Item_func
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(), my_thd_charset); str->set(val_int(), thd_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"; }
...@@ -177,7 +177,7 @@ class Item_func_weekday :public Item_func ...@@ -177,7 +177,7 @@ class Item_func_weekday :public Item_func
longlong val_int(); longlong val_int();
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(), my_thd_charset); str->set(val_int(), thd_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"; }
...@@ -243,7 +243,7 @@ class Item_date :public Item_func ...@@ -243,7 +243,7 @@ class Item_date :public Item_func
} }
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
return (!t_arg) ? result_field : new Field_date(maybe_null, name, t_arg, my_thd_charset); return (!t_arg) ? result_field : new Field_date(maybe_null, name, t_arg, thd_charset());
} }
}; };
...@@ -261,7 +261,7 @@ class Item_date_func :public Item_str_func ...@@ -261,7 +261,7 @@ class Item_date_func :public Item_str_func
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
return (!t_arg) ? result_field : new Field_datetime(maybe_null, name, return (!t_arg) ? result_field : new Field_datetime(maybe_null, name,
t_arg, my_thd_charset); t_arg, thd_charset());
} }
}; };
...@@ -288,7 +288,7 @@ class Item_func_curtime :public Item_func ...@@ -288,7 +288,7 @@ class Item_func_curtime :public Item_func
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
return (!t_arg) ? result_field : return (!t_arg) ? result_field :
new Field_time(maybe_null, name, t_arg, my_thd_charset); new Field_time(maybe_null, name, t_arg, thd_charset());
} }
}; };
...@@ -381,7 +381,7 @@ class Item_func_sec_to_time :public Item_str_func ...@@ -381,7 +381,7 @@ class Item_func_sec_to_time :public Item_str_func
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
return (!t_arg) ? result_field : return (!t_arg) ? result_field :
new Field_time(maybe_null, name, t_arg, my_thd_charset); new Field_time(maybe_null, name, t_arg, thd_charset());
} }
}; };
...@@ -446,7 +446,7 @@ class Item_date_typecast :public Item_typecast ...@@ -446,7 +446,7 @@ class Item_date_typecast :public Item_typecast
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
return (!t_arg) ? result_field : return (!t_arg) ? result_field :
new Field_date(maybe_null, name, t_arg, my_thd_charset); new Field_date(maybe_null, name, t_arg, thd_charset());
} }
}; };
...@@ -462,7 +462,7 @@ class Item_time_typecast :public Item_typecast ...@@ -462,7 +462,7 @@ class Item_time_typecast :public Item_typecast
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
return (!t_arg) ? result_field : return (!t_arg) ? result_field :
new Field_time(maybe_null, name, t_arg, my_thd_charset); new Field_time(maybe_null, name, t_arg, thd_charset());
} }
}; };
...@@ -478,6 +478,6 @@ class Item_datetime_typecast :public Item_typecast ...@@ -478,6 +478,6 @@ class Item_datetime_typecast :public Item_typecast
Field *tmp_table_field(TABLE *t_arg) Field *tmp_table_field(TABLE *t_arg)
{ {
return (!t_arg) ? result_field : new Field_datetime(maybe_null, name, return (!t_arg) ? result_field : new Field_datetime(maybe_null, name,
t_arg, my_thd_charset); t_arg, thd_charset());
} }
}; };
...@@ -896,14 +896,14 @@ int collect_real(double *element, element_count count __attribute__((unused)), ...@@ -896,14 +896,14 @@ int collect_real(double *element, element_count count __attribute__((unused)),
TREE_INFO *info) TREE_INFO *info)
{ {
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String s(buff, sizeof(buff),default_charset_info); String s(buff, sizeof(buff),current_thd->thd_charset);
if (info->found) if (info->found)
info->str->append(','); info->str->append(',');
else else
info->found = 1; info->found = 1;
info->str->append('\''); info->str->append('\'');
s.set(*element, info->item->decimals, my_thd_charset); s.set(*element, info->item->decimals, current_thd->thd_charset);
info->str->append(s); info->str->append(s);
info->str->append('\''); info->str->append('\'');
return 0; return 0;
......
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