MySQL  8.0.17
Source Code Documentation
Sql_cmd_analyze_table Class Reference

Sql_cmd_analyze_table represents the ANALYZE TABLE statement. More...

#include <sql_admin.h>

Inheritance diagram for Sql_cmd_analyze_table:
Sql_cmd_ddl_table Sql_cmd Sql_cmd_alter_table_analyze_partition

Public Types

enum  Histogram_command { Histogram_command::NONE, Histogram_command::UPDATE_HISTOGRAM, Histogram_command::DROP_HISTOGRAM }
 Specifies which (if any) of the commands UPDATE HISTOGRAM or DROP HISTOGRAM that is specified after ANALYZE TABLE tbl. More...
 

Public Member Functions

 Sql_cmd_analyze_table (THD *thd, Alter_info *alter_info, Histogram_command histogram_command, int histogram_buckets)
 Constructor, used to represent a ANALYZE TABLE statement. More...
 
bool execute (THD *thd) override
 Execute this SQL statement. More...
 
enum_sql_command sql_command_code () const override
 Return the command code for this statement. More...
 
bool set_histogram_fields (List< String > *fields)
 Set which fields to (try and) create/update or delete histogram statistics for. More...
 
- Public Member Functions inherited from Sql_cmd_ddl_table
 Sql_cmd_ddl_table (Alter_info *alter_info)
 
virtual ~Sql_cmd_ddl_table ()=0
 
- Public Member Functions inherited from Sql_cmd
bool is_prepared () const
 
virtual bool prepare (THD *thd)
 Prepare this SQL statement. More...
 
virtual void cleanup (THD *thd)
 Command-specific reinitialization before execution of prepared statement. More...
 
void set_owner (Prepared_statement *stmt)
 Set the owning prepared statement. More...
 
Prepared_statementget_owner ()
 Get the owning prepared statement. More...
 
virtual bool is_dml () const
 
virtual bool is_single_table_plan () const
 
virtual void unprepare (THD *thd)
 Temporary function used to "unprepare" a prepared statement after preparation, so that a subsequent execute statement will reprepare it. More...
 
virtual bool accept (THD *thd, Select_lex_visitor *visitor)
 
virtual const MYSQL_LEX_CSTRINGeligible_secondary_storage_engine () const
 Is this statement of a type and on a form that makes it eligible for execution in a secondary storage engine? More...
 
void disable_secondary_storage_engine ()
 Disable use of secondary storage engines in this statement. More...
 
bool secondary_storage_engine_disabled () const
 Has use of secondary storage engines been disabled for this statement? More...
 
void use_secondary_storage_engine (const handlerton *hton)
 Mark the current statement as using a secondary storage engine. More...
 
bool using_secondary_storage_engine () const
 Is this statement using a secondary storage engine? More...
 
const handlertonsecondary_engine () const
 Get the handlerton of the secondary engine that is used for executing this statement, or nullptr if a secondary engine is not used. More...
 

Private Types

using columns_set = std::set< String *, Column_name_comparator, Memroot_allocator< String * > >
 

Private Member Functions

Histogram_command get_histogram_command () const
 
int get_histogram_buckets () const
 
const columns_setget_histogram_fields () const
 
bool send_histogram_results (THD *thd, const histograms::results_map &results, const TABLE_LIST *table)
 Send the result of histogram operations back to the client as a result set. More...
 
bool update_histogram (THD *thd, TABLE_LIST *table, histograms::results_map &results)
 Update one or more histograms. More...
 
bool drop_histogram (THD *thd, TABLE_LIST *table, histograms::results_map &results)
 Drops one or more histograms. More...
 
bool handle_histogram_command (THD *thd, TABLE_LIST *table)
 

Private Attributes

Histogram_command m_histogram_command = Histogram_command::NONE
 Which histogram command (if any) is specified. More...
 
columns_set m_histogram_fields
 The fields specified by the user in UPDATE/DROP HISTOGRAM. More...
 
int m_histogram_buckets
 The number of buckets specified by the user in UPDATE HISTOGRAM. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Sql_cmd
 Sql_cmd ()
 
virtual ~Sql_cmd ()
 
bool needs_explicit_preparation () const
 
void set_prepared ()
 Set this statement as prepared. More...
 
- Protected Attributes inherited from Sql_cmd_ddl_table
Alter_info *const m_alter_info
 
- Protected Attributes inherited from Sql_cmd
bool prepare_only
 

Detailed Description

Sql_cmd_analyze_table represents the ANALYZE TABLE statement.

Also this class is a base class for Sql_cmd_alter_table_analyze_partition which represents the ALTER TABLE ... ANALYZE PARTITION statement.

Member Typedef Documentation

◆ columns_set

Member Enumeration Documentation

◆ Histogram_command

Specifies which (if any) of the commands UPDATE HISTOGRAM or DROP HISTOGRAM that is specified after ANALYZE TABLE tbl.

Enumerator
NONE 

Neither UPDATE or DROP histogram is specified.

UPDATE_HISTOGRAM 

UPDATE HISTOGRAM ...

is specified after ANALYZE TABLE

DROP_HISTOGRAM 

DROP HISTOGRAM ... is specified after ANALYZE TABLE.

Constructor & Destructor Documentation

◆ Sql_cmd_analyze_table()

Sql_cmd_analyze_table::Sql_cmd_analyze_table ( THD thd,
Alter_info alter_info,
Histogram_command  histogram_command,
int  histogram_buckets 
)

Constructor, used to represent a ANALYZE TABLE statement.

Member Function Documentation

◆ drop_histogram()

bool Sql_cmd_analyze_table::drop_histogram ( THD thd,
TABLE_LIST table,
histograms::results_map results 
)
private

Drops one or more histograms.

This is invoked by running the command "ANALYZE TABLE tbl DROP HISTOGRAM ON col1, col2;". Note that the function expects exactly one table to be specified, but multiple columns can be specified.

Parameters
thdThread handler.
tableThe table specified in ANALYZE TABLE
resultsA map where the results of the operations will be stored.
Returns
false on success, true on error.

◆ execute()

bool Sql_cmd_analyze_table::execute ( THD thd)
overridevirtual

Execute this SQL statement.

Parameters
thdthe current thread.
Returns
false if success, true if error

Implements Sql_cmd.

Reimplemented in Sql_cmd_alter_table_analyze_partition.

◆ get_histogram_buckets()

int Sql_cmd_analyze_table::get_histogram_buckets ( ) const
inlineprivate
Returns
The number of buckets specified in UPDATE HISTOGRAM.

◆ get_histogram_command()

Histogram_command Sql_cmd_analyze_table::get_histogram_command ( ) const
inlineprivate
Returns
The histogram command specified, if any.

◆ get_histogram_fields()

const columns_set& Sql_cmd_analyze_table::get_histogram_fields ( ) const
inlineprivate
Returns
The fields specified in UPDATE/DROP HISTOGRAM

◆ handle_histogram_command()

bool Sql_cmd_analyze_table::handle_histogram_command ( THD thd,
TABLE_LIST table 
)
private

◆ send_histogram_results()

bool Sql_cmd_analyze_table::send_histogram_results ( THD thd,
const histograms::results_map results,
const TABLE_LIST table 
)
private

Send the result of histogram operations back to the client as a result set.

Parameters
thdThread handle.
resultsThe messages to send back to the client.
tableThe table the operations was performed on.
Returns
false on success, true otherwise.

◆ set_histogram_fields()

bool Sql_cmd_analyze_table::set_histogram_fields ( List< String > *  fields)

Set which fields to (try and) create/update or delete histogram statistics for.

◆ sql_command_code()

enum_sql_command Sql_cmd_analyze_table::sql_command_code ( ) const
inlineoverridevirtual

Return the command code for this statement.

Implements Sql_cmd.

Reimplemented in Sql_cmd_alter_table_analyze_partition.

◆ update_histogram()

bool Sql_cmd_analyze_table::update_histogram ( THD thd,
TABLE_LIST table,
histograms::results_map results 
)
private

Update one or more histograms.

This is invoked by running the command "ANALYZE TABLE tbl UPDATE HISTOGRAM ON col1, col2 WITH n BUCKETS". Note that the function expects exactly one table to be specified, but multiple columns can be specified.

Parameters
thdThread handler.
tableThe table specified in ANALYZE TABLE
resultsA map where the results of the operations will be stored.
Returns
false on success, true on error.

Member Data Documentation

◆ m_histogram_buckets

int Sql_cmd_analyze_table::m_histogram_buckets
private

The number of buckets specified by the user in UPDATE HISTOGRAM.

◆ m_histogram_command

Histogram_command Sql_cmd_analyze_table::m_histogram_command = Histogram_command::NONE
private

Which histogram command (if any) is specified.

◆ m_histogram_fields

columns_set Sql_cmd_analyze_table::m_histogram_fields
private

The fields specified by the user in UPDATE/DROP HISTOGRAM.


The documentation for this class was generated from the following files: