MySQL  8.0.18
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 QEP_TAB;
35 class SELECT_LEX;
36 class String;
37 class THD;
38 class sp_name;
39 struct HA_CREATE_INFO;
40 struct LEX;
41 struct ST_SCHEMA_TABLE;
42 struct System_status_var;
43 struct TABLE;
44 struct TABLE_LIST;
45 struct TYPELIB;
48 enum enum_schema_table_state : int;
49 enum enum_schema_tables : int;
50 enum enum_var_type : int;
51 enum enum_field_types : int;
52 
53 bool store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
54  HA_CREATE_INFO *create_info_arg, bool show_database);
55 
56 void append_identifier(const THD *thd, String *packet, const char *name,
57  size_t length, const CHARSET_INFO *from_cs,
58  const CHARSET_INFO *to_cs);
59 
60 void append_identifier(const THD *thd, String *packet, const char *name,
61  size_t length);
62 
63 void mysqld_list_fields(THD *thd, TABLE_LIST *table, const char *wild);
64 bool mysqld_show_create(THD *thd, TABLE_LIST *table_list);
65 bool mysqld_show_create_db(THD *thd, char *dbname, HA_CREATE_INFO *create);
66 
67 void mysqld_list_processes(THD *thd, const char *user, bool verbose);
68 bool mysqld_show_privileges(THD *thd);
70 void append_definer(const THD *thd, String *buffer,
71  const LEX_CSTRING &definer_user,
72  const LEX_CSTRING &definer_host);
73 bool add_status_vars(const SHOW_VAR *list);
75 void init_status_vars();
76 void free_status_vars();
77 bool get_status_var(THD *thd, SHOW_VAR *list, const char *name,
78  char *const buff, enum_var_type var_type, size_t *length);
79 void reset_status_vars();
81 bool show_create_trigger(THD *thd, const sp_name *trg_name);
82 void view_store_options(const THD *thd, TABLE_LIST *table, String *buff);
83 
84 bool schema_table_store_record(THD *thd, TABLE *table);
85 
86 /**
87  Store record to I_S table, convert HEAP table to InnoDB table if necessary.
88 
89  @param[in] thd thread handler
90  @param[in] table Information schema table to be updated
91  @param[in] make_ondisk if true, convert heap table to on disk table.
92  default value is true.
93  @return 0 on success
94  @return error code on failure.
95 */
96 int schema_table_store_record2(THD *thd, TABLE *table, bool make_ondisk);
97 
98 /**
99  Convert HEAP table to InnoDB table if necessary
100 
101  @param[in] thd thread handler
102  @param[in] table Information schema table to be converted.
103  @param[in] error the error code returned previously.
104  @return false on success, true on error.
105 */
106 bool convert_heap_table_to_ondisk(THD *thd, TABLE *table, int error);
108 bool make_table_list(THD *thd, SELECT_LEX *sel, const LEX_CSTRING &db_name,
109  const LEX_CSTRING &table_name);
110 
111 ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char *table_name);
112 ST_SCHEMA_TABLE *get_schema_table(enum enum_schema_tables schema_table_idx);
113 bool make_schema_select(THD *thd, SELECT_LEX *sel,
114  enum enum_schema_tables schema_table_idx);
115 bool mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list);
117  enum enum_schema_table_state executed_place);
119 
120 const char *get_one_variable(THD *thd, const SHOW_VAR *variable,
122  System_status_var *status_var,
123  const CHARSET_INFO **charset, char *buff,
124  size_t *length, bool *is_null = NULL);
125 
126 const char *get_one_variable_ext(THD *running_thd, THD *target_thd,
127  const SHOW_VAR *variable,
129  System_status_var *status_var,
130  const CHARSET_INFO **charset, char *buff,
131  size_t *length, bool *is_null = NULL);
132 
133 /* These functions were under INNODB_COMPATIBILITY_HOOKS */
134 int get_quote_char_for_identifier(const THD *thd, const char *name,
135  size_t length);
136 
137 void show_sql_type(enum_field_types type, bool is_array, uint metadata,
138  String *str, const CHARSET_INFO *field_cs = NULL);
139 
140 bool do_fill_information_schema_table(THD *thd, TABLE_LIST *table_list,
141  QEP_TAB *qep_tab);
142 
143 extern TYPELIB grant_types;
144 #endif /* SQL_SHOW_H */
unsigned long long int ulonglong
Definition: my_inttypes.h:55
Definition: sql_optimizer.h:177
bool schema_table_store_record(THD *thd, TABLE *table)
Definition: sql_show.cc:2630
ulonglong get_status_vars_version(void)
Definition: sql_show.cc:2270
bool mysqld_show_create(THD *thd, TABLE_LIST *table_list)
Definition: sql_show.cc:468
const char * db_name
Definition: rules_table_service.cc:54
char * user
Definition: mysqladmin.cc:59
Definition: sql_lex.h:3192
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:2173
static uint verbose
Definition: mysqlcheck.cc:63
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:971
ST_SCHEMA_TABLE * get_schema_table(enum enum_schema_tables schema_table_idx)
Definition: sql_show.cc:3333
enum enum_mysql_show_type SHOW_TYPE
Definition: sql_show.h:46
bool add_status_vars(const SHOW_VAR *list)
Definition: sql_show.cc:2225
TYPELIB grant_types
Definition: sql_show.cc:123
Definition: mysql_lex_string.h:39
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:2604
enum_mysql_show_type
Declarations for SHOW STATUS support in plugins.
Definition: status_var.h:29
void init_status_vars()
Definition: sql_show.cc:2251
Using this class is fraught with peril, and you need to be very careful when doing so...
Definition: sql_string.h:161
Definition: table.h:1301
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. ...
Definition: sql_show.cc:3675
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:2648
uint16_t value_type
Definition: vt100.h:182
void mysqld_list_fields(THD *thd, TABLE_LIST *table, const char *wild)
Definition: sql_show.cc:696
bool mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list)
Create information_schema table.
Definition: sql_show.cc:3533
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:2227
void initialize_information_schema_acl()
Definition: sql_show.cc:4357
void reset_status_vars()
Definition: sql_show.cc:2257
bool show_create_trigger(THD *thd, const sp_name *trg_name)
SHOW CREATE TRIGGER high-level implementation.
Definition: sql_show.cc:4284
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:879
void view_store_options(const THD *thd, TABLE_LIST *table, String *buff)
Definition: sql_show.cc:1691
bool convert_heap_table_to_ondisk(THD *thd, TABLE *table, int error)
Convert HEAP table to InnoDB table if necessary.
Definition: sql_show.cc:2666
bool get_schema_tables_result(JOIN *join, enum enum_schema_table_state executed_place)
Definition: sql_show.cc:3746
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:2416
Definition: m_ctype.h:359
bool mysqld_show_privileges(THD *thd)
Definition: sql_show.cc:316
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:4465
Definition: sql_executor.h:406
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:1733
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:2681
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:2389
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:3614
ST_SCHEMA_TABLE * find_schema_table(THD *thd, const char *table_name)
Definition: sql_show.cc:3314
#define NULL
Definition: types.h:55
Definition: handler.h:2629
void mysqld_list_processes(THD *thd, const char *user, bool verbose)
Definition: sql_show.cc:1961
bool mysqld_show_create_db(THD *thd, char *dbname, HA_CREATE_INFO *create)
Definition: sql_show.cc:588
void remove_status_vars(SHOW_VAR *list)
Definition: sql_show.cc:2338
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:2690
Definition: table.h:2468
void free_status_vars()
Definition: sql_show.cc:2281
Per thread status variables.
Definition: system_variables.h:409
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:2303
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:778
const char * table_name
Definition: rules_table_service.cc:55
Log error(cerr, "ERROR")