[Commits] 57cc13d1770: More code cleanups
revision-id: 57cc13d177067979dad47307dac8ea41621899c7 (mariadb-10.6.1-115-g57cc13d1770) parent(s): 034f232e182a172847d534554cb8ed56b56c8222 author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2021-09-04 17:24:47 +0300 message: More code cleanups Remove Histogram_*::is_available(), it is not applicable anymore. Fix compilation on Windows --- sql/opt_histogram_json.cc | 2 +- sql/opt_histogram_json.h | 10 +--------- sql/sql_statistics.cc | 2 +- sql/sql_statistics.h | 23 ++++++++--------------- 4 files changed, 11 insertions(+), 26 deletions(-) diff --git a/sql/opt_histogram_json.cc b/sql/opt_histogram_json.cc index 196ee6f2737..cc20165b4db 100644 --- a/sql/opt_histogram_json.cc +++ b/sql/opt_histogram_json.cc @@ -126,7 +126,7 @@ void Histogram_json_hb::init_for_collection(MEM_ROOT *mem_root, ulonglong size_arg) { DBUG_ASSERT(htype_arg == JSON_HB); - size= (uint8) size_arg; + size= (size_t)size_arg; } diff --git a/sql/opt_histogram_json.h b/sql/opt_histogram_json.h index c5b31c273ad..3fbba8814dd 100644 --- a/sql/opt_histogram_json.h +++ b/sql/opt_histogram_json.h @@ -69,14 +69,6 @@ class Histogram_json_hb : public Histogram_base void init_for_collection(MEM_ROOT *mem_root, Histogram_type htype_arg, ulonglong size) override; - bool is_available() override {return true; } - - bool is_usable(THD *thd) override - { - return thd->variables.optimizer_use_condition_selectivity > 3 && - is_available(); - } - double point_selectivity(Field *field, key_range *endpoint, double avg_selection) override; double range_selectivity(Field *field, key_range *min_endp, @@ -84,7 +76,7 @@ class Histogram_json_hb : public Histogram_base void set_json_text(ulonglong sz, uchar *json_text_arg) { - size = (uint8) sz; + size= (size_t) sz; json_text.assign((const char*)json_text_arg, strlen((const char*)json_text_arg)); } diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index dd79cc16d59..ca9fb8ae194 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -1271,7 +1271,7 @@ void Histogram_binary::init_for_collection(MEM_ROOT *mem_root, ulonglong size_arg) { type= htype_arg; - values = (uchar*)alloc_root(mem_root, size_arg); + values= (uchar*)alloc_root(mem_root, (size_t)size_arg); size= (uint8) size_arg; } diff --git a/sql/sql_statistics.h b/sql/sql_statistics.h index 7ac315f48e2..601c5bf907f 100644 --- a/sql/sql_statistics.h +++ b/sql/sql_statistics.h @@ -175,9 +175,15 @@ class Histogram_base : public Sql_alloc virtual Histogram_builder *create_builder(Field *col, uint col_len, ha_rows rows)=0; - virtual bool is_available()=0; + /* + This function checks that histograms should be usable only when + 1) the level of optimizer_use_condition_selectivity > 3 + */ + bool is_usable(THD *thd) + { + return thd->variables.optimizer_use_condition_selectivity > 3; + } - virtual bool is_usable(THD *thd)=0; virtual double point_selectivity(Field *field, key_range *endpoint, double avg_selection)=0; @@ -312,19 +318,6 @@ class Histogram_binary : public Histogram_base Histogram_builder *create_builder(Field *col, uint col_len, ha_rows rows) override; - bool is_available() override { return (values!=NULL); } - - /* - This function checks that histograms should be usable only when - 1) the level of optimizer_use_condition_selectivity > 3 - 2) histograms have been collected - */ - bool is_usable(THD *thd) override - { - return thd->variables.optimizer_use_condition_selectivity > 3 && - is_available(); - } - void set_value(uint i, double val) { switch (type) {
participants (1)
-
psergey