• unknown's avatar
    Bug #30596 GROUP BY optimization gives wrong result order · 23686646
    unknown authored
    The optimization that uses a unique index to remove GROUP BY, did not 
    ensure that the index was actually used, thus violating the ORDER BY
    that is impled by GROUP BY.
    Fixed by replacing GROUP BY with ORDER BY if the GROUP BY clause contains
    a unique index. In case GROUP BY ... ORDER BY null is used, GROUP BY is
    simply removed.
    
    
    BitKeeper/etc/ignore:
      Added support-files/mysqld_multi.server tests/bug25714 cscope.in.out cscope.out cscope.po.out to the ignore list
    mysql-test/r/distinct.result:
      Bug#30596: Changed test case. 
      Prior to Bug#16458, These queries use temp table and filesort. The
      bug was that they used a temp table. However, that patch removed
      filesort also, in which case we can no longer gurantee correct ordering.
    mysql-test/r/group_by.result:
      Bug#30596: Correct result
    mysql-test/r/innodb_mysql.result:
      Bug#30596: Test case for innodb. Here, as opposed to for MyISAM, row 
      lookup is done using index whenever the index covers the group list.
    mysql-test/t/group_by.test:
      Bug#30596: Test case
    mysql-test/t/innodb_mysql.test:
      Bug#30596: Test case
    sql/sql_select.cc:
      Bug#30596: The fix, replacing GROUP BY with ORDER BY unless 
      ORDER BY [NULL|<constant>]
    23686646
distinct.result 22.4 KB