MySQL 8.4.2
Source Code Documentation
sql_show.h File Reference
#include <stddef.h>
#include <sys/types.h>
#include "field_types.h"
#include "lex_string.h"
#include "my_inttypes.h"
#include "mysql/status_var.h"
#include "sql/sql_select.h"
#include "typelib.h"

Go to the source code of this file.

Classes

class  Sql_cmd_show
 Sql_cmd_show represents the SHOW statements that are implemented as SELECT statements internally. More...
 
class  Sql_cmd_show_noplan
 Common base class: Represents commands that are not represented by a plan that is equivalent to a SELECT statement. More...
 
class  Sql_cmd_show_schema_base
 Common base class: Represents commands that operate on a schema (database) More...
 
class  Sql_cmd_show_table_base
 Common base class: Represents the SHOW COLUMNS and SHOW KEYS statements. More...
 
class  Sql_cmd_show_routine_code
 Represents SHOW FUNCTION CODE and SHOW PROCEDURE CODE statements. More...
 
class  Sql_cmd_show_binlog_events
 Following are all subclasses of class Sql_cmd_show, in alphabetical order. More...
 
class  Sql_cmd_show_binlogs
 Represents SHOW BINARY LOGS statement. More...
 
class  Sql_cmd_show_charsets
 Represents SHOW CHARACTER SET statement. More...
 
class  Sql_cmd_show_collations
 Represents SHOW COLLATION statement. More...
 
class  Sql_cmd_show_columns
 Represents SHOW COLUMNS statement. More...
 
class  Sql_cmd_show_create_database
 Represents SHOW CREATE DATABASE statement. More...
 
class  Sql_cmd_show_create_event
 Represents SHOW CREATE EVENT statement. More...
 
class  Sql_cmd_show_create_function
 Represents SHOW CREATE FUNCTION statement. More...
 
class  Sql_cmd_show_create_procedure
 Represents SHOW CREATE PROCEDURE statement. More...
 
class  Sql_cmd_show_create_table
 Represents SHOW CREATE TABLE/VIEW statement. More...
 
class  Sql_cmd_show_create_trigger
 Represents SHOW CREATE TRIGGER statement. More...
 
class  Sql_cmd_show_create_user
 Represents SHOW CREATE USER statement. More...
 
class  Sql_cmd_show_databases
 Represents SHOW DATABASES statement. More...
 
class  Sql_cmd_show_engine_logs
 Represents SHOW ENGINE LOGS statement. More...
 
class  Sql_cmd_show_engine_mutex
 Represents SHOW ENGINE MUTEX statement. More...
 
class  Sql_cmd_show_engine_status
 Represents SHOW ENGINE STATUS statement. More...
 
class  Sql_cmd_show_engines
 Represents SHOW STORAGE ENGINES statement. More...
 
class  Sql_cmd_show_errors
 Represents SHOW ERRORS statement. More...
 
class  Sql_cmd_show_events
 Represents SHOW EVENTS statement. More...
 
class  Sql_cmd_show_grants
 Represents SHOW GRANTS statement. More...
 
class  Sql_cmd_show_keys
 Represents the SHOW INDEX statement. More...
 
class  Sql_cmd_show_binary_log_status
 Represents SHOW BINARY LOG STATUS statement. More...
 
class  Sql_cmd_show_open_tables
 Represents SHOW OPEN TABLES statement. More...
 
class  Sql_cmd_show_plugins
 Represents SHOW PLUGINS statement. More...
 
class  Sql_cmd_show_privileges
 Represents SHOW PRIVILEGES statement. More...
 
class  Sql_cmd_show_processlist
 Represents SHOW PROCESSLIST statement. More...
 
class  Sql_cmd_show_parse_tree
 Represents SHOW PARSE_TREE statement. More...
 
class  Sql_cmd_show_profile
 Represents SHOW PROFILE statement. More...
 
class  Sql_cmd_show_profiles
 Represents SHOW PROFILES statement. More...
 
class  Sql_cmd_show_relaylog_events
 Represents SHOW RELAYLOG EVENTS statement. More...
 
class  Sql_cmd_show_replicas
 Represents SHOW REPLICAS statement. More...
 
class  Sql_cmd_show_replica_status
 Represents SHOW REPLICA STATUS statement. More...
 
class  Sql_cmd_show_status
 Represents SHOW STATUS statement. More...
 
class  Sql_cmd_show_status_func
 Represents SHOW STATUS FUNCTION statement. More...
 
class  Sql_cmd_show_status_proc
 Represents SHOW STATUS PROCEDURE statement. More...
 
class  Sql_cmd_show_table_status
 Represents SHOW TABLE STATUS statement. More...
 
class  Sql_cmd_show_tables
 Represents SHOW TABLES statement. More...
 
class  Sql_cmd_show_triggers
 Represents SHOW TRIGGERS statement. More...
 
class  Sql_cmd_show_variables
 Represents SHOW VARIABLES statement. More...
 
class  Sql_cmd_show_warnings
 Represents SHOW WARNINGS statement. More...
 

Typedefs

typedef enum enum_mysql_show_type SHOW_TYPE
 

Functions

enum enum_schema_tables int enum constexpr enum_var_type int const size_t constexpr PROCESS_LIST_WIDTH const size_t PROCESS_LIST_INFO_WIDTH bool store_create_info (THD *thd, Table_ref *table_list, String *packet, HA_CREATE_INFO *create_info_arg, bool show_database, bool for_show_create_stmt)
 Characters shown for the command in 'show processlist'. More...
 
void append_identifier (const THD *thd, String *packet, const char *name, size_t length, const CHARSET_INFO *from_cs, const CHARSET_INFO *to_cs)
 Convert and quote the given identifier if needed and append it to the target string. More...
 
void append_identifier (const THD *thd, String *packet, const char *name, size_t length)
 
void mysqld_list_fields (THD *thd, Table_ref *table, const char *wild)
 
bool mysqld_show_create (THD *thd, Table_ref *table_list)
 
bool mysqld_show_create_db (THD *thd, char *dbname, HA_CREATE_INFO *create)
 
void mysqld_list_processes (THD *thd, const char *user, bool verbose, bool has_cursor)
 List running processes (actually connected sessions). More...
 
bool mysqld_show_privileges (THD *thd)
 
void calc_sum_of_all_status (System_status_var *to)
 
void append_definer (const THD *thd, String *buffer, const LEX_CSTRING &definer_user, const LEX_CSTRING &definer_host)
 Append DEFINER clause to the given buffer. More...
 
bool add_status_vars (const SHOW_VAR *list)
 
void remove_status_vars (SHOW_VAR *list)
 
void init_status_vars ()
 
void free_status_vars ()
 
bool get_recursive_status_var (THD *thd, const char *name, char *const value, enum_var_type var_type, size_t *length, const CHARSET_INFO **charset)
 Get the string value of a status variable. More...
 
void reset_status_vars ()
 
ulonglong get_status_vars_version (void)
 
bool show_create_trigger (THD *thd, const sp_name *trg_name)
 SHOW CREATE TRIGGER high-level implementation. More...
 
void view_store_options (const THD *thd, Table_ref *table, String *buff)
 
bool schema_table_store_record (THD *thd, TABLE *table)
 
int schema_table_store_record2 (THD *thd, TABLE *table, bool make_ondisk)
 Store record to I_S table, convert HEAP table to InnoDB table if necessary. More...
 
bool convert_heap_table_to_ondisk (THD *thd, TABLE *table, int error)
 Convert HEAP table to InnoDB table if necessary. More...
 
void initialize_information_schema_acl ()
 
bool make_table_list (THD *thd, Query_block *sel, const LEX_CSTRING &db_name, const LEX_CSTRING &table_name)
 Prepare a Table_ident and add a table_list into Query_block. More...
 
ST_SCHEMA_TABLEfind_schema_table (THD *thd, const char *table_name)
 
ST_SCHEMA_TABLEget_schema_table (enum enum_schema_tables schema_table_idx)
 
bool make_schema_query_block (THD *thd, Query_block *sel, enum enum_schema_tables schema_table_idx)
 Generate select from information_schema table. More...
 
bool mysql_schema_table (THD *thd, LEX *lex, Table_ref *table_list)
 Create information_schema table. More...
 
enum enum_schema_tables get_schema_table_idx (ST_SCHEMA_TABLE *schema_table)
 
const char * get_one_variable (THD *thd, const SHOW_VAR *variable, enum_var_type value_type, SHOW_TYPE show_type, System_status_var *status_var, const CHARSET_INFO **charset, char *buff, size_t *length, bool *is_null=nullptr)
 Returns the value of a system or a status variable. More...
 
const char * get_one_variable_ext (THD *running_thd, THD *target_thd, const SHOW_VAR *variable, enum_var_type value_type, SHOW_TYPE show_type, System_status_var *status_var, const CHARSET_INFO **charset, char *buff, size_t *length, bool *is_null=nullptr)
 Returns the value of a system or a status variable. More...
 
int get_quote_char_for_identifier (const THD *thd, const char *name, size_t length)
 
void show_sql_type (enum_field_types type, bool is_array, uint metadata, String *str, const CHARSET_INFO *field_cs=nullptr)
 A field's SQL type printout. More...
 
bool do_fill_information_schema_table (THD *thd, Table_ref *table_list, Item *condition)
 Fill INFORMATION_SCHEMA-table, leave correct Diagnostics_area state after itself. More...
 

Variables

std::atomic_ulong deprecated_use_i_s_processlist_count
 Count number of times information_schema.processlist has been used. More...
 
std::atomic_ullong deprecated_use_i_s_processlist_last_timestamp
 Last time information_schema.processlist was used, as usec since epoch. More...
 
TYPELIB grant_types
 

Typedef Documentation

◆ SHOW_TYPE

Function Documentation

◆ add_status_vars()

bool add_status_vars ( const SHOW_VAR list)

◆ append_definer()

void append_definer ( const THD thd,
String buffer,
const LEX_CSTRING definer_user,
const LEX_CSTRING definer_host 
)

Append DEFINER clause to the given buffer.

Parameters
thdthread handle
[in,out]bufferbuffer to hold DEFINER clause
definer_useruser name part of definer
definer_hosthost name part of definer

◆ append_identifier() [1/2]

void append_identifier ( const THD thd,
String packet,
const char *  name,
size_t  length 
)

◆ append_identifier() [2/2]

void append_identifier ( const THD thd,
String packet,
const char *  name,
size_t  length,
const CHARSET_INFO from_cs,
const CHARSET_INFO to_cs 
)

Convert and quote the given identifier if needed and append it to the target string.

If the given identifier is empty, it will be quoted.

Parameters
thdthread handler
packettarget string
namethe identifier to be appended
lengthlength of the appending identifier
from_csCharset information about the input string
to_csCharset information about the target string

◆ calc_sum_of_all_status()

void calc_sum_of_all_status ( System_status_var to)

◆ convert_heap_table_to_ondisk()

bool convert_heap_table_to_ondisk ( THD thd,
TABLE table,
int  error 
)

Convert HEAP table to InnoDB table if necessary.

Parameters
[in]thdthread handler
[in]tableInformation schema table to be converted.
[in]errorthe error code returned previously.
Returns
false on success, true on error.

◆ do_fill_information_schema_table()

bool do_fill_information_schema_table ( THD thd,
Table_ref table_list,
Item condition 
)

Fill INFORMATION_SCHEMA-table, leave correct Diagnostics_area state after itself.

This function is a wrapper around ST_SCHEMA_TABLE::fill_table(), which may "partially silence" some errors. The thing is that during fill_table() many errors might be emitted. These errors stem from the nature of fill_table().

For example, SELECT ... FROM INFORMATION_SCHEMA.xxx WHERE TABLE_NAME = 'xxx' results in a number of 'Table <db name>.xxx does not exist' errors, because fill_table() tries to open the 'xxx' table in every possible database.

Those errors are cleared (the error status is cleared from Diagnostics_area) inside fill_table(), but they remain in the Diagnostics_area condition list (the list is not cleared because it may contain useful warnings).

This function is responsible for making sure that Diagnostics_area does not contain warnings corresponding to the cleared errors.

Note
: THD::no_warnings_for_error used to be set before calling fill_table(), thus those errors didn't go to Diagnostics_area. This is not the case now (THD::no_warnings_for_error was eliminated as a hack), so we need to take care of those warnings here.
Parameters
thdThread context.
table_listI_S table.
conditionCondition, which can be used to do less file manipulations (for example, WHERE TABLE_SCHEMA='test' allows to open only directory 'test', not other database directories).
Returns
Error status.
Return values
trueError.
falseSuccess.

◆ find_schema_table()

ST_SCHEMA_TABLE * find_schema_table ( THD thd,
const char *  table_name 
)

◆ free_status_vars()

void free_status_vars ( )

◆ get_one_variable()

const char * get_one_variable ( THD thd,
const SHOW_VAR variable,
enum_var_type  value_type,
SHOW_TYPE  show_type,
System_status_var status_var,
const CHARSET_INFO **  charset,
char *  buff,
size_t *  length,
bool *  is_null 
)

Returns the value of a system or a status variable.

Parameters
thdThe handle of the current THD.
variableDetails of the variable.
value_typeVariable type.
show_typeVariable show type.
status_varStatus values or NULL if for system variable.
[out]charsetCharacter set of the value.
[in,out]buffBuffer to store the value.
[out]lengthLength of the value.
[out]is_nullIs variable value NULL or not.
Returns
Pointer to the value buffer.

◆ get_one_variable_ext()

const char * get_one_variable_ext ( THD running_thd,
THD target_thd,
const SHOW_VAR variable,
enum_var_type  value_type,
SHOW_TYPE  show_type,
System_status_var status_var,
const CHARSET_INFO **  charset,
char *  buff,
size_t *  length,
bool *  is_null 
)

Returns the value of a system or a status variable.

Parameters
running_thdThe handle of the current THD.
target_thdThe handle of the remote THD.
variableDetails of the variable.
value_typeVariable type.
show_typeVariable show type.
status_varStatus values or NULL if for system variable.
[out]charsetCharacter set of the value.
[in,out]buffBuffer to store the value.
[out]lengthLength of the value.
[out]is_nullIs variable value NULL or not. This parameter is set only for variables of string type.
Returns
Pointer to the value buffer.

◆ get_quote_char_for_identifier()

int get_quote_char_for_identifier ( const THD thd,
const char *  name,
size_t  length 
)

◆ get_recursive_status_var()

bool get_recursive_status_var ( THD thd,
const char *  name,
char *const  value,
enum_var_type  var_type,
size_t *  length,
const CHARSET_INFO **  charset 
)

Get the string value of a status variable.

A top level API

Takes the LOCK_status lock and iterates over the registered status variable array all_status_vars to evaluate the value of a named status variable by calling get_recursive_status_var_inner for each element in all_status_vars.

Get the value of given status variable

Parameters
[in]thdthread handler
[in]namename of the status variable
[in]var_typeVariable type
[in,out]valuebuffer in which value of the status variable needs to be filled in
[in,out]lengthfilled with buffer length
[out]charsetcharset of the data returned
Returns
status
Return values
falseif variable is not found in the list
trueif variable is found in the list

◆ get_schema_table()

ST_SCHEMA_TABLE * get_schema_table ( enum enum_schema_tables  schema_table_idx)

◆ get_schema_table_idx()

enum enum_schema_tables get_schema_table_idx ( ST_SCHEMA_TABLE schema_table)

◆ get_status_vars_version()

ulonglong get_status_vars_version ( void  )

◆ init_status_vars()

void init_status_vars ( )

◆ initialize_information_schema_acl()

void initialize_information_schema_acl ( )

◆ make_schema_query_block()

bool make_schema_query_block ( THD thd,
Query_block sel,
enum enum_schema_tables  schema_table_idx 
)

Generate select from information_schema table.

Parameters
thdthread handler
selpointer to Query_block
schema_table_idxindex of 'schema_tables' element
Returns
true on error, false otherwise

◆ make_table_list()

bool make_table_list ( THD thd,
Query_block sel,
const LEX_CSTRING db_name,
const LEX_CSTRING table_name 
)

Prepare a Table_ident and add a table_list into Query_block.

Parameters
thdThread
selInstance of Query_block.
db_nameDatabase name.
table_nameTable name.
Returns
true on failure. false on success.

◆ mysql_schema_table()

bool mysql_schema_table ( THD thd,
LEX lex,
Table_ref table_list 
)

Create information_schema table.

Parameters
thdthread handler
lexpointer to LEX
table_listpointer to table_list
Returns
true on error, false otherwise.

◆ mysqld_list_fields()

void mysqld_list_fields ( THD thd,
Table_ref table,
const char *  wild 
)

◆ mysqld_list_processes()

void mysqld_list_processes ( THD thd,
const char *  user,
bool  verbose,
bool  has_cursor 
)

List running processes (actually connected sessions).

Parameters
thdthread handle.
userUsername of connected client.
verboseif false, limit output to PROCESS_LIST_WIDTH characters.
has_cursorif true, called from a command object that handles terminatation of sending to client, otherwise terminate explicitly with my_eof() call.

◆ mysqld_show_create()

bool mysqld_show_create ( THD thd,
Table_ref table_list 
)

◆ mysqld_show_create_db()

bool mysqld_show_create_db ( THD thd,
char *  dbname,
HA_CREATE_INFO create 
)

◆ mysqld_show_privileges()

bool mysqld_show_privileges ( THD thd)

◆ remove_status_vars()

void remove_status_vars ( SHOW_VAR list)

◆ reset_status_vars()

void reset_status_vars ( )

◆ schema_table_store_record()

bool schema_table_store_record ( THD thd,
TABLE table 
)

◆ schema_table_store_record2()

int schema_table_store_record2 ( THD thd,
TABLE table,
bool  make_ondisk 
)

Store record to I_S table, convert HEAP table to InnoDB table if necessary.

Parameters
[in]thdthread handler
[in]tableInformation schema table to be updated
[in]make_ondiskif true, convert heap table to on disk table. default value is true.
Returns
0 on success
error code on failure.

◆ show_create_trigger()

bool show_create_trigger ( THD thd,
const sp_name trg_name 
)

SHOW CREATE TRIGGER high-level implementation.

Parameters
thdThread context.
trg_nameTrigger name.
Returns
Operation status
Return values
trueError.
falseSuccess.

◆ show_sql_type()

void show_sql_type ( enum_field_types  type,
bool  is_array,
uint  metadata,
String str,
const CHARSET_INFO field_cs 
)

A field's SQL type printout.

Parameters
typethe type to print
is_arraywhether the field is a typed array
metadatafield's metadata, depending on the type could be nothing, length, or length + decimals
strString to print to
field_csfield's charset. When given [var]char length is printed in characters, otherwise - in bytes

◆ store_create_info()

enum enum_schema_tables int enum constexpr enum_var_type int const size_t constexpr PROCESS_LIST_WIDTH const size_t PROCESS_LIST_INFO_WIDTH bool store_create_info ( THD thd,
Table_ref table_list,
String packet,
HA_CREATE_INFO create_info_arg,
bool  show_database,
bool  for_show_create_stmt 
)
constexpr

Characters shown for the command in 'show processlist'.

Characters shown for the command in 'show processlist'.

Parameters
thdThe thread
table_listA list containing one table to write statement for.
packetPointer to a string where statement will be written.
create_info_argPointer to create information that can be used to tailor the format of the statement. Can be NULL, in which case only SQL_MODE is considered when building the statement.
show_databaseIf true, then print the database before the table name. The database name is only printed in the event that it is different from the current database. If false, then do not print the database before the table name.
for_show_create_stmtIf true, then build CREATE TABLE statement for SHOW CREATE TABLE statement. If false, then store_create_info() is invoked to build CREATE TABLE statement while logging event to binlog.
Returns
true if error, false otherwise.

Append START TRANSACTION for CREATE SELECT on SE supporting atomic DDL. This is done only while binlogging CREATE TABLE AS SELECT.

◆ view_store_options()

void view_store_options ( const THD thd,
Table_ref table,
String buff 
)

Variable Documentation

◆ deprecated_use_i_s_processlist_count

std::atomic_ulong deprecated_use_i_s_processlist_count
extern

Count number of times information_schema.processlist has been used.

◆ deprecated_use_i_s_processlist_last_timestamp

std::atomic_ullong deprecated_use_i_s_processlist_last_timestamp
extern

Last time information_schema.processlist was used, as usec since epoch.

◆ grant_types

TYPELIB grant_types
extern