• Gleb Shchepa's avatar
    Fixed bug #36632: SELECT DISTINCT from a simple view on an · fc827ae3
    Gleb Shchepa authored
                      InnoDB table, where all selected columns
                      belong to the same unique index key, returns
                      incorrect results
    
    Server executes some queries via QUICK_GROUP_MIN_MAX_SELECT
    (MIN/MAX optimization for queries with GROUP BY or DISTINCT
    clause) and that optimization implies loose index scan, so all
    grouping is done by the QUICK_GROUP_MIN_MAX_SELECT::get_next
    method.
    
    The server does not set the precomputed_group_by flag for some
    QUICK_GROUP_MIN_MAX_SELECT queries and duplicates grouping by
    call to the end_send_group function.
    
    Fix: when the test_if_skip_sort_order function selects loose 
    index scan as a best way to satisfy an ORDER BY/GROUP BY type
    of query, the precomputed_group_by flag has been set to use 
    end_send/end_write functions instead of end_send_group/
    end_write_group functions.
    fc827ae3
group_min_max_innodb.test 5.41 KB