diff options
author | unknown <bar@bar.mysql.r18.ru> | 2002-11-06 17:01:12 +0400 |
---|---|---|
committer | unknown <bar@bar.mysql.r18.ru> | 2002-11-06 17:01:12 +0400 |
commit | 6d7d19b860e0b3b9443b8059d36fb497029481d6 (patch) | |
tree | 51f69fc95a2c0f5cb568b1512cae6655412ab345 | |
parent | 245f453383489a64c49178d6600df7785e211fe7 (diff) | |
download | mariadb-git-6d7d19b860e0b3b9443b8059d36fb497029481d6.tar.gz |
Some charset code clean-ups
-rw-r--r-- | sql/field.h | 7 | ||||
-rw-r--r-- | sql/field_conv.cc | 6 | ||||
-rw-r--r-- | sql/filesort.cc | 7 | ||||
-rw-r--r-- | sql/ha_heap.cc | 2 | ||||
-rw-r--r-- | sql/ha_myisam.cc | 3 | ||||
-rw-r--r-- | sql/item.cc | 18 | ||||
-rw-r--r-- | sql/item.h | 12 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 2 | ||||
-rw-r--r-- | sql/item_timefunc.cc | 38 | ||||
-rw-r--r-- | sql/opt_range.cc | 2 | ||||
-rw-r--r-- | sql/sql_prepare.cc | 4 | ||||
-rw-r--r-- | sql/sql_select.cc | 4 | ||||
-rw-r--r-- | sql/table.cc | 3 |
13 files changed, 50 insertions, 58 deletions
diff --git a/sql/field.h b/sql/field.h index 6505b2c8462..685b2c95d1f 100644 --- a/sql/field.h +++ b/sql/field.h @@ -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) { diff --git a/sql/field_conv.cc b/sql/field_conv.cc index efb7401779c..ab71f324732 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -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) diff --git a/sql/filesort.cc b/sql/filesort.cc index 13c48b745cd..53af60b0370 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -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; } diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index 6cfd3c881cc..c06421617dd 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -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; diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 64dbcfe2056..c7f0ccf69ee 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -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) { diff --git a/sql/item.cc b/sql/item.cc index d97f8dc4b71..9c70dad045c 100644 --- a/sql/item.cc +++ b/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) { diff --git a/sql/item.h b/sql/item.h index c7c66102b43..fb6bed75d51 100644 --- a/sql/item.h +++ b/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); } }; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 40e9315d786..f930afe14a2 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -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)); diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index b42b78c9c91..e81fecabe96 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -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) }; /* diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 39e6b83221d..9a644553f26 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -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, diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 2cf51f5d72e..08377a10501 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -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; } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 93d48e3e1e0..20d9c1ca208 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -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) diff --git a/sql/table.cc b/sql/table.cc index 6e2df849700..bad453f2cad 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -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) |