• Georgi Kodinov's avatar
    Bug #41610: key_infix_len can be overwritten causing some group by queries to · 4d2f047e
    Georgi Kodinov authored
    return no rows
    
    The algorithm of determining the best key for loose index scan is doing a loop
    over the available indexes and selects the one that has the best cost.
    It retrieves the parameters of the current index into a set of variables.
    If the cost of using the current index is lower than the best cost so far it 
    copies these variables into another set of variables that contain the 
    information for the best index so far.
    After having checked all the indexes it uses these variables (outside of the 
    index loop) to create the table read plan object instance.
    The was a single omission : the key_infix/key_infix_len variables were used 
    outside of the loop without being preserved in the loop for the best index 
    so far.
    This causes these variables to get overwritten by the next index(es) checked.
    Fixed by adding variables to hold the data for the current index, passing 
    the new variables to the function that assigns values to them and copying 
    the new variables into the existing ones when selecting a new current best 
    index.
    To avoid further such problems moved the declarations of the variables used 
    to keep information about the current index inside the loop's compound 
    statement.
    4d2f047e
opt_range.cc 302 KB