1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

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.
This commit is contained in:
Igor Babaev
2013-01-13 00:40:38 -08:00
parent 7d9df8075e
commit 7d5c56cb41
7 changed files with 85 additions and 2 deletions

View File

@ -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);
}