Commit e19aa85d authored by unknown's avatar unknown

Merge mysql.com:/home/pz/mysql/mysql-4.1-root

into mysql.com:/home/pz/mysql/mysql-4.1


sql/item_strfunc.cc:
  Auto merged
parents cf2a9271 11581215
......@@ -161,7 +161,7 @@ fi
AC_PROG_RANLIB
# We use libtool
#AC_LIBTOOL_WIN32_DLL
AM_PROG_LIBTOOL
AC_PROG_LIBTOOL
#AC_LIBTOOL_DLOPEN AC_LIBTOOL_WIN32_DLL AC_DISABLE_FAST_INSTALL AC_DISABLE_SHARED AC_DISABLE_STATIC
......
......@@ -4302,7 +4302,7 @@ int Field_blob::store(const char *from,uint len,CHARSET_INFO *cs)
}
}
#endif /* USE_TIS620 */
value.copy(from,len);
value.copy(from,len,charset());
from=value.ptr();
#ifdef USE_TIS620
my_free(th_ptr,MYF(MY_ALLOW_ZERO_PTR));
......@@ -4316,14 +4316,14 @@ int Field_blob::store(const char *from,uint len,CHARSET_INFO *cs)
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());
}
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());
}
......
......@@ -198,7 +198,8 @@ public:
uint fill_cache_field(struct st_cache_field *copy);
virtual bool get_date(TIME *ltime,bool fuzzydate);
virtual bool get_time(TIME *ltime);
virtual CHARSET_INFO *charset(void) { return my_charset_bin; }
virtual CHARSET_INFO *charset(void) const { return my_charset_bin; }
virtual void set_charset(CHARSET_INFO *charset) { }
friend bool reopen_table(THD *,struct st_table *,bool);
friend int cre_myisam(my_string name, register TABLE *form, uint options,
ulonglong auto_increment_value);
......@@ -260,9 +261,9 @@ public:
uint decimals() const { return NOT_FIXED_DEC; }
void make_field(Send_field *);
uint size_of() const { return sizeof(*this); }
CHARSET_INFO *charset(void) { return field_charset; }
CHARSET_INFO *charset(void) const { return field_charset; }
inline void set_charset(CHARSET_INFO *charset) { field_charset=charset; }
void set_charset(CHARSET_INFO *charset) { field_charset=charset; }
bool binary() const { return field_charset->state & MY_CS_BINSORT ? 1 : 0; }
inline int cmp_image(char *buff,uint length)
{
......@@ -886,7 +887,7 @@ public:
inline bool copy()
{ char *tmp;
get_ptr(&tmp);
if (value.copy(tmp,get_length()))
if (value.copy(tmp,get_length(),charset()))
{
Field_blob::reset();
return 1;
......
......@@ -525,8 +525,7 @@ void field_conv(Field *to,Field *from)
if (!blob->value.is_alloced() &&
from->real_type() != FIELD_TYPE_STRING)
blob->value.copy();
blob->store(blob->value.ptr(),blob->value.length(),
to->binary()?default_charset_info:((Field_str*)to)->charset());
blob->store(blob->value.ptr(),blob->value.length(),to->charset());
return;
}
if ((from->result_type() == STRING_RESULT &&
......@@ -538,8 +537,7 @@ void field_conv(Field *to,Field *from)
char buff[MAX_FIELD_WIDTH];
String result(buff,sizeof(buff),default_charset_info);
from->val_str(&result,&result);
to->store(result.c_ptr_quick(),result.length(),
to->binary()?default_charset_info:((Field_str*)to)->charset());
to->store(result.c_ptr_quick(),result.length(),to->charset());
// QQ: what to do if "from" and "to" are of dirrent charsets?
}
else if (from->result_type() == REAL_RESULT)
......
......@@ -75,7 +75,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
uchar **sort_keys;
IO_CACHE tempfile, buffpek_pointers, *selected_records_file, *outfile;
SORTPARAM param;
CHARSET_INFO *charset=table->table_charset;
CHARSET_INFO *charset=my_charset_bin;
DBUG_ENTER("filesort");
DBUG_EXECUTE("info",TEST_filesort(sortorder,s_length););
#ifdef SKIP_DBUG_IN_FILESORT
......@@ -85,8 +85,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
// BAR TODO: this is not absolutely correct, but OK for now
for(i=0;i<table->fields;i++)
if (!table->field[i]->binary())
charset=((Field_str*)(table->field[i]))->charset();
charset=charset?charset:default_charset_info;
charset=table->field[i]->charset();
// /BAR TODO
outfile= table->io_cache;
......@@ -930,7 +929,7 @@ sortlength(SORT_FIELD *sortorder, uint s_length)
#ifdef USE_STRCOLL
if (!sortorder->field->binary())
{
CHARSET_INFO *cs=((Field_str*)(sortorder->field))->charset();
CHARSET_INFO *cs=sortorder->field->charset();
if (use_strnxfrm(cs))
sortorder->length= sortorder->length*cs->strxfrm_multiply;
}
......
This diff is collapsed.
......@@ -291,7 +291,7 @@ int ha_heap::create(const char *name, TABLE *table,
seg->start= (uint) key_part->offset;
seg->length= (uint) key_part->length;
seg->flag = 0;
seg->charset= field->binary() ? NULL : ((Field_str*)field)->charset();
seg->charset= field->charset();
if (field->null_ptr)
{
seg->null_bit= field->null_bit;
......
......@@ -1078,8 +1078,7 @@ int ha_myisam::create(const char *name, register TABLE *table,
keydef[i].seg[j].start= pos->key_part[j].offset;
keydef[i].seg[j].length= pos->key_part[j].length;
keydef[i].seg[j].bit_start=keydef[i].seg[j].bit_end=0;
keydef[i].seg[j].language = field->binary() ? MY_CHARSET_CURRENT :
((Field_str*)field)->charset()->number;
keydef[i].seg[j].language = field->charset()->number;
if (field->null_ptr)
{
......
......@@ -117,6 +117,11 @@ bool Item::get_time(TIME *ltime)
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)
{
set_field(f);
......@@ -234,7 +239,7 @@ table_map Item_field::used_tables() const
String *Item_int::val_str(String *str)
{
str->set(value, my_thd_charset);
str->set(value, thd_charset());
return str;
}
......@@ -242,7 +247,7 @@ void Item_int::print(String *str)
{
if (!name)
{
str_value.set(value, my_thd_charset);
str_value.set(value, thd_charset());
name=str_value.c_ptr();
}
str->append(name);
......@@ -250,7 +255,7 @@ void Item_int::print(String *str)
String *Item_uint::val_str(String *str)
{
str->set((ulonglong) value, my_thd_charset);
str->set((ulonglong) value, thd_charset());
return str;
}
......@@ -258,7 +263,7 @@ void Item_uint::print(String *str)
{
if (!name)
{
str_value.set((ulonglong) value, my_thd_charset);
str_value.set((ulonglong) value, thd_charset());
name=str_value.c_ptr();
}
str->append(name);
......@@ -267,7 +272,7 @@ void Item_uint::print(String *str)
String *Item_real::val_str(String *str)
{
str->set(value,decimals,my_thd_charset);
str->set(value,decimals,thd_charset());
return str;
}
......@@ -308,15 +313,15 @@ 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, CHARSET_INFO *cs)
{
str_value.set(str,length,default_charset_info);
str_value.set(str,length,cs);
item_result_type = STRING_RESULT;
item_type = STRING_ITEM;
}
void Item_param::set_longdata(const char *str, ulong length)
void Item_param::set_longdata(const char *str, ulong length, CHARSET_INFO *cs)
{
/* TODO: Fix this for binary handling by making use of
buffer_type..
......@@ -341,10 +346,8 @@ int Item_param::save_in_field(Field *field)
double nr=val();
return (field->store(nr)) ? -1 : 0;
}
String *result;
CHARSET_INFO *cs=default_charset_info; //fix this
result=val_str(&str_value);
return (field->store(result->ptr(),result->length(),cs)) ? -1 : 0;
String *result=val_str(&str_value);
return (field->store(result->ptr(),result->length(),field->charset())) ? -1 : 0;
}
......@@ -384,10 +387,10 @@ String *Item_param::val_str(String* str)
{
switch (item_result_type) {
case INT_RESULT:
str->set(int_value, my_thd_charset);
str->set(int_value, thd_charset());
return str;
case REAL_RESULT:
str->set(real_value, 2, my_thd_charset);
str->set(real_value, 2, thd_charset());
return str;
default:
return (String*) &str_value;
......@@ -653,7 +656,7 @@ int Item::save_in_field(Field *field)
field->result_type() == STRING_RESULT)
{
String *result;
CHARSET_INFO *cs=field->binary()?my_charset_bin:((Field_str*)field)->charset();
CHARSET_INFO *cs=field->charset();
char buff[MAX_FIELD_WIDTH]; // Alloc buffer for small columns
str_value.set_quick(buff,sizeof(buff),cs);
result=val_str(&str_value);
......@@ -685,7 +688,7 @@ int Item::save_in_field(Field *field)
int Item_string::save_in_field(Field *field)
{
String *result;
CHARSET_INFO *cs=field->binary()?my_charset_bin:((Field_str*)field)->charset();
CHARSET_INFO *cs=field->charset();
result=val_str(&str_value);
if (null_value)
return set_field_to_null(field);
......@@ -758,7 +761,7 @@ longlong Item_varbinary::val_int()
int Item_varbinary::save_in_field(Field *field)
{
int error;
CHARSET_INFO *cs=field->binary()?default_charset_info:((Field_str*)field)->charset();
CHARSET_INFO *cs=field->charset();
field->set_notnull();
if (field->result_type() == STRING_RESULT)
{
......
......@@ -84,6 +84,7 @@ public:
virtual bool get_date(TIME *ltime,bool fuzzydate);
virtual bool get_time(TIME *ltime);
virtual bool is_null() { return 0; };
virtual CHARSET_INFO *thd_charset() const;
virtual CHARSET_INFO *charset() const { return str_value.charset(); };
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); }
......@@ -195,10 +196,10 @@ public:
void set_null();
void set_int(longlong i);
void set_double(double i);
void set_value(const char *str, uint length);
void set_long_str(const char *str, ulong length);
void set_long_binary(const char *str, ulong length);
void set_longdata(const char *str, ulong length);
void set_value(const char *str, uint length, CHARSET_INFO *cs);
void set_long_str(const char *str, ulong length, CHARSET_INFO *cs);
void set_long_binary(const char *str, ulong length, CHARSET_INFO *cs);
void set_longdata(const char *str, ulong length, CHARSET_INFO *cs);
void set_long_end();
void reset() {}
enum Item_result result_type () const
......
......@@ -243,7 +243,7 @@ String *Item_real_func::val_str(String *str)
if (null_value)
return 0; /* purecov: inspected */
else
str->set(nr,decimals,my_thd_charset);
str->set(nr,decimals,thd_charset());
return str;
}
......@@ -256,9 +256,9 @@ String *Item_num_func::val_str(String *str)
if (null_value)
return 0; /* purecov: inspected */
else if (!unsigned_flag)
str->set(nr,my_thd_charset);
str->set(nr,thd_charset());
else
str->set((ulonglong) nr,my_thd_charset);
str->set((ulonglong) nr,thd_charset());
}
else
{
......@@ -266,7 +266,7 @@ String *Item_num_func::val_str(String *str)
if (null_value)
return 0; /* purecov: inspected */
else
str->set(nr,decimals,my_thd_charset);
str->set(nr,decimals,thd_charset());
}
return str;
}
......@@ -286,9 +286,9 @@ String *Item_int_func::val_str(String *str)
if (null_value)
return 0;
else if (!unsigned_flag)
str->set(nr,my_thd_charset);
str->set(nr,thd_charset());
else
str->set((ulonglong) nr,my_thd_charset);
str->set((ulonglong) nr,thd_charset());
return str;
}
......@@ -315,9 +315,9 @@ String *Item_num_op::val_str(String *str)
if (null_value)
return 0; /* purecov: inspected */
else if (!unsigned_flag)
str->set(nr,my_thd_charset);
str->set(nr,thd_charset());
else
str->set((ulonglong) nr,my_thd_charset);
str->set((ulonglong) nr,thd_charset());
}
else
{
......@@ -325,7 +325,7 @@ String *Item_num_op::val_str(String *str)
if (null_value)
return 0; /* purecov: inspected */
else
str->set(nr,decimals,my_thd_charset);
str->set(nr,decimals,thd_charset());
}
return str;
}
......@@ -813,9 +813,9 @@ String *Item_func_min_max::val_str(String *str)
if (null_value)
return 0;
else if (!unsigned_flag)
str->set(nr,my_thd_charset);
str->set(nr,thd_charset());
else
str->set((ulonglong) nr,my_thd_charset);
str->set((ulonglong) nr,thd_charset());
return str;
}
case REAL_RESULT:
......@@ -824,7 +824,7 @@ String *Item_func_min_max::val_str(String *str)
if (null_value)
return 0; /* purecov: inspected */
else
str->set(nr,decimals,my_thd_charset);
str->set(nr,decimals,thd_charset());
return str;
}
case STRING_RESULT:
......@@ -1447,7 +1447,7 @@ String *Item_func_udf_float::val_str(String *str)
if (null_value)
return 0; /* purecov: inspected */
else
str->set(nr,decimals,my_thd_charset);
str->set(nr,decimals,thd_charset());
return str;
}
......@@ -1468,9 +1468,9 @@ String *Item_func_udf_int::val_str(String *str)
if (null_value)
return 0;
else if (!unsigned_flag)
str->set(nr,my_thd_charset);
str->set(nr,thd_charset());
else
str->set((ulonglong) nr,my_thd_charset);
str->set((ulonglong) nr,thd_charset());
return str;
}
......@@ -1568,7 +1568,7 @@ void item_user_lock_release(ULL *ull)
char buf[256];
const char *command="DO RELEASE_LOCK(\"";
String tmp(buf,sizeof(buf), system_charset_info);
tmp.copy(command, strlen(command));
tmp.copy(command, strlen(command), tmp.charset());
tmp.append(ull->key,ull->key_length);
tmp.append("\")");
Query_log_event qev(current_thd,tmp.ptr(), tmp.length());
......@@ -2034,18 +2034,17 @@ Item_func_get_user_var::val_str(String *str)
return NULL;
switch (entry->type) {
case REAL_RESULT:
str->set(*(double*) entry->value,decimals,my_thd_charset);
str->set(*(double*) entry->value,decimals,thd_charset());
break;
case INT_RESULT:
str->set(*(longlong*) entry->value,my_thd_charset);
str->set(*(longlong*) entry->value,thd_charset());
break;
case STRING_RESULT:
if (str->copy(entry->value, entry->length-1))
if (str->copy(entry->value, entry->length-1, entry->var_charset))
{
null_value=1;
return NULL;
}
str->set_charset(entry->var_charset);
break;
}
return str;
......
......@@ -1387,7 +1387,7 @@ String *Item_func_database::val_str(String *str)
String *Item_func_user::val_str(String *str)
{
THD *thd=current_thd;
if (str->copy((const char*) thd->user,(uint) strlen(thd->user)) ||
if (str->copy((const char*) thd->user,(uint) strlen(thd->user), system_charset_info) ||
str->append('@') ||
str->append(thd->host ? thd->host : thd->ip ? thd->ip : ""))
return &empty_string;
......@@ -1483,7 +1483,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,my_thd_charset);
str->set(nr,decimals,thd_charset());
str_length=str->length();
if (nr < 0)
str_length--; // Don't count sign
......@@ -1651,7 +1651,7 @@ String *Item_func_char::val_str(String *str)
int32 num=(int32) args[i]->val_int();
if (!args[i]->null_value)
#ifdef USE_MB
if (use_mb(default_charset_info))
if (use_mb(charset()))
{
if (num&0xFF000000L) {
str->append((char)(num>>24));
......@@ -1913,7 +1913,7 @@ String *Item_func_conv::val_str(String *str)
else
dec= (longlong) strtoull(res->c_ptr(),&endptr,from_base);
ptr= longlong2str(dec,ans,to_base);
if (str->copy(ans,(uint32) (ptr-ans)))
if (str->copy(ans,(uint32) (ptr-ans), thd_charset()))
return &empty_string;
return str;
}
......@@ -2134,7 +2134,7 @@ String *Item_func_charset::val_str(String *str)
if ((null_value=(args[0]->null_value || !res->charset())))
return 0;
str->copy(res->charset()->name,strlen(res->charset()->name));
str->copy(res->charset()->name,strlen(res->charset()->name),default_charset_info);
return str;
}
......@@ -2149,7 +2149,7 @@ String *Item_func_hex::val_str(String *str)
if ((null_value= args[0]->null_value))
return 0;
ptr= longlong2str(dec,ans,16);
if (str->copy(ans,(uint32) (ptr-ans)))
if (str->copy(ans,(uint32) (ptr-ans),default_charset_info))
return &empty_string; // End of memory
return str;
}
......@@ -2468,7 +2468,9 @@ String *Item_func_geometry_type::val_str(String *str)
if ((null_value=(args[0]->null_value ||
geom.create_from_wkb(wkt->ptr(),wkt->length()))))
return 0;
str->copy(geom.get_class_info()->m_name,strlen(geom.get_class_info()->m_name));
str->copy(geom.get_class_info()->m_name,
strlen(geom.get_class_info()->m_name),
default_charset_info);
return str;
}
......
......@@ -200,7 +200,7 @@ String *Item_exists_subselect::val_str(String *str)
assign_null();
return 0;
}
str->set(value,my_thd_charset);
str->set(value,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,my_thd_charset);
str->set(nr,decimals,thd_charset());
return str;
}
......@@ -106,7 +106,7 @@ Item_sum_int::val_str(String *str)
return 0;
char buff[21];
uint length= (uint) (longlong10_to_str(nr,buff,-10)-buff);
str->copy(buff,length);
str->copy(buff,length,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,my_thd_charset);
str->set(sum,decimals,thd_charset());
break;
case INT_RESULT:
if (unsigned_flag)
str->set((ulonglong) sum_int,my_thd_charset);
str->set((ulonglong) sum_int,thd_charset());
else
str->set((longlong) sum_int,my_thd_charset);
str->set((longlong) sum_int,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,my_thd_charset);
str->set(nr,decimals,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,my_thd_charset);
str->set(nr,decimals,thd_charset());
return str;
}
......@@ -1177,7 +1177,7 @@ String *Item_sum_udf_float::val_str(String *str)
if (null_value)
return 0; /* purecov: inspected */
else
str->set(nr,decimals,my_thd_charset);
str->set(nr,decimals,thd_charset());
return str;
}
......@@ -1196,7 +1196,7 @@ String *Item_sum_udf_int::val_str(String *str)
if (null_value)
return 0;
else
str->set(nr,my_thd_charset);
str->set(nr,thd_charset());
return str;
}
......
......@@ -31,28 +31,28 @@
static String month_names[] =
{
String("January", default_charset_info),
String("February", default_charset_info),
String("March", default_charset_info),
String("April", default_charset_info),
String("May", default_charset_info),
String("June", default_charset_info),
String("July", default_charset_info),
String("August", default_charset_info),
String("September", default_charset_info),
String("October", default_charset_info),
String("November", default_charset_info),
String("December", default_charset_info)
String("January", my_charset_latin1),
String("February", my_charset_latin1),
String("March", my_charset_latin1),
String("April", my_charset_latin1),
String("May", my_charset_latin1),
String("June", my_charset_latin1),
String("July", my_charset_latin1),
String("August", my_charset_latin1),
String("September", my_charset_latin1),
String("October", my_charset_latin1),
String("November", my_charset_latin1),
String("December", my_charset_latin1)
};
static String day_names[] =
{
String("Monday", default_charset_info),
String("Tuesday", default_charset_info),
String("Wednesday", default_charset_info),
String("Thursday", default_charset_info),
String("Friday", default_charset_info),
String("Saturday", default_charset_info),
String("Sunday", default_charset_info)
String("Monday", my_charset_latin1),
String("Tuesday", my_charset_latin1),
String("Wednesday", my_charset_latin1),
String("Thursday", my_charset_latin1),
String("Friday", my_charset_latin1),
String("Saturday", my_charset_latin1),
String("Sunday", my_charset_latin1)
};
/*
......@@ -396,7 +396,7 @@ String *Item_date::val_str(String *str)
return (String*) 0;
if (!value) // zero daynr
{
str->copy("0000-00-00",10);
str->copy("0000-00-00",10,my_charset_latin1);
return str;
}
if (str->alloc(11))
......@@ -547,7 +547,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);
str->copy(buff, length, my_charset_latin1);
return str;
}
......
......@@ -69,7 +69,7 @@ public:
double val() { return (double) Item_func_month::val_int(); }
String *val_str(String *str)
{
str->set(val_int(), my_thd_charset);
str->set(val_int(), thd_charset());
return null_value ? 0 : str;
}
const char *func_name() const { return "month"; }
......@@ -177,7 +177,7 @@ public:
longlong val_int();
double val() { return (double) val_int(); }
String *val_str(String *str) {
str->set(val_int(), my_thd_charset);
str->set(val_int(), thd_charset());
return null_value ? 0 : str;
}
const char *func_name() const { return "weekday"; }
......@@ -243,7 +243,7 @@ public:
}
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 @@ public:
Field *tmp_table_field(TABLE *t_arg)
{
return (!t_arg) ? result_field : new Field_datetime(maybe_null, name,
t_arg, my_thd_charset);
t_arg, thd_charset());
}
};
......@@ -288,7 +288,7 @@ public:
Field *tmp_table_field(TABLE *t_arg)
{
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 @@ public:
Field *tmp_table_field(TABLE *t_arg)
{
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 @@ public:
Field *tmp_table_field(TABLE *t_arg)
{
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 @@ public:
Field *tmp_table_field(TABLE *t_arg)
{
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 @@ public:
Field *tmp_table_field(TABLE *t_arg)
{
return (!t_arg) ? result_field : new Field_datetime(maybe_null, name,
t_arg, my_thd_charset);
t_arg, thd_charset());
}
};
......@@ -976,7 +976,7 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part,
&min_length,&max_length);
else
{
CHARSET_INFO *charset=((Field_str*)(field))->charset();
CHARSET_INFO *charset=field->charset();
#ifdef USE_STRCOLL
if (use_strnxfrm(charset))
like_error= my_like_range(charset,
......
......@@ -94,7 +94,7 @@ public:
enum_field_types field_type() const { return FIELD_TYPE_STRING; }
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); }
void set(const char *str, uint length) { str_value.copy(str,length, my_thd_charset); }
double val() { return atof(str_value.ptr()); }
longlong val_int() { return strtoll(str_value.ptr(),NULL,10); }
String *val_str(String*)
......
......@@ -896,14 +896,14 @@ int collect_real(double *element, element_count count __attribute__((unused)),
TREE_INFO *info)
{
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)
info->str->append(',');
else
info->found = 1;
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('\'');
return 0;
......
......@@ -271,7 +271,7 @@ static uchar* setup_param_field(Item_param *item_param,
default:
{
ulong len=get_param_length(&pos);
item_param->set_value((const char*)pos,len);
item_param->set_value((const char*)pos,len,current_thd->thd_charset);
pos+=len;
}
}
......@@ -829,7 +829,7 @@ void mysql_stmt_get_longdata(THD *thd, char *pos, ulong packet_length)
sprintf(stmt->last_error, ER(ER_WRONG_ARGUMENTS), "get_longdata");
DBUG_VOID_RETURN;
}
stmt->param[param_number].set_longdata(pos, packet_length-9);
stmt->param[param_number].set_longdata(pos, packet_length-9, current_thd->thd_charset);
stmt->long_data_used= 1;
DBUG_VOID_RETURN;
}
......@@ -4231,9 +4231,7 @@ static bool create_myisam_tmp_table(TABLE *table,TMP_TABLE_PARAM *param,
{
Field *field=keyinfo->key_part[i].field;
seg->flag= 0;
seg->language= field->binary() ? MY_CHARSET_CURRENT :
((Field_str*)field)->charset()->number;
seg->language= field->charset()->number;
seg->length= keyinfo->key_part[i].length;
seg->start= keyinfo->key_part[i].offset;
if (field->flags & BLOB_FLAG)
......
......@@ -117,7 +117,7 @@ bool String::set(double num,uint decimals, CHARSET_INFO *cs)
if (decimals >= NOT_FIXED_DEC)
{
sprintf(buff,"%.14g",num); // Enough for a DATETIME
return copy(buff, (uint32) strlen(buff));
return copy(buff, (uint32) strlen(buff), my_charset_latin1);
}
#ifdef HAVE_FCONVERT
int decpt,sign;
......@@ -182,7 +182,7 @@ end:
#else
sprintf(buff,"%.*f",(int) decimals,num);
#endif
return copy(buff,(uint32) strlen(buff));
return copy(buff,(uint32) strlen(buff), my_charset_latin1);
#endif
}
......@@ -208,13 +208,14 @@ bool String::copy(const String &str)
return FALSE;
}
bool String::copy(const char *str,uint32 arg_length)
bool String::copy(const char *str,uint32 arg_length, CHARSET_INFO *cs)
{
if (alloc(arg_length))
return TRUE;
if ((str_length=arg_length))
memcpy(Ptr,str,arg_length);
Ptr[arg_length]=0;
str_charset=cs;
return FALSE;
}
......
......@@ -178,7 +178,7 @@ public:
bool copy(); // Alloc string if not alloced
bool copy(const String &s); // Allocate new string
bool copy(const char *s,uint32 arg_length); // Allocate new string
bool copy(const char *s,uint32 arg_length, CHARSET_INFO *cs); // Allocate new string
bool append(const String &s);
bool append(const char *s,uint32 arg_length=0);
bool append(IO_CACHE* file, uint32 arg_length);
......
......@@ -392,8 +392,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
outparam->fieldnames.type_names[i],
outparam);
reg_field->comment=comment;
if (!reg_field->binary())
((Field_str*) reg_field)->set_charset(charset);
reg_field->set_charset(charset);
if (!(reg_field->flags & NOT_NULL_FLAG))
{
if ((null_bit<<=1) == 256)
......
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