Commit 1b7471a4 authored by unknown's avatar unknown

remove default_charset_info


sql/field.h:
  New function to get charset
parent 9a0253ff
...@@ -251,6 +251,7 @@ public: ...@@ -251,6 +251,7 @@ public:
friend class create_field; friend class create_field;
void make_field(Send_field *); void make_field(Send_field *);
uint size_of() const { return sizeof(*this); } uint size_of() const { return sizeof(*this); }
inline CHARSET_INFO *charset() const { return field_charset; }
inline int cmp_image(char *buff,uint length) inline int cmp_image(char *buff,uint length)
{ {
if (binary()) if (binary())
......
...@@ -205,7 +205,7 @@ ha_rows filesort(TABLE *table, SORT_FIELD *sortorder, uint s_length, ...@@ -205,7 +205,7 @@ ha_rows filesort(TABLE *table, SORT_FIELD *sortorder, uint s_length,
err: err:
#ifdef USE_STRCOLL #ifdef USE_STRCOLL
if (use_strcoll(default_charset_info)) if (param.tmp_buffer)
x_free(param.tmp_buffer); x_free(param.tmp_buffer);
#endif #endif
x_free((gptr) sort_keys); x_free((gptr) sort_keys);
...@@ -470,6 +470,9 @@ static void make_sortkey(register SORTPARAM *param, ...@@ -470,6 +470,9 @@ static void make_sortkey(register SORTPARAM *param,
switch (sort_field->result_type) { switch (sort_field->result_type) {
case STRING_RESULT: case STRING_RESULT:
{ {
// BAR TODO: need checking that it is really Field_str based class
CHARSET_INFO *cs=((Field_str*)(sort_field->field))->charset();
if (item->maybe_null) if (item->maybe_null)
*to++=1; *to++=1;
/* All item->str() to use some extra byte for end null.. */ /* All item->str() to use some extra byte for end null.. */
...@@ -495,7 +498,7 @@ static void make_sortkey(register SORTPARAM *param, ...@@ -495,7 +498,7 @@ static void make_sortkey(register SORTPARAM *param,
length=sort_field->length; length=sort_field->length;
} }
#ifdef USE_STRCOLL #ifdef USE_STRCOLL
if (use_strcoll(default_charset_info)) if(use_strcoll(cs))
{ {
if (item->binary) if (item->binary)
{ {
...@@ -512,8 +515,7 @@ static void make_sortkey(register SORTPARAM *param, ...@@ -512,8 +515,7 @@ static void make_sortkey(register SORTPARAM *param,
memcpy(param->tmp_buffer,from,length); memcpy(param->tmp_buffer,from,length);
from=param->tmp_buffer; from=param->tmp_buffer;
} }
uint tmp_length=my_strnxfrm(default_charset_info, uint tmp_length=my_strnxfrm(cs,to,sort_field->length,
to,sort_field->length,
(unsigned char *) from, length); (unsigned char *) from, length);
if (tmp_length < sort_field->length) if (tmp_length < sort_field->length)
bzero((char*) to+tmp_length,sort_field->length-tmp_length); bzero((char*) to+tmp_length,sort_field->length-tmp_length);
...@@ -526,7 +528,7 @@ static void make_sortkey(register SORTPARAM *param, ...@@ -526,7 +528,7 @@ static void make_sortkey(register SORTPARAM *param,
memcpy(to,res->ptr(),length); memcpy(to,res->ptr(),length);
bzero((char *)to+length,diff); bzero((char *)to+length,diff);
if (!item->binary) if (!item->binary)
case_sort(default_charset_info, (char*) to,length); case_sort(cs, (char*) to,length);
#ifdef USE_STRCOLL #ifdef USE_STRCOLL
} }
#endif #endif
...@@ -923,8 +925,10 @@ sortlength(SORT_FIELD *sortorder, uint s_length) ...@@ -923,8 +925,10 @@ sortlength(SORT_FIELD *sortorder, uint s_length)
{ {
sortorder->length=sortorder->field->pack_length(); sortorder->length=sortorder->field->pack_length();
#ifdef USE_STRCOLL #ifdef USE_STRCOLL
if (use_strcoll(default_charset_info) && !sortorder->field->binary()) // BAR TODO: need checking that it is really Field_str based class
sortorder->length= sortorder->length*default_charset_info->strxfrm_multiply; CHARSET_INFO *cs=((Field_str*)(sortorder->field))->charset();
if (use_strcoll(cs) && !sortorder->field->binary())
sortorder->length= sortorder->length*cs->strxfrm_multiply;
#endif #endif
} }
if (sortorder->field->maybe_null()) if (sortorder->field->maybe_null())
...@@ -932,12 +936,16 @@ sortlength(SORT_FIELD *sortorder, uint s_length) ...@@ -932,12 +936,16 @@ sortlength(SORT_FIELD *sortorder, uint s_length)
} }
else else
{ {
#ifdef USE_STRCOLL
// BAR TODO: need checking that it is really Field_str based class
CHARSET_INFO *cs=((Field_str*)(sortorder->field))->charset();
#endif
switch ((sortorder->result_type=sortorder->item->result_type())) { switch ((sortorder->result_type=sortorder->item->result_type())) {
case STRING_RESULT: case STRING_RESULT:
sortorder->length=sortorder->item->max_length; sortorder->length=sortorder->item->max_length;
#ifdef USE_STRCOLL #ifdef USE_STRCOLL
if (use_strcoll(default_charset_info) && !sortorder->item->binary) if (use_strcoll(cs) && !sortorder->item->binary)
sortorder->length= sortorder->length*default_charset_info->strxfrm_multiply; sortorder->length= sortorder->length*cs->strxfrm_multiply;
#endif #endif
break; break;
case INT_RESULT: case INT_RESULT:
......
...@@ -974,9 +974,10 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part, ...@@ -974,9 +974,10 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part,
&min_length,&max_length); &min_length,&max_length);
else else
{ {
CHARSET_INFO *charset=((Field_str*)(field))->charset();
#ifdef USE_STRCOLL #ifdef USE_STRCOLL
if (use_strcoll(default_charset_info)) if (use_strcoll(charset))
like_error= my_like_range(default_charset_info, like_error= my_like_range(charset,
res->ptr(),res->length(),wild_prefix, res->ptr(),res->length(),wild_prefix,
field_length, min_str+maybe_null, field_length, min_str+maybe_null,
max_str+maybe_null,&min_length,&max_length); max_str+maybe_null,&min_length,&max_length);
...@@ -985,7 +986,7 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part, ...@@ -985,7 +986,7 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part,
like_error=like_range(res->ptr(),res->length(),wild_prefix, like_error=like_range(res->ptr(),res->length(),wild_prefix,
field_length, field_length,
min_str+offset,max_str+offset, min_str+offset,max_str+offset,
default_charset_info->max_sort_char, charset->max_sort_char,
&min_length,&max_length); &min_length,&max_length);
} }
if (like_error) // Can't optimize with LIKE if (like_error) // Can't optimize with LIKE
......
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