List:Commits« Previous MessageNext Message »
From:Chad MILLER Date:November 6 2006 8:13pm
Subject:bk commit into 4.1 tree (cmiller:1.2543) BUG#23411
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of cmiller. When cmiller 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-11-06 14:13:36-05:00, cmiller@stripped +3 -0
  Bug#23411: ... MOD-ing zero returns strange result
  
  The Item_func_mod objects never had maybe_null set, so objects never may 
  never expect that they can be NULL, and may therefore give wrong results.
  Now, set maybe_null.

  mysql-test/r/func_test.result@stripped, 2006-11-06 14:13:34-05:00,
cmiller@stripped +57 -0
    Verify that the predictions are true.

  mysql-test/t/func_test.test@stripped, 2006-11-06 14:13:34-05:00, cmiller@stripped
+26 -0
    Verify tests against predictions.

  sql/item_func.cc@stripped, 2006-11-06 14:13:34-05:00, cmiller@stripped +1 -0
    If "maybe_null" is unset for mod functions, then the "<=>" test will fail.

# 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:	cmiller
# Host:	zippy.cornsilk.net
# Root:	/home/cmiller/work/mysql/bug23411/my41-bug23411

--- 1.267/sql/item_func.cc	2006-11-06 14:13:38 -05:00
+++ 1.268/sql/item_func.cc	2006-11-06 14:13:38 -05:00
@@ -707,6 +707,7 @@ longlong Item_func_mod::val_int()
 void Item_func_mod::fix_length_and_dec()
 {
   Item_num_op::fix_length_and_dec();
+  maybe_null=1;
 }
 
 

--- 1.28/mysql-test/r/func_test.result	2006-11-06 14:13:38 -05:00
+++ 1.29/mysql-test/r/func_test.result	2006-11-06 14:13:38 -05:00
@@ -183,3 +183,60 @@ select 5.1 mod 3, 5.1 mod -3, -5.1 mod 3
 select 5 mod 3, 5 mod -3, -5 mod 3, -5 mod -3;
 5 mod 3	5 mod -3	-5 mod 3	-5 mod -3
 2	2	-2	-2
+select (12%0) <=> null      as '1';
+1
+1
+select (12%0) is null       as '1';
+1
+1
+select 12%0                 as 'NULL';
+NULL
+NULL
+select 12%2                 as '0';
+0
+0
+select 12%NULL              as 'NULL';
+NULL
+NULL
+select 12 % null            as 'NULL';
+NULL
+NULL
+select null % 12            as 'NULL';
+NULL
+NULL
+select null % 0             as 'NULL';
+NULL
+NULL
+select 0 % null             as 'NULL';
+NULL
+NULL
+select null % null          as 'NULL';
+NULL
+NULL
+select (12 mod 0) <=> null  as '1';
+1
+1
+select (12 mod 0) is null   as '1';
+1
+1
+select 12 mod 0             as 'NULL';
+NULL
+NULL
+select 12 mod 2             as '0';
+0
+0
+select 12 mod null          as 'NULL';
+NULL
+NULL
+select null mod 12          as 'NULL';
+NULL
+NULL
+select null mod 0           as 'NULL';
+NULL
+NULL
+select 0 mod null           as 'NULL';
+NULL
+NULL
+select null mod null        as 'NULL';
+NULL
+NULL

--- 1.26/mysql-test/t/func_test.test	2006-11-06 14:13:38 -05:00
+++ 1.27/mysql-test/t/func_test.test	2006-11-06 14:13:38 -05:00
@@ -108,4 +108,30 @@ select 5.1 mod 3, 5.1 mod -3, -5.1 mod 3
 
 select 5 mod 3, 5 mod -3, -5 mod 3, -5 mod -3;
 
+#
+# Bug#23411: The "%" (MOD) operator is not documented; MOD-ing zero returns strange
result
+# Manual: "Division by zero produces a NULL result"
+#
+select (12%0) <=> null      as '1';
+select (12%0) is null       as '1';
+select 12%0                 as 'NULL';
+select 12%2                 as '0';
+select 12%NULL              as 'NULL';
+select 12 % null            as 'NULL';
+select null % 12            as 'NULL';
+select null % 0             as 'NULL';
+select 0 % null             as 'NULL';
+select null % null          as 'NULL';
+
+select (12 mod 0) <=> null  as '1';
+select (12 mod 0) is null   as '1';
+select 12 mod 0             as 'NULL';
+select 12 mod 2             as '0';
+select 12 mod null          as 'NULL';
+select null mod 12          as 'NULL';
+select null mod 0           as 'NULL';
+select 0 mod null           as 'NULL';
+select null mod null        as 'NULL';
+
+
 # End of 4.1 tests
Thread
bk commit into 4.1 tree (cmiller:1.2543) BUG#23411Chad MILLER6 Nov