List:Internals« Previous MessageNext Message »
From:holyfoot Date:September 27 2005 10:11am
Subject:bk commit into 4.1 tree (hf:1.2457) BUG#13372
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 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.2457 05/09/27 15:11:39 hf@deer.(none) +5 -0
  Fix for bug #13372 (decimal union)

  sql/item.cc
    1.222 05/09/27 15:10:42 hf@deer.(none) +22 -2
    Fixed counting of the max_length for the REAL_RESULT

  mysql-test/t/type_float.test
    1.20 05/09/27 15:10:42 hf@deer.(none) +13 -0
    test case added

  mysql-test/t/type_decimal.test
    1.21 05/09/27 15:10:42 hf@deer.(none) +13 -1
    test case added

  mysql-test/r/type_float.result
    1.33 05/09/27 15:10:42 hf@deer.(none) +15 -0
    test result fixed

  mysql-test/r/type_decimal.result
    1.26 05/09/27 15:10:42 hf@deer.(none) +16 -1
    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-4.1.13372

--- 1.221/sql/item.cc	Fri Sep  9 13:22:12 2005
+++ 1.222/sql/item.cc	Tue Sep 27 15:10:42 2005
@@ -3205,9 +3205,14 @@
 
 bool Item_type_holder::join_types(THD *thd, Item *item)
 {
+  uint max_length_orig= max_length;
+  uint decimals_orig= decimals;
   max_length= max(max_length, display_length(item));
+  decimals= max(decimals, item->decimals);
   fld_type= Field::field_type_merge(fld_type, get_real_type(item));
-  if (Field::result_merge_type(fld_type) == STRING_RESULT)
+  switch (Field::result_merge_type(fld_type))
+  {
+  case STRING_RESULT:
   {
     const char *old_cs, *old_derivation;
     old_cs= collation.collation->name;
@@ -3221,8 +3226,23 @@
 	       "UNION");
       return TRUE;
     }
+    break;
   }
-  decimals= max(decimals, item->decimals);
+  case REAL_RESULT:
+  {
+    decimals= max(decimals, item->decimals);
+    if (decimals != NOT_FIXED_DEC)
+    {
+      int delta1= max_length_orig - decimals_orig;
+      int delta2= item->max_length - item->decimals;
+      max_length= max(delta1, delta2) + decimals;
+    }
+    else
+      max_length= (fld_type == MYSQL_TYPE_FLOAT) ? FLT_DIG+6 : DBL_DIG+7;
+    break;
+  }
+  default:;
+  };
   maybe_null|= item->maybe_null;
   get_full_info(item);
   return FALSE;

--- 1.25/mysql-test/r/type_decimal.result	Wed Sep 21 14:32:12 2005
+++ 1.26/mysql-test/r/type_decimal.result	Tue Sep 27 15:10:42 2005
@@ -1,4 +1,4 @@
-DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t1, t2, t3;
 SET SQL_WARNINGS=1;
 CREATE TABLE t1 (
 id int(11) NOT NULL auto_increment,
@@ -655,3 +655,18 @@
 a	b
 123.12345	123.1
 drop table t1;
+create table t1 (d decimal(10,1));
+create table t2 (d decimal(10,9));
+insert into t1 values ("100000000.0");
+insert into t2 values ("1.23456780");
+create table t3 select * from t2 union select * from t1;
+select * from t3;
+d
+1.234567800
+100000000.000000000
+show create table t3;
+Table	Create Table
+t3	CREATE TABLE `t3` (
+  `d` decimal(18,9) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1, t2, t3;

--- 1.32/mysql-test/r/type_float.result	Fri May  6 18:25:49 2005
+++ 1.33/mysql-test/r/type_float.result	Tue Sep 27 15:10:42 2005
@@ -235,3 +235,18 @@
 reckey	recdesc
 109	Has 109 as key
 drop table t1;
+create table t1 (d double(10,1));
+create table t2 (d double(10,9));
+insert into t1 values ("100000000.0");
+insert into t2 values ("1.23456780");
+create table t3 select * from t2 union select * from t1;
+select * from t3;
+d
+1.234567800
+100000000.000000000
+show create table t3;
+Table	Create Table
+t3	CREATE TABLE `t3` (
+  `d` double(61,9) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1, t2, t3;

--- 1.20/mysql-test/t/type_decimal.test	Wed Sep 21 14:32:12 2005
+++ 1.21/mysql-test/t/type_decimal.test	Tue Sep 27 15:10:42 2005
@@ -1,7 +1,7 @@
 # bug in decimal() with negative numbers by kaido@stripped
 
 --disable_warnings
-DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t1, t2, t3;
 --enable_warnings
 SET SQL_WARNINGS=1;
 
@@ -275,5 +275,17 @@
 update t1 set b=a;                                                              
 select * from t1;                                                               
 drop table t1;                                                                  
+
+#
+# Bug #13372 (decimal union)
+#
+create table t1 (d decimal(10,1));
+create table t2 (d decimal(10,9));
+insert into t1 values ("100000000.0");
+insert into t2 values ("1.23456780");
+create table t3 select * from t2 union select * from t1;
+select * from t3;
+show create table t3;
+drop table t1, t2, t3;
 
 # End of 4.1 tests

--- 1.19/mysql-test/t/type_float.test	Thu Jul 28 05:21:50 2005
+++ 1.20/mysql-test/t/type_float.test	Tue Sep 27 15:10:42 2005
@@ -149,4 +149,17 @@
 select * from t1 where reckey=1.09E2;
 drop table t1;
 
+#
+# Bug #13372 (decimal union)
+#
+create table t1 (d double(10,1));
+create table t2 (d double(10,9));
+insert into t1 values ("100000000.0");
+insert into t2 values ("1.23456780");
+create table t3 select * from t2 union select * from t1;
+select * from t3;
+show create table t3;
+drop table t1, t2, t3;
+
+
 # End of 4.1 tests
Thread
bk commit into 4.1 tree (hf:1.2457) BUG#13372holyfoot27 Sep