MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sql_show.h
1 /* Copyright (c) 2005, 2010, 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 as published by
5  the Free Software Foundation; version 2 of the License.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software
14  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15 
16 #ifndef SQL_SHOW_H
17 #define SQL_SHOW_H
18 
19 #include "sql_list.h" /* List */
20 #include "handler.h" /* enum_schema_tables */
21 #include "table.h" /* enum_schema_table_state */
22 
23 /* Forward declarations */
24 class JOIN;
25 class String;
26 class THD;
27 class sp_name;
28 struct TABLE_LIST;
30 typedef class st_select_lex SELECT_LEX;
32 struct LEX;
33 typedef struct st_mysql_show_var SHOW_VAR;
34 typedef struct st_schema_table ST_SCHEMA_TABLE;
35 struct TABLE;
36 typedef struct system_status_var STATUS_VAR;
37 
38 enum find_files_result {
39  FIND_FILES_OK,
40  FIND_FILES_OOM,
41  FIND_FILES_DIR
42 };
43 
44 /* Define fields' indexes for COLUMNS table of I_S tables */
45 #define IS_COLUMNS_TABLE_CATALOG 0
46 #define IS_COLUMNS_TABLE_SCHEMA 1
47 #define IS_COLUMNS_TABLE_NAME 2
48 #define IS_COLUMNS_COLUMN_NAME 3
49 #define IS_COLUMNS_ORDINAL_POSITION 4
50 #define IS_COLUMNS_COLUMN_DEFAULT 5
51 #define IS_COLUMNS_IS_NULLABLE 6
52 #define IS_COLUMNS_DATA_TYPE 7
53 #define IS_COLUMNS_CHARACTER_MAXIMUM_LENGTH 8
54 #define IS_COLUMNS_CHARACTER_OCTET_LENGTH 9
55 #define IS_COLUMNS_NUMERIC_PRECISION 10
56 #define IS_COLUMNS_NUMERIC_SCALE 11
57 #define IS_COLUMNS_DATETIME_PRECISION 12
58 #define IS_COLUMNS_CHARACTER_SET_NAME 13
59 #define IS_COLUMNS_COLLATION_NAME 14
60 #define IS_COLUMNS_COLUMN_TYPE 15
61 #define IS_COLUMNS_COLUMN_KEY 16
62 #define IS_COLUMNS_EXTRA 17
63 #define IS_COLUMNS_PRIVILEGES 18
64 #define IS_COLUMNS_COLUMN_COMMENT 19
65 
66 /* Define fields' indexes for ROUTINES table of I_S tables */
67 #define IS_ROUTINES_SPECIFIC_NAME 0
68 #define IS_ROUTINES_ROUTINE_CATALOG 1
69 #define IS_ROUTINES_ROUTINE_SCHEMA 2
70 #define IS_ROUTINES_ROUTINE_NAME 3
71 #define IS_ROUTINES_ROUTINE_TYPE 4
72 #define IS_ROUTINES_DATA_TYPE 5
73 #define IS_ROUTINES_CHARACTER_MAXIMUM_LENGTH 6
74 #define IS_ROUTINES_CHARACTER_OCTET_LENGTH 7
75 #define IS_ROUTINES_NUMERIC_PRECISION 8
76 #define IS_ROUTINES_NUMERIC_SCALE 9
77 #define IS_ROUTINES_DATETIME_PRECISION 10
78 #define IS_ROUTINES_CHARACTER_SET_NAME 11
79 #define IS_ROUTINES_COLLATION_NAME 12
80 #define IS_ROUTINES_DTD_IDENTIFIER 13
81 #define IS_ROUTINES_ROUTINE_BODY 14
82 #define IS_ROUTINES_ROUTINE_DEFINITION 15
83 #define IS_ROUTINES_EXTERNAL_NAME 16
84 #define IS_ROUTINES_EXTERNAL_LANGUAGE 17
85 #define IS_ROUTINES_PARAMETER_STYLE 18
86 #define IS_ROUTINES_IS_DETERMINISTIC 19
87 #define IS_ROUTINES_SQL_DATA_ACCESS 20
88 #define IS_ROUTINES_SQL_PATH 21
89 #define IS_ROUTINES_SECURITY_TYPE 22
90 #define IS_ROUTINES_CREATED 23
91 #define IS_ROUTINES_LAST_ALTERED 24
92 #define IS_ROUTINES_SQL_MODE 25
93 #define IS_ROUTINES_ROUTINE_COMMENT 26
94 #define IS_ROUTINES_DEFINER 27
95 #define IS_ROUTINES_CHARACTER_SET_CLIENT 28
96 #define IS_ROUTINES_COLLATION_CONNECTION 29
97 #define IS_ROUTINES_DATABASE_COLLATION 30
98 
99 
100 /* Define fields' indexes for PARAMETERS table of I_S tables */
101 #define IS_PARAMETERS_SPECIFIC_CATALOG 0
102 #define IS_PARAMETERS_SPECIFIC_SCHEMA 1
103 #define IS_PARAMETERS_SPECIFIC_NAME 2
104 #define IS_PARAMETERS_ORDINAL_POSITION 3
105 #define IS_PARAMETERS_PARAMETER_MODE 4
106 #define IS_PARAMETERS_PARAMETER_NAME 5
107 #define IS_PARAMETERS_DATA_TYPE 6
108 #define IS_PARAMETERS_CHARACTER_MAXIMUM_LENGTH 7
109 #define IS_PARAMETERS_CHARACTER_OCTET_LENGTH 8
110 #define IS_PARAMETERS_NUMERIC_PRECISION 9
111 #define IS_PARAMETERS_NUMERIC_SCALE 10
112 #define IS_PARAMETERS_DATETIME_PRECISION 11
113 #define IS_PARAMETERS_CHARACTER_SET_NAME 12
114 #define IS_PARAMETERS_COLLATION_NAME 13
115 #define IS_PARAMETERS_DTD_IDENTIFIER 14
116 #define IS_PARAMETERS_ROUTINE_TYPE 15
117 
118 /* Used by handlers to store things in schema tables */
119 #define IS_FILES_FILE_ID 0
120 #define IS_FILES_FILE_NAME 1
121 #define IS_FILES_FILE_TYPE 2
122 #define IS_FILES_TABLESPACE_NAME 3
123 #define IS_FILES_TABLE_CATALOG 4
124 #define IS_FILES_TABLE_SCHEMA 5
125 #define IS_FILES_TABLE_NAME 6
126 #define IS_FILES_LOGFILE_GROUP_NAME 7
127 #define IS_FILES_LOGFILE_GROUP_NUMBER 8
128 #define IS_FILES_ENGINE 9
129 #define IS_FILES_FULLTEXT_KEYS 10
130 #define IS_FILES_DELETED_ROWS 11
131 #define IS_FILES_UPDATE_COUNT 12
132 #define IS_FILES_FREE_EXTENTS 13
133 #define IS_FILES_TOTAL_EXTENTS 14
134 #define IS_FILES_EXTENT_SIZE 15
135 #define IS_FILES_INITIAL_SIZE 16
136 #define IS_FILES_MAXIMUM_SIZE 17
137 #define IS_FILES_AUTOEXTEND_SIZE 18
138 #define IS_FILES_CREATION_TIME 19
139 #define IS_FILES_LAST_UPDATE_TIME 20
140 #define IS_FILES_LAST_ACCESS_TIME 21
141 #define IS_FILES_RECOVER_TIME 22
142 #define IS_FILES_TRANSACTION_COUNTER 23
143 #define IS_FILES_VERSION 24
144 #define IS_FILES_ROW_FORMAT 25
145 #define IS_FILES_TABLE_ROWS 26
146 #define IS_FILES_AVG_ROW_LENGTH 27
147 #define IS_FILES_DATA_LENGTH 28
148 #define IS_FILES_MAX_DATA_LENGTH 29
149 #define IS_FILES_INDEX_LENGTH 30
150 #define IS_FILES_DATA_FREE 31
151 #define IS_FILES_CREATE_TIME 32
152 #define IS_FILES_UPDATE_TIME 33
153 #define IS_FILES_CHECK_TIME 34
154 #define IS_FILES_CHECKSUM 35
155 #define IS_FILES_STATUS 36
156 #define IS_FILES_EXTRA 37
157 
158 find_files_result find_files(THD *thd, List<LEX_STRING> *files, const char *db,
159  const char *path, const char *wild, bool dir);
160 
161 int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
162  HA_CREATE_INFO *create_info_arg, bool show_database);
163 int view_store_create_info(THD *thd, TABLE_LIST *table, String *buff);
164 
165 int copy_event_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table);
166 int get_quote_char_for_identifier(THD *thd, const char *name, uint length);
167 
168 void append_identifier(THD *thd, String *packet, const char *name,
169  uint length);
170 inline void append_identifier(THD *thd, String *packet, Simple_cstring str)
171 {
172  append_identifier(thd, packet, str.ptr(), static_cast<uint>(str.length()));
173 }
174 void mysqld_list_fields(THD *thd,TABLE_LIST *table, const char *wild);
175 bool mysqld_show_create(THD *thd, TABLE_LIST *table_list);
176 bool mysqld_show_create_db(THD *thd, char *dbname, HA_CREATE_INFO *create);
177 
178 void mysqld_list_processes(THD *thd,const char *user,bool verbose);
179 int mysqld_show_status(THD *thd);
180 int mysqld_show_variables(THD *thd,const char *wild);
181 bool mysqld_show_storage_engines(THD *thd);
182 bool mysqld_show_privileges(THD *thd);
183 char *make_backup_log_name(char *buff, const char *name, const char* log_ext);
184 void calc_sum_of_all_status(STATUS_VAR *to);
185 void append_definer(THD *thd, String *buffer, const LEX_STRING *definer_user,
186  const LEX_STRING *definer_host);
187 int add_status_vars(SHOW_VAR *list);
188 void remove_status_vars(SHOW_VAR *list);
189 void init_status_vars();
190 void free_status_vars();
191 void reset_status_vars();
192 bool show_create_trigger(THD *thd, const sp_name *trg_name);
193 void view_store_options(THD *thd, TABLE_LIST *table, String *buff);
194 
195 void init_fill_schema_files_row(TABLE* table);
196 bool schema_table_store_record(THD *thd, TABLE *table);
197 void initialize_information_schema_acl();
198 
199 ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name);
200 ST_SCHEMA_TABLE *get_schema_table(enum enum_schema_tables schema_table_idx);
201 int make_schema_select(THD *thd, SELECT_LEX *sel,
202  enum enum_schema_tables schema_table_idx);
203 int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list);
204 bool get_schema_tables_result(JOIN *join,
205  enum enum_schema_table_state executed_place);
206 enum enum_schema_tables get_schema_table_idx(ST_SCHEMA_TABLE *schema_table);
207 
208 /* These functions were under INNODB_COMPATIBILITY_HOOKS */
209 int get_quote_char_for_identifier(THD *thd, const char *name, uint length);
210 
211 /* Handle the ignored database directories list for SHOW/I_S. */
212 bool ignore_db_dirs_init();
213 void ignore_db_dirs_free();
214 void ignore_db_dirs_reset();
215 bool ignore_db_dirs_process_additions();
216 bool push_ignored_db_dir(char *path);
217 extern char *opt_ignore_db_dirs;
218 
219 #endif /* SQL_SHOW_H */