Fix for bug #5513: FIND_IN_SET fails if set ends with a comma
This commit is contained in:
parent
74336d596f
commit
c1d25e32ec
@ -64,3 +64,6 @@ find_in_set('a',binary 'A,B,C')
|
|||||||
select find_in_set(binary 'a', 'A,B,C');
|
select find_in_set(binary 'a', 'A,B,C');
|
||||||
find_in_set(binary 'a', 'A,B,C')
|
find_in_set(binary 'a', 'A,B,C')
|
||||||
0
|
0
|
||||||
|
select find_in_set('1','3,1,');
|
||||||
|
find_in_set('1','3,1,')
|
||||||
|
2
|
||||||
|
@ -47,3 +47,8 @@ select find_in_set(binary 'a',binary 'A,B,C');
|
|||||||
select find_in_set('a',binary 'A,B,C');
|
select find_in_set('a',binary 'A,B,C');
|
||||||
select find_in_set(binary 'a', 'A,B,C');
|
select find_in_set(binary 'a', 'A,B,C');
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug5513:FIND_IN_SET fails if set ends with a comma
|
||||||
|
#
|
||||||
|
select find_in_set('1','3,1,');
|
||||||
|
|
||||||
|
@ -1455,10 +1455,11 @@ longlong Item_func_find_in_set::val_int()
|
|||||||
{
|
{
|
||||||
const char *substr_end= str_end + symbol_len;
|
const char *substr_end= str_end + symbol_len;
|
||||||
bool is_last_item= (substr_end == real_end);
|
bool is_last_item= (substr_end == real_end);
|
||||||
if (wc == (my_wc_t) separator || is_last_item)
|
bool is_separator= (wc == (my_wc_t) separator);
|
||||||
|
if (is_separator || is_last_item)
|
||||||
{
|
{
|
||||||
position++;
|
position++;
|
||||||
if (is_last_item)
|
if (is_last_item && !is_separator)
|
||||||
str_end= substr_end;
|
str_end= substr_end;
|
||||||
if (!my_strnncoll(cs, (const uchar *) str_begin,
|
if (!my_strnncoll(cs, (const uchar *) str_begin,
|
||||||
str_end - str_begin,
|
str_end - str_begin,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user