Commit 9f53c310 authored by Igor Babaev's avatar Igor Babaev

Fixed a problem for Q18 from DBT3/SF30 with innodb database instance:

the server crashed when running the query with persistent statistics
enabled.
The field KEY::read_stat.avg_frequency must be initialized to NULL
for the keys of temporary tables.
 
parent 9e74665a
...@@ -14657,6 +14657,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, ...@@ -14657,6 +14657,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
keyinfo->algorithm= HA_KEY_ALG_UNDEF; keyinfo->algorithm= HA_KEY_ALG_UNDEF;
keyinfo->is_statistics_from_stat_tables= FALSE; keyinfo->is_statistics_from_stat_tables= FALSE;
keyinfo->rec_per_key=0; keyinfo->rec_per_key=0;
keyinfo->read_stat.avg_frequency= NULL;
/* /*
Create an extra field to hold NULL bits so that unique indexes on Create an extra field to hold NULL bits so that unique indexes on
......
...@@ -1636,6 +1636,7 @@ void set_statistics_for_table(THD *thd, TABLE *table) ...@@ -1636,6 +1636,7 @@ void set_statistics_for_table(THD *thd, TABLE *table)
key_info < key_info_end; key_info++) key_info < key_info_end; key_info++)
{ {
key_info->is_statistics_from_stat_tables= key_info->is_statistics_from_stat_tables=
(use_stat_table_mode > 1 && key_info->read_stat.avg_frequency[0] > 0.5); (use_stat_table_mode > 1 && key_info->read_stat.avg_frequency &&
key_info->read_stat.avg_frequency[0] > 0.5);
} }
} }
...@@ -5957,6 +5957,7 @@ bool TABLE::add_tmp_key(uint key, uint key_parts, ...@@ -5957,6 +5957,7 @@ bool TABLE::add_tmp_key(uint key, uint key_parts,
if (!keyinfo->rec_per_key) if (!keyinfo->rec_per_key)
return TRUE; return TRUE;
bzero(keyinfo->rec_per_key, sizeof(ulong)*key_parts); bzero(keyinfo->rec_per_key, sizeof(ulong)*key_parts);
keyinfo->read_stat.avg_frequency= NULL;
for (i= 0; i < key_parts; i++) for (i= 0; i < key_parts; i++)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment