Commit bbde41e9 authored by unknown's avatar unknown

Fix for crash in the case of non-string fields

parent 474e6408
...@@ -925,10 +925,13 @@ sortlength(SORT_FIELD *sortorder, uint s_length) ...@@ -925,10 +925,13 @@ 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
// BAR TODO: need checking that it is really Field_str based class if (!sortorder->field->binary())
CHARSET_INFO *cs=((Field_str*)(sortorder->field))->charset(); {
if (use_strcoll(cs) && !sortorder->field->binary()) // BAR TODO: need checking that it is really Field_str based class
sortorder->length= sortorder->length*cs->strxfrm_multiply; CHARSET_INFO *cs=((Field_str*)(sortorder->field))->charset();
if (use_strcoll(cs))
sortorder->length= sortorder->length*cs->strxfrm_multiply;
}
#endif #endif
} }
if (sortorder->field->maybe_null()) if (sortorder->field->maybe_null())
...@@ -937,15 +940,19 @@ sortlength(SORT_FIELD *sortorder, uint s_length) ...@@ -937,15 +940,19 @@ sortlength(SORT_FIELD *sortorder, uint s_length)
else else
{ {
#ifdef USE_STRCOLL #ifdef USE_STRCOLL
// BAR TODO: need checking that it is really Field_str based class
CHARSET_INFO *cs=((Field_str*)(sortorder->field))->charset();
#endif #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(cs) && !sortorder->item->binary) if (!sortorder->item->binary)
sortorder->length= sortorder->length*cs->strxfrm_multiply; {
// BAR TODO: need checking that it is really Field_str based class
CHARSET_INFO *cs=((Field_str*)(sortorder->field))->charset();
if (use_strcoll(cs))
sortorder->length= sortorder->length*cs->strxfrm_multiply;
}
#endif #endif
break; break;
case INT_RESULT: case INT_RESULT:
......
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