MySQL 8.0.39
Source Code Documentation
histogram.cc File Reference

Histogram base class (implementation). More...

#include "sql/histograms/histogram.h"
#include <sys/types.h>
#include <algorithm>
#include <map>
#include <memory>
#include <new>
#include <random>
#include <string>
#include <vector>
#include "base64.h"
#include "decimal.h"
#include "field_types.h"
#include "lex_string.h"
#include "m_ctype.h"
#include "my_alloc.h"
#include "my_bitmap.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_sys.h"
#include "my_systime.h"
#include "my_time.h"
#include "mysql/service_mysql_alloc.h"
#include "mysql_time.h"
#include "mysqld_error.h"
#include "scope_guard.h"
#include "sql-common/json_dom.h"
#include "sql/auth/auth_common.h"
#include "sql/create_field.h"
#include "sql/dd/cache/dictionary_client.h"
#include "sql/dd/dd.h"
#include "sql/dd/string_type.h"
#include "sql/dd/types/column.h"
#include "sql/dd/types/column_statistics.h"
#include "sql/dd/types/table.h"
#include "sql/debug_sync.h"
#include "sql/error_handler.h"
#include "sql/handler.h"
#include "sql/histograms/equi_height.h"
#include "sql/histograms/singleton.h"
#include "sql/histograms/value_map.h"
#include "sql/item.h"
#include "sql/item_json_func.h"
#include "sql/key.h"
#include "sql/mdl.h"
#include "sql/my_decimal.h"
#include "sql/psi_memory_key.h"
#include "sql/sql_base.h"
#include "sql/sql_bitmap.h"
#include "sql/sql_class.h"
#include "sql/sql_const.h"
#include "sql/sql_time.h"
#include "sql/strfunc.h"
#include "sql/system_variables.h"
#include "sql/table.h"
#include "sql/thd_raii.h"
#include "sql/transaction.h"
#include "sql/tztime.h"
#include "sql_string.h"
#include "template_utils.h"

Classes

class  histograms::Histogram_error_handler
 RAII class to trap lower-level errors. More...
 

Namespaces

namespace  histograms
 

Typedefs

using histograms::value_map_collection = std::map< uint16, std::unique_ptr< histograms::Value_map_base >, std::less< uint16 >, Histogram_key_allocator< std::pair< const uint16, std::unique_ptr< histograms::Value_map_base > > > >
 

Functions

static Value_map_type histograms::field_type_to_value_map_type (const enum_field_types field_type, const bool is_unsigned)
 Convert from enum_field_types to Value_map_type. More...
 
static Value_map_type histograms::field_type_to_value_map_type (const Field *field)
 Get the Value_map_type from a Field object. More...
 
static type_conversion_status histograms::check_value_aux (Field *field, const double *nr)
 Helper function for check_value(). More...
 
static type_conversion_status histograms::check_value_aux (Field *field, const String *str)
 
static type_conversion_status histograms::check_value_aux (Field *field, const longlong *nr)
 
static type_conversion_status histograms::check_value_aux (Field *field, const ulonglong *nr)
 
static type_conversion_status histograms::check_value_aux (Field *field, MYSQL_TIME *ltime)
 
static type_conversion_status histograms::check_value_aux (Field *field, const my_decimal *mdec)
 
static bool histograms::lock_for_write (THD *thd, const MDL_key &mdl_key)
 Lock a column statistic MDL key for writing (exclusive lock). More...
 
template<class T >
Histogram * histograms::build_histogram (MEM_ROOT *mem_root, const Value_map< T > &value_map, size_t num_buckets, const std::string &db_name, const std::string &tbl_name, const std::string &col_name)
 Create a histogram from a value map. More...
 
static bool histograms::covered_by_single_part_index (const THD *thd, const Field *field)
 Check if a field is covered by a single-part unique index (primary key or unique index). More...
 
static bool histograms::prepare_value_maps (std::vector< Field *, Histogram_key_allocator< Field * > > &fields, value_map_collection &value_maps, size_t *row_size_bytes)
 Prepare one Value_map for each field we are creating histogram statistics for. More...
 
static bool histograms::fill_value_maps (const std::vector< Field *, Histogram_key_allocator< Field * > > &fields, double sample_percentage, const TABLE *table, value_map_collection &value_maps)
 Read data from a table into the provided Value_maps. More...
 
bool histograms::update_histogram (THD *thd, Table_ref *table, const columns_set &columns, int num_buckets, LEX_STRING data, results_map &results)
 Create or update histograms for a set of columns of a given table. More...
 
bool histograms::drop_all_histograms (THD *thd, Table_ref &table, const dd::Table &original_table_def, results_map &results)
 Drop histograms for all columns in a given table. More...
 
bool histograms::drop_histograms (THD *thd, Table_ref &table, const columns_set &columns, bool needs_lock, results_map &results)
 Drop histograms for a set of columns in a given table. More...
 
static bool histograms::rename_histogram (THD *thd, const char *old_schema_name, const char *old_table_name, const char *new_schema_name, const char *new_table_name, const char *column_name, results_map &results)
 Rename a single histogram from a old schema/table name to a new schema/table name. More...
 
bool histograms::rename_histograms (THD *thd, const char *old_schema_name, const char *old_table_name, const char *new_schema_name, const char *new_table_name, results_map &results)
 Rename histograms for all columns in a given table. More...
 
bool histograms::find_histogram (THD *thd, const std::string &schema_name, const std::string &table_name, const std::string &column_name, const Histogram **histogram)
 
static bool histograms::get_temporal (Item *item, Value_map_type preferred_type, MYSQL_TIME *time_value)
 
template Histogram * histograms::build_histogram (MEM_ROOT *, const Value_map< double > &, size_t, const std::string &, const std::string &, const std::string &)
 
template Histogram * histograms::build_histogram (MEM_ROOT *, const Value_map< String > &, size_t, const std::string &, const std::string &, const std::string &)
 
template Histogram * histograms::build_histogram (MEM_ROOT *, const Value_map< ulonglong > &, size_t, const std::string &, const std::string &, const std::string &)
 
template Histogram * histograms::build_histogram (MEM_ROOT *, const Value_map< longlong > &, size_t, const std::string &, const std::string &, const std::string &)
 
template Histogram * histograms::build_histogram (MEM_ROOT *, const Value_map< MYSQL_TIME > &, size_t, const std::string &, const std::string &, const std::string &)
 
template Histogram * histograms::build_histogram (MEM_ROOT *, const Value_map< my_decimal > &, size_t, const std::string &, const std::string &, const std::string &)
 

Variables

static constexpr int histograms::MAX_NUMBER_OF_HISTOGRAM_BUCKETS = 1024
 
static std::map< const Value_map_type, const std::string > histograms::value_map_type_to_str
 

Detailed Description

Histogram base class (implementation).