diff options
author | Igor Babaev <igor@askmonty.org> | 2012-11-02 20:38:05 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2012-11-02 20:38:05 -0700 |
commit | 8d612adf70c53dcb741b097133e09d176d0780e1 (patch) | |
tree | 278a83cc5caaccbfb408471cef6bde5e5171d802 /sql/table.cc | |
parent | 4ffc9c3b01459a2904a7154a6c750d128864fc7b (diff) | |
parent | 32443e744d354fbba93c8761486462b5820b74bb (diff) | |
download | mariadb-git-8d612adf70c53dcb741b097133e09d176d0780e1.tar.gz |
Merge 5.5 -> 5.5-mwl248.
Diffstat (limited to 'sql/table.cc')
-rw-r--r-- | sql/table.cc | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/sql/table.cc b/sql/table.cc index c0e27b9a962..6a6f9681471 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -39,6 +39,7 @@ #include "my_bit.h" #include "sql_select.h" #include "sql_derived.h" +#include "sql_statistics.h" #include "mdl.h" // MDL_wait_for_graph_visitor /* INFORMATION_SCHEMA name */ @@ -544,6 +545,12 @@ inline bool is_system_table_name(const char *name, uint length) my_tolower(ci, name[2]) == 'm' && my_tolower(ci, name[3]) == 'e') || + /* one of mysql.*_stat tables */ + (my_tolower(ci, name[length-4]) == 's' && + my_tolower(ci, name[length-3]) == 't' && + my_tolower(ci, name[length-2]) == 'a' && + my_tolower(ci, name[length-1]) == 't') || + /* mysql.event table */ (my_tolower(ci, name[0]) == 'e' && my_tolower(ci, name[1]) == 'v' && @@ -753,7 +760,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, uchar forminfo[288]; uchar *record; uchar *disk_buff, *strpos, *null_flags, *null_pos; - ulong pos, record_offset; + ulong pos, record_offset; ulong *rec_per_key= NULL; ulong rec_buff_length; handler *handler_file= 0; @@ -5971,6 +5978,7 @@ bool TABLE::add_tmp_key(uint key, uint key_parts, keyinfo->algorithm= HA_KEY_ALG_UNDEF; keyinfo->flags= HA_GENERATED_KEY; keyinfo->ext_key_flags= keyinfo->flags; + keyinfo->is_statistics_from_stat_tables= FALSE; if (unique) keyinfo->flags|= HA_NOSAME; sprintf(buf, "key%i", key); @@ -5981,6 +5989,8 @@ bool TABLE::add_tmp_key(uint key, uint key_parts, if (!keyinfo->rec_per_key) return TRUE; bzero(keyinfo->rec_per_key, sizeof(ulong)*key_parts); + keyinfo->read_stats= NULL; + keyinfo->collected_stats= NULL; for (i= 0; i < key_parts; i++) { @@ -6671,6 +6681,7 @@ int TABLE_LIST::fetch_number_of_rows() { table->file->stats.records= ((select_union*)derived->result)->records; set_if_bigger(table->file->stats.records, 2); + table->used_stat_records= table->file->stats.records; } else error= table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK); @@ -6767,6 +6778,14 @@ uint TABLE_SHARE::actual_n_key_parts(THD *thd) } +double KEY::real_rec_per_key(uint i) +{ + if (rec_per_key == 0) + return 0; + return (is_statistics_from_stat_tables ? + read_stats->get_avg_frequency(i) : (double) rec_per_key[i]); +} + /***************************************************************************** ** Instansiate templates *****************************************************************************/ |