From: Date: September 28 2006 8:30pm Subject: bk commit into 4.1 tree (iggy:1.2543) BUG#20305 List-Archive: http://lists.mysql.com/commits/12758 X-Bug: 20305 Message-Id: <20060928183024.12B0317749C@ignatz42.dyndns.org> Below is the list of changes that have just been committed into a local 4.1 repository of iggy. When iggy 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-09-28 14:30:20-04:00, iggy@stripped +3 -0 Bug#20305: PROCEDURE ANALYSE() returns wrong M for FLOAT(M, D) and DOUBLE(M, D) mysql-test/r/analyse.result@stripped, 2006-09-28 14:30:18-04:00, iggy@stripped +13 -0 Added Results mysql-test/t/analyse.test@stripped, 2006-09-28 14:30:19-04:00, iggy@stripped +13 -1 Added test cases to make sure field_str and field_real return correctly. sql/sql_analyse.cc@stripped, 2006-09-28 14:30:19-04:00, iggy@stripped +4 -4 According the manaul, when declaring a FLOAT(M, N), N equals the number of decimal places and M equals the total number of digits in the number. # 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: iggy # Host: rolltop.ignatz42.dyndns.org # Root: /mnt/storeage/bug20305/my41-bug20305 --- 1.54/sql/sql_analyse.cc 2006-09-28 14:30:24 -04:00 +++ 1.55/sql/sql_analyse.cc 2006-09-28 14:30:24 -04:00 @@ -709,9 +709,9 @@ else if (num_info.decimals) // DOUBLE(%d,%d) sometime { if (num_info.dval > -FLT_MAX && num_info.dval < FLT_MAX) - sprintf(buff, "FLOAT(%d,%d)", num_info.integers, num_info.decimals); + sprintf(buff, "FLOAT(%d,%d)", (num_info.integers + num_info.decimals), num_info.decimals); else - sprintf(buff, "DOUBLE(%d,%d)", num_info.integers, num_info.decimals); + sprintf(buff, "DOUBLE(%d,%d)", (num_info.integers + num_info.decimals), num_info.decimals); } else if (ev_num_info.llval >= -128 && ev_num_info.ullval <= @@ -818,10 +818,10 @@ else { if (min_arg >= -FLT_MAX && max_arg <= FLT_MAX) - sprintf(buff, "FLOAT(%d,%d)", (int) max_length - (item->decimals + 1), + sprintf(buff, "FLOAT(%d,%d)", (int) max_length - (item->decimals + 1) + max_notzero_dec_len, max_notzero_dec_len); else - sprintf(buff, "DOUBLE(%d,%d)", (int) max_length - (item->decimals + 1), + sprintf(buff, "DOUBLE(%d,%d)", (int) max_length - (item->decimals + 1) + max_notzero_dec_len, max_notzero_dec_len); answer->append(buff, (uint) strlen(buff)); } --- 1.18/mysql-test/r/analyse.result 2006-09-28 14:30:24 -04:00 +++ 1.19/mysql-test/r/analyse.result 2006-09-28 14:30:24 -04:00 @@ -134,3 +134,16 @@ 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; +create table t1 (f1 double(10,5), f2 char(10), f3 double(10,5)); +insert into t1 values (5.999, "5.9999", 5.99999), (9.555, "9.5555", 9.55555); +select f1 from t1 procedure analyse(1, 1); +Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype +test.t1.f1 5.99900 9.55500 7 7 0 0 7.77700 1.77800 FLOAT(4,3) NOT NULL +select f2 from t1 procedure analyse(1, 1); +Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype +test.t1.f2 5.9999 9.5555 6 6 0 0 6.0000 NULL FLOAT(5,4) UNSIGNED NOT NULL +select f3 from t1 procedure analyse(1, 1); +Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype +test.t1.f3 5.99999 9.55555 7 7 0 0 7.77777 1.77778 FLOAT(6,5) NOT NULL +drop table t1; +End of 4.1 tests --- 1.15/mysql-test/t/analyse.test 2006-09-28 14:30:24 -04:00 +++ 1.16/mysql-test/t/analyse.test 2006-09-28 14:30:24 -04:00 @@ -82,4 +82,16 @@ insert into t2 values (1, 'USA'),(2,'India'), (3,'Finland'); select product, sum(profit),avg(profit) from t1 group by product with rollup procedure analyse(); drop table t1,t2; -# End of 4.1 tests + +# +# Bug #20305 PROCEDURE ANALYSE() returns wrong M for FLOAT(M, D) and DOUBLE(M, D) +# + +create table t1 (f1 double(10,5), f2 char(10), f3 double(10,5)); +insert into t1 values (5.999, "5.9999", 5.99999), (9.555, "9.5555", 9.55555); +select f1 from t1 procedure analyse(1, 1); +select f2 from t1 procedure analyse(1, 1); +select f3 from t1 procedure analyse(1, 1); +drop table t1; + +--echo End of 4.1 tests