List:Internals« Previous MessageNext Message »
From:holyfoot Date:March 7 2005 12:08pm
Subject:bk commit into 5.0 tree (hf:1.1799) BUG#8464
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of hf. When hf 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
  1.1799 05/03/07 16:08:06 hf@deer.(none) +3 -0
  Fix for bug #8464 (AVG returns incorrect result)
  
  Actually problem was not in AVG function, but in SUM before the AVG in the
  query.

  strings/decimal.c
    1.40 05/03/07 16:07:15 hf@deer.(none) +3 -0
    in this case we also need to make fsizes equal

  mysql-test/t/func_group.test
    1.36 05/03/07 16:07:15 hf@deer.(none) +11 -0
    test case added

  mysql-test/r/func_group.result
    1.37 05/03/07 16:07:15 hf@deer.(none) +10 -0
    appropriate test result

# 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:	hf
# Host:	deer.(none)
# Root:	/home/hf/work/mysql-5.0.8464

--- 1.36/mysql-test/r/func_group.result	Wed Mar  2 00:19:14 2005
+++ 1.37/mysql-test/r/func_group.result	Mon Mar  7 16:07:15 2005
@@ -832,3 +832,13 @@
 1	0.816497	0.666667	1.000000	1.000000
 2	1.118034	1.250000	1.290994	1.666667
 DROP TABLE t1;
+CREATE TABLE t1 (col1 decimal(16,12));
+INSERT INTO t1 VALUES (-5.00000000001),(-5.00000000002),(-5.00000000003),(-5.00000000000),(-5.00000000001),(-5.00000000002);
+insert into t1 select * from t1;
+select col1,count(col1),sum(col1),avg(col1) from t1 group by col1;
+col1	count(col1)	sum(col1)	avg(col1)
+-5.000000000030	2	-10.000000000060	-5.0000000000300000
+-5.000000000020	4	-20.000000000080	-5.0000000000200000
+-5.000000000010	4	-20.000000000040	-5.0000000000100000
+-5.000000000000	2	-10.000000000000	-5.0000000000000000
+DROP TABLE t1;

--- 1.35/mysql-test/t/func_group.test	Wed Mar  2 00:19:14 2005
+++ 1.36/mysql-test/t/func_group.test	Mon Mar  7 16:07:15 2005
@@ -537,3 +537,14 @@
 INSERT INTO t1 VALUES (1,0.00),(1,1.00), (1,2.00), (2,10.00), (2,11.00), (2,12.00), (2,13.00);
 select id, stddev_pop(value1), var_pop(value1), stddev_samp(value1), var_samp(value1) from t1 group by id;
 DROP TABLE t1;
+
+#
+# BUG#8464 decimal AVG returns incorrect result
+#
+
+CREATE TABLE t1 (col1 decimal(16,12));
+INSERT INTO t1 VALUES (-5.00000000001),(-5.00000000002),(-5.00000000003),(-5.00000000000),(-5.00000000001),(-5.00000000002);
+insert into t1 select * from t1;
+select col1,count(col1),sum(col1),avg(col1) from t1 group by col1;
+DROP TABLE t1;
+

--- 1.39/strings/decimal.c	Sun Feb 20 20:25:09 2005
+++ 1.40/strings/decimal.c	Mon Mar  7 16:07:15 2005
@@ -1199,7 +1199,10 @@
   else if (fsize0 > fsize1 && frac1x)
   {
     if (frac0 == frac1)
+    {
       frac1x=frac0x;
+      fsize0= fsize1;
+    }
     else
     {
       frac1++;
Thread
bk commit into 5.0 tree (hf:1.1799) BUG#8464holyfoot7 Mar