List:Internals« Previous MessageNext Message »
From:holyfoot Date:April 20 2005 7:53am
Subject:bk commit into 5.0 tree (hf:1.1823)
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.1823 05/04/20 10:53:03 hf@deer.(none) +19 -0
  Added unsigned_flag parameter to count max_length properly

  sql/sql_select.cc
    1.316 05/04/20 10:52:58 hf@deer.(none) +2 -2
    item->unsigned_flag checked

  sql/sql_parse.cc
    1.442 05/04/20 10:52:58 hf@deer.(none) +3 -2
    UNSIGNED_FLAG checked

  sql/my_decimal.h
    1.10 05/04/20 10:52:58 hf@deer.(none) +6 -4
    unsigned_flag used to count decimal's length

  sql/item_sum.cc
    1.140 05/04/20 10:52:58 hf@deer.(none) +9 -6
    unsigned_flag argument added

  sql/item_func.h
    1.106 05/04/20 10:52:58 hf@deer.(none) +1 -1
    we need different fix_length_and_dec for Item_func_round

  sql/item_func.cc
    1.182 05/04/20 10:52:58 hf@deer.(none) +68 -18
    unsigned_flag checks added

  sql/item_cmpfunc.cc
    1.145 05/04/20 10:52:58 hf@deer.(none) +4 -1
    unsigned_flag checks added

  sql/item.cc
    1.111 05/04/20 10:52:58 hf@deer.(none) +8 -6
    unsigned_flag added

  sql/field.h
    1.154 05/04/20 10:52:57 hf@deer.(none) +2 -1
    unsigned_arg added

  sql/field.cc
    1.257 05/04/20 10:52:57 hf@deer.(none) +5 -4
    unsigned flag now is used to count max_length

  mysql-test/r/type_newdecimal.result
    1.8 05/04/20 10:52:57 hf@deer.(none) +5 -5
    test result fixed

  mysql-test/r/ps_7ndb.result
    1.26 05/04/20 10:52:57 hf@deer.(none) +2 -2
    test result fixed

  mysql-test/r/ps_6bdb.result
    1.28 05/04/20 10:52:57 hf@deer.(none) +2 -2
    test result fixed

  mysql-test/r/ps_5merge.result
    1.27 05/04/20 10:52:57 hf@deer.(none) +4 -4
    test result fixed

  mysql-test/r/ps_4heap.result
    1.26 05/04/20 10:52:57 hf@deer.(none) +2 -2
    test result fixed

  mysql-test/r/ps_3innodb.result
    1.30 05/04/20 10:52:57 hf@deer.(none) +2 -2
    test result fixed

  mysql-test/r/ps_2myisam.result
    1.27 05/04/20 10:52:57 hf@deer.(none) +2 -2
    test result fixed

  mysql-test/r/metadata.result
    1.13 05/04/20 10:52:57 hf@deer.(none) +1 -1
    test result fixed

  mysql-test/r/case.result
    1.22 05/04/20 10:52:57 hf@deer.(none) +4 -4
    test result fixed

# 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.8425

--- 1.256/sql/field.cc	Wed Apr 13 12:06:50 2005
+++ 1.257/sql/field.cc	Wed Apr 20 10:52:57 2005
@@ -2242,7 +2242,7 @@
              unireg_check_arg, field_name_arg, table_arg,
              dec_arg, zero_arg, unsigned_arg)
 {
-  precision= my_decimal_length2precision(len_arg, dec_arg);
+  precision= my_decimal_length2precision(len_arg, dec_arg, unsigned_arg);
   DBUG_ASSERT((precision <= DECIMAL_MAX_PRECISION) &&
               (dec <= DECIMAL_MAX_SCALE));
   bin_size= my_decimal_get_binary_size(precision, dec);
@@ -2253,14 +2253,15 @@
                                      bool maybe_null,
                                      const char *name,
                                      struct st_table *t_arg,
-                                     uint8 dec_arg)
+                                     uint8 dec_arg,
+                                     bool unsigned_arg)
   :Field_num((char*) 0, len_arg,
              maybe_null ? (uchar*) "": 0, 0,
              NONE, name, t_arg,
              dec_arg,
-             0, 0)
+             0, unsigned_arg)
 {
-  precision= my_decimal_length2precision(len_arg, dec_arg);
+  precision= my_decimal_length2precision(len_arg, dec_arg, unsigned_arg);
   DBUG_ASSERT((precision <= DECIMAL_MAX_PRECISION) &&
               (dec <= DECIMAL_MAX_SCALE));
   bin_size= my_decimal_get_binary_size(precision, dec);

--- 1.153/sql/field.h	Wed Apr 13 12:06:50 2005
+++ 1.154/sql/field.h	Wed Apr 20 10:52:57 2005
@@ -444,7 +444,8 @@
                     uint8 dec_arg, bool zero_arg, bool unsigned_arg);
   Field_new_decimal(uint32 len_arg, bool maybe_null_arg,
                     const char *field_name_arg,
-                    struct st_table *table_arg, uint8 dec_arg);
+                    struct st_table *table_arg, uint8 dec_arg,
+                    bool unsigned_arg);
   enum_field_types type() const { return FIELD_TYPE_NEWDECIMAL;}
   enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
   Item_result result_type () const { return DECIMAL_RESULT; }

--- 1.110/sql/item.cc	Wed Apr 13 16:22:30 2005
+++ 1.111/sql/item.cc	Wed Apr 20 10:52:58 2005
@@ -1365,9 +1365,9 @@
   name= (char*) str_arg;
   decimals= (uint8) decimal_value.frac;
   precision= decimal_value.intg + decimal_value.frac;
-  max_length= my_decimal_max_length(&decimal_value);
   fixed= 1;
   unsigned_flag= !decimal_value.sign();
+  max_length= my_decimal_precision2length(precision, decimals, unsigned_flag);
 }
 
 Item_decimal::Item_decimal(longlong val, bool unsig)
@@ -1399,9 +1399,9 @@
   name= (char*) str;
   decimals= (uint8) decimal_par;
   max_length= length;
-  precision= my_decimal_length2precision(length, decimals);
-  fixed= 1;
   unsigned_flag= !decimal_value.sign();
+  precision= my_decimal_length2precision(length, decimals, unsigned_flag);
+  fixed= 1;
 }
 
 
@@ -4955,14 +4955,16 @@
   }
   if (Field::result_merge_type(fld_type) == DECIMAL_RESULT)
   {
-    int item_precision= my_decimal_length2precision(display_length(item),
-                                                    item->decimals);
+    int item_precision=
+      my_decimal_length2precision(display_length(item),
+                                  item->decimals, item->unsigned_flag);
     int intp1= my_decimal_int_part(item_precision, item->decimals);
     int intp2= my_decimal_int_part(precision, decimals);
 
     decimals= min(max(decimals, item->decimals), DECIMAL_MAX_SCALE);
     precision= min(max(intp1, intp2) + decimals, DECIMAL_MAX_PRECISION);
-    max_length= my_decimal_precision2length(precision, decimals);
+    unsigned_flag&= item->unsigned_flag;
+    max_length= my_decimal_precision2length(precision, decimals, unsigned_flag);
   }
   else
     max_length= max(max_length, display_length(item));

--- 1.144/sql/item_cmpfunc.cc	Wed Apr 13 12:06:50 2005
+++ 1.145/sql/item_cmpfunc.cc	Wed Apr 20 10:52:58 2005
@@ -1254,7 +1254,7 @@
                     args[2]->precision - args[2]->decimals) +
                 decimals);
     set_if_smaller(precision, DECIMAL_MAX_PRECISION);
-    max_length= my_decimal_precision2length(precision, decimals);
+    max_length= my_decimal_precision2length(precision, decimals, unsigned_flag);
   }
   else
   {
@@ -1620,17 +1620,20 @@
   max_length=0;
   decimals=0;
   precision=0;
+  unsigned_flag= TRUE;
   for (uint i=0 ; i < ncases ; i+=2)
   {
     set_if_bigger(max_length,args[i+1]->max_length);
     set_if_bigger(decimals,args[i+1]->decimals);
     set_if_bigger(precision, args[i+1]->precision);
+    unsigned_flag&= args[i+1]->unsigned_flag;
   }
   if (else_expr_num != -1) 
   {
     set_if_bigger(max_length,args[else_expr_num]->max_length);
     set_if_bigger(decimals,args[else_expr_num]->decimals);
     set_if_bigger(precision, args[else_expr_num]->precision);
+    unsigned_flag&= args[else_expr_num]->unsigned_flag;
   }
 }
 

--- 1.181/sql/item_func.cc	Wed Apr 13 10:38:23 2005
+++ 1.182/sql/item_func.cc	Wed Apr 20 10:52:58 2005
@@ -534,7 +534,10 @@
     res= make_string_field(t_arg);
     break;
   case DECIMAL_RESULT:
-    res= new Field_new_decimal(max_length, maybe_null, name, t_arg, decimals);
+    res= new Field_new_decimal(my_decimal_precision2length(precision,
+                                                           decimals,
+                                                           unsigned_flag),
+                               maybe_null, name, t_arg, decimals, unsigned_flag);
     break;
   case ROW_RESULT:
   default:
@@ -598,7 +601,7 @@
     set_if_bigger(max_int_part, args[i]->precision - args[i]->decimals);
   }
   precision= min(max_int_part + decimals, DECIMAL_MAX_PRECISION);
-  max_length= my_decimal_precision2length(precision, decimals);
+  max_length= my_decimal_precision2length(precision, decimals, unsigned_flag);
 }
 
 
@@ -1023,7 +1026,7 @@
   int max_int_part= max(args[0]->precision - args[0]->decimals,
                         args[1]->precision - args[1]->decimals);
   precision= min(max_int_part + 1 + decimals, DECIMAL_MAX_PRECISION);
-  max_length= my_decimal_precision2length(precision, decimals);
+  max_length= my_decimal_precision2length(precision, decimals, unsigned_flag);
 }
 
 
@@ -1122,7 +1125,7 @@
   decimals= min(args[0]->decimals + args[1]->decimals, DECIMAL_MAX_SCALE);
   precision= min(args[0]->precision + args[1]->precision,
                  DECIMAL_MAX_PRECISION);
-  max_length= my_decimal_precision2length(precision, decimals);
+  max_length= my_decimal_precision2length(precision, decimals, unsigned_flag);
 }
 
 
@@ -1172,7 +1175,7 @@
   decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
   uint precision= min(args[0]->precision + prec_increment,
                       DECIMAL_MAX_PRECISION);
-  max_length= my_decimal_precision2length(precision, decimals);
+  max_length= my_decimal_precision2length(precision, decimals, unsigned_flag);
 }
 
 
@@ -1745,24 +1748,71 @@
 }
 
 
-void Item_func_round::fix_num_length_and_dec()
+void Item_func_round::fix_length_and_dec()
 {
-  max_length= args[0]->max_length;
-  precision= args[0]->precision;
-  decimals= NOT_FIXED_DEC;
-  if (args[1]->const_item())
+  unsigned_flag= args[0]->unsigned_flag;
+  if (!args[1]->const_item())
+  {
+    max_length= args[0]->max_length;
+    precision= args[0]->precision;
+    decimals= args[0]->decimals;
+    hybrid_type= REAL_RESULT;
+    return;
+  }
+  
+  int decimals_to_set= max(args[1]->val_int(), 0);
+  if (args[0]->decimals == NOT_FIXED_DEC)
+  {
+    max_length= args[0]->max_length;
+    precision= args[0]->precision;
+    decimals= min(decimals_to_set, NOT_FIXED_DEC);
+    hybrid_type= REAL_RESULT;
+    return;
+  }
+  
+  switch (args[0]->result_type())
+  {
+  case REAL_RESULT:
+  case STRING_RESULT:
+    hybrid_type= REAL_RESULT;
+    decimals= decimals_to_set;
+    max_length= float_length(decimals);
+    precision= max_length;
+    break;
+  case INT_RESULT:
+    if (truncate || (args[0]->precision < DECIMAL_LONGLONG_DIGITS))
+    {
+      /* Here we can keep INT_RESULT */
+      hybrid_type= INT_RESULT;
+      int length_can_increase= !truncate && (args[1]->val_int() < 0);
+      max_length= args[0]->max_length + length_can_increase;
+      precision= args[0]->precision + length_can_increase;
+      decimals= 0;
+      break;
+    }
+  case DECIMAL_RESULT:
   {
-    int tmp=(int) args[1]->val_int();
-    if (tmp < 0)
-      decimals=0;
+    hybrid_type= DECIMAL_RESULT;
+    int decimals_delta= args[0]->decimals - decimals_to_set;
+    if (decimals_delta > 0)
+    {
+      int length_increase= truncate ? 0:1;
+      max_length= args[0]->max_length - decimals_delta + length_increase;
+      precision= args[0]->precision - decimals_delta + length_increase;
+      decimals= decimals_to_set;
+    }
     else
-      decimals=min(tmp, NOT_FIXED_DEC);
-    tmp= args[0]->decimals - decimals - 1;
-    if (tmp>0)
     {
-      precision-= tmp;
-      max_length-= tmp;
+      int length_can_increase= !truncate &&
+        (args[1]->val_int() < args[0]->decimals);
+      max_length= args[0]->max_length;
+      precision= args[0]->precision;
+      decimals= args[0]->decimals;
     }
+    break;
+  }
+  default:
+    DBUG_ASSERT(0); /* This result type isn't handled */
   }
 }
 

--- 1.105/sql/item_func.h	Wed Apr 13 12:06:50 2005
+++ 1.106/sql/item_func.h	Wed Apr 20 10:52:58 2005
@@ -596,7 +596,7 @@
   double real_op();
   longlong int_op();
   my_decimal *decimal_op(my_decimal *);
-  void fix_num_length_and_dec();
+  void fix_length_and_dec();
 };
 
 

--- 1.139/sql/item_sum.cc	Wed Apr 13 12:06:50 2005
+++ 1.140/sql/item_sum.cc	Wed Apr 20 10:52:58 2005
@@ -160,7 +160,8 @@
                                  collation.collation);
     return make_string_field(table);
   case DECIMAL_RESULT:
-    return new Field_new_decimal(max_length, maybe_null, name, table, decimals);
+    return new Field_new_decimal(max_length, maybe_null, name, table,
+                                 decimals, unsigned_flag);
   case ROW_RESULT:
   default:
     // This case should never be choosen
@@ -382,7 +383,7 @@
     /* SUM result can't be longer than length(arg) + length(MAX_ROWS) */
     precision=  min(args[0]->precision + DECIMAL_LONGLONG_DIGITS,
                     DECIMAL_MAX_PRECISION);
-    max_length= my_decimal_precision2length(precision, decimals);
+    max_length= my_decimal_precision2length(precision, decimals, unsigned_flag);
     curr_dec_buff= 0;
     hybrid_type= DECIMAL_RESULT;
     my_decimal_set_zero(dec_buffs);
@@ -802,7 +803,7 @@
   {
     decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
     precision= min(args[0]->precision + prec_increment, DECIMAL_MAX_PRECISION);
-    max_length= my_decimal_precision2length(precision, decimals);
+    max_length= my_decimal_precision2length(precision, decimals, unsigned_flag);
     f_precision= min(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION);
     f_scale=  args[0]->decimals;
     dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale);
@@ -834,7 +835,8 @@
                        0, name, table, &my_charset_bin);
   }
   if (hybrid_type == DECIMAL_RESULT)
-    return new Field_new_decimal(max_length, maybe_null, name, table, decimals);
+    return new Field_new_decimal(max_length, maybe_null, name, table,
+                                 decimals, unsigned_flag);
   return new Field_double(max_length, maybe_null, name, table, decimals);
 }
 
@@ -954,7 +956,7 @@
   case DECIMAL_RESULT:
     decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE);
     precision= min(args[0]->precision + prec_increment, DECIMAL_MAX_PRECISION);
-    max_length= my_decimal_precision2length(precision, decimals);
+    max_length= my_decimal_precision2length(precision, decimals, unsigned_flag);
     cur_dec= 0;
     hybrid_type= DECIMAL_RESULT;
     my_decimal_set_zero(dec_sum);
@@ -1011,7 +1013,8 @@
                             0, name, table, &my_charset_bin);
   }
   if (hybrid_type == DECIMAL_RESULT)
-    return new Field_new_decimal(max_length, maybe_null, name, table, decimals);
+    return new Field_new_decimal(max_length, maybe_null, name, table,
+                                 decimals, unsigned_flag);
   return new Field_double(max_length, maybe_null,name,table,decimals);
 }
 

--- 1.441/sql/sql_parse.cc	Wed Apr 13 12:06:51 2005
+++ 1.442/sql/sql_parse.cc	Wed Apr 20 10:52:58 2005
@@ -5403,8 +5403,9 @@
     if (new_field->length <= DECIMAL_MAX_PRECISION &&
         new_field->length >= new_field->decimals)
     {
-      new_field->length= my_decimal_precision2length(new_field->length,
-                                                     new_field->decimals);
+      new_field->length=
+        my_decimal_precision2length(new_field->length, new_field->decimals,
+                                    type_modifier & UNSIGNED_FLAG);
       break;
     }
     my_error(ER_WRONG_FIELD_SPEC, MYF(0), field_name);

--- 1.315/sql/sql_select.cc	Wed Apr 13 12:06:52 2005
+++ 1.316/sql/sql_select.cc	Wed Apr 20 10:52:58 2005
@@ -7828,8 +7828,8 @@
       new_field= item->make_string_field(table);
     break;
   case DECIMAL_RESULT:
-    new_field= new Field_new_decimal(item->max_length, maybe_null,
-                                     item->name, table, item->decimals);
+    new_field= new Field_new_decimal(item->max_length, maybe_null, item->name,
+                                     table, item->decimals, item->unsigned_flag);
     break;
   case ROW_RESULT:
   default:

--- 1.26/mysql-test/r/ps_2myisam.result	Wed Apr 13 16:22:29 2005
+++ 1.27/mysql-test/r/ps_2myisam.result	Wed Apr 20 10:52:57 2005
@@ -1776,7 +1776,7 @@
 t5	CREATE TABLE `t5` (
   `const01` bigint(1) NOT NULL default '0',
   `param01` bigint(20) default NULL,
-  `const02` decimal(2,1) NOT NULL default '0.0',
+  `const02` decimal(2,1) unsigned NOT NULL default '0.0',
   `param02` decimal(65,30) default NULL,
   `const03` double NOT NULL default '0',
   `param03` double default NULL,
@@ -1806,7 +1806,7 @@
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max
length	Is_null	Flags	Decimals	Charsetnr
 def	test	t5	t5	const01	const01	8	1	1	N	32769	0	63
 def	test	t5	t5	param01	param01	8	20	1	Y	32768	0	63
-def	test	t5	t5	const02	const02	246	4	3	N	1	1	63
+def	test	t5	t5	const02	const02	246	3	3	N	33	1	63
 def	test	t5	t5	param02	param02	246	67	32	Y	0	30	63
 def	test	t5	t5	const03	const03	5	17	1	N	32769	31	63
 def	test	t5	t5	param03	param03	5	20	1	Y	32768	31	63

--- 1.29/mysql-test/r/ps_3innodb.result	Wed Apr 13 16:22:29 2005
+++ 1.30/mysql-test/r/ps_3innodb.result	Wed Apr 20 10:52:57 2005
@@ -1759,7 +1759,7 @@
 t5	CREATE TABLE `t5` (
   `const01` bigint(1) NOT NULL default '0',
   `param01` bigint(20) default NULL,
-  `const02` decimal(2,1) NOT NULL default '0.0',
+  `const02` decimal(2,1) unsigned NOT NULL default '0.0',
   `param02` decimal(65,30) default NULL,
   `const03` double NOT NULL default '0',
   `param03` double default NULL,
@@ -1789,7 +1789,7 @@
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max
length	Is_null	Flags	Decimals	Charsetnr
 def	test	t5	t5	const01	const01	8	1	1	N	32769	0	63
 def	test	t5	t5	param01	param01	8	20	1	Y	32768	0	63
-def	test	t5	t5	const02	const02	246	4	3	N	1	1	63
+def	test	t5	t5	const02	const02	246	3	3	N	33	1	63
 def	test	t5	t5	param02	param02	246	67	32	Y	0	30	63
 def	test	t5	t5	const03	const03	5	17	1	N	32769	31	63
 def	test	t5	t5	param03	param03	5	20	1	Y	32768	31	63

--- 1.25/mysql-test/r/ps_4heap.result	Wed Apr 13 16:22:29 2005
+++ 1.26/mysql-test/r/ps_4heap.result	Wed Apr 20 10:52:57 2005
@@ -1760,7 +1760,7 @@
 t5	CREATE TABLE `t5` (
   `const01` bigint(1) NOT NULL default '0',
   `param01` bigint(20) default NULL,
-  `const02` decimal(2,1) NOT NULL default '0.0',
+  `const02` decimal(2,1) unsigned NOT NULL default '0.0',
   `param02` decimal(65,30) default NULL,
   `const03` double NOT NULL default '0',
   `param03` double default NULL,
@@ -1790,7 +1790,7 @@
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max
length	Is_null	Flags	Decimals	Charsetnr
 def	test	t5	t5	const01	const01	8	1	1	N	32769	0	63
 def	test	t5	t5	param01	param01	8	20	1	Y	32768	0	63
-def	test	t5	t5	const02	const02	246	4	3	N	1	1	63
+def	test	t5	t5	const02	const02	246	3	3	N	33	1	63
 def	test	t5	t5	param02	param02	246	67	32	Y	0	30	63
 def	test	t5	t5	const03	const03	5	17	1	N	32769	31	63
 def	test	t5	t5	param03	param03	5	20	1	Y	32768	31	63

--- 1.26/mysql-test/r/ps_5merge.result	Wed Apr 13 16:22:29 2005
+++ 1.27/mysql-test/r/ps_5merge.result	Wed Apr 20 10:52:57 2005
@@ -1696,7 +1696,7 @@
 t5	CREATE TABLE `t5` (
   `const01` bigint(1) NOT NULL default '0',
   `param01` bigint(20) default NULL,
-  `const02` decimal(2,1) NOT NULL default '0.0',
+  `const02` decimal(2,1) unsigned NOT NULL default '0.0',
   `param02` decimal(65,30) default NULL,
   `const03` double NOT NULL default '0',
   `param03` double default NULL,
@@ -1726,7 +1726,7 @@
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max
length	Is_null	Flags	Decimals	Charsetnr
 def	test	t5	t5	const01	const01	8	1	1	N	32769	0	63
 def	test	t5	t5	param01	param01	8	20	1	Y	32768	0	63
-def	test	t5	t5	const02	const02	246	4	3	N	1	1	63
+def	test	t5	t5	const02	const02	246	3	3	N	33	1	63
 def	test	t5	t5	param02	param02	246	67	32	Y	0	30	63
 def	test	t5	t5	const03	const03	5	17	1	N	32769	31	63
 def	test	t5	t5	param03	param03	5	20	1	Y	32768	31	63
@@ -4709,7 +4709,7 @@
 t5	CREATE TABLE `t5` (
   `const01` bigint(1) NOT NULL default '0',
   `param01` bigint(20) default NULL,
-  `const02` decimal(2,1) NOT NULL default '0.0',
+  `const02` decimal(2,1) unsigned NOT NULL default '0.0',
   `param02` decimal(65,30) default NULL,
   `const03` double NOT NULL default '0',
   `param03` double default NULL,
@@ -4739,7 +4739,7 @@
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max
length	Is_null	Flags	Decimals	Charsetnr
 def	test	t5	t5	const01	const01	8	1	1	N	32769	0	63
 def	test	t5	t5	param01	param01	8	20	1	Y	32768	0	63
-def	test	t5	t5	const02	const02	246	4	3	N	1	1	63
+def	test	t5	t5	const02	const02	246	3	3	N	33	1	63
 def	test	t5	t5	param02	param02	246	67	32	Y	0	30	63
 def	test	t5	t5	const03	const03	5	17	1	N	32769	31	63
 def	test	t5	t5	param03	param03	5	20	1	Y	32768	31	63

--- 1.27/mysql-test/r/ps_6bdb.result	Wed Apr 13 16:22:30 2005
+++ 1.28/mysql-test/r/ps_6bdb.result	Wed Apr 20 10:52:57 2005
@@ -1759,7 +1759,7 @@
 t5	CREATE TABLE `t5` (
   `const01` bigint(1) NOT NULL default '0',
   `param01` bigint(20) default NULL,
-  `const02` decimal(2,1) NOT NULL default '0.0',
+  `const02` decimal(2,1) unsigned NOT NULL default '0.0',
   `param02` decimal(65,30) default NULL,
   `const03` double NOT NULL default '0',
   `param03` double default NULL,
@@ -1789,7 +1789,7 @@
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max
length	Is_null	Flags	Decimals	Charsetnr
 def	test	t5	t5	const01	const01	8	1	1	N	32769	0	63
 def	test	t5	t5	param01	param01	8	20	1	Y	32768	0	63
-def	test	t5	t5	const02	const02	246	4	3	N	1	1	63
+def	test	t5	t5	const02	const02	246	3	3	N	33	1	63
 def	test	t5	t5	param02	param02	246	67	32	Y	0	30	63
 def	test	t5	t5	const03	const03	5	17	1	N	32769	31	63
 def	test	t5	t5	param03	param03	5	20	1	Y	32768	31	63

--- 1.7/mysql-test/r/type_newdecimal.result	Wed Apr 13 16:22:30 2005
+++ 1.8/mysql-test/r/type_newdecimal.result	Wed Apr 20 10:52:57 2005
@@ -174,10 +174,10 @@
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
-  `round(15.4,-1)` decimal(4,0) NOT NULL default '0',
-  `truncate(-5678.123451,-3)` decimal(7,0) NOT NULL default '0',
-  `abs(-1.1)` decimal(3,1) NOT NULL default '0.0',
-  `-(-1.1)` decimal(4,1) NOT NULL default '0.0'
+  `round(15.4,-1)` decimal(3,0) unsigned NOT NULL default '0',
+  `truncate(-5678.123451,-3)` decimal(4,0) NOT NULL default '0',
+  `abs(-1.1)` decimal(2,1) NOT NULL default '0.0',
+  `-(-1.1)` decimal(2,1) NOT NULL default '0.0'
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 drop table t1;
 set session sql_mode='traditional';
@@ -783,7 +783,7 @@
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
-  `0.5` decimal(2,1) NOT NULL default '0.0'
+  `0.5` decimal(2,1) unsigned NOT NULL default '0.0'
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 drop table t1;
 select round(1.5),round(2.5);

--- 1.9/sql/my_decimal.h	Wed Apr 13 16:22:30 2005
+++ 1.10/sql/my_decimal.h	Wed Apr 20 10:52:58 2005
@@ -132,15 +132,17 @@
   return result;
 }
 
-inline uint my_decimal_length2precision(uint length, uint scale)
+inline uint my_decimal_length2precision(uint length, uint scale,
+                                        bool unsigned_flag)
 {
 
-  return (uint) (length - (scale>0 ? 1:0) - 1);
+  return (uint) (length - (scale>0 ? 1:0) - (unsigned_flag ? 0:1));
 }
 
-inline uint32 my_decimal_precision2length(uint precision, uint8 scale)
+inline uint32 my_decimal_precision2length(uint precision, uint8 scale,
+                                          bool unsigned_flag)
 {
-  return (uint32)(precision + (scale>0 ? 1:0) + 1);
+  return (uint32)(precision + (scale>0 ? 1:0) + (unsigned_flag ? 0:1));
 }
 
 inline

--- 1.25/mysql-test/r/ps_7ndb.result	Wed Apr 13 21:35:08 2005
+++ 1.26/mysql-test/r/ps_7ndb.result	Wed Apr 20 10:52:57 2005
@@ -1759,7 +1759,7 @@
 t5	CREATE TABLE `t5` (
   `const01` bigint(1) NOT NULL default '0',
   `param01` bigint(20) default NULL,
-  `const02` decimal(2,1) NOT NULL default '0.0',
+  `const02` decimal(2,1) unsigned NOT NULL default '0.0',
   `param02` decimal(65,30) default NULL,
   `const03` double NOT NULL default '0',
   `param03` double default NULL,
@@ -1789,7 +1789,7 @@
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max
length	Is_null	Flags	Decimals	Charsetnr
 def	test	t5	t5	const01	const01	8	1	1	N	32769	0	63
 def	test	t5	t5	param01	param01	8	20	1	Y	32768	0	63
-def	test	t5	t5	const02	const02	246	4	3	N	1	1	63
+def	test	t5	t5	const02	const02	246	3	3	N	33	1	63
 def	test	t5	t5	param02	param02	246	67	32	Y	0	30	63
 def	test	t5	t5	const03	const03	5	17	1	N	32769	31	63
 def	test	t5	t5	param03	param03	5	20	1	Y	32768	31	63

--- 1.21/mysql-test/r/case.result	Wed Apr 13 10:38:22 2005
+++ 1.22/mysql-test/r/case.result	Wed Apr 20 10:52:57 2005
@@ -103,11 +103,11 @@
   `c2` varchar(1) character set latin1 collate latin1_danish_ci NOT NULL default '',
   `c3` varbinary(1) NOT NULL default '',
   `c4` varbinary(1) NOT NULL default '',
-  `c5` varbinary(4) NOT NULL default '',
-  `c6` varbinary(4) NOT NULL default '',
+  `c5` varbinary(3) NOT NULL default '',
+  `c6` varbinary(3) NOT NULL default '',
   `c7` decimal(2,1) NOT NULL default '0.0',
   `c8` decimal(2,1) NOT NULL default '0.0',
-  `c9` decimal(2,1) default NULL,
+  `c9` decimal(2,1) unsigned default NULL,
   `c10` double NOT NULL default '0',
   `c11` double NOT NULL default '0',
   `c12` varbinary(5) NOT NULL default ''
@@ -156,7 +156,7 @@
   `COALESCE('a')` varchar(1) NOT NULL default '',
   `COALESCE(1,1.0)` decimal(2,1) NOT NULL default '0.0',
   `COALESCE(1,'1')` varbinary(1) NOT NULL default '',
-  `COALESCE(1.1,'1')` varbinary(4) NOT NULL default '',
+  `COALESCE(1.1,'1')` varbinary(3) NOT NULL default '',
   `COALESCE('a' COLLATE latin1_bin,'b')` varchar(1) character set latin1 collate
latin1_bin NOT NULL default ''
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 DROP TABLE t1;

--- 1.12/mysql-test/r/metadata.result	Wed Apr 13 16:22:29 2005
+++ 1.13/mysql-test/r/metadata.result	Wed Apr 20 10:52:57 2005
@@ -2,7 +2,7 @@
 select 1, 1.0, -1, "hello", NULL;
 Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max
length	Is_null	Flags	Decimals	Charsetnr
 def					1	8	1	1	N	32897	0	63
-def					1.0	246	4	3	N	161	1	63
+def					1.0	246	3	3	N	161	1	63
 def					-1	8	2	2	N	32897	0	63
 def					hello	253	5	5	N	1	31	8
 def					NULL	6	0	0	Y	32896	0	63
Thread
bk commit into 5.0 tree (hf:1.1823)holyfoot20 Apr