• Sergei Petrunia's avatar
    MDEV-20371: Invalid reads at plan refinement stage: join->positions... · c8dc866f
    Sergei Petrunia authored
    best_access_path() is called from two optimization phases:
    
    1. Plan choice phase, in choose_plan(). Here, the join prefix being
       considered is in join->positions[]
    
    2. Plan refinement stage, in fix_semijoin_strategies_for_picked_join_order
       Here, the join prefix is in join->best_positions[]
    
    It used to access join->positions[] from stage #2. This didnt cause any
    valgrind or asan failures (as join->positions[] has been written-to before)
    but the effect was similar to that of reading the random data:
    The join prefix we've picked (in join->best_positions) could have
    nothing in common with the join prefix that was last to be considered
    (in join->positions).
    c8dc866f
opt_subselect.h 13.9 KB