Commit 85f35cbf authored by unknown's avatar unknown

All String->set() now have charset argument

parent 2b6c55db
......@@ -4316,17 +4316,15 @@ int Field_blob::store(const char *from,uint len,CHARSET_INFO *cs)
int Field_blob::store(double nr)
{
value.set(nr);
return Field_blob::store(value.ptr(),(uint) value.length(),
default_charset_info);
value.set(nr,2,my_thd_charset);
return Field_blob::store(value.ptr(),(uint) value.length(), value.charset());
}
int Field_blob::store(longlong nr)
{
value.set(nr);
return Field_blob::store(value.ptr(), (uint) value.length(),
default_charset_info);
value.set(nr,my_thd_charset);
return Field_blob::store(value.ptr(), (uint) value.length(), value.charset());
}
......
......@@ -234,7 +234,7 @@ table_map Item_field::used_tables() const
String *Item_int::val_str(String *str)
{
str->set(value);
str->set(value, my_thd_charset);
return str;
}
......@@ -242,7 +242,7 @@ void Item_int::print(String *str)
{
if (!name)
{
str_value.set(value);
str_value.set(value, my_thd_charset);
name=str_value.c_ptr();
}
str->append(name);
......@@ -250,7 +250,7 @@ void Item_int::print(String *str)
String *Item_uint::val_str(String *str)
{
str->set((ulonglong) value);
str->set((ulonglong) value, my_thd_charset);
return str;
}
......@@ -258,7 +258,7 @@ void Item_uint::print(String *str)
{
if (!name)
{
str_value.set((ulonglong) value);
str_value.set((ulonglong) value, my_thd_charset);
name=str_value.c_ptr();
}
str->append(name);
......@@ -267,7 +267,7 @@ void Item_uint::print(String *str)
String *Item_real::val_str(String *str)
{
str->set(value,decimals);
str->set(value,decimals,my_thd_charset);
return str;
}
......@@ -384,10 +384,10 @@ String *Item_param::val_str(String* str)
{
switch (item_result_type) {
case INT_RESULT:
str->set(int_value);
str->set(int_value, my_thd_charset);
return str;
case REAL_RESULT:
str->set(real_value);
str->set(real_value, 2, my_thd_charset);
return str;
default:
return (String*) &str_value;
......
......@@ -245,7 +245,7 @@ String *Item_real_func::val_str(String *str)
if (null_value)
return 0; /* purecov: inspected */
else
str->set(nr,decimals);
str->set(nr,decimals,my_thd_charset);
return str;
}
......@@ -258,9 +258,9 @@ String *Item_num_func::val_str(String *str)
if (null_value)
return 0; /* purecov: inspected */
else if (!unsigned_flag)
str->set(nr);
str->set(nr,my_thd_charset);
else
str->set((ulonglong) nr);
str->set((ulonglong) nr,my_thd_charset);
}
else
{
......@@ -268,7 +268,7 @@ String *Item_num_func::val_str(String *str)
if (null_value)
return 0; /* purecov: inspected */
else
str->set(nr,decimals);
str->set(nr,decimals,my_thd_charset);
}
return str;
}
......@@ -288,9 +288,9 @@ String *Item_int_func::val_str(String *str)
if (null_value)
return 0;
else if (!unsigned_flag)
str->set(nr);
str->set(nr,my_thd_charset);
else
str->set((ulonglong) nr);
str->set((ulonglong) nr,my_thd_charset);
return str;
}
......@@ -317,9 +317,9 @@ String *Item_num_op::val_str(String *str)
if (null_value)
return 0; /* purecov: inspected */
else if (!unsigned_flag)
str->set(nr);
str->set(nr,my_thd_charset);
else
str->set((ulonglong) nr);
str->set((ulonglong) nr,my_thd_charset);
}
else
{
......@@ -327,7 +327,7 @@ String *Item_num_op::val_str(String *str)
if (null_value)
return 0; /* purecov: inspected */
else
str->set(nr,decimals);
str->set(nr,decimals,my_thd_charset);
}
return str;
}
......@@ -815,9 +815,9 @@ String *Item_func_min_max::val_str(String *str)
if (null_value)
return 0;
else if (!unsigned_flag)
str->set(nr);
str->set(nr,my_thd_charset);
else
str->set((ulonglong) nr);
str->set((ulonglong) nr,my_thd_charset);
return str;
}
case REAL_RESULT:
......@@ -826,7 +826,7 @@ String *Item_func_min_max::val_str(String *str)
if (null_value)
return 0; /* purecov: inspected */
else
str->set(nr,decimals);
str->set(nr,decimals,my_thd_charset);
return str;
}
case STRING_RESULT:
......@@ -1449,7 +1449,7 @@ String *Item_func_udf_float::val_str(String *str)
if (null_value)
return 0; /* purecov: inspected */
else
str->set(nr,decimals);
str->set(nr,decimals,my_thd_charset);
return str;
}
......@@ -1470,9 +1470,9 @@ String *Item_func_udf_int::val_str(String *str)
if (null_value)
return 0;
else if (!unsigned_flag)
str->set(nr);
str->set(nr,my_thd_charset);
else
str->set((ulonglong) nr);
str->set((ulonglong) nr,my_thd_charset);
return str;
}
......@@ -2036,10 +2036,10 @@ Item_func_get_user_var::val_str(String *str)
return NULL;
switch (entry->type) {
case REAL_RESULT:
str->set(*(double*) entry->value,decimals);
str->set(*(double*) entry->value,decimals,my_thd_charset);
break;
case INT_RESULT:
str->set(*(longlong*) entry->value);
str->set(*(longlong*) entry->value,my_thd_charset);
break;
case STRING_RESULT:
if (str->copy(entry->value, entry->length-1))
......
......@@ -1469,7 +1469,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);
str->set(nr,decimals,my_thd_charset);
str_length=str->length();
if (nr < 0)
str_length--; // Don't count sign
......
......@@ -200,7 +200,7 @@ String *Item_exists_subselect::val_str(String *str)
assign_null();
return 0;
}
str->set(value);
str->set(value,my_thd_charset);
return str;
}
......
......@@ -93,7 +93,7 @@ Item_sum_num::val_str(String *str)
double nr=val();
if (null_value)
return 0;
str->set(nr,decimals);
str->set(nr,decimals,my_thd_charset);
return str;
}
......@@ -359,13 +359,13 @@ Item_sum_hybrid::val_str(String *str)
case STRING_RESULT:
return &value;
case REAL_RESULT:
str->set(sum,decimals);
str->set(sum,decimals,my_thd_charset);
break;
case INT_RESULT:
if (unsigned_flag)
str->set((ulonglong) sum_int);
str->set((ulonglong) sum_int,my_thd_charset);
else
str->set((longlong) sum_int);
str->set((longlong) sum_int,my_thd_charset);
break;
}
return str; // Keep compiler happy
......@@ -810,7 +810,7 @@ String *Item_avg_field::val_str(String *str)
double nr=Item_avg_field::val();
if (null_value)
return 0;
str->set(nr,decimals);
str->set(nr,decimals,my_thd_charset);
return str;
}
......@@ -847,7 +847,7 @@ String *Item_std_field::val_str(String *str)
double nr=val();
if (null_value)
return 0;
str->set(nr,decimals);
str->set(nr,decimals,my_thd_charset);
return str;
}
......@@ -1174,7 +1174,7 @@ String *Item_sum_udf_float::val_str(String *str)
if (null_value)
return 0; /* purecov: inspected */
else
str->set(nr,decimals);
str->set(nr,decimals,my_thd_charset);
return str;
}
......@@ -1193,7 +1193,7 @@ String *Item_sum_udf_int::val_str(String *str)
if (null_value)
return 0;
else
str->set(nr);
str->set(nr,my_thd_charset);
return str;
}
......
......@@ -67,7 +67,11 @@ public:
Item_func_month(Item *a) :Item_func(a) {}
longlong val_int();
double val() { return (double) Item_func_month::val_int(); }
String *val_str(String *str) { str->set(val_int()); return null_value ? 0 : str;}
String *val_str(String *str)
{
str->set(val_int(), my_thd_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() { decimals=0; max_length=2; maybe_null=1; }
......@@ -172,7 +176,10 @@ public:
:Item_func(a), odbc_type(type_arg) {}
longlong val_int();
double val() { return (double) val_int(); }
String *val_str(String *str) { str->set(val_int()); return null_value ? 0 : str;}
String *val_str(String *str) {
str->set(val_int(), my_thd_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() { decimals=0; max_length=1; maybe_null=1; }
......
......@@ -61,6 +61,8 @@ char* query_table_status(THD *thd,const char *db,const char *table_name);
#endif
#endif
#define my_thd_charset default_charset_info
/***************************************************************************
Configuration parameters
****************************************************************************/
......
......@@ -62,7 +62,7 @@ public:
{ value=atof(str); }
double val() { return value; }
longlong val_int() { return (longlong) value; }
String *val_str(String *s) { s->set(value,decimals); return s; }
String *val_str(String *s) { s->set(value,decimals,my_thd_charset); return s; }
unsigned int size_of() { return sizeof(*this);}
};
......@@ -80,7 +80,7 @@ public:
{ value=strtoll(str,NULL,10); }
double val() { return (double) value; }
longlong val_int() { return value; }
String *val_str(String *s) { s->set(value); return s; }
String *val_str(String *s) { s->set(value, my_thd_charset); return s; }
unsigned int size_of() { return sizeof(*this);}
};
......@@ -92,8 +92,8 @@ public:
{ this->max_length=length; }
enum Item_result result_type () const { return STRING_RESULT; }
enum_field_types field_type() const { return FIELD_TYPE_STRING; }
void set(double nr) { str_value.set(nr); }
void set(longlong nr) { str_value.set(nr); }
void set(double nr) { str_value.set(nr, 2, my_thd_charset); }
void set(longlong nr) { str_value.set(nr, my_thd_charset); }
void set(const char *str, uint length) { str_value.copy(str,length); }
double val() { return atof(str_value.ptr()); }
longlong val_int() { return strtoll(str_value.ptr(),NULL,10); }
......
......@@ -903,7 +903,7 @@ int collect_real(double *element, element_count count __attribute__((unused)),
else
info->found = 1;
info->str->append('\'');
s.set(*element, info->item->decimals);
s.set(*element, info->item->decimals, my_thd_charset);
info->str->append(s);
info->str->append('\'');
return 0;
......@@ -922,7 +922,7 @@ int collect_longlong(longlong *element,
else
info->found = 1;
info->str->append('\'');
s.set(*element);
s.set(*element,default_charset_info);
info->str->append(s);
info->str->append('\'');
return 0;
......@@ -941,7 +941,7 @@ int collect_ulonglong(ulonglong *element,
else
info->found = 1;
info->str->append('\'');
s.set(*element);
s.set(*element,default_charset_info);
info->str->append(s);
info->str->append('\'');
return 0;
......
......@@ -128,10 +128,10 @@ public:
String *avg(String *s, ha_rows rows)
{
if (!(rows - nulls))
s->set((double) 0.0, 1);
s->set((double) 0.0, 1,my_thd_charset);
else
s->set((ulonglong2double(sum) / ulonglong2double(rows - nulls)),
DEC_IN_AVG);
DEC_IN_AVG,my_thd_charset);
return s;
}
friend int collect_string(String *element, element_count count,
......@@ -160,26 +160,34 @@ public:
void add();
void get_opt_type(String*, ha_rows);
String *get_min_arg(String *s) { s->set(min_arg, item->decimals); return s; }
String *get_max_arg(String *s) { s->set(max_arg, item->decimals); return s; }
String *get_min_arg(String *s)
{
s->set(min_arg, item->decimals,my_thd_charset);
return s;
}
String *get_max_arg(String *s)
{
s->set(max_arg, item->decimals,my_thd_charset);
return s;
}
String *avg(String *s, ha_rows rows)
{
if (!(rows - nulls))
s->set((double) 0.0, 1);
s->set((double) 0.0, 1,my_thd_charset);
else
s->set(((double)sum / (double) (rows - nulls)), item->decimals);
s->set(((double)sum / (double) (rows - nulls)), item->decimals,my_thd_charset);
return s;
}
String *std(String *s, ha_rows rows)
{
double tmp = ulonglong2double(rows);
if (!(tmp - nulls))
s->set((double) 0.0, 1);
s->set((double) 0.0, 1,my_thd_charset);
else
{
double tmp2 = ((sum_sqr - sum * sum / (tmp - nulls)) /
(tmp - nulls));
s->set(((double) tmp2 <= 0.0 ? 0.0 : sqrt(tmp2)), item->decimals);
s->set(((double) tmp2 <= 0.0 ? 0.0 : sqrt(tmp2)), item->decimals,my_thd_charset);
}
return s;
}
......@@ -206,26 +214,26 @@ public:
void add();
void get_opt_type(String*, ha_rows);
String *get_min_arg(String *s) { s->set(min_arg); return s; }
String *get_max_arg(String *s) { s->set(max_arg); return s; }
String *get_min_arg(String *s) { s->set(min_arg,my_thd_charset); return s; }
String *get_max_arg(String *s) { s->set(max_arg,my_thd_charset); return s; }
String *avg(String *s, ha_rows rows)
{
if (!(rows - nulls))
s->set((double) 0.0, 1);
s->set((double) 0.0, 1,my_thd_charset);
else
s->set(((double) sum / (double) (rows - nulls)), DEC_IN_AVG);
s->set(((double) sum / (double) (rows - nulls)), DEC_IN_AVG,my_thd_charset);
return s;
}
String *std(String *s, ha_rows rows)
{
double tmp = ulonglong2double(rows);
if (!(tmp - nulls))
s->set((double) 0.0, 1);
s->set((double) 0.0, 1,my_thd_charset);
else
{
double tmp2 = ((sum_sqr - sum * sum / (tmp - nulls)) /
(tmp - nulls));
s->set(((double) tmp2 <= 0.0 ? 0.0 : sqrt(tmp2)), DEC_IN_AVG);
s->set(((double) tmp2 <= 0.0 ? 0.0 : sqrt(tmp2)), DEC_IN_AVG,my_thd_charset);
}
return s;
}
......@@ -250,28 +258,28 @@ public:
(qsort_cmp2) compare_ulonglong2, 0, NULL, NULL); }
void add();
void get_opt_type(String*, ha_rows);
String *get_min_arg(String *s) { s->set(min_arg); return s; }
String *get_max_arg(String *s) { s->set(max_arg); return s; }
String *get_min_arg(String *s) { s->set(min_arg,my_thd_charset); return s; }
String *get_max_arg(String *s) { s->set(max_arg,my_thd_charset); return s; }
String *avg(String *s, ha_rows rows)
{
if (!(rows - nulls))
s->set((double) 0.0, 1);
s->set((double) 0.0, 1,my_thd_charset);
else
s->set((ulonglong2double(sum) / ulonglong2double(rows - nulls)),
DEC_IN_AVG);
DEC_IN_AVG,my_thd_charset);
return s;
}
String *std(String *s, ha_rows rows)
{
double tmp = ulonglong2double(rows);
if (!(tmp - nulls))
s->set((double) 0.0, 1);
s->set((double) 0.0, 1,my_thd_charset);
else
{
double tmp2 = ((ulonglong2double(sum_sqr) -
ulonglong2double(sum * sum) / (tmp - nulls)) /
(tmp - nulls));
s->set(((double) tmp2 <= 0.0 ? 0.0 : sqrt(tmp2)), DEC_IN_AVG);
s->set(((double) tmp2 <= 0.0 ? 0.0 : sqrt(tmp2)), DEC_IN_AVG,my_thd_charset);
}
return s;
}
......
......@@ -91,25 +91,29 @@ bool String::realloc(uint32 alloc_length)
return FALSE;
}
bool String::set(longlong num)
bool String::set(longlong num, CHARSET_INFO *cs)
{
if (alloc(21))
return TRUE;
str_length=(uint32) (longlong10_to_str(num,Ptr,-10)-Ptr);
str_charset=cs;
return FALSE;
}
bool String::set(ulonglong num)
bool String::set(ulonglong num, CHARSET_INFO *cs)
{
if (alloc(21))
return TRUE;
str_length=(uint32) (longlong10_to_str(num,Ptr,10)-Ptr);
str_charset=cs;
return FALSE;
}
bool String::set(double num,uint decimals)
bool String::set(double num,uint decimals, CHARSET_INFO *cs)
{
char buff[331];
str_charset=cs;
if (decimals >= NOT_FIXED_DEC)
{
sprintf(buff,"%.14g",num); // Enough for a DATETIME
......
......@@ -125,10 +125,9 @@ public:
}
str_charset=cs;
}
bool set(longlong num);
/* bool set(long num); */
bool set(ulonglong num);
bool set(double num,uint decimals=2);
bool set(longlong num, CHARSET_INFO *cs);
bool set(ulonglong num, CHARSET_INFO *cs);
bool set(double num,uint decimals, CHARSET_INFO *cs);
inline void free()
{
if (alloced)
......
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