List:Commits« Previous MessageNext Message »
From:holyfoot Date:May 16 2007 7:12am
Subject:bk commit into 5.0 tree (holyfoot:1.2489) BUG#8663
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@stripped, 2007-05-16 10:12:49+05:00, holyfoot@stripped +3 -0
  bug #8663 cant use bigint unsigned as input to cast
  in the case of the overflow in the decimal->integer conversion
  we didn't return the proper boundary value, but just the result
  of the conversion we calculated on the moment of the error

  mysql-test/r/bigint.result@stripped, 2007-05-16 10:12:48+05:00, holyfoot@stripped +10 -0
    bug #8663 cant use bigint unsigned as input to cast
    test result fixed

  mysql-test/t/bigint.test@stripped, 2007-05-16 10:12:48+05:00, holyfoot@stripped +6 -0
    bug #8663 cant use bigint unsigned as input to cast
    test case

  strings/decimal.c@stripped, 2007-05-16 10:12:48+05:00, holyfoot@stripped +5 -1
    bug #8663 cant use bigint unsigned as input to cast
    decimal->int conversion fixed to return proper boundary value
    in the case of overflow

# 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:	holyfoot
# Host:	hfmain.(none)
# Root:	/home/hf/work/8663/my50-8663

--- 1.34/mysql-test/r/bigint.result	2007-05-16 10:12:57 +05:00
+++ 1.35/mysql-test/r/bigint.result	2007-05-16 10:12:57 +05:00
@@ -352,3 +352,13 @@ select c1 mod 50 as result from t1;
 result
 6
 drop table t1;
+select cast(19999999999999999999 as signed);
+cast(19999999999999999999 as signed)
+9223372036854775807
+Warnings:
+Error	1292	Truncated incorrect DECIMAL value: ''
+select cast(-19999999999999999999 as signed);
+cast(-19999999999999999999 as signed)
+-9223372036854775808
+Warnings:
+Error	1292	Truncated incorrect DECIMAL value: ''

--- 1.29/mysql-test/t/bigint.test	2007-05-16 10:12:57 +05:00
+++ 1.30/mysql-test/t/bigint.test	2007-05-16 10:12:57 +05:00
@@ -288,3 +288,9 @@ insert into t1 values (10000002383263201
 select c1 mod 50 as result from t1;
 drop table t1;
 
+#
+# Bug #8663 cant use bgint unsigned as input to cast
+#
+
+select cast(19999999999999999999 as signed);
+select cast(-19999999999999999999 as signed);

--- 1.78/strings/decimal.c	2007-05-16 10:12:57 +05:00
+++ 1.79/strings/decimal.c	2007-05-16 10:12:57 +05:00
@@ -1083,7 +1083,11 @@ int decimal2longlong(decimal_t *from, lo
     x=x*DIG_BASE - *buf++;
     if (unlikely(y < (LONGLONG_MIN/DIG_BASE) || x > y))
     {
-      *to= from->sign ? y : -y;
+      /*
+        the decimal is bigger than any possible integer
+        return border integer depending on the sign
+      */
+      *to= from->sign ? LONGLONG_MIN : LONGLONG_MAX;
       return E_DEC_OVERFLOW;
     }
   }
Thread
bk commit into 5.0 tree (holyfoot:1.2489) BUG#8663holyfoot16 May