From 5d4c57b900c164345f8635d13e66070e98208a29 Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Wed, 15 Nov 2006 12:23:07 -0500 Subject: 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. --- sql/item_func.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sql/item_func.cc') diff --git a/sql/item_func.cc b/sql/item_func.cc index 8e6b4d82b1d..a68c85ad658 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1326,6 +1326,10 @@ longlong Item_func_mod::int_op() signal_divide_by_null(); return 0; } + + if (args[0]->unsigned_flag) + return ((ulonglong) value) % val2; + return value % val2; } -- cgit v1.2.1