• Sergei Petrunia's avatar
    MDEV-21243: Join buffer: condition is checked in wrong place for range access · 9c3eca85
    Sergei Petrunia authored
    In this scenario:
    - There is a possible range access for table T
    - And there is a ref access on the same index which uses fewer key parts
    - The join optimizer picks the ref access (because it is cheaper)
    - make_join_select applies this heuristic to switch to range:
      /* Range uses longer key;  Use this instead of ref on key */
    
    Join buffer will be used without having called
    JOIN_TAB::make_scan_filter(). This means, conditions that should be
    checked when reading table T will be checked after T is joined with the
    contents of the join buffer, instead.
    
    Fixed this by adding a make_scan_filter() check.
    (updated patch after backport to 10.3)
    (Fix testcase on Windows)
    9c3eca85
sql_select.cc 901 KB