MySQL  8.0.18
Source Code Documentation
sql_show.h File Reference
#include <stddef.h>
#include "m_ctype.h"
#include "my_inttypes.h"
#include "mysql/status_var.h"

Go to the source code of this file.

Typedefs

typedef enum enum_mysql_show_type SHOW_TYPE
 
typedef struct MYSQL_LEX_CSTRING LEX_CSTRING
 

Functions

enum enum_schema_table_state int enum enum_schema_tables int enum enum_var_type int enum enum_field_types int bool store_create_info (THD *thd, TABLE_LIST *table_list, String *packet, HA_CREATE_INFO *create_info_arg, bool show_database)
 Build a CREATE TABLE statement for a table. 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_LIST *table, const char *wild)
 
bool mysqld_show_create (THD *thd, TABLE_LIST *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 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_status_var (THD *thd, SHOW_VAR *list, const char *name, char *const buff, enum_var_type var_type, size_t *length)
 Get the value of given 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_LIST *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, SELECT_LEX *sel, const LEX_CSTRING &db_name, const LEX_CSTRING &table_name)
 Prepare a Table_ident and add a table_list into SELECT_LEX. 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_select (THD *thd, SELECT_LEX *sel, enum enum_schema_tables schema_table_idx)
 Generate select from information_schema table. More...
 
bool mysql_schema_table (THD *thd, LEX *lex, TABLE_LIST *table_list)
 Create information_schema table. More...
 
bool get_schema_tables_result (JOIN *join, enum enum_schema_table_state executed_place)
 
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=NULL)
 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=NULL)
 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=NULL)
 A field's SQL type printout. More...
 
bool do_fill_information_schema_table (THD *thd, TABLE_LIST *table_list, QEP_TAB *qep_tab)
 Fill INFORMATION_SCHEMA-table, leave correct Diagnostics_area state after itself. More...
 

Variables

TYPELIB grant_types
 

Typedef Documentation

◆ LEX_CSTRING

◆ 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,
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

◆ append_identifier() [2/2]

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

◆ 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_LIST table_list,
QEP_TAB qep_tab 
)

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.
qep_tabJOIN/SELECT table.
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_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_schema_tables_result()

bool get_schema_tables_result ( JOIN join,
enum enum_schema_table_state  executed_place 
)

◆ get_status_var()

bool get_status_var ( THD thd,
SHOW_VAR list,
const char *  name,
char *const  value,
enum_var_type  var_type,
size_t *  length 
)

Get the value of given status variable.

Parameters
[in]thdthread handler
[in]listlist of SHOW_VAR objects in which function should search
[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
Returns
status
Return values
falseif variable is not found in the list
trueif variable is found in the list

◆ 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_select()

bool make_schema_select ( THD thd,
SELECT_LEX sel,
enum enum_schema_tables  schema_table_idx 
)

Generate select from information_schema table.

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

◆ make_table_list()

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

Prepare a Table_ident and add a table_list into SELECT_LEX.

Parameters
thdThread
selInstance of SELECT_LEX.
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_LIST 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_LIST table,
const char *  wild 
)

◆ mysqld_list_processes()

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

◆ mysqld_show_create()

bool mysqld_show_create ( THD thd,
TABLE_LIST 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_table_state int enum enum_schema_tables int enum enum_var_type int enum enum_field_types int bool store_create_info ( THD thd,
TABLE_LIST table_list,
String packet,
HA_CREATE_INFO create_info_arg,
bool  show_database 
)

Build a CREATE TABLE statement for a table.

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.
Returns
true if error, false otherwise.

◆ view_store_options()

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

Variable Documentation

◆ grant_types

TYPELIB grant_types