• Martin Hansson's avatar
    Bug#42846: wrong result returned for range scan when using · 5ef9ec9d
    Martin Hansson authored
    covering index
          
    When two range predicates were combined under an OR
    predicate, the algorithm tried to merge overlapping ranges
    into one. But the case when a range overlapped several other
    ranges was not handled. This lead to
    
    1) ranges overlapping, which gave repeated results and 
    2) a range that overlapped several other ranges was cut off.  
    
    Fixed by 
    
    1) Making sure that a range got an upper bound equal to the
    next range with a greater minimum.
    2) Removing a continue statement
    
    
    mysql-test/r/group_min_max.result:
      Bug#42846: Changed query plans
    mysql-test/r/range.result:
      Bug#42846: Test result.
    mysql-test/t/range.test:
      Bug#42846: Test case.
    sql/opt_range.cc:
      Bug#42846: The fix. 
      
      Part1: Previously, both endpoints from key2 were copied,
      which is not safe. Since ranges are processed in ascending
      order of minimum endpoints, it is safe to copy the minimum
      endpoint from key2 but not the maximum. The maximum may only
      be copied if there is no other range or the other range's
      minimum is greater than key2's maximum.
    5ef9ec9d
range.test 43.4 KB