diff options
author | unknown <ramil/ram@mysql.com/ramil.myoffice.izhnet.ru> | 2006-12-22 09:29:28 +0400 |
---|---|---|
committer | unknown <ramil/ram@mysql.com/ramil.myoffice.izhnet.ru> | 2006-12-22 09:29:28 +0400 |
commit | c872b005e2987ebc10db219c5ce8657441fe3533 (patch) | |
tree | ddd29b141c9a275f24f6361a13d2e0f413c8c5c5 /sql/item_sum.cc | |
parent | 6cf0571a97b9d9381c650b96e039c0c0aba955a5 (diff) | |
download | mariadb-git-c872b005e2987ebc10db219c5ce8657441fe3533.tar.gz |
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.
Diffstat (limited to 'sql/item_sum.cc')
-rw-r--r-- | sql/item_sum.cc | 32 |
1 files changed, 5 insertions, 27 deletions
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; |