MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:ramil Date:December 22 2006 5:29am
Subject:bk commit into 5.0 tree (ramil:1.2336) BUG#21976
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@stripped, 2006-12-22 09:29:28+04:00, ramil@stripped +4 -0
  Fix for bug #21976: Unnecessary warning with count(decimal)
  
  We use val_int() calls (followed by null_value check) to determine 
  nullness in some Item_sum_count' and Item_sum_count_distinct' methods, 
  as a side effect we get extra warnings raised in the val_int().
  Fix: use is_null() instead.

  mysql-test/r/func_group.result@stripped, 2006-12-22 09:29:26+04:00, ramil@stripped +10 -0
    Fix for bug #21976: Unnecessary warning with count(decimal)
      - test result.

  mysql-test/t/func_group.test@stripped, 2006-12-22 09:29:26+04:00, ramil@stripped +11 -0
    Fix for bug #21976: Unnecessary warning with count(decimal)
      - test case.

  sql/item.h@stripped, 2006-12-22 09:29:26+04:00, ramil@stripped +5 -6
    Fix for bug #21976: Unnecessary warning with count(decimal)
      - comment adjusted.
    

  sql/item_sum.cc@stripped, 2006-12-22 09:29:26+04:00, ramil@stripped +5 -27
    Fix for bug #21976: Unnecessary warning with count(decimal)
      - use is_null() to determine nullness.

# 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:	ramil.myoffice.izhnet.ru
# Root:	/home/ram/work/b21976/my50-b21976

--- 1.209/sql/item.h	2006-12-22 09:29:32 +04:00
+++ 1.210/sql/item.h	2006-12-22 09:29:32 +04:00
@@ -701,12 +701,11 @@ public:
   virtual bool get_date_result(TIME *ltime,uint fuzzydate)
   { return get_date(ltime,fuzzydate); }
   /*
-    This function is used only in Item_func_isnull/Item_func_isnotnull
-    (implementations of IS NULL/IS NOT NULL clauses). Item_func_is{not}null
-    calls this method instead of one of val/result*() methods, which
-    normally will set null_value. This allows to determine nullness of
-    a complex expression without fully evaluating it.
-    Any new item which can be NULL must implement this call.
+    The method allows to determine nullness of a complex expression 
+    without fully evaluating it, instead of calling val/result*() then 
+    checking null_value. Used in Item_func_isnull/Item_func_isnotnull
+    and Item_sum_count/Item_sum_count_distinct.
+    Any new item which can be NULL must implement this method.
   */
   virtual bool is_null() { return 0; }
 

--- 1.185/sql/item_sum.cc	2006-12-22 09:29:32 +04:00
+++ 1.186/sql/item_sum.cc	2006-12-22 09:29:32 +04:00
@@ -1034,14 +1034,8 @@ void Item_sum_count::clear()
 
 bool Item_sum_count::add()
 {
-  if (!args[0]->maybe_null)
+  if (!args[0]->maybe_null || !args[0]->is_null())
     count++;
-  else
-  {
-    (void) args[0]->val_int();
-    if (!args[0]->null_value)
-      count++;
-  }
   return 0;
 }
 
@@ -1941,14 +1935,8 @@ void Item_sum_count::reset_field()
   char *res=result_field->ptr;
   longlong nr=0;
 
-  if (!args[0]->maybe_null)
+  if (!args[0]->maybe_null || !args[0]->is_null())
     nr=1;
-  else
-  {
-    (void) args[0]->val_int();
-    if (!args[0]->null_value)
-      nr=1;
-  }
   int8store(res,nr);
 }
 
@@ -2051,14 +2039,8 @@ void Item_sum_count::update_field()
   char *res=result_field->ptr;
 
   nr=sint8korr(res);
-  if (!args[0]->maybe_null)
+  if (!args[0]->maybe_null || !args[0]->is_null())
     nr++;
-  else
-  {
-    (void) args[0]->val_int();
-    if (!args[0]->null_value)
-      nr++;
-  }
   int8store(res,nr);
 }
 
@@ -2531,12 +2513,8 @@ bool Item_sum_count_distinct::setup(THD 
     Item *item=args[i];
     if (list.push_back(item))
       return TRUE;                              // End of memory
-    if (item->const_item())
-    {
-      (void) item->val_int();
-      if (item->null_value)
-	always_null=1;
-    }
+    if (item->const_item() && item->is_null())
+      always_null= 1;
   }
   if (always_null)
     return FALSE;

--- 1.53/mysql-test/r/func_group.result	2006-12-22 09:29:32 +04:00
+++ 1.54/mysql-test/r/func_group.result	2006-12-22 09:29:32 +04:00
@@ -1029,3 +1029,13 @@ t1	CREATE TABLE `t1` (
   `stddev(0)` double(8,4) default NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 drop table t1;
+create table t1 (a decimal(20));
+insert into t1 values (12345678901234567890);
+select count(a) from t1;
+count(a)
+1
+select count(distinct a) from t1;
+count(distinct a)
+1
+drop table t1;
+End of 5.0 tests

--- 1.49/mysql-test/t/func_group.test	2006-12-22 09:29:32 +04:00
+++ 1.50/mysql-test/t/func_group.test	2006-12-22 09:29:32 +04:00
@@ -700,3 +700,14 @@ create table t1 select stddev(0);
 show create table t1;
 drop table t1;
  
+#
+# Bug #21976: Unnecessary warning with count(decimal)
+#
+
+create table t1 (a decimal(20));
+insert into t1 values (12345678901234567890);
+select count(a) from t1;
+select count(distinct a) from t1;
+drop table t1;
+
+--echo End of 5.0 tests
Thread
bk commit into 5.0 tree (ramil:1.2336) BUG#21976ramil22 Dec