List:Commits« Previous MessageNext Message »
From:<gshchepa Date:June 16 2007 8:05am
Subject:bk commit into 5.0 tree (gshchepa:1.2506) BUG#28625
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of uchum. When uchum 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-06-16 13:05:07+05:00, gshchepa@stripped +3 -0
  Fixed bug #28625:
  DECIMAL column was used instead of BIGINT for the minimal possible
  BIGINT (-9223372036854775808).
  
  The Item_func_neg::fix_length_and_dec has been adjusted to
  to inherit the type of the argument in the case when it's an 
  Item_int object whose value is equal to LONGLONG_MIN.

  mysql-test/r/bigint.result@stripped, 2007-06-16 13:04:54+05:00, gshchepa@stripped +26 -0
    Added test case for bug #28625.

  mysql-test/t/bigint.test@stripped, 2007-06-16 13:04:52+05:00, gshchepa@stripped +13 -0
    Added test result for bug #28625.

  sql/item_func.cc@stripped, 2007-06-16 13:03:24+05:00, gshchepa@stripped +13 -9
    Fixed bug #28625.
    The Item_func_neg::fix_length_and_dec has been adjusted to
    to inherit the type of the argument in the case when it's an 
    Item_int object whose value is equal to LONGLONG_MIN.

# 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:	gshchepa
# Host:	gleb.loc
# Root:	/home/uchum/work/bk/5.0-opt-28625

--- 1.344/sql/item_func.cc	2007-06-01 02:17:03 +05:00
+++ 1.345/sql/item_func.cc	2007-06-16 13:03:24 +05:00
@@ -1523,16 +1523,20 @@ void Item_func_neg::fix_length_and_dec()
     Use val() to get value as arg_type doesn't mean that item is
     Item_int or Item_real due to existence of Item_param.
   */
-  if (hybrid_type == INT_RESULT &&
-      args[0]->type() == INT_ITEM &&
-      ((ulonglong) args[0]->val_int() >= (ulonglong) LONGLONG_MIN))
+  if (hybrid_type == INT_RESULT && args[0]->const_item())
   {
-    /*
-      Ensure that result is converted to DECIMAL, as longlong can't hold
-      the negated number
-    */
-    hybrid_type= DECIMAL_RESULT;
-    DBUG_PRINT("info", ("Type changed: DECIMAL_RESULT"));
+    longlong val= args[0]->val_int();
+    if ((ulonglong) val >= (ulonglong) LONGLONG_MIN &&
+        ((ulonglong) val != (ulonglong) LONGLONG_MIN ||
+          args[0]->type() != INT_ITEM))        
+    {
+      /*
+        Ensure that result is converted to DECIMAL, as longlong can't hold
+        the negated number
+      */
+      hybrid_type= DECIMAL_RESULT;
+      DBUG_PRINT("info", ("Type changed: DECIMAL_RESULT"));
+    }
   }
   unsigned_flag= 0;
   DBUG_VOID_RETURN;

--- 1.35/mysql-test/r/bigint.result	2007-05-16 10:12:48 +05:00
+++ 1.36/mysql-test/r/bigint.result	2007-06-16 13:04:54 +05:00
@@ -362,3 +362,29 @@ cast(-19999999999999999999 as signed)
 -9223372036854775808
 Warnings:
 Error	1292	Truncated incorrect DECIMAL value: ''
+select -9223372036854775808;
+Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
+def					-9223372036854775808	8	20	20	N	32897	0	63
+-9223372036854775808
+-9223372036854775808
+select -(9223372036854775808);
+Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
+def					-(9223372036854775808)	8	20	20	N	32897	0	63
+-(9223372036854775808)
+-9223372036854775808
+select -((9223372036854775808));
+Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
+def					-((9223372036854775808))	8	20	20	N	32897	0	63
+-((9223372036854775808))
+-9223372036854775808
+select -(-(9223372036854775808));
+Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
+def					-(-(9223372036854775808))	246	21	19	N	129	0	63
+-(-(9223372036854775808))
+9223372036854775808
+select --9223372036854775808, ---9223372036854775808, ----9223372036854775808;
+--9223372036854775808	---9223372036854775808	----9223372036854775808
+9223372036854775808	-9223372036854775808	9223372036854775808
+select -(-9223372036854775808), -(-(-9223372036854775808));
+-(-9223372036854775808)	-(-(-9223372036854775808))
+9223372036854775808	-9223372036854775808

--- 1.30/mysql-test/t/bigint.test	2007-05-16 10:12:48 +05:00
+++ 1.31/mysql-test/t/bigint.test	2007-06-16 13:04:52 +05:00
@@ -294,3 +294,16 @@ drop table t1;
 
 select cast(19999999999999999999 as signed);
 select cast(-19999999999999999999 as signed);
+
+#
+# Bug #28625: -9223372036854775808 doesn't fit in BIGINT.
+#
+
+--enable_metadata
+select -9223372036854775808;
+select -(9223372036854775808);
+select -((9223372036854775808));
+select -(-(9223372036854775808));
+--disable_metadata
+select --9223372036854775808, ---9223372036854775808, ----9223372036854775808;
+select -(-9223372036854775808), -(-(-9223372036854775808));
Thread
bk commit into 5.0 tree (gshchepa:1.2506) BUG#28625gshchepa16 Jun