MySQL 8.0.39
Source Code Documentation
Sql_cmd Class Referenceabstract

Representation of an SQL command. More...

#include <sql_cmd.h>

Inheritance diagram for Sql_cmd:
[legend]

Public Member Functions

virtual enum_sql_command sql_command_code () const =0
 Return the command code for this statement. More...
 
bool needs_explicit_preparation () const
 
bool is_regular () const
 
bool is_prepared () const
 
virtual bool prepare (THD *)
 Prepare this SQL statement. More...
 
virtual bool execute (THD *thd)=0
 Execute this SQL statement. More...
 
virtual void cleanup (THD *)
 Command-specific reinitialization before execution of prepared statement. More...
 
void set_owner (Prepared_statement *stmt)
 Set the owning prepared statement. More...
 
Prepared_statementowner () const
 Get the owning prepared statement. More...
 
void set_as_part_of_sp ()
 Mark statement as part of procedure. More...
 
bool is_part_of_sp () const
 
virtual bool is_dml () const
 
virtual bool is_single_table_plan () const
 
virtual bool accept (THD *, Select_lex_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...
 
void set_optional_transform_prepared (bool value)
 
bool is_optional_transform_prepared ()
 

Protected Member Functions

 Sql_cmd ()
 
virtual ~Sql_cmd ()
 
void set_prepared ()
 Set this statement as prepared. More...
 

Private Member Functions

 Sql_cmd (const Sql_cmd &)
 
void operator= (Sql_cmd &)
 

Private Attributes

Prepared_statementm_owner
 
bool m_part_of_sp
 Owning prepared statement, NULL if non-prep. More...
 
bool m_prepared
 True when statement is part of stored proc. More...
 
bool m_secondary_engine_enabled {true}
 True when statement has been prepared. More...
 
bool m_prepared_with_optional_transform {false}
 Keeps track of whether the statement was prepared optional transformation. More...
 
const handlertonm_secondary_engine {nullptr}
 The secondary storage engine to use for execution of this statement, if any, or nullptr if the primary engine is used. More...
 

Detailed Description

Representation of an SQL command.

This class is an interface between the parser and the runtime. The parser builds the appropriate derived classes of Sql_cmd to represent a SQL statement in the parsed tree. The execute() method in the derived classes of Sql_cmd contain the runtime implementation. Note that this interface is used for SQL statements recently implemented, the code for older statements tend to load the LEX structure with more attributes instead. Implement new statements by sub-classing Sql_cmd, as this improves code modularity (see the 'big switch' in dispatch_command()), and decreases the total size of the LEX structure (therefore saving memory in stored programs). The recommended name of a derived class of Sql_cmd is Sql_cmd_<derived>.

Notice that the Sql_cmd class should not be confused with the Statement class. Statement is a class that is used to manage an SQL command or a set of SQL commands. When the SQL statement text is analyzed, the parser will create one or more Sql_cmd objects to represent the actual SQL commands.

Constructor & Destructor Documentation

◆ Sql_cmd() [1/2]

Sql_cmd::Sql_cmd ( const Sql_cmd )
private

◆ Sql_cmd() [2/2]

Sql_cmd::Sql_cmd ( )
inlineprotected

◆ ~Sql_cmd()

virtual Sql_cmd::~Sql_cmd ( )
inlineprotectedvirtual

Member Function Documentation

◆ accept()

virtual bool Sql_cmd::accept ( THD ,
Select_lex_visitor  
)
inlinevirtual

◆ cleanup()

virtual void Sql_cmd::cleanup ( THD )
inlinevirtual

Command-specific reinitialization before execution of prepared statement.

param thd Current THD.

◆ disable_secondary_storage_engine()

void Sql_cmd::disable_secondary_storage_engine ( )
inline

Disable use of secondary storage engines in this statement.

After a call to this function, the statement will not try to use a secondary storage engine until it is reprepared.

◆ eligible_secondary_storage_engine()

virtual const MYSQL_LEX_CSTRING * Sql_cmd::eligible_secondary_storage_engine ( ) const
inlinevirtual

Is this statement of a type and on a form that makes it eligible for execution in a secondary storage engine?

Returns
the name of the secondary storage engine, or nullptr if the statement is not eligible for execution in a secondary storage engine

Reimplemented in Sql_cmd_create_table, Sql_cmd_do, Sql_cmd_insert_select, and Sql_cmd_select.

◆ execute()

virtual bool Sql_cmd::execute ( THD thd)
pure virtual

Execute this SQL statement.

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

Implemented in Sql_cmd_create_tablespace, Sql_cmd_drop_tablespace, Sql_cmd_alter_tablespace_add_datafile, Sql_cmd_alter_tablespace_drop_datafile, Sql_cmd_alter_tablespace_rename, Sql_cmd_create_undo_tablespace, Sql_cmd_alter_undo_tablespace, Sql_cmd_drop_undo_tablespace, Sql_cmd_truncate_table, Sql_cmd_create_trigger, Sql_cmd_drop_trigger, Sql_cmd_explain_other_thread, resourcegroups::Sql_cmd_create_resource_group, resourcegroups::Sql_cmd_alter_resource_group, resourcegroups::Sql_cmd_drop_resource_group, resourcegroups::Sql_cmd_set_resource_group, Sql_cmd_change_repl_filter, Sql_cmd_analyze_table, Sql_cmd_check_table, Sql_cmd_optimize_table, Sql_cmd_repair_table, Sql_cmd_shutdown, Sql_cmd_set_role, Sql_cmd_create_role, Sql_cmd_drop_role, Sql_cmd_grant_roles, Sql_cmd_revoke_roles, Sql_cmd_alter_user_default_role, Sql_cmd_alter_instance, Sql_cmd_clone, Sql_cmd_alter_table, Sql_cmd_discard_import_tablespace, Sql_cmd_secondary_load_unload, Sql_cmd_lock_instance, Sql_cmd_unlock_instance, Sql_cmd_create_table, Sql_cmd_create_or_drop_index_base, Sql_cmd_cache_index, Sql_cmd_load_index, Sql_cmd_dml, Sql_cmd_create_srs, Sql_cmd_drop_srs, Sql_cmd_install_component, Sql_cmd_uninstall_component, Sql_cmd_get_diagnostics, Sql_cmd_handler_open, Sql_cmd_handler_read, Sql_cmd_handler_close, Sql_cmd_import_table, Sql_cmd_load_table, Sql_cmd_alter_table_exchange_partition, Sql_cmd_alter_table_analyze_partition, Sql_cmd_alter_table_check_partition, Sql_cmd_alter_table_optimize_partition, Sql_cmd_alter_table_repair_partition, Sql_cmd_alter_table_truncate_partition, Sql_cmd_install_plugin, Sql_cmd_uninstall_plugin, Sql_cmd_restart_server, Sql_cmd_create_server, Sql_cmd_alter_server, Sql_cmd_drop_server, Sql_cmd_show, Sql_cmd_show_noplan, Sql_cmd_show_status, Sql_cmd_signal, Sql_cmd_resignal, Sql_cmd_alter_tablespace, Sql_cmd_logfile_group, Sql_cmd_xa_commit, Sql_cmd_xa_end, Sql_cmd_xa_prepare, Sql_cmd_xa_recover, Sql_cmd_xa_rollback, and Sql_cmd_xa_start.

◆ is_dml()

virtual bool Sql_cmd::is_dml ( ) const
inlinevirtual
Returns
true if SQL command is a DML statement

Reimplemented in Sql_cmd_ddl, and Sql_cmd_dml.

◆ is_optional_transform_prepared()

bool Sql_cmd::is_optional_transform_prepared ( )
inline

◆ is_part_of_sp()

bool Sql_cmd::is_part_of_sp ( ) const
inline
Returns
true if statement is part of a stored procedure

◆ is_prepared()

bool Sql_cmd::is_prepared ( ) const
inline
Returns
true if this statement is prepared

◆ is_regular()

bool Sql_cmd::is_regular ( ) const
inline
Returns
true if statement is regular, ie not prepared statement and not part of stored procedure.

◆ is_single_table_plan()

virtual bool Sql_cmd::is_single_table_plan ( ) const
inlinevirtual
Returns
true if implemented as single table plan, DML statement only

Reimplemented in Sql_cmd_dml, Sql_cmd_delete, Sql_cmd_insert_values, and Sql_cmd_update.

◆ needs_explicit_preparation()

bool Sql_cmd::needs_explicit_preparation ( ) const
inline
Returns
true if object represents a preparable statement, ie. a query that is prepared with a PREPARE statement and executed with an EXECUTE statement. False is returned for regular statements (non-preparable statements) that are executed directly. Also false if statement is part of a stored procedure.

◆ operator=()

void Sql_cmd::operator= ( Sql_cmd )
private

◆ owner()

Prepared_statement * Sql_cmd::owner ( ) const
inline

Get the owning prepared statement.

◆ prepare()

virtual bool Sql_cmd::prepare ( THD )
inlinevirtual

Prepare this SQL statement.

param thd the current thread

Returns
false if success, true if error

Reimplemented in resourcegroups::Sql_cmd_set_resource_group, Sql_cmd_create_table, and Sql_cmd_dml.

◆ secondary_engine()

const handlerton * Sql_cmd::secondary_engine ( ) const
inline

Get the handlerton of the secondary engine that is used for executing this statement, or nullptr if a secondary engine is not used.

◆ secondary_storage_engine_disabled()

bool Sql_cmd::secondary_storage_engine_disabled ( ) const
inline

Has use of secondary storage engines been disabled for this statement?

◆ set_as_part_of_sp()

void Sql_cmd::set_as_part_of_sp ( )
inline

Mark statement as part of procedure.

Such statements can be executed multiple times, the first execute() call will also prepare it.

◆ set_optional_transform_prepared()

void Sql_cmd::set_optional_transform_prepared ( bool  value)
inline

◆ set_owner()

void Sql_cmd::set_owner ( Prepared_statement stmt)
inline

Set the owning prepared statement.

◆ set_prepared()

void Sql_cmd::set_prepared ( )
inlineprotected

Set this statement as prepared.

◆ sql_command_code()

virtual enum_sql_command Sql_cmd::sql_command_code ( ) const
pure virtual

Return the command code for this statement.

Implemented in Sql_cmd_common_alter_table, Sql_cmd_tablespace, Sql_cmd_create_trigger, Sql_cmd_drop_trigger, Sql_cmd_explain_other_thread, resourcegroups::Sql_cmd_create_resource_group, resourcegroups::Sql_cmd_alter_resource_group, resourcegroups::Sql_cmd_drop_resource_group, resourcegroups::Sql_cmd_set_resource_group, Sql_cmd_change_repl_filter, Sql_cmd_analyze_table, Sql_cmd_check_table, Sql_cmd_optimize_table, Sql_cmd_repair_table, Sql_cmd_shutdown, Sql_cmd_set_role, Sql_cmd_create_role, Sql_cmd_drop_role, Sql_cmd_grant_roles, Sql_cmd_revoke_roles, Sql_cmd_alter_user_default_role, Sql_cmd_alter_instance, Sql_cmd_clone, Sql_cmd_lock_instance, Sql_cmd_unlock_instance, Sql_cmd_call, Sql_cmd_create_table, Sql_cmd_create_index, Sql_cmd_drop_index, Sql_cmd_cache_index, Sql_cmd_load_index, Sql_cmd_create_srs, Sql_cmd_drop_srs, Sql_cmd_install_component, Sql_cmd_uninstall_component, Sql_cmd_delete, Sql_cmd_do, Sql_cmd_get_diagnostics, Sql_cmd_handler_open, Sql_cmd_handler_read, Sql_cmd_handler_close, Sql_cmd_import_table, Sql_cmd_insert_values, Sql_cmd_insert_select, Sql_cmd_load_table, Sql_cmd_alter_table_analyze_partition, Sql_cmd_alter_table_check_partition, Sql_cmd_alter_table_optimize_partition, Sql_cmd_alter_table_repair_partition, Sql_cmd_alter_table_truncate_partition, Sql_cmd_install_plugin, Sql_cmd_uninstall_plugin, Sql_cmd_restart_server, Sql_cmd_select, Sql_cmd_create_server, Sql_cmd_alter_server, Sql_cmd_drop_server, Sql_cmd_show, Sql_cmd_signal, Sql_cmd_resignal, Sql_cmd_create_undo_tablespace, Sql_cmd_alter_undo_tablespace, Sql_cmd_drop_undo_tablespace, Sql_cmd_logfile_group, Sql_cmd_truncate_table, Sql_cmd_update, Sql_cmd_xa_commit, Sql_cmd_xa_end, Sql_cmd_xa_prepare, Sql_cmd_xa_recover, Sql_cmd_xa_rollback, and Sql_cmd_xa_start.

◆ use_secondary_storage_engine()

void Sql_cmd::use_secondary_storage_engine ( const handlerton hton)
inline

Mark the current statement as using a secondary storage engine.

This function must be called before the statement starts opening tables in a secondary engine.

◆ using_secondary_storage_engine()

bool Sql_cmd::using_secondary_storage_engine ( ) const
inline

Is this statement using a secondary storage engine?

Note
that this is reliable during optimization and afterwards; during preparation, if this is an explicit preparation (SQL PREPARE, C API PREPARE, and automatic repreparation), it may be false as RAPID tables have not yet been opened. Therefore, during preparation, it is safer to test THD::secondary_engine_optimization().

Member Data Documentation

◆ m_owner

Prepared_statement* Sql_cmd::m_owner
private

◆ m_part_of_sp

bool Sql_cmd::m_part_of_sp
private

Owning prepared statement, NULL if non-prep.

◆ m_prepared

bool Sql_cmd::m_prepared
private

True when statement is part of stored proc.

◆ m_prepared_with_optional_transform

bool Sql_cmd::m_prepared_with_optional_transform {false}
private

Keeps track of whether the statement was prepared optional transformation.

◆ m_secondary_engine

const handlerton* Sql_cmd::m_secondary_engine {nullptr}
private

The secondary storage engine to use for execution of this statement, if any, or nullptr if the primary engine is used.

This property is reset at the start of each execution.

◆ m_secondary_engine_enabled

bool Sql_cmd::m_secondary_engine_enabled {true}
private

True when statement has been prepared.

Tells if a secondary storage engine can be used for this statement. If it is false, use of a secondary storage engine will not be considered for executing this statement.


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