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 #include <sys/types.h> 28 29 #include "lex_string.h" 30 #include "my_inttypes.h" 31 #include "mysql/status_var.h" 32 #include "typelib.h" 33 34 /* Forward declarations */ 35 class JOIN; 36 class QEP_TAB; 37 class SELECT_LEX; 38 class String; 39 class THD; 40 class sp_name; 41 struct CHARSET_INFO; 42 struct HA_CREATE_INFO; 43 struct LEX; 44 struct ST_SCHEMA_TABLE; 45 struct System_status_var; 46 struct TABLE; 47 struct TABLE_LIST; 48 typedef enum enum_mysql_show_type SHOW_TYPE; 49 enum enum_schema_table_state : int; 50 enum enum_schema_tables : int; 51 enum enum_var_type : int; 52 enum enum_field_types : int; 53 54 bool store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, 55 HA_CREATE_INFO *create_info_arg, bool show_database); 56 57 void append_identifier(const THD *thd, String *packet, const char *name, 58 size_t length, const CHARSET_INFO *from_cs, 59 const CHARSET_INFO *to_cs); 60 61 void append_identifier(const THD *thd, String *packet, const char *name, 62 size_t length); 63 64 void mysqld_list_fields(THD *thd, TABLE_LIST *table, const char *wild); 65 bool mysqld_show_create(THD *thd, TABLE_LIST *table_list); 66 bool mysqld_show_create_db(THD *thd, char *dbname, HA_CREATE_INFO *create); 67 68 void mysqld_list_processes(THD *thd, const char *user, bool verbose); 69 bool mysqld_show_privileges(THD *thd); 70 void calc_sum_of_all_status(System_status_var *to); 71 void append_definer(const THD *thd, String *buffer, 72 const LEX_CSTRING &definer_user, 73 const LEX_CSTRING &definer_host); 74 bool add_status_vars(const SHOW_VAR *list); 75 void remove_status_vars(SHOW_VAR *list); 76 void init_status_vars(); 77 void free_status_vars(); 78 bool get_status_var(THD *thd, SHOW_VAR *list, const char *name, 79 char *const buff, enum_var_type var_type, size_t *length); 80 void reset_status_vars(); 81 ulonglong get_status_vars_version(void); 82 bool show_create_trigger(THD *thd, const sp_name *trg_name); 83 void view_store_options(const THD *thd, TABLE_LIST *table, String *buff); 84 85 bool schema_table_store_record(THD *thd, TABLE *table); 86 87 /** 88 Store record to I_S table, convert HEAP table to InnoDB table if necessary. 89 90 @param[in] thd thread handler 91 @param[in] table Information schema table to be updated 92 @param[in] make_ondisk if true, convert heap table to on disk table. 93 default value is true. 94 @return 0 on success 95 @return error code on failure. 96 */ 97 int schema_table_store_record2(THD *thd, TABLE *table, bool make_ondisk); 98 99 /** 100 Convert HEAP table to InnoDB table if necessary 101 102 @param[in] thd thread handler 103 @param[in] table Information schema table to be converted. 104 @param[in] error the error code returned previously. 105 @return false on success, true on error. 106 */ 107 bool convert_heap_table_to_ondisk(THD *thd, TABLE *table, int error); 108 void initialize_information_schema_acl(); 109 bool make_table_list(THD *thd, SELECT_LEX *sel, const LEX_CSTRING &db_name, 110 const LEX_CSTRING &table_name); 111 112 ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char *table_name); 113 ST_SCHEMA_TABLE *get_schema_table(enum enum_schema_tables schema_table_idx); 114 bool make_schema_select(THD *thd, SELECT_LEX *sel, 115 enum enum_schema_tables schema_table_idx); 116 bool mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list); 117 bool get_schema_tables_result(JOIN *join, 118 enum enum_schema_table_state executed_place); 119 enum enum_schema_tables get_schema_table_idx(ST_SCHEMA_TABLE *schema_table); 120 121 const char *get_one_variable(THD *thd, const SHOW_VAR *variable, 122 enum_var_type value_type, SHOW_TYPE show_type, 123 System_status_var *status_var, 124 const CHARSET_INFO **charset, char *buff, 125 size_t *length, bool *is_null = nullptr); 126 127 const char *get_one_variable_ext(THD *running_thd, THD *target_thd, 128 const SHOW_VAR *variable, 129 enum_var_type value_type, SHOW_TYPE show_type, 130 System_status_var *status_var, 131 const CHARSET_INFO **charset, char *buff, 132 size_t *length, bool *is_null = nullptr); 133 134 /* These functions were under INNODB_COMPATIBILITY_HOOKS */ 135 int get_quote_char_for_identifier(const THD *thd, const char *name, 136 size_t length); 137 138 void show_sql_type(enum_field_types type, bool is_array, uint metadata, 139 String *str, const CHARSET_INFO *field_cs = nullptr); 140 141 bool do_fill_information_schema_table(THD *thd, TABLE_LIST *table_list, 142 QEP_TAB *qep_tab); 143 144 extern TYPELIB grant_types; 145 #endif /* SQL_SHOW_H */ 146