MySQL  8.0.17
Source Code Documentation
sql_show.h
Go to the documentation of this file.
1 /* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License, version 2.0,
5  as published by the Free Software Foundation.
6 
7  This program is also distributed with certain software (including
8  but not limited to OpenSSL) that is licensed under separate terms,
9  as designated in a particular file or component or in included license
10  documentation. The authors of MySQL hereby grant you an additional
11  permission to link the program and your derivative works with the
12  separately licensed software that they have included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef SQL_SHOW_H
24 #define SQL_SHOW_H
25 
26 #include <stddef.h>
27 
28 #include "m_ctype.h"
29 #include "my_inttypes.h"
30 #include "mysql/status_var.h"
31 
32 /* Forward declarations */
33 class JOIN;
34 class SELECT_LEX;
35 class String;
36 class THD;
37 class sp_name;
38 struct HA_CREATE_INFO;
39 struct LEX;
40 struct ST_SCHEMA_TABLE;
41 struct System_status_var;
42 struct TABLE;
43 struct TABLE_LIST;
44 struct TYPELIB;
47 enum enum_schema_table_state : int;
48 enum enum_schema_tables : int;
49 enum enum_var_type : int;
50 enum enum_field_types : int;
51 
52 bool store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
53  HA_CREATE_INFO *create_info_arg, bool show_database);
54 
55 void append_identifier(const THD *thd, String *packet, const char *name,
56  size_t length, const CHARSET_INFO *from_cs,
57  const CHARSET_INFO *to_cs);
58 
59 void append_identifier(const THD *thd, String *packet, const char *name,
60  size_t length);
61 
62 void mysqld_list_fields(THD *thd, TABLE_LIST *table, const char *wild);
63 bool mysqld_show_create(THD *thd, TABLE_LIST *table_list);
64 bool mysqld_show_create_db(THD *thd, char *dbname, HA_CREATE_INFO *create);
65 
66 void mysqld_list_processes(THD *thd, const char *user, bool verbose);
67 bool mysqld_show_privileges(THD *thd);
69 void append_definer(const THD *thd, String *buffer,
70  const LEX_CSTRING &definer_user,
71  const LEX_CSTRING &definer_host);
72 bool add_status_vars(const SHOW_VAR *list);
74 void init_status_vars();
75 void free_status_vars();
76 bool get_status_var(THD *thd, SHOW_VAR *list, const char *name,
77  char *const buff, enum_var_type var_type, size_t *length);
78 void reset_status_vars();
80 bool show_create_trigger(THD *thd, const sp_name *trg_name);
81 void view_store_options(const THD *thd, TABLE_LIST *table, String *buff);
82 
83 bool schema_table_store_record(THD *thd, TABLE *table);
84 
85 /**
86  Store record to I_S table, convert HEAP table to InnoDB table if necessary.
87 
88  @param[in] thd thread handler
89  @param[in] table Information schema table to be updated
90  @param[in] make_ondisk if true, convert heap table to on disk table.
91  default value is true.
92  @return 0 on success
93  @return error code on failure.
94 */
95 int schema_table_store_record2(THD *thd, TABLE *table, bool make_ondisk);
96 
97 /**
98  Convert HEAP table to InnoDB table if necessary
99 
100  @param[in] thd thread handler
101  @param[in] table Information schema table to be converted.
102  @param[in] error the error code returned previously.
103  @return false on success, true on error.
104 */
105 bool convert_heap_table_to_ondisk(THD *thd, TABLE *table, int error);
107 bool make_table_list(THD *thd, SELECT_LEX *sel, const LEX_CSTRING &db_name,
108  const LEX_CSTRING &table_name);
109 
110 ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char *table_name);
111 ST_SCHEMA_TABLE *get_schema_table(enum enum_schema_tables schema_table_idx);
112 bool make_schema_select(THD *thd, SELECT_LEX *sel,
113  enum enum_schema_tables schema_table_idx);
114 bool mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list);
116  enum enum_schema_table_state executed_place);
118 
119 const char *get_one_variable(THD *thd, const SHOW_VAR *variable,
121  System_status_var *status_var,
122  const CHARSET_INFO **charset, char *buff,
123  size_t *length, bool *is_null = NULL);
124 
125 const char *get_one_variable_ext(THD *running_thd, THD *target_thd,
126  const SHOW_VAR *variable,
128  System_status_var *status_var,
129  const CHARSET_INFO **charset, char *buff,
130  size_t *length, bool *is_null = NULL);
131 
132 /* These functions were under INNODB_COMPATIBILITY_HOOKS */
133 int get_quote_char_for_identifier(const THD *thd, const char *name,
134  size_t length);
135 
136 void show_sql_type(enum_field_types type, bool is_array, uint metadata,
137  String *str, const CHARSET_INFO *field_cs = NULL);
138 
139 extern TYPELIB grant_types;
140 #endif /* SQL_SHOW_H */
unsigned long long int ulonglong
Definition: my_inttypes.h:74
Definition: sql_optimizer.h:177
bool schema_table_store_record(THD *thd, TABLE *table)
Definition: sql_show.cc:2610
ulonglong get_status_vars_version(void)
Definition: sql_show.cc:2254
bool mysqld_show_create(THD *thd, TABLE_LIST *table_list)
Definition: sql_show.cc:466
const char * db_name
Definition: rules_table_service.cc:54
char * user
Definition: mysqladmin.cc:58
Definition: sql_lex.h:3063
const string name("\ame\)
char buffer[STRING_BUFFER]
Definition: test_sql_9_sessions.cc:57
Some integer typedefs for easier portability.
enum_schema_table_state
Definition: table.h:2148
static uint verbose
Definition: mysqlcheck.cc:62
const char * str
Definition: mysql_lex_string.h:40
This class represents a query block, aka a query specification, which is a query consisting of a SELE...
Definition: sql_lex.h:847
ST_SCHEMA_TABLE * get_schema_table(enum enum_schema_tables schema_table_idx)
Definition: sql_show.cc:3315
enum enum_mysql_show_type SHOW_TYPE
Definition: sql_show.h:45
bool add_status_vars(const SHOW_VAR *list)
Definition: sql_show.cc:2209
TYPELIB grant_types
Definition: sql_show.cc:123
Definition: mysql_lex_string.h:39
Sergei Dialog Client Authentication NULL
Definition: dialog.cc:352
std::string join(Container cont, const std::string &delim)
join elements of an container into a string seperated by a delimiter.
Definition: string.h:144
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.
Definition: sql_show.cc:1088
class udf_list * list
void calc_sum_of_all_status(System_status_var *to)
Definition: sql_show.cc:2583
enum_mysql_show_type
Declarations for SHOW STATUS support in plugins.
Definition: status_var.h:29
void init_status_vars()
Definition: sql_show.cc:2235
Using this class is fraught with peril, and you need to be very careful when doing so...
Definition: sql_string.h:159
Definition: table.h:1294
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.
Definition: sql_show.cc:2628
uint16_t value_type
Definition: vt100.h:182
void mysqld_list_fields(THD *thd, TABLE_LIST *table, const char *wild)
Definition: sql_show.cc:694
bool mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list)
Create information_schema table.
Definition: sql_show.cc:3515
int get_quote_char_for_identifier(const THD *thd, const char *name, size_t length)
Definition: sql_show.cc:908
enum enum_mysql_show_type SHOW_TYPE
Definition: set_var.h:68
SHOW STATUS Server status variable.
Definition: status_var.h:78
Definition: table.h:2202
void initialize_information_schema_acl()
Definition: sql_show.cc:4361
void reset_status_vars()
Definition: sql_show.cc:2241
bool show_create_trigger(THD *thd, const sp_name *trg_name)
SHOW CREATE TRIGGER high-level implementation.
Definition: sql_show.cc:4288
enum_field_types
Column types for MySQL.
Definition: field_types.h:52
unsigned int uint
Definition: uca-dump.cc:29
enum_schema_tables
Definition: handler.h:885
void view_store_options(const THD *thd, TABLE_LIST *table, String *buff)
Definition: sql_show.cc:1690
bool convert_heap_table_to_ondisk(THD *thd, TABLE *table, int error)
Convert HEAP table to InnoDB table if necessary.
Definition: sql_show.cc:2646
bool get_schema_tables_result(JOIN *join, enum enum_schema_table_state executed_place)
Definition: sql_show.cc:3727
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.
Definition: sql_show.cc:2400
Definition: m_ctype.h:359
bool mysqld_show_privileges(THD *thd)
Definition: sql_show.cc:315
void show_sql_type(enum_field_types type, bool is_array, uint metadata, String *str, const CHARSET_INFO *field_cs=NULL)
A field&#39;s SQL type printout.
Definition: sql_show.cc:4469
Definition: typelib.h:34
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.
Definition: sql_show.cc:1732
const string metadata("\etadata\)
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.
Definition: sql_show.cc:2661
enum_var_type
Definition: set_var.h:87
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.
Definition: sql_show.cc:2373
int type
Definition: http_common.h:411
bool make_schema_select(THD *thd, SELECT_LEX *sel, enum enum_schema_tables schema_table_idx)
Generate select from information_schema table.
Definition: sql_show.cc:3596
ST_SCHEMA_TABLE * find_schema_table(THD *thd, const char *table_name)
Definition: sql_show.cc:3296
Definition: handler.h:2607
void mysqld_list_processes(THD *thd, const char *user, bool verbose)
Definition: sql_show.cc:1952
bool mysqld_show_create_db(THD *thd, char *dbname, HA_CREATE_INFO *create)
Definition: sql_show.cc:586
void remove_status_vars(SHOW_VAR *list)
Definition: sql_show.cc:2322
A better implementation of the UNIX ctype(3) library.
enum enum_schema_tables get_schema_table_idx(ST_SCHEMA_TABLE *schema_table)
Definition: sql_show.cc:2670
Definition: table.h:2442
void free_status_vars()
Definition: sql_show.cc:2265
Per thread status variables.
Definition: system_variables.h:399
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.
Definition: sql_show.cc:2287
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:75
Definition: sp_head.h:125
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.
Definition: sql_show.cc:823
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:777
const char * table_name
Definition: rules_table_service.cc:55
Log error(cerr, "ERROR")