• Gleb Shchepa's avatar
    Bug #39844: Query Crash Mysql Server 5.0.67 · c411a11e
    Gleb Shchepa authored
    Server crashed during a sort order optimization
    of a dependent subquery:
    
    SELECT
        (SELECT t1.a FROM t1, t2
          WHERE t1.a = t2.b AND t2.a = t3.c
          ORDER BY t1.a)
      FROM t3;
    
    
    Bitmap of tables, that the reference to outer table
    column uses, in addition to the regular table bit
    has the OUTER_REF_TABLE_BIT bit set.
    The only_eq_ref_tables function traverses this map
    bit by bit simultaneously with join->map2table list.
    Obviously join->map2table never contains an entry
    for the OUTER_REF_TABLE_BIT pseudo-table, so the
    server crashed there.
    
    
    The only_eq_ref_tables function has been modified
    to traverse regular table bits only like the
    update_depend_map function (resetting of the
    OUTER_REF_TABLE_BIT there is enough, but
    resetting of the whole set of PSEUDO_TABLE_BITS
    is used there for sure).
    c411a11e
sql_select.cc 501 KB