Commit 5fb35050 authored by Mayank Prasad's avatar Mayank Prasad

Bug#11766101 : 59140: LIKE CONCAT('%',@A,'%') DOESN'T MATCH WHEN @A CONTAINS LATIN1 STRING

Issue/Cause:
Issue is of memory corruption.During optimization phase, pattern to be matched in where 
clause, is prepared. This is done in Item_func_concat::val_str() function which forms the
resultant string (tmp_value) and return its pointer. In caller, Item_func_like::fix_fields, 
pattern is made to point to this string (tmp_value). In further processing, tmp_value is 
getting modified which causes pattern to have changed/wrong values.

Fix:
Allocate its own memroy location in caller, copy value of resultant string (tmp_value) 
into that and make pattern to point to that. This makes sure no further changes to 
tmp_value will affect pattern.
parent 495d37f9
......@@ -4877,8 +4877,8 @@ bool Item_func_like::fix_fields(THD *thd, Item **ref)
}
if (canDoTurboBM)
{
pattern = first + 1;
pattern_len = (int) len - 2;
pattern = thd->strmake(first + 1, pattern_len);
DBUG_PRINT("info", ("Initializing pattern: '%s'", first));
int *suff = (int*) thd->alloc((int) (sizeof(int)*
((pattern_len + 1)*2+
......
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