summaryrefslogtreecommitdiff
path: root/sql/opt_sum.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/opt_sum.cc')
-rw-r--r--sql/opt_sum.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc
index af2d9ddc2e7..6cf09afad9d 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -298,6 +298,7 @@ int opt_sum_query(THD *thd,
if (!(tl->table->file->ha_table_flags() & HA_STATS_RECORDS_IS_EXACT) ||
tl->schema_table)
{
+stats_records_inexact:
maybe_exact_count&= MY_TEST(!tl->schema_table &&
(tl->table->file->ha_table_flags() &
HA_HAS_RECORDS));
@@ -321,7 +322,12 @@ int opt_sum_query(THD *thd,
tl->table->file->print_error(error, MYF(ME_FATAL));
DBUG_RETURN(error);
}
- count*= tl->table->file->stats.records;
+
+ ha_rows num_rows;
+ if (tl->table->file->records2(&num_rows)) {
+ goto stats_records_inexact;
+ }
+ count *= num_rows;
}
}