From: Date: August 23 2006 2:37pm Subject: bk commit into 4.1 tree (timour:1.2533) BUG#21456 List-Archive: http://lists.mysql.com/commits/10754 X-Bug: 21456 Message-Id: <20060823123715.273911EF11@lamia.home> Below is the list of changes that have just been committed into a local 4.1 repository of timka. When timka does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet@stripped, 2006-08-23 15:37:12+03:00, timour@stripped +2 -0 BUG#21456: SELECT DISTINCT(x) produces incorrect results when using order by GROUP BY/DISTINCT pruning optimization must be done before ORDER BY optimization because ORDER BY may be removed when GROUP BY/DISTINCT sorts as a side effect, e.g. in SELECT DISTINCT , FROM t1 ORDER BY DISTINCT must be removed before ORDER BY as if done the other way around it will remove both. mysql-test/r/distinct.result@stripped, 2006-08-23 15:37:10+03:00, timour@stripped +11 -0 Test for BUG#21456. mysql-test/t/distinct.test@stripped, 2006-08-23 15:37:10+03:00, timour@stripped +11 -0 Test for BUG#21456. # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: timour # Host: lamia.home # Root: /home/timka/mysql/src/4.1-bug-21456 --- 1.33/mysql-test/r/distinct.result 2006-08-23 15:37:15 +03:00 +++ 1.34/mysql-test/r/distinct.result 2006-08-23 15:37:15 +03:00 @@ -555,3 +555,14 @@ EXPLAIN SELECT DISTINCT a,b,d FROM t2 GR id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 DROP TABLE t1,t2; +CREATE TABLE t1 (a int primary key, b int); +INSERT INTO t1 (a,b) values (1,1), (2,3), (3,2); +explain SELECT DISTINCT a, b FROM t1 ORDER BY b; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort +SELECT DISTINCT a, b FROM t1 ORDER BY b; +a b +1 1 +3 2 +2 3 +DROP TABLE t1; --- 1.18/mysql-test/t/distinct.test 2006-08-23 15:37:15 +03:00 +++ 1.19/mysql-test/t/distinct.test 2006-08-23 15:37:15 +03:00 @@ -378,4 +378,15 @@ EXPLAIN SELECT DISTINCT a,b,d FROM t2 GR DROP TABLE t1,t2; +# +# Bug 21456: SELECT DISTINCT(x) produces incorrect results when using order by +# +CREATE TABLE t1 (a int primary key, b int); + +INSERT INTO t1 (a,b) values (1,1), (2,3), (3,2); + +explain SELECT DISTINCT a, b FROM t1 ORDER BY b; +SELECT DISTINCT a, b FROM t1 ORDER BY b; +DROP TABLE t1; + # End of 4.1 tests