Some charset code clean-ups
This commit is contained in:
parent
245f453383
commit
6d7d19b860
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
18
sql/item.cc
18
sql/item.cc
@ -313,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..
|
||||
@ -346,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;
|
||||
}
|
||||
|
||||
|
||||
@ -658,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);
|
||||
@ -690,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);
|
||||
@ -763,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)
|
||||
{
|
||||
|
12
sql/item.h
12
sql/item.h
@ -196,14 +196,14 @@ 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_long_end();
|
||||
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
|
||||
{ return item_result_type; }
|
||||
{ return item_result_type; }
|
||||
Item *new_item() { return new Item_param(name); }
|
||||
};
|
||||
|
||||
|
@ -1637,7 +1637,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));
|
||||
|
@ -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)
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user