• Sergei Golubchik's avatar
    MDEV-12580 Wrong query result in join when using an index (Version > "10.2.3") · d53eb859
    Sergei Golubchik authored
    JOIN_TAB::remove_redundant_bnl_scan_conds() removes select_cond
    from a JOIN_TAB if join cache is enabled, and tab->cache_select->cond
    is the equal to tab->select_cond.
    
    But after 8d99166c the code to initialize join cache was moved
    to happen much later than JOIN_TAB::remove_redundant_bnl_scan_conds(),
    and that code might, under certain conditions, revert to *not* using
    join cache (set_join_cache_denial()).
    
    If JOIN_TAB::remove_redundant_bnl_scan_conds() removes the WHERE
    condition from the JOIN_TAB and later set_join_cache_denial() disables
    join cache, we end up with no WHERE condition at all.
    
    Fix: move JOIN_TAB::remove_redundant_bnl_scan_conds() to happen
    after all possible set_join_cache_denial() calls.
    d53eb859
limit_rows_examined.result 36.3 KB