summaryrefslogtreecommitdiff
path: root/sql/opt_sum.cc
diff options
context:
space:
mode:
authorunknown <hartmut@mysql.com>2006-04-07 11:23:55 +0200
committerunknown <hartmut@mysql.com>2006-04-07 11:23:55 +0200
commit7589de6c10d3b15c37ca038b4bd7451b73fca9ca (patch)
tree53b2a624f9e559d7dcebca903ec3ab83e2ccd93c /sql/opt_sum.cc
parent040fc2d335bc8dc83b403562cde3c6e2e89c0e6a (diff)
parentf7b039cc5060313390f31098b336d4fa811ab5f8 (diff)
downloadmariadb-git-7589de6c10d3b15c37ca038b4bd7451b73fca9ca.tar.gz
Merge mysql.com:/home/hartmut/projects/mysql/dev/5.0
into mysql.com:/home/hartmut/projects/mysql/dev/5.1 mysql-test/r/ctype_ucs.result: Auto merged mysql-test/r/func_gconcat.result: Auto merged mysql-test/r/func_time.result: Auto merged mysql-test/r/information_schema.result: Auto merged mysql-test/t/ctype_ucs.test: Auto merged mysql-test/t/information_schema.test: Auto merged sql/item_sum.cc: Auto merged sql/item_timefunc.cc: Auto merged sql/opt_sum.cc: Auto merged
Diffstat (limited to 'sql/opt_sum.cc')
-rw-r--r--sql/opt_sum.cc27
1 files changed, 7 insertions, 20 deletions
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc
index aac47707d1b..d4e7745551a 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -123,8 +123,11 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
If the storage manager of 'tl' gives exact row count, compute the total
number of rows. If there are no outer table dependencies, this count
may be used as the real count.
+ Schema tables are filled after this function is invoked, so we can't
+ get row count
*/
- if (tl->table->file->table_flags() & HA_NOT_EXACT_COUNT)
+ if ((tl->table->file->table_flags() & HA_NOT_EXACT_COUNT) ||
+ tl->schema_table)
{
is_exact_count= FALSE;
count= 1; // ensure count != 0
@@ -149,31 +152,15 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
switch (item_sum->sum_func()) {
case Item_sum::COUNT_FUNC:
/*
- If the expr in count(expr) can never be null we can change this
+ If the expr in COUNT(expr) can never be null we can change this
to the number of rows in the tables if this number is exact and
there are no outer joins.
*/
if (!conds && !((Item_sum_count*) item)->args[0]->maybe_null &&
!outer_tables && is_exact_count)
{
- longlong count= 1;
- TABLE_LIST *table;
- for (table= tables; table; table= table->next_leaf)
- {
- if (outer_tables || (table->table->file->table_flags() &
- HA_NOT_EXACT_COUNT) || table->schema_table)
- {
- const_result= 0; // Can't optimize left join
- break;
- }
- tables->table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
- count*= table->table->file->records;
- }
- if (!table)
- {
- ((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;