summaryrefslogtreecommitdiff
path: root/sql/sql_statistics.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_statistics.cc')
-rw-r--r--sql/sql_statistics.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index 3c5e3859939..dd59ba23b0d 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -3627,10 +3627,15 @@ void set_statistics_for_table(THD *thd, TABLE *table)
{
TABLE_STATISTICS_CB *stats_cb= &table->s->stats_cb;
Table_statistics *read_stats= stats_cb->table_stats;
- table->used_stat_records=
+
+ /*
+ The MAX below is to ensure that we don't return 0 rows for a table if it
+ not guaranteed to be empty.
+ */
+ table->used_stat_records=
(!check_eits_preferred(thd) ||
!table->stats_is_read || read_stats->cardinality_is_null) ?
- table->file->stats.records : read_stats->cardinality;
+ table->file->stats.records : MY_MAX(read_stats->cardinality, 1);
/*
For partitioned table, EITS statistics is based on data from all partitions.