MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:ramil Date:May 13 2005 2:01pm
Subject:bk commit into 5.0 tree (ramil:1.1944) BUG#10599
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of ram. When ram 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.1944 05/05/13 19:01:07 ramil@stripped +3 -0
  a fix (bug #10599: Numeric function 'abs' make server crash).
  

  sql/item_func.cc
    1.193 05/05/13 19:01:01 ramil@stripped +11 -10
    a fix (bug #10599: Numeric function 'abs' make server crash).
    Item_func_abs::decimal_op() now returns 0 if NULL.
    In order to avoid such problems in the future, tests for NULL in the 
    Item_func_numhybrid::val_xxx() functions changed.

  mysql-test/t/type_newdecimal.test
    1.12 05/05/13 19:01:01 ramil@stripped +6 -0
    a fix (bug #10599: Numeric function 'abs' make server crash).
    

  mysql-test/r/type_newdecimal.result
    1.13 05/05/13 19:01:01 ramil@stripped +3 -0
    a fix (bug #10599: Numeric function 'abs' make server crash).
    

# 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:	ramil
# Host:	gw.mysql.r18.ru
# Root:	/usr/home/ram/work/mysql-5.0

--- 1.192/sql/item_func.cc	2005-05-09 17:21:54 +05:00
+++ 1.193/sql/item_func.cc	2005-05-13 19:01:01 +05:00
@@ -789,9 +789,9 @@
   switch (hybrid_type) {
   case DECIMAL_RESULT:
   {
-    my_decimal decimal_value, *val;
-    if (!(val= decimal_op(&decimal_value)))
-      return 0;                                 // null is set
+    my_decimal decimal_value, *val= decimal_op(&decimal_value);
+    if (null_value)
+      return 0;
     my_decimal_round(E_DEC_FATAL_ERROR, val, decimals, FALSE, val);
     my_decimal2string(E_DEC_FATAL_ERROR, val, 0, 0, 0, str);
     break;
@@ -828,10 +828,10 @@
   switch (hybrid_type) {
   case DECIMAL_RESULT:
   {
-    my_decimal decimal_value, *val;
+    my_decimal decimal_value, *val= decimal_op(&decimal_value);
     double result;
-    if (!(val= decimal_op(&decimal_value)))
-      return 0.0;                               // null is set
+    if (null_value)
+      return 0.0;
     my_decimal2double(E_DEC_FATAL_ERROR, val, &result);
     return result;
   }
@@ -852,9 +852,9 @@
   switch (hybrid_type) {
   case DECIMAL_RESULT:
   {
-    my_decimal decimal_value, *val;
-    if (!(val= decimal_op(&decimal_value)))
-      return 0;                                 // null is set
+    my_decimal decimal_value, *val= decimal_op(&decimal_value);
+    if (null_value)
+      return 0;
     longlong result;
     my_decimal2int(E_DEC_FATAL_ERROR, val, unsigned_flag, &result);
     return result;
@@ -1460,8 +1460,9 @@
     my_decimal2decimal(value, decimal_value);
     if (decimal_value->sign())
       my_decimal_neg(decimal_value);
+    return decimal_value;
   }
-  return decimal_value;
+  return 0;
 }
 
 

--- 1.12/mysql-test/r/type_newdecimal.result	2005-05-12 19:36:29 +05:00
+++ 1.13/mysql-test/r/type_newdecimal.result	2005-05-13 19:01:01 +05:00
@@ -885,3 +885,6 @@
 GRADE
 151
 DROP TABLE t1;
+select abs(10/0);
+abs(10/0)
+NULL

--- 1.11/mysql-test/t/type_newdecimal.test	2005-05-12 19:36:29 +05:00
+++ 1.12/mysql-test/t/type_newdecimal.test	2005-05-13 19:01:01 +05:00
@@ -916,3 +916,9 @@
 SELECT GRADE  FROM t1 WHERE GRADE > 160 AND GRADE < 300;
 SELECT GRADE  FROM t1 WHERE GRADE= 151;
 DROP TABLE t1;
+
+#
+# Bug #10599: problem with NULL
+#
+
+select abs(10/0);
Thread
bk commit into 5.0 tree (ramil:1.1944) BUG#10599ramil13 May