List:Internals« Previous MessageNext Message »
From:jani Date:September 9 2005 2:30pm
Subject:bk commit into 4.1 tree (jani:1.2417) BUG#10716
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of jani. When jani 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.2417 05/09/09 17:29:57 jani@stripped +3 -0
  Fixed Bug#10716, Procedure Analyse results in wrong values for optimal field type
  Added test case.

  sql/sql_analyse.cc
    1.53 05/09/09 17:29:52 jani@stripped +10 -5
    Fixed Bug#10716, Procedure Analyse results in wrong values for optimal field type
    Added test case.

  mysql-test/t/analyse.test
    1.14 05/09/09 17:29:52 jani@stripped +9 -0
    Fixed Bug#10716, Procedure Analyse results in wrong values for optimal field type
    Added test case.

  mysql-test/r/analyse.result
    1.17 05/09/09 17:29:51 jani@stripped +6 -0
    Fixed Bug#10716, Procedure Analyse results in wrong values for optimal field type
    Added test case.

# 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:	jani
# Host:	a193-229-222-105.elisa-laajakaista.fi
# Root:	/home/my/bk/mysql-4.1

--- 1.52/sql/sql_analyse.cc	2005-06-05 20:38:41 +03:00
+++ 1.53/sql/sql_analyse.cc	2005-09-09 17:29:52 +03:00
@@ -789,18 +789,23 @@
   if (!max_notzero_dec_len)
   {
     if (min_arg >= -128 && max_arg <= (min_arg >= 0 ? 255 : 127))
-      sprintf(buff, "TINYINT(%d)", (int) max_length - (item->decimals + 1));
+      sprintf(buff, "TINYINT(%d)", (int) max_length -
+	      ((item->decimals == NOT_FIXED_DEC) ? 0 : (item->decimals + 1)));
     else if (min_arg >= INT_MIN16 && max_arg <= (min_arg >= 0 ?
 						 UINT_MAX16 : INT_MAX16))
-      sprintf(buff, "SMALLINT(%d)", (int) max_length - (item->decimals + 1));
+      sprintf(buff, "SMALLINT(%d)", (int) max_length -
+	      ((item->decimals == NOT_FIXED_DEC) ? 0 : (item->decimals + 1)));
     else if (min_arg >= INT_MIN24 && max_arg <= (min_arg >= 0 ?
 						 UINT_MAX24 : INT_MAX24))
-      sprintf(buff, "MEDIUMINT(%d)", (int) max_length - (item->decimals + 1));
+      sprintf(buff, "MEDIUMINT(%d)", (int) max_length -
+	      ((item->decimals == NOT_FIXED_DEC) ? 0 : (item->decimals + 1)));
     else if (min_arg >= INT_MIN32 && max_arg <= (min_arg >= 0 ?
 						 UINT_MAX32 : INT_MAX32))
-      sprintf(buff, "INT(%d)", (int) max_length - (item->decimals + 1));
+      sprintf(buff, "INT(%d)", (int) max_length -
+	      ((item->decimals == NOT_FIXED_DEC) ? 0 : (item->decimals + 1)));
     else
-      sprintf(buff, "BIGINT(%d)", (int) max_length - (item->decimals + 1));
+      sprintf(buff, "BIGINT(%d)", (int) max_length -
+	      ((item->decimals == NOT_FIXED_DEC) ? 0 : (item->decimals + 1)));
     answer->append(buff, (uint) strlen(buff));
     if (min_arg >= 0)
       answer->append(" UNSIGNED");

--- 1.16/mysql-test/r/analyse.result	2005-01-18 15:41:02 +02:00
+++ 1.17/mysql-test/r/analyse.result	2005-09-09 17:29:51 +03:00
@@ -102,3 +102,9 @@
 Field_name	Min_value	Max_value	Min_length	Max_length	Empties_or_zeros	Nulls	Avg_value_or_avg_length	Std	Optimal_fieldtype
 test.t1.v	"	\\	1	19	0	0	3.7619	NULL	ENUM('"','""','"c','\'\0\\"','\'','\'\'','\'b','a\0\0\0b','a\0','a""""b','a\'\'\'\'b','abc','abc\'def\\hij"klm\0opq','a\\\\\\\\b','b\'','c"','d\\','The\ZEnd','\\','\\d','\\\\') NOT NULL
 drop table t1;
+create table t1 (d double);
+insert into t1 values (100000);
+select * 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.d	100000	100000	6	6	0	0	100000	0	MEDIUMINT(6) UNSIGNED NOT NULL
+drop table t1;

--- 1.13/mysql-test/t/analyse.test	2005-07-28 03:21:39 +03:00
+++ 1.14/mysql-test/t/analyse.test	2005-09-09 17:29:52 +03:00
@@ -48,4 +48,13 @@
 select * from t1 procedure analyse();
 drop table t1;
 
+#
+# Bug#10716 - Procedure Analyse results in wrong values for optimal field type
+#
+
+create table t1 (d double);
+insert into t1 values (100000);
+select * from t1 procedure analyse (1,1);
+drop table t1;
+
 # End of 4.1 tests
Thread
bk commit into 4.1 tree (jani:1.2417) BUG#10716jani9 Sep