List:Commits« Previous MessageNext Message »
From:eugene Date:March 6 2007 9:58pm
Subject:bk commit into 5.0 tree (evgen:1.2431) BUG#25376
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of evgen. When evgen 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, 2007-03-06 23:58:10+03:00, evgen@stripped +3 -0
  Bug#25376: Incomplete setup of ORDER BY clause results in a wrong result.
  
  Functions over sum functions wasn't set up correctly for the ORDER BY clause
  which leads to a wrong order of the result set.
  
  The split_sum_func() function is called now for each ORDER BY item that
  contains a sum function to set it up correctly.

  mysql-test/r/order_by.result@stripped, 2007-03-06 23:49:17+03:00, evgen@stripped +8 -0
    Added a test case for bug#25376: Incomplete setup of ORDER BY clause results in a
wrong result.

  mysql-test/t/order_by.test@stripped, 2007-03-06 23:49:15+03:00, evgen@stripped +8 -0
    Added a test case for bug#25376: Incomplete setup of ORDER BY clause results in a
wrong result.

  sql/sql_select.cc@stripped, 2007-03-06 23:49:29+03:00, evgen@stripped +11 -0
    Bug#25376: Incomplete setup of ORDER BY clause results in a wrong result.
    The split_sum_func() function is called now for each ORDER BY item that
    contains a sum function to set it up correctly.

# 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:	evgen
# Host:	moonbone.local
# Root:	/mnt/gentoo64/work/25376-bug-5.0-opt-mysql

--- 1.495/sql/sql_select.cc	2007-02-27 11:37:15 +03:00
+++ 1.496/sql/sql_select.cc	2007-03-06 23:49:29 +03:00
@@ -455,6 +455,17 @@
 
   select_lex->fix_prepare_information(thd, &conds, &having);
 
+  if (order)
+  {
+    ORDER *ord;
+    for (ord= order; ord; ord= ord->next)
+    {
+      Item *item= *ord->item;
+      if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM)
+        item->split_sum_func(thd, ref_pointer_array, all_fields);
+    }
+  }
+
   if (having && having->with_sum_func)
     having->split_sum_func2(thd, ref_pointer_array, all_fields,
                             &having, TRUE);

--- 1.59/mysql-test/r/order_by.result	2007-01-10 19:55:54 +03:00
+++ 1.60/mysql-test/r/order_by.result	2007-03-06 23:49:17 +03:00
@@ -926,3 +926,11 @@
 2
 3
 DROP TABLE t1,t2,t3,t4;
+create table t1 (a int, b int, c int);
+insert into t1 values (1,2,3), (9,8,3), (19,4,3), (1,4,9);
+select a,(sum(b)/sum(c)) as ratio from t1 group by a order by sum(b)/sum(c) asc;
+a	ratio
+1	0.5000
+19	1.3333
+9	2.6667
+drop table t1;

--- 1.42/mysql-test/t/order_by.test	2007-01-10 19:55:54 +03:00
+++ 1.43/mysql-test/t/order_by.test	2007-03-06 23:49:15 +03:00
@@ -640,3 +640,11 @@
 ON (t1.a=t2.a AND t1.b=t3.b) order by t2.b;
 
 DROP TABLE t1,t2,t3,t4;
+
+#
+# Bug#25376: Incomplete setup of ORDER BY clause results in a wrong result.
+#
+create table t1 (a int, b int, c int);
+insert into t1 values (1,2,3), (9,8,3), (19,4,3), (1,4,9);
+select a,(sum(b)/sum(c)) as ratio from t1 group by a order by sum(b)/sum(c) asc;
+drop table t1;
Thread
bk commit into 5.0 tree (evgen:1.2431) BUG#25376eugene6 Mar