MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Ian Greenhoe Date:September 10 2006 9:30am
Subject:bk commit into 5.0 tree (igreenhoe:1.2272) BUG#19955
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of greenman. When greenman 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, 2006-09-10 02:30:39-07:00, igreenhoe@stripped +3 -0
  Fix for bug #19955 (unsigned bigint used as signed with MOD function)
  
  Problem:  When we have a really large number (between 2^63 and 2^64)
  as the left side of the mod operator, it gets improperly corerced
  into a signed value.
  
  Solution:  Added check to see if the "negative" number is really
  positive, and if so, cast it.

  mysql-test/r/bigint.result@stripped, 2006-09-10 02:30:35-07:00, igreenhoe@stripped +11 -0
    Added test case results

  mysql-test/t/bigint.test@stripped, 2006-09-10 02:30:35-07:00, igreenhoe@stripped +9 -0
    Added test case

  sql/item_func.cc@stripped, 2006-09-10 02:30:35-07:00, igreenhoe@stripped +4 -0
    Added check to see if we have an unsigned number that looks like a
    signed number.

# 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:	igreenhoe
# Host:	anubis.greendragongames.com
# Root:	/home/greenman/workspace-mysql/mysql/bug-5.0-19955

--- 1.300/sql/item_func.cc	2006-09-10 02:30:47 -07:00
+++ 1.301/sql/item_func.cc	2006-09-10 02:30:47 -07:00
@@ -1278,6 +1278,10 @@
     signal_divide_by_null();
     return 0;
   }
+
+  if (args[0]->unsigned_flag)
+    return ((ulonglong) value) % val2;
+
   return value % val2;
 }
 

--- 1.33/mysql-test/r/bigint.result	2006-09-10 02:30:47 -07:00
+++ 1.34/mysql-test/r/bigint.result	2006-09-10 02:30:47 -07:00
@@ -341,3 +341,14 @@
 bigint_col
 17666000000000000000
 drop table t1;
+
+bug 19955 -- mod is signed with bigint
+select cast(10000002383263201056 as unsigned) mod 50 as result;
+result
+6
+create table t1 (c1 bigint unsigned);
+insert into t1 values (10000002383263201056);
+select c1 mod 50 as result from t1;
+result
+6
+drop table t1;

--- 1.28/mysql-test/t/bigint.test	2006-09-10 02:30:47 -07:00
+++ 1.29/mysql-test/t/bigint.test	2006-09-10 02:30:47 -07:00
@@ -278,4 +278,13 @@
 select * from t1 where bigint_col='17666000000000000000';
 drop table t1;
 
+--echo
+--echo bug 19955 -- mod is signed with bigint
+
+select cast(10000002383263201056 as unsigned) mod 50 as result;
+
+create table t1 (c1 bigint unsigned);
+insert into t1 values (10000002383263201056);
+select c1 mod 50 as result from t1;
+drop table t1;
 
Thread
bk commit into 5.0 tree (igreenhoe:1.2272) BUG#19955Ian Greenhoe10 Sep