• Sreeharsha Ramanavarapu's avatar
    Bug #20730155: BACKPORT BUG#19699237 TO 5.1 · c788e693
    Sreeharsha Ramanavarapu authored
    Backport from mysql-5.5 to mysql-5.1
    
    Bug# 19699237: UNINITIALIZED VARIABLE IN
                   ITEM_FIELD::STR_RESULT LEADS TO INCORRECT
                   BEHAVIOR
    
    ISSUE:
    ------
    When the following conditions are satisfied in a query, a
    server crash occurs:
    a) Two rows are compared using a NULL-safe equal-to operator.
    b) Each of these rows belong to different charsets.
    
    SOLUTION:
    ---------
    When one charset is converted to another for comparision,
    the constructor of "Item_func_conv_charset" is called.
    This will attempt to use the Item_cache if the string is a
    constant. This check succeeds because the "used_table_map"
    of the Item_cache class is never set to the correct value.
    Since it is mistakenly assumed to be a constant, it tries
    to fetch the relevant null value related fields which are
    yet to be initialized. This results in valgrind issues
    and wrong results.
    
    The fix is to update the "used_table_map" of "Item_cache".
    This will allow "Item_func_conv_charset" to realise that
    this is not a constant.
    c788e693
item.h 104 KB