Commit 9271bd17 authored by Sergei Petrunia's avatar Sergei Petrunia

More code cleanups

Remove Histogram_*::is_available(), it is not applicable anymore.
Fix compilation on Windows
parent 1d981685
...@@ -126,7 +126,7 @@ void Histogram_json_hb::init_for_collection(MEM_ROOT *mem_root, ...@@ -126,7 +126,7 @@ void Histogram_json_hb::init_for_collection(MEM_ROOT *mem_root,
ulonglong size_arg) ulonglong size_arg)
{ {
DBUG_ASSERT(htype_arg == JSON_HB); DBUG_ASSERT(htype_arg == JSON_HB);
size= (uint8) size_arg; size= (size_t)size_arg;
} }
......
...@@ -69,14 +69,6 @@ class Histogram_json_hb : public Histogram_base ...@@ -69,14 +69,6 @@ class Histogram_json_hb : public Histogram_base
void init_for_collection(MEM_ROOT *mem_root, Histogram_type htype_arg, void init_for_collection(MEM_ROOT *mem_root, Histogram_type htype_arg,
ulonglong size) override; 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 point_selectivity(Field *field, key_range *endpoint,
double avg_selection) override; double avg_selection) override;
double range_selectivity(Field *field, key_range *min_endp, double range_selectivity(Field *field, key_range *min_endp,
...@@ -84,7 +76,7 @@ class Histogram_json_hb : public Histogram_base ...@@ -84,7 +76,7 @@ class Histogram_json_hb : public Histogram_base
void set_json_text(ulonglong sz, uchar *json_text_arg) 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, json_text.assign((const char*)json_text_arg,
strlen((const char*)json_text_arg)); strlen((const char*)json_text_arg));
} }
......
...@@ -1271,7 +1271,7 @@ void Histogram_binary::init_for_collection(MEM_ROOT *mem_root, ...@@ -1271,7 +1271,7 @@ void Histogram_binary::init_for_collection(MEM_ROOT *mem_root,
ulonglong size_arg) ulonglong size_arg)
{ {
type= htype_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; size= (uint8) size_arg;
} }
......
...@@ -175,9 +175,15 @@ class Histogram_base : public Sql_alloc ...@@ -175,9 +175,15 @@ class Histogram_base : public Sql_alloc
virtual Histogram_builder *create_builder(Field *col, uint col_len, virtual Histogram_builder *create_builder(Field *col, uint col_len,
ha_rows rows)=0; 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, virtual double point_selectivity(Field *field, key_range *endpoint,
double avg_selection)=0; double avg_selection)=0;
...@@ -312,19 +318,6 @@ class Histogram_binary : public Histogram_base ...@@ -312,19 +318,6 @@ class Histogram_binary : public Histogram_base
Histogram_builder *create_builder(Field *col, uint col_len, Histogram_builder *create_builder(Field *col, uint col_len,
ha_rows rows) override; 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) void set_value(uint i, double val)
{ {
switch (type) { switch (type) {
......
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