From c872b005e2987ebc10db219c5ce8657441fe3533 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 22 Dec 2006 09:29:28 +0400 Subject: 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: Fix for bug #21976: Unnecessary warning with count(decimal) - test result. mysql-test/t/func_group.test: Fix for bug #21976: Unnecessary warning with count(decimal) - test case. sql/item.h: Fix for bug #21976: Unnecessary warning with count(decimal) - comment adjusted. sql/item_sum.cc: Fix for bug #21976: Unnecessary warning with count(decimal) - use is_null() to determine nullness. --- sql/item_sum.cc | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) (limited to 'sql/item_sum.cc') diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 77c6e17607f..f7a92f16b29 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -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 *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; -- cgit v1.2.1