List:Internals« Previous MessageNext Message »
From:Jim Winstead Date:October 29 2005 3:13am
Subject:bk commit into 4.1 tree (jimw:1.2467) BUG#14216
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of jimw. When jimw 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.2467 05/10/28 18:12:57 jimw@stripped +3 -0
  Fix bug in handling of decimal fields in UNION statements that could
  cause a crash or write to an incorrect memory location. (Bug #14216)

  sql/item.cc
    1.229 05/10/28 18:12:48 jimw@stripped +5 -2
    Set max_length for decimal fields correctly

  mysql-test/t/union.test
    1.88 05/10/28 18:12:48 jimw@stripped +18 -0
    Add regression test

  mysql-test/r/union.result
    1.94 05/10/28 18:12:48 jimw@stripped +26 -0
    Update results

# 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:	jimw
# Host:	rama.(none)
# Root:	/home/jimw/my/mysql-4.1-14216

--- 1.228/sql/item.cc	2005-10-25 09:01:39 -07:00
+++ 1.229/sql/item.cc	2005-10-28 18:12:48 -07:00
@@ -3274,8 +3274,11 @@
     {
       int delta1= max_length_orig - decimals_orig;
       int delta2= item->max_length - item->decimals;
-      max_length= min(max(delta1, delta2) + decimals,
-                      (fld_type == MYSQL_TYPE_FLOAT) ? FLT_DIG+6 : DBL_DIG+7);
+      if (fld_type == MYSQL_TYPE_DECIMAL)
+        max_length= max(delta1, delta2) + decimals;
+      else
+        max_length= min(max(delta1, delta2) + decimals,
+                        (fld_type == MYSQL_TYPE_FLOAT) ? FLT_DIG+6 : DBL_DIG+7);
     }
     else
       max_length= (fld_type == MYSQL_TYPE_FLOAT) ? FLT_DIG+6 : DBL_DIG+7;

--- 1.93/mysql-test/r/union.result	2005-09-27 04:23:33 -07:00
+++ 1.94/mysql-test/r/union.result	2005-10-28 18:12:48 -07:00
@@ -1253,3 +1253,29 @@
 5
 99
 drop table t1;
+create table t1 (f1 decimal(60,25), f2 decimal(60,25));
+insert into t1 values (0.0,0.0);
+select f1 from t1 union all select f2 from t1;
+f1
+0.0000000000000000000000000
+0.0000000000000000000000000
+select 'XXXXXXXXXXXXXXXXXXXX' as description, f1 from t1
+union all
+select 'YYYYYYYYYYYYYYYYYYYY' as description, f2 from t1;
+description	f1
+XXXXXXXXXXXXXXXXXXXX	0.0000000000000000000000000
+YYYYYYYYYYYYYYYYYYYY	0.0000000000000000000000000
+drop table t1;
+create table t1 (f1 decimal(60,24), f2 decimal(60,24));
+insert into t1 values (0.0,0.0);
+select f1 from t1 union all select f2 from t1;
+f1
+0.000000000000000000000000
+0.000000000000000000000000
+select 'XXXXXXXXXXXXXXXXXXXX' as description, f1 from t1
+union all
+select 'YYYYYYYYYYYYYYYYYYYY' as description, f2 from t1;
+description	f1
+XXXXXXXXXXXXXXXXXXXX	0.000000000000000000000000
+YYYYYYYYYYYYYYYYYYYY	0.000000000000000000000000
+drop table t1;

--- 1.87/mysql-test/t/union.test	2005-09-21 02:32:12 -07:00
+++ 1.88/mysql-test/t/union.test	2005-10-28 18:12:48 -07:00
@@ -756,4 +756,22 @@
 select id from t1 union all select 99 order by 1;
 drop table t1;
 
+# 
+# Bug #14216: UNION + DECIMAL wrong values in result
+#
+create table t1 (f1 decimal(60,25), f2 decimal(60,25));
+insert into t1 values (0.0,0.0);
+select f1 from t1 union all select f2 from t1;
+select 'XXXXXXXXXXXXXXXXXXXX' as description, f1 from t1
+union all
+select 'YYYYYYYYYYYYYYYYYYYY' as description, f2 from t1;
+drop table t1;
+create table t1 (f1 decimal(60,24), f2 decimal(60,24));
+insert into t1 values (0.0,0.0);
+select f1 from t1 union all select f2 from t1;
+select 'XXXXXXXXXXXXXXXXXXXX' as description, f1 from t1
+union all
+select 'YYYYYYYYYYYYYYYYYYYY' as description, f2 from t1;
+drop table t1;
+
 # End of 4.1 tests
Thread
bk commit into 4.1 tree (jimw:1.2467) BUG#14216Jim Winstead29 Oct