summaryrefslogtreecommitdiff
path: root/sql/sql_statistics.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2013-01-13 00:40:38 -0800
committerIgor Babaev <igor@askmonty.org>2013-01-13 00:40:38 -0800
commit7d5c56cb410bd0363e1c66c31149a79086584bbb (patch)
treecf76debbd4fa1d761c00f5798aec2e1843185686 /sql/sql_statistics.cc
parent7d9df8075e4c9392f4352e6ccd86921994f264bc (diff)
downloadmariadb-git-7d5c56cb410bd0363e1c66c31149a79086584bbb.tar.gz
Fixed bug mdev-4019.
The bug could cause a crash when several connections needed persistent statistics for the same table. Also added a missing call of set_statistics_for_table() in the code of the function mysql_update.
Diffstat (limited to 'sql/sql_statistics.cc')
-rw-r--r--sql/sql_statistics.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index 9de5aa080e1..68f26ebf90b 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -2501,6 +2501,8 @@ int read_statistics_for_table(THD *thd, TABLE *table, TABLE_LIST *stat_tables)
}
}
+ table->stats_is_read= TRUE;
+
DBUG_RETURN(0);
}
@@ -2559,6 +2561,8 @@ bool statistics_for_tables_is_needed(THD *thd, TABLE_LIST *tables)
table_share->stats_cb.stats_can_be_read &&
!table_share->stats_cb.stats_is_read)
return TRUE;
+ if (table_share->stats_cb.stats_is_read)
+ tl->table->stats_is_read= TRUE;
}
}
@@ -2618,6 +2622,8 @@ int read_statistics_for_tables_if_needed(THD *thd, TABLE_LIST *tables)
(void) read_statistics_for_table(thd, tl->table, stat_tables);
table_share->stats_cb.stats_is_read= TRUE;
}
+ if (table_share->stats_cb.stats_is_read)
+ tl->table->stats_is_read= TRUE;
}
}
@@ -3045,7 +3051,7 @@ void set_statistics_for_table(THD *thd, TABLE *table)
Use_stat_tables_mode use_stat_table_mode= get_use_stat_tables_mode(thd);
table->used_stat_records=
(use_stat_table_mode <= COMPLEMENTARY ||
- !stats_cb->stats_is_read || read_stats->cardinality_is_null) ?
+ !table->stats_is_read || read_stats->cardinality_is_null) ?
table->file->stats.records : read_stats->cardinality;
KEY *key_info, *key_info_end;
for (key_info= table->key_info, key_info_end= key_info+table->s->keys;
@@ -3053,7 +3059,7 @@ void set_statistics_for_table(THD *thd, TABLE *table)
{
key_info->is_statistics_from_stat_tables=
(use_stat_table_mode > COMPLEMENTARY &&
- stats_cb->stats_is_read &&
+ table->stats_is_read &&
key_info->read_stats->avg_frequency_is_inited() &&
key_info->read_stats->get_avg_frequency(0) > 0.5);
}