Commit 54520d97 authored by serg@serg.mylan's avatar serg@serg.mylan

automerged

parents 8f254c1b 510cacbb
......@@ -1435,30 +1435,43 @@ longlong Item_func_find_in_set::val_int()
int diff;
if ((diff=buffer->length() - find->length()) >= 0)
{
const char *f_pos=find->ptr();
const char *f_end=f_pos+find->length();
const char *str=buffer->ptr();
const char *end=str+diff+1;
const char *real_end=str+buffer->length();
uint position=1;
do
{
const char *pos= f_pos;
while (pos != f_end)
{
if (my_toupper(cmp_collation.collation,*str) !=
my_toupper(cmp_collation.collation,*pos))
goto not_found;
str++;
pos++;
}
if (str == real_end || str[0] == separator)
return (longlong) position;
not_found:
while (str < end && str[0] != separator)
str++;
my_wc_t wc;
CHARSET_INFO *cs= cmp_collation.collation;
const char *str_begin= buffer->ptr();
const char *str_end= buffer->ptr();
const char *real_end= str_end+buffer->length();
const uchar *find_str= (const uchar *) find->ptr();
uint find_str_len= find->length();
int position= 0;
while (1)
{
int symbol_len;
if ((symbol_len= cs->cset->mb_wc(cs, &wc, (uchar*) str_end,
(uchar*) real_end)) > 0)
{
const char *substr_end= str_end + symbol_len;
bool is_last_item= (substr_end == real_end);
if (wc == (my_wc_t) separator || is_last_item)
{
position++;
} while (++str <= end);
if (is_last_item)
str_end= substr_end;
if (!my_strnncoll(cs, (const uchar *) str_begin,
str_end - str_begin,
find_str, find_str_len))
return (longlong) position;
else
str_begin= substr_end;
}
str_end= substr_end;
}
else if (str_end - str_begin == 0 &&
find_str_len == 0 &&
wc == (my_wc_t) separator)
return (longlong) ++position;
else
return (longlong) 0;
}
}
return 0;
}
......
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