MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:holyfoot Date:October 17 2005 7:32am
Subject:bk commit into 5.0 tree (hf:1.2046) BUG#13820
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
  1.2046 05/10/17 12:32:22 hf@deer.(none) +3 -0
  Fix for bug #13820 (No warning on log(NEGATIVE))

  sql/item_func.cc
    1.260 05/10/17 12:30:01 hf@deer.(none) +32 -6
    tests for (value<=0.0) added to LOG* functions

  mysql-test/t/func_math.test
    1.23 05/10/17 12:30:01 hf@deer.(none) +12 -0
    test case added

  mysql-test/r/func_math.result
    1.31 05/10/17 12:30:01 hf@deer.(none) +27 -0
    result fixed

# 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:	hf
# Host:	deer.(none)
# Root:	/home/hf/work/mysql-5.0.13820

--- 1.259/sql/item_func.cc	Fri Oct 14 12:04:23 2005
+++ 1.260/sql/item_func.cc	Mon Oct 17 12:30:01 2005
@@ -1386,8 +1386,13 @@
 {
   DBUG_ASSERT(fixed == 1);
   double value= args[0]->val_real();
-  if ((null_value=(args[0]->null_value || value <= 0.0)))
+  if ((null_value=args[0]->null_value))
     return 0.0;
+  if ((null_value= value <=0.0))
+  {
+    signal_divide_by_null();
+    return 0.0;
+  }
   return log(value);
 }
 
@@ -1400,13 +1405,23 @@
 {
   DBUG_ASSERT(fixed == 1);
   double value= args[0]->val_real();
-  if ((null_value=(args[0]->null_value || value <= 0.0)))
+  if ((null_value=args[0]->null_value))
+    return 0.0;
+  if ((null_value= value <=0.0))
+  {
+    signal_divide_by_null();
     return 0.0;
+  }
   if (arg_count == 2)
   {
     double value2= args[1]->val_real();
-    if ((null_value=(args[1]->null_value || value2 <= 0.0 || value == 1.0)))
+    if ((null_value=args[1]->null_value))
       return 0.0;
+    if ((null_value= value2 <=0.0) || (value == 1.0))
+    {
+      signal_divide_by_null();
+      return 0.0;
+    }
     return log(value2) / log(value);
   }
   return log(value);
@@ -1416,8 +1431,14 @@
 {
   DBUG_ASSERT(fixed == 1);
   double value= args[0]->val_real();
-  if ((null_value=(args[0]->null_value || value <= 0.0)))
+
+  if ((null_value=args[0]->null_value))
     return 0.0;
+  if ((null_value= value <=0.0))
+  {
+    signal_divide_by_null();
+    return 0.0;
+  }
   return log(value) / M_LN2;
 }
 
@@ -1425,8 +1446,13 @@
 {
   DBUG_ASSERT(fixed == 1);
   double value= args[0]->val_real();
-  if ((null_value=(args[0]->null_value || value <= 0.0)))
-    return 0.0; /* purecov: inspected */
+  if ((null_value=args[0]->null_value))
+    return 0.0;
+  if ((null_value= value <=0.0))
+  {
+    signal_divide_by_null();
+    return 0.0;
+  }
   return log10(value);
 }
 

--- 1.30/mysql-test/r/func_math.result	Tue Sep  6 22:51:07 2005
+++ 1.31/mysql-test/r/func_math.result	Mon Oct 17 12:30:01 2005
@@ -170,3 +170,30 @@
 select rand(i) from t1;
 ERROR HY000: Incorrect arguments to RAND
 drop table t1;
+set sql_mode='traditional';
+select ln(-1);
+ln(-1)
+NULL
+Warnings:
+Error	1365	Division by 0
+select log10(-1);
+log10(-1)
+NULL
+Warnings:
+Error	1365	Division by 0
+select log2(-1);
+log2(-1)
+NULL
+Warnings:
+Error	1365	Division by 0
+select log(2,-1);
+log(2,-1)
+NULL
+Warnings:
+Error	1365	Division by 0
+select log(-2,1);
+log(-2,1)
+NULL
+Warnings:
+Error	1365	Division by 0
+set sql_mode='';

--- 1.22/mysql-test/t/func_math.test	Tue Sep  6 22:51:07 2005
+++ 1.23/mysql-test/t/func_math.test	Mon Oct 17 12:30:01 2005
@@ -117,3 +117,15 @@
 drop table t1;
 
 # End of 4.1 tests
+
+#
+# Bug #13820 (No warning on log(negative)
+#
+set sql_mode='traditional';
+select ln(-1);
+select log10(-1);
+select log2(-1);
+select log(2,-1);
+select log(-2,1);
+set sql_mode='';
+
Thread
bk commit into 5.0 tree (hf:1.2046) BUG#13820holyfoot17 Oct