• Monty's avatar
    Fixed usage of not initialized memory in LIKE ... ESCAPE · 6033cc85
    Monty authored
    This was noticed wben running "mtr --valgrind main.precedence"
    
    The problem was that Item_func_like::escape could be left unitialized
    when used with views combined with UNIONS like in:
    
    create or replace view v1 as select 2 LIKE 1 ESCAPE 3 IN (SELECT 0 UNION SELECT 1), 2 LIKE 1 ESCAPE (3 IN (SELECT 0 UNION SELECT 1)), (2 LIKE 1 ESCAPE 3) IN (SELECT 0 UNION SELECT 1);
    
    The above query causes in fix_escape_item()
    escape_item->const_during_execution() to be true
    and
    escape_item->const_item() to be false
    
    in which case 'escape' is never calculated.
    
    The fix is to make the main logic of fix_escape_item() out to a
    separate function and call that function once in Item.
    
    Other things:
    - Reorganized fields in Item_func_like class to make it more compact
    6033cc85
item_cmpfunc.h 120 KB