Bug #14445 ANALYSE() computes wrong STD value for integer types
Submitted: 28 Oct 2005 22:36 Modified: 1 Nov 2005 12:21
Reporter: Evgeny Potemkin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0 OS:
Assigned to: Alexey Botchkov CPU Architecture:Any

[28 Oct 2005 22:36] Evgeny Potemkin
Description:
*** r/analyse.result    Fri Oct 28 22:18:01 2005
--- r/analyse.reject    Sat Oct 29 01:31:51 2005
***************
*** 138,143 ****
  select product, sum(profit),avg(profit) from t1 group by product with rollup procedure analyse();
  Field_name    Min_value       Max_value       Min_length      Max_length      Empties_or_zeros        Nulls   Avg_value_or_avg_length StdOptimal_fieldtype
  test.t1.product       Computer        TV      2       8       0       0       4.2500  NULL    ENUM('Computer','Phone','TV') NOT NULL
! sum(profit)   10      6900    2       4       0       0       1946    2868    ENUM('10','275','600','6900') NOT NULL
! avg(profit)   10.0000 1380.0000       7       9       0       0       394.6875        570.2003        ENUM('10.0000','68.7500','120.0000','1380.0000') NOT NULL
  drop table t1,t2;
--- 138,143 ----
  select product, sum(profit),avg(profit) from t1 group by product with rollup procedure analyse();
  Field_name    Min_value       Max_value       Min_length      Max_length      Empties_or_zeros        Nulls   Avg_value_or_avg_length StdOptimal_fieldtype
  test.t1.product       Computer        TV      2       8       0       0       4.2500  NULL    ENUM('Computer','Phone','TV') NOT NULL
! sum(profit)   10      6900    11      11      0       0       1946    8223542 ENUM('10','275','600','6900') NOT NULL
! avg(profit)   10.000000000    1380.000000000  21      21      0       0       394.687500000   325128.417968750000000000       ENUM('10.0000','68.7500','120.0000','1380.0000') NOT NULL
  drop table t1,t2;
-------------------------------------------------------
325128.417968750 is wrong

How to repeat:
mysql-test-run analyse

Suggested fix:
sql_analyse.cc:field_decimal::std() should do sqrt() on it's result.
[31 Oct 2005 12:11] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/31680
[1 Nov 2005 8:52] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/31720
[1 Nov 2005 11:58] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/31730