• Sergey Glukhov's avatar
    Bug#52005 'JOIN_TAB->dependent' may be incorrectly propageted for multilevel outer joins · 8ede529b
    Sergey Glukhov authored
    There are two problems:
    1. In simplify_joins function we calculate table dependencies. If STRAIGHT_JOIN hint
    is used for whole SELECT we do not count it and as result some dependendecies
    might be lost. It leads to incorrect table order which is returned by
    join_tab_cmp_straight() function.
    2. make_join_statistics() calculate the transitive closure for relations a particular
    JOIN_TAB is 'dependent on'.
    We aggregate the dependent table_map of a JOIN_TAB by adding dependencies from other
    tables which we depend on. However, this may also cause new dependencies to be
    available after we have completed processing a certain JOIN_TAB.
    Both these problems affect condition pushdown and as result condition might be pushed
    into wrong table which leads to crash or even omitted which leads to wrong result.
    The fix:
    1. Use modified 'transitive closure' algorithm provided by Ole John Aske
    2. Update table dependences in simplify_joins according to 
       global STRAIGHT_JOIN hint.
    Note: the patch also fixes bugs 46091 & 51492
    
    
    mysql-test/r/join_outer.result:
      test case
    mysql-test/t/join_outer.test:
      test case
    sql/sql_select.cc:
      1. Use modified 'transitive closure' algorithm provided by Ole John Aske
      2. Update table dependences in simplify_joins according to 
         global STRAIGHT_JOIN hint.
    8ede529b
sql_select.cc 547 KB