MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:holyfoot Date:March 10 2005 8:34am
Subject:bk commit into 5.0 tree (hf:1.1796) BUG#8463
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.1796 05/03/10 12:33:53 hf@deer.(none) +4 -0
  Fix for bug #8463 (SQRT(negative) should return an error)

  sql/share/errmsg.txt
    1.15 05/03/10 12:33:47 hf@deer.(none) +2 -0
    error message added

  sql/item_func.cc
    1.173 05/03/10 12:33:47 hf@deer.(none) +5 -0
    now we launch the error if SQRT(negative)

  mysql-test/t/func_math.test
    1.14 05/03/10 12:33:47 hf@deer.(none) +6 -0
    test case

  mysql-test/r/func_math.result
    1.22 05/03/10 12:33:46 hf@deer.(none) +5 -0
    Test 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.8463

--- 1.172/sql/item_func.cc	Thu Mar 10 01:52:48 2005
+++ 1.173/sql/item_func.cc	Thu Mar 10 12:33:47 2005
@@ -1439,7 +1439,12 @@
   DBUG_ASSERT(fixed == 1);
   double value= args[0]->val_real();
   if ((null_value=(args[0]->null_value || value < 0)))
+  {
+    push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
+			ER_BAD_DATA_FOR_FUNCTION, ER(ER_BAD_DATA_FOR_FUNCTION),
+                        "SQRT");
     return 0.0; /* purecov: inspected */
+  }
   return sqrt(value);
 }
 

--- 1.14/sql/share/errmsg.txt	Wed Mar  9 20:55:37 2005
+++ 1.15/sql/share/errmsg.txt	Thu Mar 10 12:33:47 2005
@@ -5330,3 +5330,5 @@
 	eng "Bad SQLSTATE: '%s'"
 ER_STARTUP
 	eng "%s: ready for connections.\nVersion: '%s'  socket: '%s'  port: %d  %s"
+ER_BAD_DATA_FOR_FUNCTION
+	eng "Number is out of the range for function %s"

--- 1.21/mysql-test/r/func_math.result	Mon Dec 20 13:47:34 2004
+++ 1.22/mysql-test/r/func_math.result	Thu Mar 10 12:33:46 2005
@@ -126,3 +126,8 @@
 Note	1003	select degrees(pi()) AS `degrees(pi())`,radians(360) AS `radians(360)`
 select rand(rand);
 ERROR 42S22: Unknown column 'rand' in 'field list'
+select SQRT(-10);
+SQRT(-10)
+NULL
+Warnings:
+Error	1409	Number is out of the range for function SQRT

--- 1.13/mysql-test/t/func_math.test	Mon Dec 20 13:47:34 2004
+++ 1.14/mysql-test/t/func_math.test	Thu Mar 10 12:33:47 2005
@@ -58,3 +58,9 @@
 
 --error 1054
 select rand(rand);
+
+#
+# Bug #8463: error when SQRT(negative number)
+#
+
+select SQRT(-10);
Thread
bk commit into 5.0 tree (hf:1.1796) BUG#8463holyfoot10 Mar