• unknown's avatar
    Fix for BUG#21787: COUNT(*) + ORDER BY + LIMIT returns wrong result · b017caef
    unknown authored
      
    The problem was due to a prior fix for BUG 9676, which limited
    the rows stored in a temporary table to the LIMIT clause. This
    optimization is not applicable to non-group queries with aggregate
    functions. The fix disables the optimization in this case.
    
    
    mysql-test/r/limit.result:
      Test case for BUG#21787
    mysql-test/t/limit.test:
      Test case for BUG#21787
    sql/sql_select.cc:
      If there is an aggregate function in a non-group query,
      materialize all rows in the temporary table no matter if
      there is a LIMIT clause. This is necessary, since the
      aggregate functions must be computed over all result rows,
      not just the first LIMIT rows.
    b017caef
limit.test 1.85 KB