• unknown's avatar
    Fix for bug #34928: Confusion by having Primary Key and Index · b4b72fb3
    unknown authored
    The bug is a regression introduced in 5.1 by the patch for bug28404.
    
    Under some circumstances test_if_skip_sort_order() could leave some
    data structures in an inconsistent state so that some parts of code
    could assume the selected execution strategy for GROUP BY/DISTINCT as
    a loose index scan (e.g. JOIN_TAB::is_using_loose_index_scan()), while
    the actual strategy chosen was an ordered index scan, which led to
    wrong data being returned.
    
    Fixed test_if_skip_sort_order() so that when changing the type for a
    join table, select->quick is reset not only for EXPLAIN, but for the 
    actual join execution as well, to not confuse code that depends on its
    value to determine the chosen GROUP BY/DISTINCT strategy.
    
    
    mysql-test/r/distinct.result:
      Added a test case for bug #34928.
    mysql-test/t/distinct.test:
      Added a test case for bug #34928.
    sql/sql_select.cc:
      When changing the table's join type to JT_NEXT in 
      test_if_skip_sort_order(), also reset select->quick because other
      code may depend on its value to determine the GROUP BY/DISTINCT
      execution strategy.
    b4b72fb3
sql_select.cc 528 KB