summaryrefslogtreecommitdiff
path: root/sql/opt_sum.cc
diff options
context:
space:
mode:
authormonty@mysql.com <>2005-09-25 21:22:23 +0300
committermonty@mysql.com <>2005-09-25 21:22:23 +0300
commitea6d5f9ec38e63532bf6b7f4b21ff7b227336954 (patch)
tree8f55cf36de04a78555166306a41f58ce8628a240 /sql/opt_sum.cc
parentaa74affb19517f1cd6c7d1e133ad41c344b9d750 (diff)
downloadmariadb-git-ea6d5f9ec38e63532bf6b7f4b21ff7b227336954.tar.gz
Fixed error found during review of new pushed code
Diffstat (limited to 'sql/opt_sum.cc')
-rw-r--r--sql/opt_sum.cc14
1 files changed, 7 insertions, 7 deletions
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc
index 3ac72e5a6f9..cfb5b3695a3 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -108,7 +108,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
WHERE t2.field IS NULL;
*/
if (tl->table->map & where_tables)
- const_result= 0;
+ return 0;
}
else
used_tables|= tl->table->map;
@@ -119,7 +119,10 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
may be used as the real count.
*/
if (tl->table->file->table_flags() & HA_NOT_EXACT_COUNT)
+ {
is_exact_count= FALSE;
+ count= 1; // ensure count != 0
+ }
else
{
tl->table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
@@ -127,9 +130,6 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
}
}
- if (!const_result)
- return 0;
-
/*
Iterate through all items in the SELECT clause and replace
COUNT(), MIN() and MAX() with constants (if possible).
@@ -150,8 +150,8 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
if (!conds && !((Item_sum_count*) item)->args[0]->maybe_null &&
!outer_tables && is_exact_count)
{
- ((Item_sum_count*) item)->make_const(count);
- recalc_const_item= 1;
+ ((Item_sum_count*) item)->make_const(count);
+ recalc_const_item= 1;
}
else
const_result= 0;
@@ -234,7 +234,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
}
if (!count)
{
- /* If count != 1, then we know that is_exact_count == TRUE. */
+ /* If count == 0, then we know that is_exact_count == TRUE. */
((Item_sum_min*) item_sum)->clear(); /* Set to NULL. */
}
else