19 #include "my_global.h"
26 #include "sql_table.h"
30 #include "sql_parse.h"
31 #include "sql_partition.h"
32 #include "sql_derived.h"
42 #include "sp_pcontext.h"
44 #include "sql_trigger.h"
45 #include "sql_derived.h"
46 #include "sql_partition.h"
47 #ifdef HAVE_EVENT_SCHEDULER
57 #include "sql_optimizer.h"
58 #include "global_threads.h"
64 #define STR_OR_NIL(S) ((S) ? (S) : "<nil>")
66 #ifdef WITH_PARTITION_STORAGE_ENGINE
67 #include "ha_partition.h"
69 enum enum_i_s_events_fields
97 #ifndef NO_EMBEDDED_ACCESS_CHECKS
98 static const char *grant_names[]={
99 "select",
"insert",
"update",
"delete",
"create",
"drop",
"reload",
"shutdown",
100 "process",
"file",
"grant",
"references",
"index",
"alter"};
102 static TYPELIB grant_types = {
sizeof(grant_names)/
sizeof(
char **),
110 #ifdef WITH_PARTITION_STORAGE_ENGINE
111 static void get_cs_converted_string_value(THD *thd,
127 static int make_version_string(
char *
buf,
int buf_length, uint version)
129 return my_snprintf(buf, buf_length,
"%d.%d", version>>8,version&0xff);
132 static my_bool show_plugins(THD *thd,
plugin_ref plugin,
139 char version_buf[20];
141 restore_record(table, s->default_values);
143 table->field[0]->store(plugin_name(plugin)->str,
144 plugin_name(plugin)->length, cs);
146 table->field[1]->store(version_buf,
147 make_version_string(version_buf,
sizeof(version_buf), plug->version),
151 switch (plugin_state(plugin)) {
153 case PLUGIN_IS_DELETED:
154 table->field[2]->store(STRING_WITH_LEN(
"DELETED"), cs);
156 case PLUGIN_IS_UNINITIALIZED:
157 table->field[2]->store(STRING_WITH_LEN(
"INACTIVE"), cs);
159 case PLUGIN_IS_READY:
160 table->field[2]->store(STRING_WITH_LEN(
"ACTIVE"), cs);
162 case PLUGIN_IS_DISABLED:
163 table->field[2]->store(STRING_WITH_LEN(
"DISABLED"), cs);
169 table->field[3]->store(plugin_type_names[plug->type].str,
170 plugin_type_names[plug->type].length,
172 table->field[4]->store(version_buf,
173 make_version_string(version_buf,
sizeof(version_buf),
174 *(uint *)plug->info), cs);
178 table->field[5]->store(plugin_dl->dl.str, plugin_dl->dl.length, cs);
179 table->field[5]->set_notnull();
180 table->field[6]->store(version_buf,
181 make_version_string(version_buf,
sizeof(version_buf),
184 table->field[6]->set_notnull();
188 table->field[5]->set_null();
189 table->field[6]->set_null();
195 table->field[7]->store(plug->author, strlen(plug->author), cs);
196 table->field[7]->set_notnull();
199 table->field[7]->set_null();
203 table->field[8]->store(plug->descr, strlen(plug->descr), cs);
204 table->field[8]->set_notnull();
207 table->field[8]->set_null();
209 switch (plug->license) {
210 case PLUGIN_LICENSE_GPL:
211 table->field[9]->store(PLUGIN_LICENSE_GPL_STRING,
212 strlen(PLUGIN_LICENSE_GPL_STRING), cs);
214 case PLUGIN_LICENSE_BSD:
215 table->field[9]->store(PLUGIN_LICENSE_BSD_STRING,
216 strlen(PLUGIN_LICENSE_BSD_STRING), cs);
219 table->field[9]->store(PLUGIN_LICENSE_PROPRIETARY_STRING,
220 strlen(PLUGIN_LICENSE_PROPRIETARY_STRING), cs);
223 table->field[9]->set_notnull();
225 table->field[10]->store(
226 global_plugin_typelib_names[plugin_load_option(plugin)],
227 strlen(global_plugin_typelib_names[plugin_load_option(plugin)]),
230 return schema_table_store_record(thd, table);
236 DBUG_ENTER(
"fill_plugins");
237 TABLE *table= tables->table;
239 if (plugin_foreach_with_mask(thd, show_plugins, MYSQL_ANY_PLUGIN,
240 ~PLUGIN_IS_FREED, table))
252 const char *privilege;
259 {
"Alter",
"Tables",
"To alter the table"},
260 {
"Alter routine",
"Functions,Procedures",
"To alter or drop stored functions/procedures"},
261 {
"Create",
"Databases,Tables,Indexes",
"To create new databases and tables"},
262 {
"Create routine",
"Databases",
"To use CREATE FUNCTION/PROCEDURE"},
263 {
"Create temporary tables",
"Databases",
"To use CREATE TEMPORARY TABLE"},
264 {
"Create view",
"Tables",
"To create new views"},
265 {
"Create user",
"Server Admin",
"To create new users"},
266 {
"Delete",
"Tables",
"To delete existing rows"},
267 {
"Drop",
"Databases,Tables",
"To drop databases, tables, and views"},
268 #ifdef HAVE_EVENT_SCHEDULER
269 {
"Event",
"Server Admin",
"To create, alter, drop and execute events"},
271 {
"Execute",
"Functions,Procedures",
"To execute stored routines"},
272 {
"File",
"File access on server",
"To read and write files on the server"},
273 {
"Grant option",
"Databases,Tables,Functions,Procedures",
"To give to other users those privileges you possess"},
274 {
"Index",
"Tables",
"To create or drop indexes"},
275 {
"Insert",
"Tables",
"To insert data into tables"},
276 {
"Lock tables",
"Databases",
"To use LOCK TABLES (together with SELECT privilege)"},
277 {
"Process",
"Server Admin",
"To view the plain text of currently executing queries"},
278 {
"Proxy",
"Server Admin",
"To make proxy user possible"},
279 {
"References",
"Databases,Tables",
"To have references on tables"},
280 {
"Reload",
"Server Admin",
"To reload or refresh tables, logs and privileges"},
281 {
"Replication client",
"Server Admin",
"To ask where the slave or master servers are"},
282 {
"Replication slave",
"Server Admin",
"To read binary log events from the master"},
283 {
"Select",
"Tables",
"To retrieve rows from table"},
284 {
"Show databases",
"Server Admin",
"To see all databases with SHOW DATABASES"},
285 {
"Show view",
"Tables",
"To see views with SHOW CREATE VIEW"},
286 {
"Shutdown",
"Server Admin",
"To shut down the server"},
287 {
"Super",
"Server Admin",
"To use KILL thread, SET GLOBAL, CHANGE MASTER, etc."},
288 {
"Trigger",
"Tables",
"To use triggers"},
289 {
"Create tablespace",
"Server Admin",
"To create/alter/drop tablespaces"},
290 {
"Update",
"Tables",
"To update existing rows"},
291 {
"Usage",
"Server Admin",
"No privileges - allow connect only"},
292 {NullS, NullS, NullS}
295 bool mysqld_show_privileges(THD *thd)
299 DBUG_ENTER(
"mysqld_show_privileges");
306 Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
310 for (privilege= sys_privileges; privilege->privilege ; privilege++)
312 protocol->prepare_for_resend();
313 protocol->
store(privilege->privilege, system_charset_info);
314 protocol->
store(privilege->context, system_charset_info);
315 protocol->
store(privilege->comment, system_charset_info);
316 if (protocol->write())
325 static HASH ignore_db_dirs_hash;
337 char *opt_ignore_db_dirs= NULL;
352 ignore_db_dirs_init()
354 return my_init_dynamic_array(&ignore_db_dirs_array,
sizeof(
LEX_STRING *),
371 db_dirs_hash_get_key(
const uchar *data,
size_t *len_ret,
372 my_bool __attribute__((unused)))
377 return (uchar *) e->str;
393 push_ignored_db_dir(
char *path)
396 char *new_elt_buffer;
397 size_t path_len= strlen(path);
399 if (!path_len || path_len >= FN_REFLEN)
403 if (!my_multi_malloc(0,
405 &new_elt_buffer, path_len + 1,
408 new_elt->str= new_elt_buffer;
409 memcpy(new_elt_buffer, path, path_len);
410 new_elt_buffer[path_len]= 0;
411 new_elt->length= path_len;
412 return insert_dynamic(&ignore_db_dirs_array, &new_elt);
424 ignore_db_dirs_reset()
427 while (NULL!= (elt= (
LEX_STRING **) pop_dynamic(&ignore_db_dirs_array)))
440 ignore_db_dirs_free()
442 if (opt_ignore_db_dirs)
444 my_free(opt_ignore_db_dirs);
445 opt_ignore_db_dirs= NULL;
447 ignore_db_dirs_reset();
448 delete_dynamic(&ignore_db_dirs_array);
449 my_hash_free(&ignore_db_dirs_hash);
466 ignore_db_dirs_process_additions()
473 DBUG_ASSERT(opt_ignore_db_dirs == NULL);
475 if (my_hash_init(&ignore_db_dirs_hash,
476 lower_case_table_names ?
477 character_set_filesystem : &my_charset_bin,
478 0, 0, 0, db_dirs_hash_get_key,
485 for (i= 0; i < ignore_db_dirs_array.elements; i++)
487 get_dynamic(&ignore_db_dirs_array, (uchar *) &dir, i);
488 len+= dir->length + 1;
496 ptr= opt_ignore_db_dirs= (
char *) my_malloc(len + 1, MYF(0));
503 for (i= 0; i < ignore_db_dirs_array.elements; i++)
505 get_dynamic(&ignore_db_dirs_array, (uchar *) &dir, i);
506 if (my_hash_insert(&ignore_db_dirs_hash, (uchar *) dir))
508 ptr= strnmov(ptr, dir->str, dir->length);
509 if (i + 1 < ignore_db_dirs_array.elements)
510 ptr= strmov(ptr,
",");
517 set_dynamic(&ignore_db_dirs_array, (uchar *) &dir, i);
521 DBUG_ASSERT(ptr - opt_ignore_db_dirs <= (ptrdiff_t) len);
528 reset_dynamic(&ignore_db_dirs_array);
543 is_in_ignore_db_dirs_list(
const char *directory)
545 return ignore_db_dirs_hash.records &&
546 NULL != my_hash_search(&ignore_db_dirs_hash, (
const uchar *) directory,
573 const char *path,
const char *wild,
bool dir)
577 #ifndef NO_EMBEDDED_ACCESS_CHECKS
578 uint col_access=thd->col_access;
582 DBUG_ENTER(
"find_files");
589 wild_length= strlen(wild);
594 memset(&table_list, 0,
sizeof(table_list));
596 if (!(dirp = my_dir(path,MYF(dir ? MY_WANT_STAT : 0))))
598 if (my_errno == ENOENT)
599 my_error(ER_BAD_DB_ERROR, MYF(ME_BELL+ME_WAITTANG), db);
602 char errbuf[MYSYS_STRERROR_SIZE];
603 my_error(ER_CANT_READ_DIR, MYF(ME_BELL+ME_WAITTANG), path,
604 my_errno, my_strerror(errbuf,
sizeof(errbuf), my_errno));
606 DBUG_RETURN(FIND_FILES_DIR);
609 for (i=0 ; i < (uint) dirp->number_off_files ; i++)
611 char uname[NAME_LEN + 1];
617 file=dirp->dir_entry+
i;
626 if (file->name[0] ==
'.')
629 char buff[FN_REFLEN];
630 if (my_use_symdir && !strcmp(ext=fn_ext(file->name),
".sym"))
636 unpack_dirname(buff, file->name, ¬_used);
638 if (end != buff && end[-1] == FN_LIBCHAR)
644 if (!MY_S_ISDIR(file->mystat->st_mode))
647 if (is_in_ignore_db_dirs_list(file->name))
654 if (my_strcasecmp(system_charset_info, ext=fn_rext(file->name),reg_ext) ||
660 file_name_len= filename_to_tablename(file->name, uname,
sizeof(uname));
664 if (lower_case_table_names)
666 if (my_wildcmp(files_charset_info,
667 uname, uname + file_name_len,
668 wild, wild + wild_length,
669 wild_prefix, wild_one,wild_many))
672 else if (wild_compare(uname, wild, 0))
676 #ifndef NO_EMBEDDED_ACCESS_CHECKS
678 if (db && !(col_access & TABLE_ACLS))
680 table_list.db= (
char*) db;
681 table_list.db_length= strlen(db);
682 table_list.table_name= uname;
683 table_list.table_name_length= file_name_len;
685 if (check_grant(thd, TABLE_ACLS, &table_list, TRUE, 1, TRUE))
690 thd->make_lex_string(file_name, uname, file_name_len, TRUE)) ||
691 files->push_back(file_name))
694 DBUG_RETURN(FIND_FILES_OOM);
697 DBUG_PRINT(
"info",(
"found: %d files", files->elements));
700 (void) ha_find_files(thd, db, path, wild, dir, files);
702 DBUG_RETURN(FIND_FILES_OK);
723 Security_context *m_sctx;
725 char m_view_access_denied_message[MYSQL_ERRMSG_SIZE];
726 char *m_view_access_denied_message_ptr;
739 m_top_view(top_view), m_handling(FALSE),
740 m_view_access_denied_message_ptr(NULL)
743 m_sctx =
test(m_top_view->security_ctx) ?
744 m_top_view->security_ctx : thd->security_ctx;
758 if (!m_view_access_denied_message_ptr)
760 m_view_access_denied_message_ptr= m_view_access_denied_message;
761 my_snprintf(m_view_access_denied_message, MYSQL_ERRMSG_SIZE,
762 ER(ER_TABLEACCESS_DENIED_ERROR),
"SHOW VIEW",
766 return m_view_access_denied_message_ptr;
769 bool handle_condition(THD *thd, uint sql_errno,
const char * ,
770 Sql_condition::enum_warning_level
level,
777 if (m_handling || !m_top_view->view)
786 case ER_TABLEACCESS_DENIED_ERROR:
793 case ER_COLUMNACCESS_DENIED_ERROR:
794 case ER_VIEW_NO_EXPLAIN:
795 case ER_PROCACCESS_DENIED_ERROR:
799 case ER_NO_SUCH_TABLE:
801 push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
809 case ER_SP_DOES_NOT_EXIST:
811 push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
829 mysqld_show_create(THD *thd,
TABLE_LIST *table_list)
833 String buffer(buff,
sizeof(buff), system_charset_info);
836 DBUG_ENTER(
"mysqld_show_create");
837 DBUG_PRINT(
"enter",(
"db: %s table: %s",table_list->db,
838 table_list->table_name));
844 MDL_savepoint mdl_savepoint= thd->mdl_context.mdl_savepoint();
847 thd->lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW;
857 thd->push_internal_handler(&view_error_suppressor);
860 MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL) ||
861 mysql_handle_derived(thd->lex, &mysql_derived_prepare);
862 thd->pop_internal_handler();
863 if (open_error && (thd->killed || thd->is_error()))
868 if (thd->lex->only_view && !table_list->view)
870 my_error(ER_WRONG_OBJECT, MYF(0),
871 table_list->db, table_list->table_name,
"VIEW");
877 if (table_list->view)
878 buffer.set_charset(table_list->view_creation_ctx->get_client_cs());
880 if ((table_list->view ?
881 view_store_create_info(thd, table_list, &buffer) :
882 store_create_info(thd, table_list, &buffer, NULL,
886 if (table_list->view)
890 max(buffer.length(), 1024
U)));
901 max(buffer.length(), 1024
U)));
905 Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
908 protocol->prepare_for_resend();
909 if (table_list->view)
910 protocol->
store(table_list->view_name.str, system_charset_info);
913 if (table_list->schema_table)
914 protocol->
store(table_list->schema_table->table_name,
915 system_charset_info);
917 protocol->
store(table_list->table->alias, system_charset_info);
920 if (table_list->view)
922 protocol->
store(buffer.ptr(), buffer.length(),
923 table_list->view_creation_ctx->get_client_cs());
925 protocol->
store(table_list->view_creation_ctx->get_client_cs()->csname,
926 system_charset_info);
928 protocol->
store(table_list->view_creation_ctx->get_connection_cl()->name,
929 system_charset_info);
932 protocol->
store(buffer.ptr(), buffer.length(), buffer.charset());
934 if (protocol->write())
941 close_thread_tables(thd);
943 thd->mdl_context.rollback_to_savepoint(mdl_savepoint);
947 bool mysqld_show_create_db(THD *thd,
char *dbname,
950 char buff[2048], orig_dbname[NAME_LEN];
951 String buffer(buff,
sizeof(buff), system_charset_info);
952 #ifndef NO_EMBEDDED_ACCESS_CHECKS
953 Security_context *sctx= thd->security_ctx;
957 uint create_options = create_info ? create_info->options : 0;
959 DBUG_ENTER(
"mysql_show_create_db");
961 strcpy(orig_dbname, dbname);
962 if (lower_case_table_names && dbname != any_db)
963 my_casedn_str(files_charset_info, dbname);
965 #ifndef NO_EMBEDDED_ACCESS_CHECKS
966 if (test_all_bits(sctx->master_access, DB_ACLS))
969 db_access= (acl_get(sctx->get_host()->ptr(), sctx->get_ip()->ptr(),
970 sctx->priv_user, dbname, 0) | sctx->master_access);
971 if (!(db_access & DB_ACLS) && check_grant_db(thd,dbname))
973 my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
974 sctx->priv_user, sctx->host_or_ip, dbname);
975 general_log_print(thd,COM_INIT_DB,ER(ER_DBACCESS_DENIED_ERROR),
976 sctx->priv_user, sctx->host_or_ip, dbname);
980 if (is_infoschema_db(dbname))
982 dbname= INFORMATION_SCHEMA_NAME.str;
983 create.default_table_charset= system_charset_info;
987 if (check_db_dir_existence(dbname))
989 my_error(ER_BAD_DB_ERROR, MYF(0), dbname);
993 load_db_opt_by_name(thd, dbname, &create);
1000 Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
1003 protocol->prepare_for_resend();
1004 protocol->
store(orig_dbname, strlen(orig_dbname), system_charset_info);
1006 buffer.append(STRING_WITH_LEN(
"CREATE DATABASE "));
1007 if (create_options & HA_LEX_CREATE_IF_NOT_EXISTS)
1008 buffer.append(STRING_WITH_LEN(
"/*!32312 IF NOT EXISTS*/ "));
1009 append_identifier(thd, &buffer, orig_dbname, strlen(orig_dbname));
1011 if (create.default_table_charset)
1013 buffer.append(STRING_WITH_LEN(
" /*!40100"));
1014 buffer.append(STRING_WITH_LEN(
" DEFAULT CHARACTER SET "));
1015 buffer.append(create.default_table_charset->csname);
1016 if (!(create.default_table_charset->state & MY_CS_PRIMARY))
1018 buffer.append(STRING_WITH_LEN(
" COLLATE "));
1019 buffer.append(create.default_table_charset->name);
1021 buffer.append(STRING_WITH_LEN(
" */"));
1023 protocol->
store(buffer.ptr(), buffer.length(), buffer.charset());
1025 if (protocol->write())
1039 mysqld_list_fields(THD *thd,
TABLE_LIST *table_list,
const char *wild)
1042 DBUG_ENTER(
"mysqld_list_fields");
1043 DBUG_PRINT(
"enter",(
"table: %s",table_list->table_name));
1046 MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL))
1048 table= table_list->table;
1050 mysql_handle_single_derived(thd->lex, table_list, &mysql_derived_create);
1054 for (ptr=table->field ; (field= *ptr); ptr++)
1056 if (!wild || !wild[0] ||
1057 !wild_case_compare(system_charset_info, field->field_name,wild))
1059 if (table_list->view)
1061 table_list->view_db.str,
1062 table_list->view_name.str));
1067 restore_record(table, s->default_values);
1068 table->use_all_columns();
1069 if (thd->protocol->send_result_set_metadata(&field_list, Protocol::SEND_DEFAULTS))
1089 static const char *require_quotes(
const char *
name, uint name_length)
1092 bool pure_digit= TRUE;
1093 const char *end= name + name_length;
1095 for (; name < end ; name++)
1097 uchar chr= (uchar) *name;
1098 length= my_mbcharlen(system_charset_info, chr);
1099 if (length == 1 && !system_charset_info->ident_map[chr])
1101 if (length == 1 && (chr < '0' || chr >
'9'))
1123 append_identifier(THD *thd,
String *packet,
const char *name, uint length)
1125 const char *name_end;
1128 q= thd ? get_quote_char_for_identifier(thd, name, length) :
'`';
1132 packet->append(name, length, packet->charset());
1141 (void) packet->reserve(length*2 + 2);
1142 quote_char= (char) q;
1143 packet->append("e_char, 1, system_charset_info);
1145 for (name_end= name+length ; name < name_end ; name+= length)
1147 uchar chr= (uchar) *name;
1148 length= my_mbcharlen(system_charset_info, chr);
1158 if (length == 1 && chr == (uchar) quote_char)
1159 packet->append("e_char, 1, system_charset_info);
1160 packet->append(name, length, system_charset_info);
1162 packet->append("e_char, 1, system_charset_info);
1189 int get_quote_char_for_identifier(THD *thd,
const char *name, uint length)
1192 !is_keyword(name,length) &&
1193 !require_quotes(name, length) &&
1194 !(thd->variables.option_bits & OPTION_QUOTE_SHOW_CREATE))
1196 if (thd->variables.sql_mode & MODE_ANSI_QUOTES)
1204 static void append_directory(THD *thd,
String *packet,
const char *dir_type,
1205 const char *filename)
1207 if (filename && !(thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE))
1209 uint length= dirname_length(filename);
1210 packet->append(
' ');
1211 packet->append(dir_type);
1212 packet->append(STRING_WITH_LEN(
" DIRECTORY='"));
1215 char *winfilename= (
char*) thd->memdup(filename, length);
1217 for (pos= winfilename, end= pos+length ; pos < end ; pos++)
1222 filename= winfilename;
1224 packet->append(filename, length);
1225 packet->append(
'\'');
1230 #define LIST_PROCESS_HOST_LEN 64
1240 static bool print_on_update_clause(
Field *field,
String *val,
bool lcase)
1242 DBUG_ASSERT(val->charset()->mbminlen == 1);
1244 if (field->has_update_default_function())
1247 val->copy(STRING_WITH_LEN(
"on update "), val->charset());
1249 val->copy(STRING_WITH_LEN(
"ON UPDATE "), val->charset());
1250 val->append(STRING_WITH_LEN(
"CURRENT_TIMESTAMP"));
1251 if (field->decimals() > 0)
1259 static bool print_default_clause(THD *thd,
Field *field,
String *def_value,
1262 enum enum_field_types field_type= field->type();
1264 const bool has_now_default= field->has_insert_default_function();
1265 const bool has_default=
1266 (field_type != FIELD_TYPE_BLOB &&
1267 !(field->flags & NO_DEFAULT_VALUE_FLAG) &&
1268 field->unireg_check != Field::NEXT_NUMBER &&
1269 !((thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40))
1270 && has_now_default));
1272 def_value->length(0);
1275 if (has_now_default)
1281 def_value->append(STRING_WITH_LEN(
"CURRENT_TIMESTAMP"));
1282 if (field->decimals() > 0)
1285 else if (!field->is_null())
1287 char tmp[MAX_FIELD_WIDTH];
1288 String type(tmp,
sizeof(tmp), field->charset());
1289 if (field_type == MYSQL_TYPE_BIT)
1291 longlong dec= field->val_int();
1292 char *ptr= longlong2str(dec, tmp + 2, 2);
1293 uint32 length= (uint32) (ptr - tmp);
1297 type.length(length + 1);
1301 field->val_str(&
type);
1307 def_val.copy(
type.ptr(),
type.length(), field->charset(),
1308 system_charset_info, &dummy_errors);
1310 append_unescaped(def_value, def_val.ptr(), def_val.length());
1312 def_value->append(def_val.ptr(), def_val.length());
1315 def_value->append(STRING_WITH_LEN(
"''"));
1317 else if (field->maybe_null() && quoted)
1318 def_value->append(STRING_WITH_LEN(
"NULL"));
1354 char tmp[MAX_FIELD_WIDTH], *for_str, buff[128], def_value_buf[MAX_FIELD_WIDTH];
1356 String type(tmp,
sizeof(tmp), system_charset_info);
1357 String def_value(def_value_buf,
sizeof(def_value_buf), system_charset_info);
1361 TABLE *table= table_list->table;
1365 #ifdef WITH_PARTITION_STORAGE_ENGINE
1366 bool show_table_options= FALSE;
1368 bool foreign_db_mode= (thd->variables.sql_mode & (MODE_POSTGRESQL |
1374 bool limited_mysql_mode= (thd->variables.sql_mode & (MODE_NO_FIELD_OPTIONS |
1376 MODE_MYSQL40)) != 0;
1377 my_bitmap_map *old_map;
1379 DBUG_ENTER(
"store_create_info");
1380 DBUG_PRINT(
"enter",(
"table: %s", table->s->table_name.str));
1382 restore_record(table, s->default_values);
1384 if (share->tmp_table)
1385 packet->append(STRING_WITH_LEN(
"CREATE TEMPORARY TABLE "));
1387 packet->append(STRING_WITH_LEN(
"CREATE TABLE "));
1388 if (create_info_arg &&
1389 (create_info_arg->options & HA_LEX_CREATE_IF_NOT_EXISTS))
1390 packet->append(STRING_WITH_LEN(
"IF NOT EXISTS "));
1391 if (table_list->schema_table)
1392 alias= table_list->schema_table->table_name;
1395 if (lower_case_table_names == 2)
1396 alias= table->alias;
1399 alias= share->table_name.str;
1413 table_list->schema_table ? &INFORMATION_SCHEMA_NAME : &table->s->db;
1414 if (!thd->db || strcmp(db->str, thd->db))
1416 append_identifier(thd, packet, db->str, db->length);
1417 packet->append(STRING_WITH_LEN(
"."));
1421 append_identifier(thd, packet, alias, strlen(alias));
1422 packet->append(STRING_WITH_LEN(
" (\n"));
1428 old_map= tmp_use_all_columns(table, table->read_set);
1430 for (ptr=table->field ; (field= *ptr); ptr++)
1432 uint
flags = field->flags;
1434 if (ptr != table->field)
1435 packet->append(STRING_WITH_LEN(
",\n"));
1437 packet->append(STRING_WITH_LEN(
" "));
1438 append_identifier(thd,packet,field->field_name, strlen(field->field_name));
1439 packet->append(
' ');
1441 if (
type.ptr() != tmp)
1442 type.set(tmp,
sizeof(tmp), system_charset_info);
1444 type.set_charset(system_charset_info);
1446 field->sql_type(
type);
1447 packet->append(
type.ptr(),
type.length(), system_charset_info);
1449 if (field->has_charset() &&
1450 !(thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40)))
1452 if (field->charset() != share->table_charset)
1454 packet->append(STRING_WITH_LEN(
" CHARACTER SET "));
1455 packet->append(field->charset()->csname);
1461 if (!(field->charset()->state & MY_CS_PRIMARY))
1463 packet->append(STRING_WITH_LEN(
" COLLATE "));
1464 packet->append(field->charset()->name);
1468 if (flags & NOT_NULL_FLAG)
1469 packet->append(STRING_WITH_LEN(
" NOT NULL"));
1470 else if (field->type() == MYSQL_TYPE_TIMESTAMP)
1476 packet->append(STRING_WITH_LEN(
" NULL"));
1479 switch(field->field_storage_type()){
1483 packet->append(STRING_WITH_LEN(
" /*!50606 STORAGE DISK */"));
1486 packet->append(STRING_WITH_LEN(
" /*!50606 STORAGE MEMORY */"));
1493 switch(field->column_format()){
1494 case COLUMN_FORMAT_TYPE_DEFAULT:
1496 case COLUMN_FORMAT_TYPE_FIXED:
1497 packet->append(STRING_WITH_LEN(
" /*!50606 COLUMN_FORMAT FIXED */"));
1499 case COLUMN_FORMAT_TYPE_DYNAMIC:
1500 packet->append(STRING_WITH_LEN(
" /*!50606 COLUMN_FORMAT DYNAMIC */"));
1507 if (print_default_clause(thd, field, &def_value,
true))
1509 packet->append(STRING_WITH_LEN(
" DEFAULT "));
1510 packet->append(def_value.ptr(), def_value.length(), system_charset_info);
1513 if (!limited_mysql_mode &&
1514 print_on_update_clause(field, &def_value,
false))
1516 packet->append(STRING_WITH_LEN(
" "));
1517 packet->append(def_value);
1520 if (field->unireg_check == Field::NEXT_NUMBER &&
1521 !(thd->variables.sql_mode & MODE_NO_FIELD_OPTIONS))
1522 packet->append(STRING_WITH_LEN(
" AUTO_INCREMENT"));
1524 if (field->comment.length)
1526 packet->append(STRING_WITH_LEN(
" COMMENT "));
1527 append_unescaped(packet, field->comment.str, field->comment.length);
1531 key_info= table->key_info;
1532 memset(&create_info, 0,
sizeof(create_info));
1534 create_info.
row_type= share->row_type;
1535 file->update_create_info(&create_info);
1536 primary_key= share->primary_key;
1538 for (uint i=0 ; i < share->keys ; i++,key_info++)
1541 bool found_primary=0;
1542 packet->append(STRING_WITH_LEN(
",\n "));
1544 if (i == primary_key && !strcmp(key_info->
name, primary_key_name))
1551 packet->append(STRING_WITH_LEN(
"PRIMARY KEY"));
1553 else if (key_info->
flags & HA_NOSAME)
1554 packet->append(STRING_WITH_LEN(
"UNIQUE KEY "));
1555 else if (key_info->
flags & HA_FULLTEXT)
1556 packet->append(STRING_WITH_LEN(
"FULLTEXT KEY "));
1557 else if (key_info->
flags & HA_SPATIAL)
1558 packet->append(STRING_WITH_LEN(
"SPATIAL KEY "));
1560 packet->append(STRING_WITH_LEN(
"KEY "));
1563 append_identifier(thd, packet, key_info->
name, strlen(key_info->
name));
1565 packet->append(STRING_WITH_LEN(
" ("));
1570 packet->append(
',');
1572 if (key_part->field)
1573 append_identifier(thd,packet,key_part->field->field_name,
1574 strlen(key_part->field->field_name));
1575 if (key_part->field &&
1576 (key_part->length !=
1577 table->field[key_part->fieldnr-1]->key_length() &&
1578 !(key_info->
flags & (HA_FULLTEXT | HA_SPATIAL))))
1581 key_part->field->charset()->mbmaxlen);
1584 packet->append(
')');
1585 store_key_options(thd, packet, table, key_info);
1589 packet->append(STRING_WITH_LEN(
" /*!50100 WITH PARSER "));
1590 append_identifier(thd, packet, parser_name->str, parser_name->length);
1591 packet->append(STRING_WITH_LEN(
" */ "));
1600 if ((for_str= file->get_foreign_key_create_info()))
1602 packet->append(for_str, strlen(for_str));
1603 file->free_foreign_key_create_info(for_str);
1606 packet->append(STRING_WITH_LEN(
"\n)"));
1607 if (!(thd->variables.sql_mode & MODE_NO_TABLE_OPTIONS) && !foreign_db_mode)
1609 #ifdef WITH_PARTITION_STORAGE_ENGINE
1610 show_table_options= TRUE;
1614 if (share->tablespace ||
1615 share->default_storage_media != HA_SM_DEFAULT)
1617 packet->append(STRING_WITH_LEN(
" /*!50100"));
1618 if (share->tablespace)
1620 packet->append(STRING_WITH_LEN(
" TABLESPACE "));
1621 packet->append(share->tablespace, strlen(share->tablespace));
1624 if (share->default_storage_media == HA_SM_DISK)
1625 packet->append(STRING_WITH_LEN(
" STORAGE DISK"));
1626 if (share->default_storage_media == HA_SM_MEMORY)
1627 packet->append(STRING_WITH_LEN(
" STORAGE MEMORY"));
1629 packet->append(STRING_WITH_LEN(
" */"));
1636 if (!create_info_arg ||
1637 (create_info_arg->used_fields & HA_CREATE_USED_ENGINE))
1639 if (thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40))
1640 packet->append(STRING_WITH_LEN(
" TYPE="));
1642 packet->append(STRING_WITH_LEN(
" ENGINE="));
1643 #ifdef WITH_PARTITION_STORAGE_ENGINE
1644 if (table->part_info)
1645 packet->append(ha_resolve_storage_engine_name(
1646 table->part_info->default_engine_type));
1665 if (create_info.auto_increment_value > 1)
1668 packet->append(STRING_WITH_LEN(
" AUTO_INCREMENT="));
1669 end= longlong10_to_str(create_info.auto_increment_value, buff,10);
1670 packet->append(buff, (uint) (end - buff));
1673 if (share->table_charset &&
1674 !(thd->variables.sql_mode & MODE_MYSQL323) &&
1675 !(thd->variables.sql_mode & MODE_MYSQL40))
1681 if (!create_info_arg ||
1682 (create_info_arg->used_fields & HA_CREATE_USED_DEFAULT_CHARSET))
1684 packet->append(STRING_WITH_LEN(
" DEFAULT CHARSET="));
1685 packet->append(share->table_charset->csname);
1686 if (!(share->table_charset->state & MY_CS_PRIMARY))
1688 packet->append(STRING_WITH_LEN(
" COLLATE="));
1689 packet->append(table->s->table_charset->name);
1694 if (share->min_rows)
1697 packet->append(STRING_WITH_LEN(
" MIN_ROWS="));
1698 end= longlong10_to_str(share->min_rows, buff, 10);
1699 packet->append(buff, (uint) (end- buff));
1702 if (share->max_rows && !table_list->schema_table)
1705 packet->append(STRING_WITH_LEN(
" MAX_ROWS="));
1706 end= longlong10_to_str(share->max_rows, buff, 10);
1707 packet->append(buff, (uint) (end - buff));
1710 if (share->avg_row_length)
1713 packet->append(STRING_WITH_LEN(
" AVG_ROW_LENGTH="));
1714 end= longlong10_to_str(share->avg_row_length, buff,10);
1715 packet->append(buff, (uint) (end - buff));
1718 if (share->db_create_options & HA_OPTION_PACK_KEYS)
1719 packet->append(STRING_WITH_LEN(
" PACK_KEYS=1"));
1720 if (share->db_create_options & HA_OPTION_NO_PACK_KEYS)
1721 packet->append(STRING_WITH_LEN(
" PACK_KEYS=0"));
1722 if (share->db_create_options & HA_OPTION_STATS_PERSISTENT)
1723 packet->append(STRING_WITH_LEN(
" STATS_PERSISTENT=1"));
1724 if (share->db_create_options & HA_OPTION_NO_STATS_PERSISTENT)
1725 packet->append(STRING_WITH_LEN(
" STATS_PERSISTENT=0"));
1726 if (share->stats_auto_recalc == HA_STATS_AUTO_RECALC_ON)
1727 packet->append(STRING_WITH_LEN(
" STATS_AUTO_RECALC=1"));
1728 else if (share->stats_auto_recalc == HA_STATS_AUTO_RECALC_OFF)
1729 packet->append(STRING_WITH_LEN(
" STATS_AUTO_RECALC=0"));
1730 if (share->stats_sample_pages != 0)
1733 packet->append(STRING_WITH_LEN(
" STATS_SAMPLE_PAGES="));
1734 end= longlong10_to_str(share->stats_sample_pages, buff, 10);
1735 packet->append(buff, (uint) (end - buff));
1738 if (share->db_create_options & HA_OPTION_CHECKSUM)
1739 packet->append(STRING_WITH_LEN(
" CHECKSUM=1"));
1740 if (share->db_create_options & HA_OPTION_DELAY_KEY_WRITE)
1741 packet->append(STRING_WITH_LEN(
" DELAY_KEY_WRITE=1"));
1742 if (create_info.
row_type != ROW_TYPE_DEFAULT)
1744 packet->append(STRING_WITH_LEN(
" ROW_FORMAT="));
1745 packet->append(ha_row_type[(uint) create_info.
row_type]);
1747 if (table->s->key_block_size)
1750 packet->append(STRING_WITH_LEN(
" KEY_BLOCK_SIZE="));
1751 end= longlong10_to_str(table->s->key_block_size, buff, 10);
1752 packet->append(buff, (uint) (end - buff));
1754 table->file->append_create_info(packet);
1755 if (share->comment.length)
1757 packet->append(STRING_WITH_LEN(
" COMMENT="));
1758 append_unescaped(packet, share->comment.str, share->comment.length);
1760 if (share->connect_string.length)
1762 packet->append(STRING_WITH_LEN(
" CONNECTION="));
1763 append_unescaped(packet, share->connect_string.str, share->connect_string.length);
1765 append_directory(thd, packet,
"DATA", create_info.data_file_name);
1766 append_directory(thd, packet,
"INDEX", create_info.index_file_name);
1768 #ifdef WITH_PARTITION_STORAGE_ENGINE
1770 if (table->part_info &&
1771 !((table->s->db_type()->partition_flags() & HA_USE_AUTO_PARTITION) &&
1772 table->part_info->is_auto_partitioned))
1777 uint part_syntax_len;
1780 table->part_info->set_show_version_string(&comment_start);
1781 if ((part_syntax= generate_partition_syntax(table->part_info,
1786 comment_start.c_ptr())))
1788 packet->append(comment_start);
1789 if (packet->append(part_syntax, part_syntax_len) ||
1790 packet->append(STRING_WITH_LEN(
" */")))
1792 my_free(part_syntax);
1797 tmp_restore_column_map(table->read_set, old_map);
1802 static void store_key_options(THD *thd,
String *packet,
TABLE *table,
1805 bool limited_mysql_mode= (thd->variables.sql_mode &
1806 (MODE_NO_FIELD_OPTIONS | MODE_MYSQL323 |
1807 MODE_MYSQL40)) != 0;
1808 bool foreign_db_mode= (thd->variables.sql_mode & (MODE_POSTGRESQL |
1814 char *end, buff[32];
1816 if (!(thd->variables.sql_mode & MODE_NO_KEY_OPTIONS) &&
1817 !limited_mysql_mode && !foreign_db_mode)
1820 if (key_info->algorithm == HA_KEY_ALG_BTREE)
1821 packet->append(STRING_WITH_LEN(
" USING BTREE"));
1823 if (key_info->algorithm == HA_KEY_ALG_HASH)
1824 packet->append(STRING_WITH_LEN(
" USING HASH"));
1827 if ((key_info->algorithm == HA_KEY_ALG_RTREE) &&
1828 !(key_info->
flags & HA_SPATIAL))
1829 packet->append(STRING_WITH_LEN(
" USING RTREE"));
1831 if ((key_info->
flags & HA_USES_BLOCK_SIZE) &&
1832 table->s->key_block_size != key_info->block_size)
1834 packet->append(STRING_WITH_LEN(
" KEY_BLOCK_SIZE="));
1835 end= longlong10_to_str(key_info->block_size, buff, 10);
1836 packet->append(buff, (uint) (end - buff));
1838 DBUG_ASSERT(
test(key_info->
flags & HA_USES_COMMENT) ==
1839 (key_info->comment.length > 0));
1840 if (key_info->
flags & HA_USES_COMMENT)
1842 packet->append(STRING_WITH_LEN(
" COMMENT "));
1843 append_unescaped(packet, key_info->comment.str,
1844 key_info->comment.length);
1853 append_algorithm(table, buff);
1854 append_definer(thd, buff, &table->definer.user, &table->definer.host);
1855 if (table->view_suid)
1856 buff->append(STRING_WITH_LEN(
"SQL SECURITY DEFINER "));
1858 buff->append(STRING_WITH_LEN(
"SQL SECURITY INVOKER "));
1875 buff->append(STRING_WITH_LEN(
"ALGORITHM="));
1877 case VIEW_ALGORITHM_UNDEFINED:
1878 buff->append(STRING_WITH_LEN(
"UNDEFINED "));
1880 case VIEW_ALGORITHM_TMPTABLE:
1881 buff->append(STRING_WITH_LEN(
"TEMPTABLE "));
1883 case VIEW_ALGORITHM_MERGE:
1884 buff->append(STRING_WITH_LEN(
"MERGE "));
1902 void append_definer(THD *thd,
String *buffer,
const LEX_STRING *definer_user,
1905 buffer->append(STRING_WITH_LEN(
"DEFINER="));
1906 append_identifier(thd, buffer, definer_user->str, definer_user->length);
1907 buffer->append(
'@');
1908 append_identifier(thd, buffer, definer_host->str, definer_host->length);
1909 buffer->append(
' ');
1916 my_bool compact_view_name= TRUE;
1917 my_bool foreign_db_mode= (thd->variables.sql_mode & (MODE_POSTGRESQL |
1924 if (!thd->db || strcmp(thd->db, table->view_db.str))
1928 compact_view_name= table->compact_view_format= FALSE;
1936 table->compact_view_format= TRUE;
1937 for (tbl= thd->lex->query_tables;
1939 tbl= tbl->next_global)
1941 if (strcmp(table->view_db.str, tbl->view ? tbl->view_db.str :tbl->db)!= 0)
1943 table->compact_view_format= FALSE;
1949 buff->append(STRING_WITH_LEN(
"CREATE "));
1950 if (!foreign_db_mode)
1952 view_store_options(thd, table, buff);
1954 buff->append(STRING_WITH_LEN(
"VIEW "));
1955 if (!compact_view_name)
1957 append_identifier(thd, buff, table->view_db.str, table->view_db.length);
1960 append_identifier(thd, buff, table->view_name.str, table->view_name.length);
1961 buff->append(STRING_WITH_LEN(
" AS "));
1967 table->view->unit.print(buff, QT_ORDINARY);
1969 if (table->with_check != VIEW_CHECK_NONE)
1971 if (table->with_check == VIEW_CHECK_LOCAL)
1972 buff->append(STRING_WITH_LEN(
" WITH LOCAL CHECK OPTION"));
1974 buff->append(STRING_WITH_LEN(
" WITH CASCADED CHECK OPTION"));
1988 static void *
operator new(
size_t size)
1990 return (
void*) sql_alloc((uint)
size);
1992 static void operator delete(
void *ptr __attribute__((unused)),
1993 size_t size __attribute__((unused)))
1994 { TRASH(ptr,
size); }
1999 const char *user,*host,*db,*proc_info,*state_info;
2005 public std::binary_function<const thread_info*, const thread_info*, bool>
2010 return p1->thread_id < p2->thread_id;
2014 static const char *thread_state_info(THD *tmp)
2016 #ifndef EMBEDDED_LIBRARY
2017 if (tmp->net.reading_or_writing)
2019 if (tmp->net.reading_or_writing == 2)
2020 return "Writing to net";
2021 else if (tmp->get_command() == COM_SLEEP)
2024 return "Reading from net";
2030 return tmp->proc_info;
2031 else if (tmp->mysys_var && tmp->mysys_var->current_cond)
2032 return "Waiting on cond";
2038 void mysqld_list_processes(THD *thd,
const char *user,
bool verbose)
2043 ulong max_query_length= (verbose ? thd->variables.max_allowed_packet :
2046 DBUG_ENTER(
"mysqld_list_processes");
2048 field_list.push_back(
new Item_int(NAME_STRING(
"Id"), 0, MY_INT64_NUM_DECIMAL_DIGITS));
2052 field->maybe_null=1;
2054 field_list.push_back(field=
new Item_return_int(
"Time",7, MYSQL_TYPE_LONG));
2055 field->unsigned_flag= 0;
2057 field->maybe_null=1;
2059 field->maybe_null=1;
2061 Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
2067 thread_infos.reserve(get_thread_count());
2068 Thread_iterator it= global_thread_list_begin();
2069 Thread_iterator end= global_thread_list_end();
2070 for (; it != end; ++it)
2073 Security_context *tmp_sctx= tmp->security_ctx;
2075 if ((tmp->vio_ok() || tmp->system_thread) &&
2076 (!user || (tmp_sctx->user && !strcmp(tmp_sctx->user, user))))
2080 thd_info->thread_id=tmp->thread_id;
2081 thd_info->user= thd->strdup(tmp_sctx->user ? tmp_sctx->user :
2082 (tmp->system_thread ?
2083 "system user" :
"unauthenticated user"));
2084 if (tmp->peer_port && (tmp_sctx->get_host()->length() ||
2085 tmp_sctx->get_ip()->length()) && thd->security_ctx->host_or_ip[0])
2087 if ((thd_info->host= (
char*) thd->alloc(LIST_PROCESS_HOST_LEN+1)))
2088 my_snprintf((
char *) thd_info->host, LIST_PROCESS_HOST_LEN,
2089 "%s:%u", tmp_sctx->host_or_ip, tmp->peer_port);
2092 thd_info->host= thd->strdup(tmp_sctx->host_or_ip[0] ?
2093 tmp_sctx->host_or_ip :
2094 tmp_sctx->get_host()->length() ?
2095 tmp_sctx->get_host()->ptr() :
"");
2096 thd_info->command=(int) tmp->get_command();
2098 if ((thd_info->db= tmp->db))
2099 thd_info->db= thd->strdup(thd_info->db);
2100 if ((mysys_var= tmp->mysys_var))
2102 thd_info->proc_info= (
char*) (tmp->killed == THD::KILL_CONNECTION?
"Killed" : 0);
2103 thd_info->state_info= thread_state_info(tmp);
2110 uint length= min<uint>(max_query_length, tmp->query_length());
2111 char *q= thd->strmake(tmp->query(),length);
2113 thd_info->query_string=
2114 CSET_STRING(q, q ? length : 0, tmp->query_charset());
2117 thd_info->start_time= tmp->start_time.tv_sec;
2118 thread_infos.push_back(thd_info);
2127 time_t now= my_time(0);
2128 for (
size_t ix= 0; ix < thread_infos.size(); ++ix)
2131 protocol->prepare_for_resend();
2132 protocol->
store((ulonglong) thd_info->thread_id);
2133 protocol->
store(thd_info->user, system_charset_info);
2134 protocol->
store(thd_info->host, system_charset_info);
2135 protocol->
store(thd_info->db, system_charset_info);
2136 if (thd_info->proc_info)
2137 protocol->
store(thd_info->proc_info, system_charset_info);
2139 protocol->
store(command_name[thd_info->command].str, system_charset_info);
2140 if (thd_info->start_time)
2141 protocol->store_long ((longlong) (now - thd_info->start_time));
2143 protocol->store_null();
2144 protocol->
store(thd_info->state_info, system_charset_info);
2145 protocol->
store(thd_info->query_string.str(),
2146 thd_info->query_string.charset());
2147 if (protocol->write())
2154 int fill_schema_processlist(THD* thd,
TABLE_LIST* tables,
Item* cond)
2156 TABLE *table= tables->table;
2159 time_t now= my_time(0);
2160 DBUG_ENTER(
"fill_process_list");
2162 user= thd->security_ctx->master_access & PROCESS_ACL ?
2163 NullS : thd->security_ctx->priv_user;
2168 Thread_iterator it= global_thread_list_begin();
2169 Thread_iterator end= global_thread_list_end();
2170 for (; it != end; ++it)
2173 Security_context *tmp_sctx= tmp->security_ctx;
2175 const char *val, *db;
2177 if ((!tmp->vio_ok() && !tmp->system_thread) ||
2178 (user && (!tmp_sctx->user || strcmp(tmp_sctx->user, user))))
2181 restore_record(table, s->default_values);
2184 table->field[0]->store((ulonglong) tmp->thread_id, TRUE);
2186 val= tmp_sctx->user ? tmp_sctx->user :
2187 (tmp->system_thread ?
"system user" :
"unauthenticated user");
2188 table->field[1]->store(val, strlen(val), cs);
2190 if (tmp->peer_port && (tmp_sctx->get_host()->length() ||
2191 tmp_sctx->get_ip()->length()) && thd->security_ctx->host_or_ip[0])
2193 char host[LIST_PROCESS_HOST_LEN + 1];
2194 my_snprintf(host, LIST_PROCESS_HOST_LEN,
"%s:%u",
2195 tmp_sctx->host_or_ip, tmp->peer_port);
2196 table->field[2]->store(host, strlen(host), cs);
2199 table->field[2]->store(tmp_sctx->host_or_ip,
2200 strlen(tmp_sctx->host_or_ip), cs);
2205 table->field[3]->store(db, strlen(db), cs);
2206 table->field[3]->set_notnull();
2209 if ((mysys_var= tmp->mysys_var))
2212 if ((val= (
char *) (tmp->killed == THD::KILL_CONNECTION?
"Killed" : 0)))
2213 table->field[4]->store(val, strlen(val), cs);
2215 table->field[4]->store(command_name[tmp->get_command()].str,
2216 command_name[tmp->get_command()].length, cs);
2218 table->field[5]->store((longlong)(tmp->start_time.tv_sec ?
2219 now - tmp->start_time.tv_sec : 0), FALSE);
2221 if ((val= thread_state_info(tmp)))
2223 table->field[6]->store(val, strlen(val), cs);
2224 table->field[6]->set_notnull();
2237 min<size_t>(PROCESS_LIST_INFO_WIDTH, tmp->query_length());
2238 table->field[7]->store(tmp->query(), width, cs);
2239 table->field[7]->set_notnull();
2243 if (schema_table_store_record(thd, table))
2260 static bool status_vars_inited= 0;
2263 static int show_var_cmp(
const void *var1,
const void *var2)
2278 for (a= b= 0; b < array->elements; b++)
2279 if (all[b].
type != SHOW_UNDEF)
2283 memset(all+a, 0,
sizeof(
SHOW_VAR));
2287 delete_dynamic(array);
2309 int add_status_vars(
SHOW_VAR *list)
2312 if (status_vars_inited)
2314 if (!all_status_vars.buffer &&
2315 my_init_dynamic_array(&all_status_vars,
sizeof(
SHOW_VAR), 200, 20))
2321 res|= insert_dynamic(&all_status_vars, list++);
2322 res|= insert_dynamic(&all_status_vars, list);
2323 all_status_vars.elements--;
2324 if (status_vars_inited)
2325 sort_dynamic(&all_status_vars, show_var_cmp);
2327 if (status_vars_inited)
2340 void init_status_vars()
2342 status_vars_inited=1;
2343 sort_dynamic(&all_status_vars, show_var_cmp);
2346 void reset_status_vars()
2349 SHOW_VAR *last= ptr + all_status_vars.elements;
2350 for (; ptr < last; ptr++)
2353 if (ptr->type == SHOW_LONG || ptr->type == SHOW_SIGNED_LONG)
2354 *(ulong*) ptr->value= 0;
2367 void free_status_vars()
2369 delete_dynamic(&all_status_vars);
2386 void remove_status_vars(
SHOW_VAR *list)
2388 if (status_vars_inited)
2392 int a= 0, b= all_status_vars.elements, c= (a+b)/2;
2394 for (; list->name; list++)
2397 for (a= 0, b= all_status_vars.elements; b-a > 1; c= (a+b)/2)
2399 res= show_var_cmp(list, all+c);
2408 all[c].type= SHOW_UNDEF;
2410 shrink_var_array(&all_status_vars);
2417 for (; list->name; list++)
2419 for (i= 0; i < all_status_vars.elements; i++)
2421 if (show_var_cmp(list, all+i))
2423 all[
i].type= SHOW_UNDEF;
2427 shrink_var_array(&all_status_vars);
2431 inline void make_upper(
char *
buf)
2434 *buf= my_toupper(system_charset_info, *buf);
2437 static bool show_status_array(THD *thd,
const char *wild,
2439 enum enum_var_type value_type,
2441 const char *prefix,
TABLE *table,
2445 my_aligned_storage<SHOW_VAR_FUNC_BUFF_SIZE, MY_ALIGNOF(long)> buffer;
2446 char *
const buff= buffer.data;
2449 char name_buffer[64];
2453 Item *partial_cond= 0;
2454 enum_check_fields save_count_cuted_fields= thd->count_cuted_fields;
2457 DBUG_ENTER(
"show_status_array");
2459 thd->count_cuted_fields= CHECK_FIELD_WARN;
2460 null_lex_str.str= 0;
2461 null_lex_str.length= 0;
2463 prefix_end=strnmov(name_buffer, prefix,
sizeof(name_buffer)-1);
2466 len=name_buffer +
sizeof(name_buffer) - prefix_end;
2467 partial_cond= make_cond_for_info_schema(cond, table->pos_in_table_list);
2469 for (; variables->name; variables++)
2471 strnmov(prefix_end, variables->name, len);
2472 name_buffer[
sizeof(name_buffer)-1]=0;
2474 make_upper(name_buffer);
2476 restore_record(table, s->default_values);
2477 table->field[0]->store(name_buffer, strlen(name_buffer),
2478 system_charset_info);
2483 for (var=variables; var->type == SHOW_FUNC; var= &tmp)
2484 ((mysql_show_var_func)(var->value))(thd, &tmp, buff);
2486 SHOW_TYPE show_type=var->type;
2487 if (show_type == SHOW_ARRAY)
2489 show_status_array(thd, wild, (
SHOW_VAR *) var->value, value_type,
2490 status_var, name_buffer, table, ucase_names, partial_cond);
2494 if (!(wild && wild[0] && wild_case_compare(system_charset_info,
2495 name_buffer, wild)) &&
2496 (!partial_cond || partial_cond->val_int()))
2498 char *value=var->value;
2499 const char *pos, *end;
2503 if (show_type == SHOW_SYS)
2506 show_type= var->show_type();
2507 value= (
char*) var->value_ptr(thd, value_type, &null_lex_str);
2508 charset= var->charset(thd);
2516 switch (show_type) {
2517 case SHOW_DOUBLE_STATUS:
2518 value= ((
char *) status_var + (ulong) value);
2522 end= buff + my_fcvt(*(
double *) value, 6, buff, NULL);
2524 case SHOW_LONG_STATUS:
2525 value= ((
char *) status_var + (ulong) value);
2528 case SHOW_LONG_NOFLUSH:
2529 end= int10_to_str(*(
long*) value, buff, 10);
2531 case SHOW_SIGNED_LONG:
2532 end= int10_to_str(*(
long*) value, buff, -10);
2534 case SHOW_LONGLONG_STATUS:
2535 value= ((
char *) status_var + (ulong) value);
2538 end= longlong10_to_str(*(longlong*) value, buff, 10);
2541 end= longlong10_to_str((longlong) *(ha_rows*) value, buff, 10);
2544 end= strmov(buff, *(
bool*) value ?
"ON" :
"OFF");
2547 end= strmov(buff, *(my_bool*) value ?
"ON" :
"OFF");
2550 end= int10_to_str((
long) *(uint32*) value, buff, 10);
2554 SHOW_COMP_OPTION tmp= *(SHOW_COMP_OPTION*) value;
2555 pos= show_comp_option_name[(int) tmp];
2568 if (!(pos= *(
char**) value))
2571 DBUG_EXECUTE_IF(
"alter_server_version_str",
2572 if (!my_strcasecmp(system_charset_info,
2575 pos=
"some-other-version";
2581 case SHOW_LEX_STRING:
2584 if (!(pos= ls->str))
2587 end= pos + ls->length;
2590 case SHOW_KEY_CACHE_LONG:
2591 value= (
char*) dflt_key_cache + (ulong)value;
2592 end= int10_to_str(*(
long*) value, buff, 10);
2594 case SHOW_KEY_CACHE_LONGLONG:
2595 value= (
char*) dflt_key_cache + (ulong)value;
2596 end= longlong10_to_str(*(longlong*) value, buff, 10);
2605 table->field[1]->store(pos, (uint32) (end - pos), charset);
2606 thd->count_cuted_fields= CHECK_FIELD_IGNORE;
2607 table->field[1]->set_notnull();
2611 if (schema_table_store_record(thd, table))
2620 thd->count_cuted_fields= save_count_cuted_fields;
2629 DBUG_ENTER(
"calc_sum_of_all_status");
2633 Thread_iterator it= global_thread_list_begin();
2634 Thread_iterator end= global_thread_list_end();
2636 *to= global_status_var;
2639 for (; it != end; ++it)
2640 add_to_status(to, &(*it)->status_var);
2653 bool wild_db_value, wild_table_value;
2671 bool schema_table_store_record(THD *thd,
TABLE *table)
2674 if ((error= table->file->ha_write_row(table->record[0])))
2676 TMP_TABLE_PARAM *param= table->pos_in_table_list->schema_table_param;
2678 if (create_myisam_from_heap(thd, table, param->start_recinfo,
2679 ¶m->recinfo, error, FALSE, NULL))
2686 static int make_table_list(THD *thd, SELECT_LEX *sel,
2689 Table_ident *table_ident;
2690 table_ident=
new Table_ident(thd, *db_name, *table_name, 1);
2691 if (!sel->add_table_to_list(thd, table_ident, 0, 0, TL_READ, MDL_SHARED_READ))
2715 bool get_lookup_value(THD *thd,
Item_func *item_func,
2721 const char *field_name1= schema_table->idx_field1 >= 0 ?
2722 field_info[schema_table->idx_field1].
field_name :
"";
2723 const char *field_name2= schema_table->idx_field2 >= 0 ?
2724 field_info[schema_table->idx_field2].
field_name :
"";
2726 if (item_func->functype() == Item_func::EQ_FUNC ||
2727 item_func->functype() == Item_func::EQUAL_FUNC)
2729 int idx_field, idx_val;
2730 char tmp[MAX_FIELD_WIDTH];
2731 String *tmp_str, str_buff(tmp,
sizeof(tmp), system_charset_info);
2735 if (item_func->arguments()[0]->type() == Item::FIELD_ITEM &&
2736 item_func->arguments()[1]->const_item())
2741 else if (item_func->arguments()[1]->type() == Item::FIELD_ITEM &&
2742 item_func->arguments()[0]->const_item())
2750 item_field= (
Item_field*) item_func->arguments()[idx_field];
2751 if (table->table != item_field->field->table)
2753 tmp_str= item_func->arguments()[idx_val]->val_str(&str_buff);
2760 if (!cs->coll->strnncollsp(cs, (uchar *) field_name1, strlen(field_name1),
2761 (uchar *) item_field->field_name,
2762 strlen(item_field->field_name), 0))
2764 thd->make_lex_string(&lookup_field_vals->db_value, tmp_str->ptr(),
2765 tmp_str->length(), FALSE);
2768 else if (!cs->coll->strnncollsp(cs, (uchar *) field_name2,
2769 strlen(field_name2),
2770 (uchar *) item_field->field_name,
2771 strlen(item_field->field_name), 0))
2773 thd->make_lex_string(&lookup_field_vals->table_value, tmp_str->ptr(),
2774 tmp_str->length(), FALSE);
2798 bool calc_lookup_values_from_cond(THD *thd,
Item *cond,
TABLE_LIST *table,
2804 if (cond->type() == Item::COND_ITEM)
2806 if (((
Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC)
2810 while ((item= li++))
2812 if (item->type() == Item::FUNC_ITEM)
2814 if (get_lookup_value(thd, (
Item_func*)item, table, lookup_field_vals))
2819 if (calc_lookup_values_from_cond(thd, item, table, lookup_field_vals))
2826 else if (cond->type() == Item::FUNC_ITEM &&
2827 get_lookup_value(thd, (
Item_func*) cond, table, lookup_field_vals))
2835 if (item->type() == Item::FUNC_ITEM)
2838 for (uint i=0; i<item_func->argument_count(); i++)
2840 if (!uses_only_table_name_fields(item_func->arguments()[
i],
table))
2844 else if (item->type() == Item::FIELD_ITEM)
2850 const char *field_name1= schema_table->idx_field1 >= 0 ?
2851 field_info[schema_table->idx_field1].
field_name :
"";
2852 const char *field_name2= schema_table->idx_field2 >= 0 ?
2853 field_info[schema_table->idx_field2].
field_name :
"";
2854 if (table->table != item_field->field->table ||
2855 (cs->coll->strnncollsp(cs, (uchar *) field_name1, strlen(field_name1),
2856 (uchar *) item_field->field_name,
2857 strlen(item_field->field_name), 0) &&
2858 cs->coll->strnncollsp(cs, (uchar *) field_name2, strlen(field_name2),
2859 (uchar *) item_field->field_name,
2860 strlen(item_field->field_name), 0)))
2863 else if (item->type() == Item::REF_ITEM)
2864 return uses_only_table_name_fields(item->real_item(),
table);
2866 if (item->type() == Item::SUBSELECT_ITEM && !item->const_item())
2877 if (cond->type() == Item::COND_ITEM)
2879 if (((
Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC)
2889 Item *fix= make_cond_for_info_schema(item, table);
2891 new_cond->argument_list()->push_back(fix);
2893 switch (new_cond->argument_list()->elements) {
2897 return new_cond->argument_list()->head();
2899 new_cond->quick_fix_field();
2912 Item *fix=make_cond_for_info_schema(item, table);
2915 new_cond->argument_list()->push_back(fix);
2917 new_cond->quick_fix_field();
2918 new_cond->top_level_item();
2923 if (!uses_only_table_name_fields(cond, table))
2947 bool get_lookup_field_values(THD *thd,
Item *cond,
TABLE_LIST *tables,
2951 const char *wild= lex->wild ? lex->wild->ptr() : NullS;
2955 switch (lex->sql_command) {
2956 case SQLCOM_SHOW_DATABASES:
2959 thd->make_lex_string(&lookup_field_values->db_value,
2960 wild, strlen(wild), 0);
2961 lookup_field_values->wild_db_value= 1;
2964 case SQLCOM_SHOW_TABLES:
2965 case SQLCOM_SHOW_TABLE_STATUS:
2966 case SQLCOM_SHOW_TRIGGERS:
2967 case SQLCOM_SHOW_EVENTS:
2968 thd->make_lex_string(&lookup_field_values->db_value,
2969 lex->select_lex.db, strlen(lex->select_lex.db), 0);
2972 thd->make_lex_string(&lookup_field_values->table_value,
2973 wild, strlen(wild), 0);
2974 lookup_field_values->wild_table_value= 1;
2982 rc= calc_lookup_values_from_cond(thd, cond, tables, lookup_field_values);
2986 if (lower_case_table_names && !rc)
2992 if (lookup_field_values->db_value.str && lookup_field_values->db_value.str[0])
2993 my_casedn_str(system_charset_info, lookup_field_values->db_value.str);
2994 if (lookup_field_values->table_value.str &&
2995 lookup_field_values->table_value.str[0])
2996 my_casedn_str(system_charset_info, lookup_field_values->table_value.str);
3003 enum enum_schema_tables get_schema_table_idx(
ST_SCHEMA_TABLE *schema_table)
3005 return (
enum enum_schema_tables) (schema_table - &schema_tables[0]);
3029 bool *with_i_schema)
3032 i_s_name_copy= thd->make_lex_string(i_s_name_copy,
3033 INFORMATION_SCHEMA_NAME.str,
3034 INFORMATION_SCHEMA_NAME.length, TRUE);
3036 if (lookup_field_vals->wild_db_value)
3043 if (!lookup_field_vals->db_value.str ||
3044 !wild_case_compare(system_charset_info,
3045 INFORMATION_SCHEMA_NAME.str,
3046 lookup_field_vals->db_value.str))
3049 if (files->push_back(i_s_name_copy))
3052 return (find_files(thd, files, NullS, mysql_data_home,
3053 lookup_field_vals->db_value.str, 1) != FIND_FILES_OK);
3063 if (lookup_field_vals->db_value.str &&
3064 lookup_field_vals->db_value.length < FN_REFLEN)
3066 if (is_infoschema_db(lookup_field_vals->db_value.str,
3067 lookup_field_vals->db_value.length))
3070 if (files->push_back(i_s_name_copy))
3074 if (files->push_back(&lookup_field_vals->db_value))
3083 if (files->push_back(i_s_name_copy))
3086 return (find_files(thd, files, NullS,
3087 mysql_data_home, NullS, 1) != FIND_FILES_OK);
3098 static my_bool add_schema_table(THD *thd,
plugin_ref plugin,
3104 const char *wild= data->wild;
3106 DBUG_ENTER(
"add_schema_table");
3108 if (schema_table->hidden)
3112 if (lower_case_table_names)
3114 if (wild_case_compare(files_charset_info,
3115 schema_table->table_name,
3119 else if (wild_compare(schema_table->table_name, wild, 0))
3123 if ((file_name= thd->make_lex_string(file_name, schema_table->table_name,
3124 strlen(schema_table->table_name),
3126 !file_list->push_back(file_name))
3137 DBUG_ENTER(
"schema_tables_add");
3139 for (; tmp_schema_table->table_name; tmp_schema_table++)
3141 if (tmp_schema_table->hidden)
3145 if (lower_case_table_names)
3147 if (wild_case_compare(files_charset_info,
3148 tmp_schema_table->table_name,
3152 else if (wild_compare(tmp_schema_table->table_name, wild, 0))
3156 thd->make_lex_string(file_name, tmp_schema_table->table_name,
3157 strlen(tmp_schema_table->table_name), TRUE)) &&
3158 !files->push_back(file_name))
3163 add_data.files= files;
3164 add_data.wild= wild;
3165 if (plugin_foreach(thd, add_schema_table,
3166 MYSQL_INFORMATION_SCHEMA_PLUGIN, &add_data))
3197 char path[FN_REFLEN + 1];
3198 build_table_filename(path,
sizeof(path) - 1, db_name->str,
"",
"", 0);
3199 if (!lookup_field_vals->wild_table_value &&
3200 lookup_field_vals->table_value.str)
3206 find_schema_table(thd, lookup_field_vals->table_value.str);
3207 if (schema_table && !schema_table->hidden)
3210 thd->make_lex_string(NULL, schema_table->table_name,
3211 strlen(schema_table->table_name), TRUE)) ||
3212 table_names->push_back(name))
3218 if (table_names->push_back(&lookup_field_vals->table_value))
3224 (void) ha_find_files(thd, db_name->str, path,
3225 lookup_field_vals->table_value.str, 0,
3236 return (schema_tables_add(thd, table_names,
3237 lookup_field_vals->table_value.str));
3239 find_files_result res= find_files(thd, table_names, db_name->str, path,
3240 lookup_field_vals->table_value.str, 0);
3241 if (res != FIND_FILES_OK)
3249 if (res == FIND_FILES_DIR)
3284 fill_schema_table_by_open(THD *thd,
bool is_show_fields_or_keys,
3288 Open_tables_backup *open_tables_state_backup,
3291 Query_arena i_s_arena(thd->mem_root,
3292 Query_arena::STMT_CONVENTIONAL_EXECUTION),
3293 backup_arena, *old_arena;
3294 LEX *old_lex= thd->lex, temp_lex, *lex;
3299 DBUG_ENTER(
"fill_schema_table_by_open");
3313 old_arena= thd->stmt_arena;
3314 thd->stmt_arena= &i_s_arena;
3315 thd->set_n_backup_active_arena(&i_s_arena, &backup_arena);
3318 thd->lex= lex= &temp_lex;
3322 lex->context_analysis_only= CONTEXT_ANALYSIS_ONLY_VIEW;
3328 lex->wild= old_lex->wild;
3336 if (!thd->make_lex_string(&db_name, orig_db_name->str,
3337 orig_db_name->length, FALSE) ||
3338 !thd->make_lex_string(&table_name, orig_table_name->str,
3339 orig_table_name->length, FALSE))
3347 if (make_table_list(thd, &lex->select_lex, &db_name, &table_name))
3350 table_list= lex->select_lex.table_list.first;
3352 if (is_show_fields_or_keys)
3360 thd->temporary_tables= open_tables_state_backup->temporary_tables;
3369 table_list->i_s_requested_object= schema_table->i_s_requested_object;
3379 lex->sql_command= SQLCOM_SHOW_FIELDS;
3386 (MYSQL_OPEN_IGNORE_FLUSH |
3387 MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL |
3389 MYSQL_OPEN_FAIL_ON_MDL_CONFLICT : 0)));
3390 lex->select_lex.handle_derived(lex, &mysql_derived_create);
3396 lex->sql_command= old_lex->sql_command;
3398 DEBUG_SYNC(thd,
"after_open_table_ignore_flush");
3411 if (!is_show_fields_or_keys && result && thd->is_error() &&
3412 thd->get_stmt_da()->sql_errno() == ER_NO_SUCH_TABLE)
3424 result= schema_table->process_table(thd, table_list,
3432 lex->unit.cleanup();
3438 DBUG_ASSERT(i_s_arena.free_list == NULL);
3445 thd->temporary_tables= NULL;
3446 close_thread_tables(thd);
3451 thd->mdl_context.rollback_to_savepoint(open_tables_state_backup->mdl_system_tables_svp);
3455 thd->stmt_arena= old_arena;
3456 thd->restore_active_arena(&i_s_arena, &backup_arena);
3458 DBUG_RETURN(result);
3476 static int fill_schema_table_names(THD *thd,
TABLE *table,
3479 bool need_table_type)
3482 if (need_table_type)
3486 table->field[3]->store(STRING_WITH_LEN(
"SYSTEM VIEW"),
3487 system_charset_info);
3491 enum legacy_db_type not_used;
3492 char path[FN_REFLEN + 1];
3493 (void) build_table_filename(path,
sizeof(path) - 1, db_name->str,
3494 table_name->str, reg_ext, 0);
3495 switch (dd_frm_type(thd, path, ¬_used)) {
3497 table->field[3]->store(STRING_WITH_LEN(
"ERROR"),
3498 system_charset_info);
3501 table->field[3]->store(STRING_WITH_LEN(
"BASE TABLE"),
3502 system_charset_info);
3505 table->field[3]->store(STRING_WITH_LEN(
"VIEW"),
3506 system_charset_info);
3511 if (thd->is_error() && thd->get_stmt_da()->sql_errno() == ER_NO_SUCH_TABLE)
3518 if (schema_table_store_record(thd, table))
3540 uint get_table_open_method(
TABLE_LIST *tables,
3542 enum enum_schema_tables schema_table_idx)
3547 if (schema_table->i_s_requested_object & OPTIMIZE_I_S_TABLE)
3549 Field **ptr, *field;
3550 int table_open_method= 0, field_indx= 0;
3551 uint star_table_open_method= OPEN_FULL_TABLE;
3552 bool used_star=
true;
3553 for (ptr=tables->table->field; (field= *ptr) ; ptr++)
3555 star_table_open_method=
3556 min(star_table_open_method,
3557 schema_table->fields_info[field_indx].
open_method);
3558 if (bitmap_is_set(tables->table->read_set, field->field_index))
3561 table_open_method|= schema_table->fields_info[field_indx].
open_method;
3566 return star_table_open_method;
3567 return table_open_method;
3570 return (uint) OPEN_FULL_TABLE;
3598 try_acquire_high_prio_shared_mdl_lock(THD *thd,
TABLE_LIST *table,
3602 table->mdl_request.
init(MDL_key::TABLE, table->db, table->table_name,
3603 MDL_SHARED_HIGH_PRIO, MDL_TRANSACTION);
3619 error= thd->mdl_context.try_acquire_lock(&table->mdl_request);
3622 error= thd->mdl_context.acquire_lock(&table->mdl_request,
3623 thd->variables.lock_wait_timeout);
3653 static int fill_schema_table_from_frm(THD *thd,
TABLE_LIST *tables,
3657 enum enum_schema_tables schema_table_idx,
3658 Open_tables_backup *open_tables_state_backup,
3661 TABLE *table= tables->table;
3667 my_hash_value_type hash_value;
3670 char db_name_buff[NAME_LEN + 1], table_name_buff[NAME_LEN + 1];
3673 memset(&tbl, 0,
sizeof(
TABLE));
3675 if (lower_case_table_names)
3682 strmov(db_name_buff, db_name->str);
3683 strmov(table_name_buff, table_name->str);
3684 my_casedn_str(files_charset_info, db_name_buff);
3685 my_casedn_str(files_charset_info, table_name_buff);
3686 table_list.db= db_name_buff;
3687 table_list.table_name= table_name_buff;
3691 table_list.table_name= table_name->str;
3692 table_list.db= db_name->str;
3700 if (try_acquire_high_prio_shared_mdl_lock(thd, &table_list, can_deadlock))
3710 if (! table_list.mdl_request.
ticket)
3717 DBUG_ASSERT(can_deadlock);
3719 push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
3720 ER_WARN_I_S_SKIPPED_TABLE,
3721 ER(ER_WARN_I_S_SKIPPED_TABLE),
3722 table_list.db, table_list.table_name);
3726 if (schema_table->i_s_requested_object & OPEN_TRIGGER_ONLY)
3728 init_sql_alloc(&tbl.
mem_root, TABLE_ALLOC_BLOCK_SIZE, 0);
3730 table_name->str, &tbl, 1))
3732 table_list.table= &tbl;
3733 res= schema_table->process_table(thd, &table_list, table,
3734 res, db_name, table_name);
3735 delete tbl.triggers;
3742 hash_value= my_calc_hash(&table_def_cache, (uchar*) key, key_length);
3744 share= get_table_share(thd, &table_list, key,
3745 key_length, OPEN_VIEW, ¬_used, hash_value);
3754 if (schema_table->i_s_requested_object & OPEN_TABLE_ONLY)
3760 else if (schema_table->i_s_requested_object & OPEN_VIEW_FULL)
3773 if (mysql_make_view(thd, share, &table_list,
true))
3775 table_list.view= (LEX*) share->is_view;
3776 res= schema_table->process_table(thd, &table_list, table,
3777 res, db_name, table_name);
3781 if (!open_table_from_share(thd, share, table_name->str, 0,
3782 (EXTRA_RECORD | OPEN_FRM_FILE_ONLY),
3783 thd->open_options, &tbl, FALSE))
3786 table_list.table= &tbl;
3787 table_list.view= (LEX*) share->is_view;
3788 res= schema_table->process_table(thd, &table_list, table,
3789 res, db_name, table_name);
3791 my_free((
void *) tbl.alias);
3818 DBUG_ASSERT(thd->open_tables == NULL);
3819 thd->mdl_context.rollback_to_savepoint(open_tables_state_backup->mdl_system_tables_svp);
3846 bool handle_condition(THD *thd,
3848 const char* sqlstate,
3849 Sql_condition::enum_warning_level level,
3853 if (sql_errno == ER_PARSE_ERROR ||
3854 sql_errno == ER_TRG_NO_DEFINER ||
3855 sql_errno == ER_TRG_NO_CREATION_CTX)
3886 TABLE *table= tables->table;
3887 SELECT_LEX *lsel= tables->schema_select_lex;
3892 enum enum_schema_tables schema_table_idx;
3895 Item *partial_cond= 0;
3897 Open_tables_backup open_tables_state_backup;
3898 #ifndef NO_EMBEDDED_ACCESS_CHECKS
3899 Security_context *sctx= thd->security_ctx;
3901 uint table_open_method;
3903 DBUG_ENTER(
"get_all_tables");
3914 can_deadlock= thd->mdl_context.has_locks();
3922 thd->reset_n_backup_open_tables_state(&open_tables_state_backup);
3924 schema_table_idx= get_schema_table_idx(schema_table);
3925 tables->table_open_method= table_open_method=
3926 get_table_open_method(tables, schema_table, schema_table_idx);
3927 DBUG_PRINT(
"open_method", (
"%d", tables->table_open_method));
3933 if (lsel && lsel->table_list.first)
3937 db_name.str= lsel->table_list.first->db;
3938 db_name.length= lsel->table_list.first->db_length;
3940 table_name.str= lsel->table_list.first->table_name;
3941 table_name.length= lsel->table_list.first->table_name_length;
3943 error= fill_schema_table_by_open(thd, TRUE,
3944 table, schema_table,
3945 &db_name, &table_name,
3946 &open_tables_state_backup,
3951 if (get_lookup_field_values(thd, cond, tables, &lookup_field_vals))
3957 DBUG_PRINT(
"INDEX VALUES",(
"db_name='%s', table_name='%s'",
3958 STR_OR_NIL(lookup_field_vals.db_value.str),
3959 STR_OR_NIL(lookup_field_vals.table_value.str)));
3961 if (!lookup_field_vals.wild_db_value && !lookup_field_vals.wild_table_value)
3967 if ((lookup_field_vals.db_value.str &&
3968 !lookup_field_vals.db_value.str[0]) ||
3969 (lookup_field_vals.table_value.str &&
3970 !lookup_field_vals.table_value.str[0]))
3977 if (lookup_field_vals.db_value.length &&
3978 !lookup_field_vals.wild_db_value)
3979 tables->has_db_lookup_value= TRUE;
3980 if (lookup_field_vals.table_value.length &&
3981 !lookup_field_vals.wild_table_value)
3982 tables->has_table_lookup_value= TRUE;
3984 if (tables->has_db_lookup_value && tables->has_table_lookup_value)
3987 partial_cond= make_cond_for_info_schema(cond, tables);
3996 if (make_db_list(thd, &db_names, &lookup_field_vals, &with_i_schema))
3999 while ((db_name= it++))
4001 #ifndef NO_EMBEDDED_ACCESS_CHECKS
4003 &thd->col_access, NULL, 0, 1) ||
4004 (!thd->col_access && check_grant_db(thd, db_name->str))) ||
4005 sctx->master_access & (DB_ACLS | SHOW_DB_ACL) ||
4006 acl_get(sctx->get_host()->ptr(), sctx->get_ip()->ptr(),
4007 sctx->priv_user, db_name->str, 0))
4011 int res= make_table_name_list(thd, &table_names, lex,
4013 with_i_schema, db_name);
4020 while ((table_name= it_files++))
4022 restore_record(table, s->default_values);
4023 table->field[schema_table->idx_field1]->
4024 store(db_name->str, db_name->length, system_charset_info);
4025 table->field[schema_table->idx_field2]->
4026 store(table_name->str, table_name->length, system_charset_info);
4028 if (!partial_cond || partial_cond->val_int())
4036 if (!table_open_method && schema_table_idx == SCH_TABLES &&
4037 (!lookup_field_vals.table_value.length ||
4038 lookup_field_vals.wild_table_value))
4040 table->field[0]->store(STRING_WITH_LEN(
"def"), system_charset_info);
4041 if (schema_table_store_record(thd, table))
4047 if (schema_table_idx == SCH_TABLE_NAMES)
4049 if (fill_schema_table_names(thd, tables->table, db_name,
4050 table_name, with_i_schema,
4056 if (!(table_open_method & ~OPEN_FRM_ONLY) &&
4067 thd->push_internal_handler(&err_handler);
4069 int res= fill_schema_table_from_frm(thd, tables, schema_table,
4070 db_name, table_name,
4072 &open_tables_state_backup,
4075 thd->pop_internal_handler();
4081 DEBUG_SYNC(thd,
"before_open_in_get_all_tables");
4083 if (fill_schema_table_by_open(thd, FALSE,
4084 table, schema_table,
4085 db_name, table_name,
4086 &open_tables_state_backup,
4102 thd->restore_backup_open_tables_state(&open_tables_state_backup);
4108 bool store_schema_shemata(THD* thd,
TABLE *table,
LEX_STRING *db_name,
4111 restore_record(table, s->default_values);
4112 table->field[0]->store(STRING_WITH_LEN(
"def"), system_charset_info);
4113 table->field[1]->store(db_name->str, db_name->length, system_charset_info);
4114 table->field[2]->store(cs->csname, strlen(cs->csname), system_charset_info);
4115 table->field[3]->store(cs->name, strlen(cs->name), system_charset_info);
4116 return schema_table_store_record(thd, table);
4120 int fill_schema_schemata(THD *thd,
TABLE_LIST *tables,
Item *cond)
4132 TABLE *table= tables->table;
4133 #ifndef NO_EMBEDDED_ACCESS_CHECKS
4134 Security_context *sctx= thd->security_ctx;
4136 DBUG_ENTER(
"fill_schema_shemata");
4138 if (get_lookup_field_values(thd, cond, tables, &lookup_field_vals))
4140 DBUG_PRINT(
"INDEX VALUES",(
"db_name='%s', table_name='%s'",
4141 lookup_field_vals.db_value.str,
4142 lookup_field_vals.table_value.str));
4143 if (make_db_list(thd, &db_names, &lookup_field_vals,
4150 if(lookup_field_vals.db_value.str && !lookup_field_vals.wild_db_value &&
4153 char path[FN_REFLEN+16];
4156 if (!lookup_field_vals.db_value.str[0])
4158 path_len= build_table_filename(path,
sizeof(path) - 1,
4159 lookup_field_vals.db_value.str,
"",
"", 0);
4160 path[path_len-1]= 0;
4166 while ((db_name=it++))
4170 if (store_schema_shemata(thd, table, db_name,
4171 system_charset_info))
4176 #ifndef NO_EMBEDDED_ACCESS_CHECKS
4177 if (sctx->master_access & (DB_ACLS | SHOW_DB_ACL) ||
4178 acl_get(sctx->get_host()->ptr(), sctx->get_ip()->ptr(),
4179 sctx->priv_user, db_name->str, 0) ||
4180 !check_grant_db(thd, db_name->str))
4183 load_db_opt_by_name(thd, db_name->str, &create);
4184 if (store_schema_shemata(thd, table, db_name,
4185 create.default_table_charset))
4193 static int get_schema_tables_record(THD *thd,
TABLE_LIST *tables,
4194 TABLE *table,
bool res,
4198 const char *tmp_buff;
4202 DBUG_ENTER(
"get_schema_tables_record");
4204 restore_record(table, s->default_values);
4205 table->field[0]->store(STRING_WITH_LEN(
"def"), cs);
4206 table->field[1]->store(db_name->str, db_name->length, cs);
4207 table->field[2]->store(table_name->str, table_name->length, cs);
4213 table->field[3]->store(STRING_WITH_LEN(
"VIEW"), cs);
4214 else if (tables->schema_table)
4215 table->field[3]->store(STRING_WITH_LEN(
"SYSTEM VIEW"), cs);
4217 table->field[3]->store(STRING_WITH_LEN(
"BASE TABLE"), cs);
4224 table->field[3]->store(STRING_WITH_LEN(
"VIEW"), cs);
4225 table->field[20]->store(STRING_WITH_LEN(
"VIEW"), cs);
4229 char option_buff[350],*ptr;
4230 TABLE *show_table= tables->table;
4232 handler *file= show_table->file;
4234 #ifdef WITH_PARTITION_STORAGE_ENGINE
4235 bool is_partitioned= FALSE;
4238 if (share->tmp_table == SYSTEM_TMP_TABLE)
4239 table->field[3]->store(STRING_WITH_LEN(
"SYSTEM VIEW"), cs);
4240 else if (share->tmp_table)
4241 table->field[3]->store(STRING_WITH_LEN(
"LOCAL TEMPORARY"), cs);
4243 table->field[3]->store(STRING_WITH_LEN(
"BASE TABLE"), cs);
4245 for (
int i= 4; i < 20; i++)
4247 if (i == 7 || (i > 12 && i < 17) || i == 18)
4249 table->field[
i]->set_notnull();
4254 #ifdef WITH_PARTITION_STORAGE_ENGINE
4255 if (share->db_type() == partition_hton &&
4256 share->partition_info_str_len)
4258 tmp_db_type= share->default_part_db_type;
4259 is_partitioned= TRUE;
4263 tmp_buff= (
char *) ha_resolve_storage_engine_name(tmp_db_type);
4264 table->field[4]->store(tmp_buff, strlen(tmp_buff), cs);
4265 table->field[5]->store((longlong) share->frm_version, TRUE);
4269 if (share->min_rows)
4271 ptr=strmov(ptr,
" min_rows=");
4272 ptr=longlong10_to_str(share->min_rows,ptr,10);
4275 if (share->max_rows)
4277 ptr=strmov(ptr,
" max_rows=");
4278 ptr=longlong10_to_str(share->max_rows,ptr,10);
4281 if (share->avg_row_length)
4283 ptr=strmov(ptr,
" avg_row_length=");
4284 ptr=longlong10_to_str(share->avg_row_length,ptr,10);
4287 if (share->db_create_options & HA_OPTION_PACK_KEYS)
4288 ptr=strmov(ptr,
" pack_keys=1");
4290 if (share->db_create_options & HA_OPTION_NO_PACK_KEYS)
4291 ptr=strmov(ptr,
" pack_keys=0");
4293 if (share->db_create_options & HA_OPTION_STATS_PERSISTENT)
4294 ptr=strmov(ptr,
" stats_persistent=1");
4296 if (share->db_create_options & HA_OPTION_NO_STATS_PERSISTENT)
4297 ptr=strmov(ptr,
" stats_persistent=0");
4299 if (share->stats_auto_recalc == HA_STATS_AUTO_RECALC_ON)
4300 ptr=strmov(ptr,
" stats_auto_recalc=1");
4301 else if (share->stats_auto_recalc == HA_STATS_AUTO_RECALC_OFF)
4302 ptr=strmov(ptr,
" stats_auto_recalc=0");
4304 if (share->stats_sample_pages != 0)
4306 ptr= strmov(ptr,
" stats_sample_pages=");
4307 ptr= longlong10_to_str(share->stats_sample_pages, ptr, 10);
4311 if (share->db_create_options & HA_OPTION_CHECKSUM)
4312 ptr=strmov(ptr,
" checksum=1");
4314 if (share->db_create_options & HA_OPTION_DELAY_KEY_WRITE)
4315 ptr=strmov(ptr,
" delay_key_write=1");
4317 if (share->row_type != ROW_TYPE_DEFAULT)
4318 ptr=strxmov(ptr,
" row_format=",
4319 ha_row_type[(uint) share->row_type],
4322 if (share->key_block_size)
4324 ptr= strmov(ptr,
" KEY_BLOCK_SIZE=");
4325 ptr= longlong10_to_str(share->key_block_size, ptr, 10);
4328 #ifdef WITH_PARTITION_STORAGE_ENGINE
4330 ptr= strmov(ptr,
" partitioned");
4333 table->field[19]->store(option_buff+1,
4334 (ptr == option_buff ? 0 :
4335 (uint) (ptr-option_buff)-1), cs);
4337 tmp_buff= (share->table_charset ?
4338 share->table_charset->name :
"default");
4340 table->field[17]->store(tmp_buff, strlen(tmp_buff), cs);
4342 if (share->comment.str)
4343 table->field[20]->store(share->comment.str, share->comment.length, cs);
4350 if ((info_error= file->info(HA_STATUS_VARIABLE |
4352 HA_STATUS_VARIABLE_EXTRA |
4353 HA_STATUS_AUTO)) != 0)
4358 case ROW_TYPE_NOT_USED:
4359 case ROW_TYPE_DEFAULT:
4360 tmp_buff= ((share->db_options_in_use &
4361 HA_OPTION_COMPRESS_RECORD) ?
"Compressed" :
4362 (share->db_options_in_use & HA_OPTION_PACK_RECORD) ?
4363 "Dynamic" :
"Fixed");
4365 case ROW_TYPE_FIXED:
4368 case ROW_TYPE_DYNAMIC:
4369 tmp_buff=
"Dynamic";
4371 case ROW_TYPE_COMPRESSED:
4372 tmp_buff=
"Compressed";
4374 case ROW_TYPE_REDUNDANT:
4375 tmp_buff=
"Redundant";
4377 case ROW_TYPE_COMPACT:
4378 tmp_buff=
"Compact";
4385 table->field[6]->store(tmp_buff, strlen(tmp_buff), cs);
4387 if (!tables->schema_table)
4389 table->field[7]->store((longlong) file->stats.records, TRUE);
4390 table->field[7]->set_notnull();
4392 table->field[8]->store((longlong) file->stats.mean_rec_length, TRUE);
4393 table->field[9]->store((longlong) file->stats.data_file_length, TRUE);
4394 if (file->stats.max_data_file_length)
4396 table->field[10]->store((longlong) file->stats.max_data_file_length,
4399 table->field[11]->store((longlong) file->stats.index_file_length, TRUE);
4400 table->field[12]->store((longlong) file->stats.delete_length, TRUE);
4401 if (show_table->found_next_number_field)
4403 table->field[13]->store((longlong) file->stats.auto_increment_value,
4405 table->field[13]->set_notnull();
4407 if (file->stats.create_time)
4409 thd->variables.time_zone->gmt_sec_to_TIME(&time,
4410 (my_time_t) file->stats.create_time);
4412 table->field[14]->set_notnull();
4414 if (file->stats.update_time)
4416 thd->variables.time_zone->gmt_sec_to_TIME(&time,
4417 (my_time_t) file->stats.update_time);
4419 table->field[15]->set_notnull();
4421 if (file->stats.check_time)
4423 thd->variables.time_zone->gmt_sec_to_TIME(&time,
4424 (my_time_t) file->stats.check_time);
4426 table->field[16]->set_notnull();
4430 table->field[18]->store((longlong) file->checksum(), TRUE);
4431 table->field[18]->set_notnull();
4437 if (res || info_error)
4444 const char *error= thd->is_error() ? thd->get_stmt_da()->message() :
"";
4445 table->field[20]->store(error, strlen(error), cs);
4447 if (thd->is_error())
4449 push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
4450 thd->get_stmt_da()->sql_errno(), thd->get_stmt_da()->message());
4455 DBUG_RETURN(schema_table_store_record(thd, table));
4476 int decimals, field_length;
4477 const char *tmp_buff;
4478 char column_type_buff[MAX_FIELD_WIDTH];
4479 String column_type(column_type_buff,
sizeof(column_type_buff), cs);
4481 field->sql_type(column_type);
4483 table->field[offset + 8]->store(column_type.ptr(), column_type.length(), cs);
4484 table->field[offset + 8]->set_notnull();
4491 tmp_buff= strchr(column_type.ptr(),
'(');
4497 tmp_buff= strchr(column_type.ptr(),
' ');
4498 table->field[
offset]->store(column_type.ptr(),
4499 (tmp_buff ? tmp_buff - column_type.ptr() :
4500 column_type.length()), cs);
4502 is_blob= (field->type() == MYSQL_TYPE_BLOB);
4503 if (field->has_charset() || is_blob ||
4504 field->real_type() == MYSQL_TYPE_VARCHAR ||
4505 field->real_type() == MYSQL_TYPE_STRING)
4507 uint32 octet_max_length= field->max_display_length();
4508 if (is_blob && octet_max_length != (uint32) 4294967295
U)
4509 octet_max_length /= field->charset()->mbmaxlen;
4510 longlong char_max_len= is_blob ?
4511 (longlong) octet_max_length / field->charset()->mbminlen :
4512 (longlong) octet_max_length / field->charset()->mbmaxlen;
4514 table->field[offset + 1]->store(char_max_len, TRUE);
4515 table->field[offset + 1]->set_notnull();
4517 table->field[offset + 2]->store((longlong) octet_max_length, TRUE);
4518 table->field[offset + 2]->set_notnull();
4526 decimals= field->decimals();
4527 switch (field->type()) {
4528 case MYSQL_TYPE_NEWDECIMAL:
4531 case MYSQL_TYPE_DECIMAL:
4532 field_length= field->field_length - (decimals ? 2 : 1);
4534 case MYSQL_TYPE_TINY:
4535 case MYSQL_TYPE_SHORT:
4536 case MYSQL_TYPE_LONG:
4537 case MYSQL_TYPE_INT24:
4538 field_length= field->max_display_length() - 1;
4540 case MYSQL_TYPE_LONGLONG:
4541 field_length= field->max_display_length() -
4542 ((field->flags & UNSIGNED_FLAG) ? 0 : 1);
4544 case MYSQL_TYPE_BIT:
4545 field_length= field->max_display_length();
4548 case MYSQL_TYPE_FLOAT:
4549 case MYSQL_TYPE_DOUBLE:
4550 field_length= field->field_length;
4551 if (decimals == NOT_FIXED_DEC)
4554 case MYSQL_TYPE_DATETIME:
4555 case MYSQL_TYPE_TIMESTAMP:
4556 case MYSQL_TYPE_TIME:
4558 table->field[offset + 5]->store(field->decimals(), TRUE);
4559 table->field[offset + 5]->set_notnull();
4560 field_length= decimals= -1;
4563 field_length= decimals= -1;
4568 if (field_length >= 0)
4570 table->field[offset + 3]->store((longlong) field_length, TRUE);
4571 table->field[offset + 3]->set_notnull();
4576 table->field[offset + 4]->store((longlong) decimals, TRUE);
4577 table->field[offset + 4]->set_notnull();
4579 if (field->has_charset())
4582 tmp_buff= field->charset()->csname;
4583 table->field[offset + 6]->store(tmp_buff, strlen(tmp_buff), cs);
4584 table->field[offset + 6]->set_notnull();
4586 tmp_buff= field->charset()->name;
4587 table->field[offset + 7]->store(tmp_buff, strlen(tmp_buff), cs);
4588 table->field[offset + 7]->set_notnull();
4593 static int get_schema_column_record(THD *thd,
TABLE_LIST *tables,
4594 TABLE *table,
bool res,
4599 const char *wild= lex->wild ? lex->wild->ptr() : NullS;
4602 Field **ptr, *field;
4604 DBUG_ENTER(
"get_schema_column_record");
4608 if (lex->sql_command != SQLCOM_SHOW_FIELDS)
4614 if (thd->is_error())
4615 push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
4616 thd->get_stmt_da()->sql_errno(), thd->get_stmt_da()->message());
4623 show_table= tables->table;
4625 ptr= show_table->field;
4626 show_table->use_all_columns();
4627 restore_record(show_table, s->default_values);
4629 for (; (field= *ptr) ; ptr++)
4632 char tmp[MAX_FIELD_WIDTH];
4633 String type(tmp,
sizeof(tmp), system_charset_info);
4635 DEBUG_SYNC(thd,
"get_schema_column");
4637 if (wild && wild[0] &&
4638 wild_case_compare(system_charset_info, field->field_name,wild))
4643 restore_record(table, s->default_values);
4645 #ifndef NO_EMBEDDED_ACCESS_CHECKS
4648 &tables->grant.
privilege, 0, 0,
test(tables->schema_table));
4649 col_access= get_column_grant(thd, &tables->grant,
4650 db_name->str, table_name->str,
4651 field->field_name) & COL_ACLS;
4652 if (!tables->schema_table && !col_access)
4655 for (uint bitnr=0; col_access ; col_access>>=1,bitnr++)
4660 end=strmov(end,grant_types.type_names[bitnr]);
4663 table->field[IS_COLUMNS_PRIVILEGES]->store(tmp+1,
4665 (uint) (end-tmp-1), cs);
4668 table->field[IS_COLUMNS_TABLE_CATALOG]->store(STRING_WITH_LEN(
"def"), cs);
4669 table->field[IS_COLUMNS_TABLE_SCHEMA]->store(db_name->str,
4670 db_name->length, cs);
4671 table->field[IS_COLUMNS_TABLE_NAME]->store(table_name->str,
4672 table_name->length, cs);
4673 table->field[IS_COLUMNS_COLUMN_NAME]->store(field->field_name,
4674 strlen(field->field_name), cs);
4675 table->field[IS_COLUMNS_ORDINAL_POSITION]->store((longlong) count, TRUE);
4676 field->sql_type(
type);
4677 table->field[IS_COLUMNS_COLUMN_TYPE]->store(
type.ptr(),
type.length(), cs);
4679 if (print_default_clause(thd, field, &
type,
false))
4681 table->field[IS_COLUMNS_COLUMN_DEFAULT]->store(
type.ptr(),
type.length(),
4683 table->field[IS_COLUMNS_COLUMN_DEFAULT]->set_notnull();
4685 pos=(uchar*) ((field->flags & NOT_NULL_FLAG) ?
"NO" :
"YES");
4686 table->field[IS_COLUMNS_IS_NULLABLE]->store((
const char*) pos,
4687 strlen((
const char*) pos), cs);
4688 store_column_type(table, field, cs, IS_COLUMNS_DATA_TYPE);
4689 pos=(uchar*) ((field->flags & PRI_KEY_FLAG) ?
"PRI" :
4690 (field->flags & UNIQUE_KEY_FLAG) ?
"UNI" :
4691 (field->flags & MULTIPLE_KEY_FLAG) ?
"MUL":
"");
4692 table->field[IS_COLUMNS_COLUMN_KEY]->store((
const char*) pos,
4693 strlen((
const char*) pos), cs);
4695 if (field->unireg_check == Field::NEXT_NUMBER)
4696 table->field[IS_COLUMNS_EXTRA]->store(STRING_WITH_LEN(
"auto_increment"),
4698 if (print_on_update_clause(field, &
type,
true))
4699 table->field[IS_COLUMNS_EXTRA]->store(
type.ptr(),
type.length(), cs);
4700 table->field[IS_COLUMNS_COLUMN_COMMENT]->store(field->comment.str,
4701 field->comment.length, cs);
4702 if (schema_table_store_record(thd, table))
4709 int fill_schema_charsets(THD *thd,
TABLE_LIST *tables,
Item *cond)
4712 const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
4713 TABLE *table= tables->table;
4716 for (cs= all_charsets ;
4717 cs < all_charsets + array_elements(all_charsets) ;
4721 if (tmp_cs && (tmp_cs->state & MY_CS_PRIMARY) &&
4722 (tmp_cs->state & MY_CS_AVAILABLE) &&
4723 !(tmp_cs->state & MY_CS_HIDDEN) &&
4724 !(wild && wild[0] &&
4725 wild_case_compare(scs, tmp_cs->csname,wild)))
4727 const char *comment;
4728 restore_record(table, s->default_values);
4729 table->field[0]->store(tmp_cs->csname, strlen(tmp_cs->csname), scs);
4730 table->field[1]->store(tmp_cs->name, strlen(tmp_cs->name), scs);
4731 comment= tmp_cs->comment ? tmp_cs->comment :
"";
4732 table->field[2]->store(comment, strlen(comment), scs);
4733 table->field[3]->store((longlong) tmp_cs->mbmaxlen, TRUE);
4734 if (schema_table_store_record(thd, table))
4742 static my_bool iter_schema_engines(THD *thd,
plugin_ref plugin,
4747 const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
4750 DBUG_ENTER(
"iter_schema_engines");
4754 if (plugin_state(plugin) != PLUGIN_IS_READY)
4758 if (!(wild && wild[0] &&
4759 wild_case_compare(scs, plug->name,wild)))
4761 restore_record(table, s->default_values);
4762 table->field[0]->store(plug->name, strlen(plug->name), scs);
4763 table->field[1]->store(C_STRING_WITH_LEN(
"NO"), scs);
4764 table->field[2]->store(plug->descr, strlen(plug->descr), scs);
4765 if (schema_table_store_record(thd, table))
4771 if (!(hton->flags & HTON_HIDDEN))
4774 if (!(wild && wild[0] &&
4775 wild_case_compare(scs, name->str,wild)))
4777 LEX_STRING yesno[2]= {{ C_STRING_WITH_LEN(
"NO") },
4778 { C_STRING_WITH_LEN(
"YES") }};
4780 const char *option_name= show_comp_option_name[(int) hton->state];
4781 restore_record(table, s->default_values);
4783 table->field[0]->store(name->str, name->length, scs);
4784 if (hton->state == SHOW_OPTION_YES && default_type == hton)
4785 option_name=
"DEFAULT";
4786 table->field[1]->store(option_name, strlen(option_name), scs);
4787 table->field[2]->store(plugin_decl(plugin)->
descr,
4788 strlen(plugin_decl(plugin)->
descr), scs);
4789 tmp= &yesno[
test(hton->commit)];
4790 table->field[3]->store(tmp->str, tmp->length, scs);
4791 table->field[3]->set_notnull();
4792 tmp= &yesno[
test(hton->prepare)];
4793 table->field[4]->store(tmp->str, tmp->length, scs);
4794 table->field[4]->set_notnull();
4795 tmp= &yesno[
test(hton->savepoint_set)];
4796 table->field[5]->store(tmp->str, tmp->length, scs);
4797 table->field[5]->set_notnull();
4799 if (schema_table_store_record(thd, table))
4806 int fill_schema_engines(THD *thd,
TABLE_LIST *tables,
Item *cond)
4808 DBUG_ENTER(
"fill_schema_engines");
4809 if (plugin_foreach_with_mask(thd, iter_schema_engines,
4810 MYSQL_STORAGE_ENGINE_PLUGIN,
4811 ~PLUGIN_IS_FREED, tables->table))
4817 int fill_schema_collation(THD *thd,
TABLE_LIST *tables,
Item *cond)
4820 const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
4821 TABLE *table= tables->table;
4823 for (cs= all_charsets ;
4824 cs < all_charsets + array_elements(all_charsets) ;
4829 if (!tmp_cs || !(tmp_cs->state & MY_CS_AVAILABLE) ||
4830 (tmp_cs->state & MY_CS_HIDDEN) ||
4831 !(tmp_cs->state & MY_CS_PRIMARY))
4833 for (cl= all_charsets;
4834 cl < all_charsets + array_elements(all_charsets) ;
4838 if (!tmp_cl || !(tmp_cl->state & MY_CS_AVAILABLE) ||
4839 !my_charset_same(tmp_cs, tmp_cl))
4841 if (!(wild && wild[0] &&
4842 wild_case_compare(scs, tmp_cl->name,wild)))
4844 const char *tmp_buff;
4845 restore_record(table, s->default_values);
4846 table->field[0]->store(tmp_cl->name, strlen(tmp_cl->name), scs);
4847 table->field[1]->store(tmp_cl->csname , strlen(tmp_cl->csname), scs);
4848 table->field[2]->store((longlong) tmp_cl->number, TRUE);
4849 tmp_buff= (tmp_cl->state & MY_CS_PRIMARY) ?
"Yes" :
"";
4850 table->field[3]->store(tmp_buff, strlen(tmp_buff), scs);
4851 tmp_buff= (tmp_cl->state & MY_CS_COMPILED)?
"Yes" :
"";
4852 table->field[4]->store(tmp_buff, strlen(tmp_buff), scs);
4853 table->field[5]->store((longlong) tmp_cl->strxfrm_multiply, TRUE);
4854 if (schema_table_store_record(thd, table))
4863 int fill_schema_coll_charset_app(THD *thd,
TABLE_LIST *tables,
Item *cond)
4866 TABLE *table= tables->table;
4868 for (cs= all_charsets ;
4869 cs < all_charsets + array_elements(all_charsets) ;
4874 if (!tmp_cs || !(tmp_cs->state & MY_CS_AVAILABLE) ||
4875 !(tmp_cs->state & MY_CS_PRIMARY))
4877 for (cl= all_charsets;
4878 cl < all_charsets + array_elements(all_charsets) ;
4882 if (!tmp_cl || !(tmp_cl->state & MY_CS_AVAILABLE) ||
4883 (tmp_cl->state & MY_CS_HIDDEN) ||
4884 !my_charset_same(tmp_cs,tmp_cl))
4886 restore_record(table, s->default_values);
4887 table->field[0]->store(tmp_cl->name, strlen(tmp_cl->name), scs);
4888 table->field[1]->store(tmp_cl->csname , strlen(tmp_cl->csname), scs);
4889 if (schema_table_store_record(thd, table))
4897 static inline void copy_field_as_string(
Field *to_field,
Field *from_field)
4899 char buff[MAX_FIELD_WIDTH];
4900 String tmp_str(buff,
sizeof(buff), system_charset_info);
4901 from_field->val_str(&tmp_str);
4902 to_field->store(tmp_str.ptr(), tmp_str.length(), system_charset_info);
4923 bool store_schema_params(THD *thd,
TABLE *table,
TABLE *proc_table,
4924 const char *wild,
bool full_access,
4925 const char *sp_user)
4930 char params_buff[MAX_FIELD_WIDTH], returns_buff[MAX_FIELD_WIDTH],
4931 sp_db_buff[NAME_LEN], sp_name_buff[NAME_LEN], path[FN_REFLEN],
4932 definer_buff[USERNAME_LENGTH + HOSTNAME_LENGTH + 1];
4933 String params(params_buff,
sizeof(params_buff), cs);
4934 String returns(returns_buff,
sizeof(returns_buff), cs);
4935 String sp_db(sp_db_buff,
sizeof(sp_db_buff), cs);
4937 String definer(definer_buff,
sizeof(definer_buff), cs);
4939 enum_sp_type routine_type;
4941 DBUG_ENTER(
"store_schema_params");
4943 memset(&tbl, 0,
sizeof(
TABLE));
4944 (void) build_table_filename(path,
sizeof(path),
"",
"",
"", 0);
4945 init_tmp_table_share(thd, &share,
"", 0,
"", path);
4947 get_field(thd->mem_root, proc_table->field[MYSQL_PROC_FIELD_DB], &sp_db);
4948 get_field(thd->mem_root, proc_table->field[MYSQL_PROC_FIELD_NAME], &
sp_name);
4949 get_field(thd->mem_root,proc_table->field[MYSQL_PROC_FIELD_DEFINER],&definer);
4950 routine_type= (enum_sp_type) proc_table->field[MYSQL_PROC_MYSQL_TYPE]->val_int();
4953 full_access= !strcmp(sp_user, definer.ptr());
4956 routine_type == SP_TYPE_PROCEDURE))
4960 get_field(thd->mem_root, proc_table->field[MYSQL_PROC_FIELD_PARAM_LIST],
4963 if (routine_type == SP_TYPE_FUNCTION)
4964 get_field(thd->mem_root, proc_table->field[MYSQL_PROC_FIELD_RETURNS],
4967 sp= sp_load_for_information_schema(thd, proc_table, &sp_db, &
sp_name,
4968 (sql_mode_t) proc_table->
4969 field[MYSQL_PROC_FIELD_SQL_MODE]->val_int(),
4971 returns.c_ptr_safe(),
4972 params.c_ptr_safe(),
4980 if (routine_type == SP_TYPE_FUNCTION)
4982 restore_record(table, s->default_values);
4983 table->field[IS_PARAMETERS_SPECIFIC_CATALOG]->store(STRING_WITH_LEN
4985 table->field[IS_PARAMETERS_SPECIFIC_SCHEMA]->store(sp_db.ptr(),
4986 sp_db.length(), cs);
4987 table->field[IS_PARAMETERS_SPECIFIC_NAME]->store(
sp_name.ptr(),
4989 table->field[IS_PARAMETERS_ORDINAL_POSITION]->store((longlong) 0, TRUE);
4990 get_field(thd->mem_root, proc_table->field[MYSQL_PROC_MYSQL_TYPE],
4992 table->field[IS_PARAMETERS_ROUTINE_TYPE]->store(tmp_string.ptr(),
4993 tmp_string.length(), cs);
4995 field= make_field(&share, (uchar*) 0, field_def->length,
4996 (uchar*)
"", 0, field_def->pack_flag,
4997 field_def->sql_type, field_def->charset,
4998 field_def->geom_type, Field::NONE,
4999 field_def->interval,
"");
5003 store_column_type(table, field, cs, IS_PARAMETERS_DATA_TYPE);
5004 if (schema_table_store_record(thd, table))
5006 free_table_share(&share);
5017 const char *tmp_buff;
5020 switch (spvar->
mode) {
5021 case sp_variable::MODE_IN:
5024 case sp_variable::MODE_OUT:
5027 case sp_variable::MODE_INOUT:
5035 restore_record(table, s->default_values);
5036 table->field[IS_PARAMETERS_SPECIFIC_CATALOG]->store(STRING_WITH_LEN
5038 table->field[IS_PARAMETERS_SPECIFIC_SCHEMA]->store(sp_db.ptr(),
5039 sp_db.length(), cs);
5040 table->field[IS_PARAMETERS_SPECIFIC_NAME]->store(
sp_name.ptr(),
5042 table->field[IS_PARAMETERS_ORDINAL_POSITION]->store((longlong) i + 1,
5044 table->field[IS_PARAMETERS_PARAMETER_MODE]->store(tmp_buff,
5045 strlen(tmp_buff), cs);
5046 table->field[IS_PARAMETERS_PARAMETER_MODE]->set_notnull();
5047 table->field[IS_PARAMETERS_PARAMETER_NAME]->store(spvar->
name.str,
5048 spvar->
name.length, cs);
5049 table->field[IS_PARAMETERS_PARAMETER_NAME]->set_notnull();
5050 get_field(thd->mem_root, proc_table->field[MYSQL_PROC_MYSQL_TYPE],
5052 table->field[IS_PARAMETERS_ROUTINE_TYPE]->store(tmp_string.ptr(),
5053 tmp_string.length(), cs);
5055 field= make_field(&share, (uchar*) 0, field_def->length,
5056 (uchar*)
"", 0, field_def->pack_flag,
5057 field_def->sql_type, field_def->charset,
5058 field_def->geom_type, Field::NONE,
5059 field_def->interval, spvar->
name.str);
5063 store_column_type(table, field, cs, IS_PARAMETERS_DATA_TYPE);
5064 if (schema_table_store_record(thd, table))
5066 free_table_share(&share);
5075 free_table_share(&share);
5080 bool store_schema_proc(THD *thd,
TABLE *table,
TABLE *proc_table,
5081 const char *wild,
bool full_access,
const char *sp_user)
5086 char sp_db_buff[NAME_LEN + 1], sp_name_buff[NAME_LEN + 1],
5087 definer_buff[USERNAME_LENGTH + HOSTNAME_LENGTH + 2],
5088 returns_buff[MAX_FIELD_WIDTH];
5090 String sp_db(sp_db_buff,
sizeof(sp_db_buff), cs);
5092 String definer(definer_buff,
sizeof(definer_buff), cs);
5093 String returns(returns_buff,
sizeof(returns_buff), cs);
5095 proc_table->field[MYSQL_PROC_FIELD_DB]->val_str(&sp_db);
5096 proc_table->field[MYSQL_PROC_FIELD_NAME]->val_str(&
sp_name);
5097 proc_table->field[MYSQL_PROC_FIELD_DEFINER]->val_str(&definer);
5099 enum_sp_type sp_type=
5100 (enum_sp_type) proc_table->field[MYSQL_PROC_MYSQL_TYPE]->val_int();
5103 full_access= !strcmp(sp_user, definer.c_ptr_safe());
5106 sp_type == SP_TYPE_PROCEDURE))
5109 if ((lex->sql_command == SQLCOM_SHOW_STATUS_PROC &&
5110 sp_type == SP_TYPE_PROCEDURE) ||
5111 (lex->sql_command == SQLCOM_SHOW_STATUS_FUNC &&
5112 sp_type == SP_TYPE_FUNCTION) ||
5115 restore_record(table, s->default_values);
5116 if (!wild || !wild[0] || !wild_case_compare(system_charset_info,
5119 int enum_idx= (int) proc_table->field[MYSQL_PROC_FIELD_ACCESS]->val_int();
5120 table->field[IS_ROUTINES_ROUTINE_NAME]->store(
sp_name.ptr(),
5123 copy_field_as_string(table->field[IS_ROUTINES_SPECIFIC_NAME],
5124 proc_table->field[MYSQL_PROC_FIELD_SPECIFIC_NAME]);
5125 table->field[IS_ROUTINES_ROUTINE_CATALOG]->store(STRING_WITH_LEN(
"def"),
5127 table->field[IS_ROUTINES_ROUTINE_SCHEMA]->store(sp_db.ptr(), sp_db.length(), cs);
5128 copy_field_as_string(table->field[IS_ROUTINES_ROUTINE_TYPE],
5129 proc_table->field[MYSQL_PROC_MYSQL_TYPE]);
5131 if (sp_type == SP_TYPE_FUNCTION)
5135 proc_table->field[MYSQL_PROC_FIELD_RETURNS]->val_str(&returns);
5136 sp= sp_load_for_information_schema(thd, proc_table, &sp_db, &
sp_name,
5137 (sql_mode_t) proc_table->
5138 field[MYSQL_PROC_FIELD_SQL_MODE]->
5141 returns.c_ptr_safe(),
5146 char path[FN_REFLEN];
5152 memset(&tbl, 0,
sizeof(
TABLE));
5153 (void) build_table_filename(path,
sizeof(path),
"",
"",
"", 0);
5154 init_tmp_table_share(thd, &share,
"", 0,
"", path);
5155 field= make_field(&share, (uchar*) 0, field_def->length,
5156 (uchar*)
"", 0, field_def->pack_flag,
5157 field_def->sql_type, field_def->charset,
5158 field_def->geom_type, Field::NONE,
5159 field_def->interval,
"");
5163 store_column_type(table, field, cs, IS_ROUTINES_DATA_TYPE);
5164 free_table_share(&share);
5172 copy_field_as_string(table->field[IS_ROUTINES_ROUTINE_DEFINITION],
5173 proc_table->field[MYSQL_PROC_FIELD_BODY_UTF8]);
5174 table->field[IS_ROUTINES_ROUTINE_DEFINITION]->set_notnull();
5176 table->field[IS_ROUTINES_ROUTINE_BODY]->store(STRING_WITH_LEN(
"SQL"), cs);
5177 table->field[IS_ROUTINES_PARAMETER_STYLE]->store(STRING_WITH_LEN(
"SQL"),
5179 copy_field_as_string(table->field[IS_ROUTINES_IS_DETERMINISTIC],
5180 proc_table->field[MYSQL_PROC_FIELD_DETERMINISTIC]);
5181 table->field[IS_ROUTINES_SQL_DATA_ACCESS]->
5182 store(sp_data_access_name[enum_idx].str,
5183 sp_data_access_name[enum_idx].length , cs);
5184 copy_field_as_string(table->field[IS_ROUTINES_SECURITY_TYPE],
5185 proc_table->field[MYSQL_PROC_FIELD_SECURITY_TYPE]);
5187 memset(&time, 0,
sizeof(time));
5188 proc_table->field[MYSQL_PROC_FIELD_CREATED]->get_time(&time);
5189 table->field[IS_ROUTINES_CREATED]->
store_time(&time);
5190 memset(&time, 0,
sizeof(time));
5191 proc_table->field[MYSQL_PROC_FIELD_MODIFIED]->get_time(&time);
5192 table->field[IS_ROUTINES_LAST_ALTERED]->
store_time(&time);
5193 copy_field_as_string(table->field[IS_ROUTINES_SQL_MODE],
5194 proc_table->field[MYSQL_PROC_FIELD_SQL_MODE]);
5195 copy_field_as_string(table->field[IS_ROUTINES_ROUTINE_COMMENT],
5196 proc_table->field[MYSQL_PROC_FIELD_COMMENT]);
5198 table->field[IS_ROUTINES_DEFINER]->store(definer.ptr(),
5199 definer.length(), cs);
5200 copy_field_as_string(table->field[IS_ROUTINES_CHARACTER_SET_CLIENT],
5202 field[MYSQL_PROC_FIELD_CHARACTER_SET_CLIENT]);
5203 copy_field_as_string(table->field[IS_ROUTINES_COLLATION_CONNECTION],
5205 field[MYSQL_PROC_FIELD_COLLATION_CONNECTION]);
5206 copy_field_as_string(table->field[IS_ROUTINES_DATABASE_COLLATION],
5207 proc_table->field[MYSQL_PROC_FIELD_DB_COLLATION]);
5209 return schema_table_store_record(thd, table);
5220 const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
5222 TABLE *table= tables->table;
5224 char definer[USER_HOST_BUFF_SIZE];
5225 Open_tables_backup open_tables_state_backup;
5226 enum enum_schema_tables schema_table_idx=
5227 get_schema_table_idx(tables->schema_table);
5228 DBUG_ENTER(
"fill_schema_proc");
5230 strxmov(definer, thd->security_ctx->priv_user,
"@",
5231 thd->security_ctx->priv_host, NullS);
5233 memset(&proc_tables, 0,
sizeof(proc_tables));
5234 proc_tables.db= (
char*)
"mysql";
5235 proc_tables.db_length= 5;
5236 proc_tables.table_name= proc_tables.alias= (
char*)
"proc";
5237 proc_tables.table_name_length= 4;
5238 proc_tables.lock_type= TL_READ;
5241 if (!(proc_table= open_proc_table_for_read(thd, &open_tables_state_backup)))
5251 if ((error= proc_table->file->
ha_index_first(proc_table->record[0])))
5253 res= (error == HA_ERR_END_OF_FILE) ? 0 : 1;
5259 if (schema_table_idx == SCH_PROCEDURES ?
5260 store_schema_proc(thd, table, proc_table, wild, full_access, definer) :
5261 store_schema_params(thd, table, proc_table, wild, full_access, definer))
5266 while (!proc_table->file->
ha_index_next(proc_table->record[0]))
5268 if (schema_table_idx == SCH_PROCEDURES ?
5269 store_schema_proc(thd, table, proc_table, wild, full_access, definer):
5270 store_schema_params(thd, table, proc_table, wild, full_access, definer))
5278 if (proc_table->file->inited)
5280 close_system_tables(thd, &open_tables_state_backup);
5285 static int get_schema_stat_record(THD *thd,
TABLE_LIST *tables,
5286 TABLE *table,
bool res,
5291 DBUG_ENTER(
"get_schema_stat_record");
5294 if (thd->lex->sql_command != SQLCOM_SHOW_KEYS)
5300 if (thd->is_error())
5301 push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
5302 thd->get_stmt_da()->sql_errno(), thd->get_stmt_da()->message());
5308 else if (!tables->view)
5310 TABLE *show_table= tables->table;
5311 KEY *key_info=show_table->s->key_info;
5312 if (show_table->file)
5313 show_table->file->info(HA_STATUS_VARIABLE |
5316 for (uint i=0 ; i < show_table->s->keys ; i++,key_info++)
5322 restore_record(table, s->default_values);
5323 table->field[0]->store(STRING_WITH_LEN(
"def"), cs);
5324 table->field[1]->store(db_name->str, db_name->length, cs);
5325 table->field[2]->store(table_name->str, table_name->length, cs);
5326 table->field[3]->store((longlong) ((key_info->
flags &
5327 HA_NOSAME) ? 0 : 1), TRUE);
5328 table->field[4]->store(db_name->str, db_name->length, cs);
5329 table->field[5]->store(key_info->
name, strlen(key_info->
name), cs);
5330 table->field[6]->store((longlong) (j+1), TRUE);
5331 str=(key_part->field ? key_part->field->field_name :
5333 table->field[7]->store(str, strlen(str), cs);
5334 if (show_table->file)
5336 if (show_table->file->index_flags(i, j, 0) & HA_READ_ORDER)
5338 table->field[8]->store(((key_part->key_part_flag &
5341 table->field[8]->set_notnull();
5343 KEY *key=show_table->key_info+
i;
5346 ha_rows records=(show_table->file->stats.records /
5348 table->field[9]->store((longlong) records, TRUE);
5349 table->field[9]->set_notnull();
5351 str= show_table->file->index_type(i);
5352 table->field[13]->store(str, strlen(str), cs);
5354 if (!(key_info->
flags & HA_FULLTEXT) &&
5357 show_table->s->field[key_part->fieldnr-1]->key_length()))
5359 table->field[10]->store((longlong) key_part->length /
5360 key_part->field->charset()->mbmaxlen, TRUE);
5361 table->field[10]->set_notnull();
5363 uint flags= key_part->field ? key_part->field->flags : 0;
5364 const char *pos=(
char*) ((flags & NOT_NULL_FLAG) ?
"" :
"YES");
5365 table->field[12]->store(pos, strlen(pos), cs);
5366 if (!show_table->s->keys_in_use.is_set(i))
5367 table->field[14]->store(STRING_WITH_LEN(
"disabled"), cs);
5369 table->field[14]->store(
"", 0, cs);
5370 table->field[14]->set_notnull();
5371 DBUG_ASSERT(
test(key_info->
flags & HA_USES_COMMENT) ==
5372 (key_info->comment.length > 0));
5373 if (key_info->
flags & HA_USES_COMMENT)
5374 table->field[15]->store(key_info->comment.str,
5375 key_info->comment.length, cs);
5376 if (schema_table_store_record(thd, table))
5385 static int get_schema_views_record(THD *thd,
TABLE_LIST *tables,
5386 TABLE *table,
bool res,
5391 char definer[USER_HOST_BUFF_SIZE];
5393 bool updatable_view;
5394 DBUG_ENTER(
"get_schema_views_record");
5398 Security_context *sctx= thd->security_ctx;
5399 if (!tables->allowed_show)
5401 if (!my_strcasecmp(system_charset_info, tables->definer.user.str,
5403 !my_strcasecmp(system_charset_info, tables->definer.host.str,
5405 tables->allowed_show= TRUE;
5406 #ifndef NO_EMBEDDED_ACCESS_CHECKS
5409 if ((thd->col_access & (SHOW_VIEW_ACL|SELECT_ACL)) ==
5410 (SHOW_VIEW_ACL|SELECT_ACL))
5411 tables->allowed_show= TRUE;
5416 memset(&table_list, 0,
sizeof(table_list));
5417 table_list.db= tables->db;
5418 table_list.table_name= tables->table_name;
5419 table_list.grant.
privilege= thd->col_access;
5420 view_access= get_table_grant(thd, &table_list);
5421 if ((view_access & (SHOW_VIEW_ACL|SELECT_ACL)) ==
5422 (SHOW_VIEW_ACL|SELECT_ACL))
5423 tables->allowed_show= TRUE;
5428 restore_record(table, s->default_values);
5429 table->field[0]->store(STRING_WITH_LEN(
"def"), cs);
5430 table->field[1]->store(db_name->str, db_name->length, cs);
5431 table->field[2]->store(table_name->str, table_name->length, cs);
5433 if (tables->allowed_show)
5435 table->field[3]->store(tables->view_body_utf8.str,
5436 tables->view_body_utf8.length,
5440 if (tables->with_check != VIEW_CHECK_NONE)
5442 if (tables->with_check == VIEW_CHECK_LOCAL)
5443 table->field[4]->store(STRING_WITH_LEN(
"LOCAL"), cs);
5445 table->field[4]->store(STRING_WITH_LEN(
"CASCADED"), cs);
5448 table->field[4]->store(STRING_WITH_LEN(
"NONE"), cs);
5461 table->pos_in_table_list->table_open_method & OPEN_FULL_TABLE)
5464 if (tables->
algorithm != VIEW_ALGORITHM_TMPTABLE)
5474 List<Item> *fields= &tables->view->select_lex.item_list;
5481 while ((item= it++))
5483 if ((field= item->field_for_view_update()) && field->field &&
5484 !field->field->table->pos_in_table_list->schema_table)
5490 if (updatable_view && !tables->view->can_be_merged())
5494 table->field[5]->store(STRING_WITH_LEN(
"YES"), cs);
5496 table->field[5]->store(STRING_WITH_LEN(
"NO"), cs);
5499 definer_len= (strxmov(definer, tables->definer.user.str,
"@",
5500 tables->definer.host.str, NullS) - definer);
5501 table->field[6]->store(definer, definer_len, cs);
5502 if (tables->view_suid)
5503 table->field[7]->store(STRING_WITH_LEN(
"DEFINER"), cs);
5505 table->field[7]->store(STRING_WITH_LEN(
"INVOKER"), cs);
5507 table->field[8]->store(tables->view_creation_ctx->get_client_cs()->csname,
5508 strlen(tables->view_creation_ctx->
5509 get_client_cs()->csname), cs);
5511 table->field[9]->store(tables->view_creation_ctx->
5512 get_connection_cl()->name,
5513 strlen(tables->view_creation_ctx->
5514 get_connection_cl()->name), cs);
5517 if (schema_table_store_record(thd, table))
5519 if (res && thd->is_error())
5520 push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
5521 thd->get_stmt_da()->sql_errno(), thd->get_stmt_da()->message());
5530 LEX_STRING *table_name,
const char *key_name,
5531 uint key_len,
const char *con_type, uint con_len)
5534 restore_record(table, s->default_values);
5535 table->field[0]->store(STRING_WITH_LEN(
"def"), cs);
5536 table->field[1]->store(db_name->str, db_name->length, cs);
5537 table->field[2]->store(key_name, key_len, cs);
5538 table->field[3]->store(db_name->str, db_name->length, cs);
5539 table->field[4]->store(table_name->str, table_name->length, cs);
5540 table->field[5]->store(con_type, con_len, cs);
5541 return schema_table_store_record(thd, table);
5545 static int get_schema_constraints_record(THD *thd,
TABLE_LIST *tables,
5546 TABLE *table,
bool res,
5550 DBUG_ENTER(
"get_schema_constraints_record");
5553 if (thd->is_error())
5554 push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
5555 thd->get_stmt_da()->sql_errno(), thd->get_stmt_da()->message());
5559 else if (!tables->view)
5562 TABLE *show_table= tables->table;
5563 KEY *key_info=show_table->key_info;
5564 uint primary_key= show_table->s->primary_key;
5565 for (uint i=0 ; i < show_table->s->keys ; i++, key_info++)
5567 if (i != primary_key && !(key_info->
flags & HA_NOSAME))
5570 if (i == primary_key && !strcmp(key_info->
name, primary_key_name))
5572 if (store_constraints(thd, table, db_name, table_name, key_info->
name,
5573 strlen(key_info->
name),
5574 STRING_WITH_LEN(
"PRIMARY KEY")))
5577 else if (key_info->
flags & HA_NOSAME)
5579 if (store_constraints(thd, table, db_name, table_name, key_info->
name,
5580 strlen(key_info->
name),
5581 STRING_WITH_LEN(
"UNIQUE")))
5589 while ((f_key_info=it++))
5591 if (store_constraints(thd, table, db_name, table_name,
5592 f_key_info->foreign_id->str,
5593 strlen(f_key_info->foreign_id->str),
5602 static bool store_trigger(THD *thd,
TABLE *table,
LEX_STRING *db_name,
5604 enum trg_event_type
event,
5605 enum trg_action_time_type timing,
5607 sql_mode_t sql_mode,
5616 restore_record(table, s->default_values);
5617 table->field[0]->store(STRING_WITH_LEN(
"def"), cs);
5618 table->field[1]->store(db_name->str, db_name->length, cs);
5619 table->field[2]->store(trigger_name->str, trigger_name->length, cs);
5620 table->field[3]->store(trg_event_type_names[event].str,
5621 trg_event_type_names[event].length, cs);
5622 table->field[4]->store(STRING_WITH_LEN(
"def"), cs);
5623 table->field[5]->store(db_name->str, db_name->length, cs);
5624 table->field[6]->store(table_name->str, table_name->length, cs);
5625 table->field[9]->store(trigger_stmt->str, trigger_stmt->length, cs);
5626 table->field[10]->store(STRING_WITH_LEN(
"ROW"), cs);
5627 table->field[11]->store(trg_action_time_type_names[timing].str,
5628 trg_action_time_type_names[timing].length, cs);
5629 table->field[14]->store(STRING_WITH_LEN(
"OLD"), cs);
5630 table->field[15]->store(STRING_WITH_LEN(
"NEW"), cs);
5632 sql_mode_string_representation(thd, sql_mode, &sql_mode_rep);
5633 table->field[17]->store(sql_mode_rep.str, sql_mode_rep.length, cs);
5634 table->field[18]->store(definer_buffer->str, definer_buffer->length, cs);
5635 table->field[19]->store(client_cs_name->str, client_cs_name->length, cs);
5636 table->field[20]->store(connection_cl_name->str,
5637 connection_cl_name->length, cs);
5638 table->field[21]->store(db_cl_name->str, db_cl_name->length, cs);
5640 return schema_table_store_record(thd, table);
5644 static int get_schema_triggers_record(THD *thd,
TABLE_LIST *tables,
5645 TABLE *table,
bool res,
5649 DBUG_ENTER(
"get_schema_triggers_record");
5656 if (thd->is_error())
5657 push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
5658 thd->get_stmt_da()->sql_errno(), thd->get_stmt_da()->message());
5662 if (!tables->view && tables->table->triggers)
5670 for (event= 0;
event < (int)TRG_EVENT_MAX;
event++)
5672 for (timing= 0; timing < (int)TRG_ACTION_MAX; timing++)
5676 sql_mode_t sql_mode;
5677 char definer_holder[USER_HOST_BUFF_SIZE];
5683 definer_buffer.str= definer_holder;
5685 (
enum trg_action_time_type)timing,
5686 &trigger_name, &trigger_stmt,
5690 &connection_cl_name,
5694 if (store_trigger(thd, table, db_name, table_name, &trigger_name,
5695 (
enum trg_event_type) event,
5696 (
enum trg_action_time_type) timing, &trigger_stmt,
5700 &connection_cl_name,
5712 LEX_STRING *table_name,
const char *key_name,
5713 uint key_len,
const char *con_type, uint con_len,
5717 table->field[0]->store(STRING_WITH_LEN(
"def"), cs);
5718 table->field[1]->store(db_name->str, db_name->length, cs);
5719 table->field[2]->store(key_name, key_len, cs);
5720 table->field[3]->store(STRING_WITH_LEN(
"def"), cs);
5721 table->field[4]->store(db_name->str, db_name->length, cs);
5722 table->field[5]->store(table_name->str, table_name->length, cs);
5723 table->field[6]->store(con_type, con_len, cs);
5724 table->field[7]->store((longlong) idx, TRUE);
5728 static int get_schema_key_column_usage_record(THD *thd,
5730 TABLE *table,
bool res,
5734 DBUG_ENTER(
"get_schema_key_column_usage_record");
5737 if (thd->is_error())
5738 push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
5739 thd->get_stmt_da()->sql_errno(), thd->get_stmt_da()->message());
5743 else if (!tables->view)
5746 TABLE *show_table= tables->table;
5747 KEY *key_info=show_table->key_info;
5748 uint primary_key= show_table->s->primary_key;
5749 for (uint i=0 ; i < show_table->s->keys ; i++, key_info++)
5751 if (i != primary_key && !(key_info->
flags & HA_NOSAME))
5757 if (key_part->field)
5760 restore_record(table, s->default_values);
5761 store_key_column_usage(table, db_name, table_name,
5763 strlen(key_info->
name),
5764 key_part->field->field_name,
5765 strlen(key_part->field->field_name),
5767 if (schema_table_store_record(thd, table))
5776 while ((f_key_info= fkey_it++))
5781 it1(f_key_info->referenced_fields);
5783 while ((f_info= it++))
5787 restore_record(table, s->default_values);
5788 store_key_column_usage(table, db_name, table_name,
5789 f_key_info->foreign_id->str,
5790 f_key_info->foreign_id->length,
5791 f_info->str, f_info->length,
5793 table->field[8]->store((longlong) f_idx, TRUE);
5794 table->field[8]->set_notnull();
5795 table->field[9]->store(f_key_info->referenced_db->str,
5796 f_key_info->referenced_db->length,
5797 system_charset_info);
5798 table->field[9]->set_notnull();
5799 table->field[10]->store(f_key_info->referenced_table->str,
5800 f_key_info->referenced_table->length,
5801 system_charset_info);
5802 table->field[10]->set_notnull();
5803 table->field[11]->store(r_info->str, r_info->length,
5804 system_charset_info);
5805 table->field[11]->set_notnull();
5806 if (schema_table_store_record(thd, table))
5815 #ifdef WITH_PARTITION_STORAGE_ENGINE
5816 static void collect_partition_expr(THD *thd,
List<char> &field_list,
5820 ulong no_fields= field_list.elements;
5823 while ((field_str= part_it++))
5825 append_identifier(thd, str, field_str, strlen(field_str));
5826 if (--no_fields != 0)
5857 int get_cs_converted_part_value_from_string(THD *thd,
5864 if (item->result_type() == INT_RESULT)
5866 longlong value= item->val_int();
5867 output_str->set(value, system_charset_info);
5872 my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0));
5875 get_cs_converted_string_value(thd,
5885 static void store_schema_partitions_record(THD *thd,
TABLE *schema_table,
5886 TABLE *showing_table,
5890 TABLE* table= schema_table;
5894 file->get_dynamic_partition_info(&stat_info, part_id);
5895 table->field[0]->store(STRING_WITH_LEN(
"def"), cs);
5896 table->field[12]->store((longlong) stat_info.records, TRUE);
5897 table->field[13]->store((longlong) stat_info.mean_rec_length, TRUE);
5898 table->field[14]->store((longlong) stat_info.data_file_length, TRUE);
5899 if (stat_info.max_data_file_length)
5901 table->field[15]->store((longlong) stat_info.max_data_file_length, TRUE);
5902 table->field[15]->set_notnull();
5904 table->field[16]->store((longlong) stat_info.index_file_length, TRUE);
5905 table->field[17]->store((longlong) stat_info.delete_length, TRUE);
5906 if (stat_info.create_time)
5908 thd->variables.time_zone->gmt_sec_to_TIME(&time,
5909 (my_time_t)stat_info.create_time);
5911 table->field[18]->set_notnull();
5913 if (stat_info.update_time)
5915 thd->variables.time_zone->gmt_sec_to_TIME(&time,
5916 (my_time_t)stat_info.update_time);
5918 table->field[19]->set_notnull();
5920 if (stat_info.check_time)
5922 thd->variables.time_zone->gmt_sec_to_TIME(&time,
5923 (my_time_t)stat_info.check_time);
5925 table->field[20]->set_notnull();
5929 table->field[21]->store((longlong) stat_info.check_sum, TRUE);
5930 table->field[21]->set_notnull();
5934 if (part_elem->part_comment)
5935 table->field[22]->store(part_elem->part_comment,
5936 strlen(part_elem->part_comment), cs);
5938 table->field[22]->store(STRING_WITH_LEN(
""), cs);
5939 if (part_elem->nodegroup_id != UNDEF_NODEGROUP)
5940 table->field[23]->store((longlong) part_elem->nodegroup_id, TRUE);
5942 table->field[23]->store(STRING_WITH_LEN(
"default"), cs);
5944 table->field[24]->set_notnull();
5945 if (part_elem->tablespace_name)
5946 table->field[24]->store(part_elem->tablespace_name,
5947 strlen(part_elem->tablespace_name), cs);
5950 char *ts= showing_table->s->tablespace;
5952 table->field[24]->store(ts, strlen(ts), cs);
5954 table->field[24]->set_null();
5960 #ifdef WITH_PARTITION_STORAGE_ENGINE
5962 get_partition_column_description(THD *thd,
5967 uint num_elements= part_info->part_field_list.elements;
5969 DBUG_ENTER(
"get_partition_column_description");
5971 for (i= 0; i < num_elements; i++)
5974 if (col_val->max_value)
5975 tmp_str.append(partition_keywords[PKW_MAXVALUE].str);
5976 else if (col_val->null_value)
5977 tmp_str.append(
"NULL");
5980 char buffer[MAX_KEY_LENGTH];
5981 String str(buffer,
sizeof(buffer), &my_charset_bin);
5983 Item *item= col_val->item_expression;
5985 if (!(item= part_info->get_column_item(item,
5986 part_info->part_field_array[i])))
5990 String *res= item->val_str(&str);
5991 if (get_cs_converted_part_value_from_string(thd, item, res, &val_conv,
5992 part_info->part_field_array[i]->charset(),
5997 tmp_str.append(val_conv);
5999 if (i != num_elements - 1)
6000 tmp_str.append(
",");
6006 static int get_schema_partitions_record(THD *thd,
TABLE_LIST *tables,
6007 TABLE *table,
bool res,
6013 String tmp_res(buff,
sizeof(buff), cs);
6015 TABLE *show_table= tables->table;
6017 #ifdef WITH_PARTITION_STORAGE_ENGINE
6020 DBUG_ENTER(
"get_schema_partitions_record");
6024 if (thd->is_error())
6025 push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
6026 thd->get_stmt_da()->sql_errno(), thd->get_stmt_da()->message());
6030 file= show_table->file;
6031 #ifdef WITH_PARTITION_STORAGE_ENGINE
6032 part_info= show_table->part_info;
6037 uint part_pos= 0, part_id= 0;
6039 restore_record(table, s->default_values);
6040 table->field[0]->store(STRING_WITH_LEN(
"def"), cs);
6041 table->field[1]->store(db_name->str, db_name->length, cs);
6042 table->field[2]->store(table_name->str, table_name->length, cs);
6046 switch (part_info->part_type) {
6047 case RANGE_PARTITION:
6048 case LIST_PARTITION:
6050 if (part_info->part_type == RANGE_PARTITION)
6051 tmp_res.append(partition_keywords[PKW_RANGE].str,
6052 partition_keywords[PKW_RANGE].length);
6054 tmp_res.append(partition_keywords[PKW_LIST].str,
6055 partition_keywords[PKW_LIST].length);
6056 if (part_info->column_list)
6057 tmp_res.append(partition_keywords[PKW_COLUMNS].str,
6058 partition_keywords[PKW_COLUMNS].length);
6059 table->field[7]->store(tmp_res.ptr(), tmp_res.length(), cs);
6061 case HASH_PARTITION:
6063 if (part_info->linear_hash_ind)
6064 tmp_res.append(partition_keywords[PKW_LINEAR].str,
6065 partition_keywords[PKW_LINEAR].length);
6066 if (part_info->list_of_part_fields)
6067 tmp_res.append(partition_keywords[PKW_KEY].str,
6068 partition_keywords[PKW_KEY].length);
6070 tmp_res.append(partition_keywords[PKW_HASH].str,
6071 partition_keywords[PKW_HASH].length);
6072 table->field[7]->store(tmp_res.ptr(), tmp_res.length(), cs);
6076 my_error(ER_OUT_OF_RESOURCES, MYF(ME_FATALERROR));
6079 table->field[7]->set_notnull();
6082 if (part_info->part_expr)
6084 table->field[9]->store(part_info->part_func_string,
6085 part_info->part_func_len, cs);
6087 else if (part_info->list_of_part_fields)
6089 collect_partition_expr(thd, part_info->part_field_list, &tmp_str);
6090 table->field[9]->store(tmp_str.ptr(), tmp_str.length(), cs);
6092 table->field[9]->set_notnull();
6094 if (part_info->is_sub_partitioned())
6098 if (part_info->linear_hash_ind)
6099 tmp_res.append(partition_keywords[PKW_LINEAR].str,
6100 partition_keywords[PKW_LINEAR].length);
6101 if (part_info->list_of_subpart_fields)
6102 tmp_res.append(partition_keywords[PKW_KEY].str,
6103 partition_keywords[PKW_KEY].length);
6105 tmp_res.append(partition_keywords[PKW_HASH].str,
6106 partition_keywords[PKW_HASH].length);
6107 table->field[8]->store(tmp_res.ptr(), tmp_res.length(), cs);
6108 table->field[8]->set_notnull();
6111 if (part_info->subpart_expr)
6113 table->field[10]->store(part_info->subpart_func_string,
6114 part_info->subpart_func_len, cs);
6116 else if (part_info->list_of_subpart_fields)
6118 collect_partition_expr(thd, part_info->subpart_field_list, &tmp_str);
6119 table->field[10]->store(tmp_str.ptr(), tmp_str.length(), cs);
6121 table->field[10]->set_notnull();
6124 while ((part_elem= part_it++))
6126 table->field[3]->store(part_elem->partition_name,
6127 strlen(part_elem->partition_name), cs);
6128 table->field[3]->set_notnull();
6130 table->field[5]->store((longlong) ++part_pos, TRUE);
6131 table->field[5]->set_notnull();
6134 if (part_info->part_type == RANGE_PARTITION)
6136 if (part_info->column_list)
6141 if (get_partition_column_description(thd,
6148 table->field[11]->store(tmp_str.ptr(), tmp_str.length(), cs);
6152 if (part_elem->range_value != LONGLONG_MAX)
6153 table->field[11]->store((longlong) part_elem->range_value, FALSE);
6155 table->field[11]->store(partition_keywords[PKW_MAXVALUE].str,
6156 partition_keywords[PKW_MAXVALUE].length, cs);
6158 table->field[11]->set_notnull();
6160 else if (part_info->part_type == LIST_PARTITION)
6164 uint num_items= part_elem->list_val_list.elements;
6167 if (part_elem->has_null_value)
6169 tmp_str.append(
"NULL");
6171 tmp_str.append(
",");
6173 while ((list_value= list_val_it++))
6175 if (part_info->column_list)
6177 if (part_info->part_field_list.elements > 1U)
6178 tmp_str.append(
"(");
6179 if (get_partition_column_description(thd,
6186 if (part_info->part_field_list.elements > 1U)
6187 tmp_str.append(
")");
6191 if (!list_value->unsigned_flag)
6192 tmp_res.set(list_value->value, cs);
6194 tmp_res.set((ulonglong)list_value->value, cs);
6195 tmp_str.append(tmp_res);
6197 if (--num_items != 0)
6198 tmp_str.append(
",");
6200 table->field[11]->store(tmp_str.ptr(), tmp_str.length(), cs);
6201 table->field[11]->set_notnull();
6204 if (part_elem->subpartitions.elements)
6208 uint subpart_pos= 0;
6210 while ((subpart_elem= sub_it++))
6212 table->field[4]->store(subpart_elem->partition_name,
6213 strlen(subpart_elem->partition_name), cs);
6214 table->field[4]->set_notnull();
6216 table->field[6]->store((longlong) ++subpart_pos, TRUE);
6217 table->field[6]->set_notnull();
6219 store_schema_partitions_record(thd, table, show_table, subpart_elem,
6222 if(schema_table_store_record(thd, table))
6228 store_schema_partitions_record(thd, table, show_table, part_elem,
6231 if(schema_table_store_record(thd, table))
6240 store_schema_partitions_record(thd, table, show_table, 0, file, 0);
6241 if(schema_table_store_record(thd, table))
6248 #ifdef HAVE_EVENT_SCHEDULER
6265 copy_event_to_schema_table(THD *thd,
TABLE *sch_table,
TABLE *event_table)
6267 const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
6271 DBUG_ENTER(
"copy_event_to_schema_table");
6273 restore_record(sch_table, s->default_values);
6277 my_error(ER_CANNOT_LOAD_FROM_TABLE_V2, MYF(0),
"mysql",
"event");
6281 if (!(!wild || !wild[0] || !wild_case_compare(scs, et.name.str, wild)))
6289 if (thd->lex->sql_command != SQLCOM_SHOW_EVENTS &&
6290 check_access(thd, EVENT_ACL, et.dbname.str, NULL, NULL, 0, 1))
6293 sch_table->field[ISE_EVENT_CATALOG]->store(STRING_WITH_LEN(
"def"), scs);
6294 sch_table->field[ISE_EVENT_SCHEMA]->
6295 store(et.dbname.str, et.dbname.length,scs);
6296 sch_table->field[ISE_EVENT_NAME]->
6297 store(et.name.str, et.name.length, scs);
6298 sch_table->field[ISE_DEFINER]->
6299 store(et.definer.str, et.definer.length, scs);
6301 sch_table->field[ISE_TIME_ZONE]->
6302 store(tz_name->ptr(), tz_name->length(), scs);
6303 sch_table->field[ISE_EVENT_BODY]->
6304 store(STRING_WITH_LEN(
"SQL"), scs);
6305 sch_table->field[ISE_EVENT_DEFINITION]->store(
6306 et.body_utf8.str, et.body_utf8.length, scs);
6311 sql_mode_string_representation(thd, et.sql_mode, &sql_mode);
6312 sch_table->field[ISE_SQL_MODE]->
6313 store(sql_mode.str, sql_mode.length, scs);
6322 sch_table->field[ISE_EVENT_TYPE]->store(STRING_WITH_LEN(
"RECURRING"), scs);
6328 sch_table->field[ISE_INTERVAL_VALUE]->set_notnull();
6329 sch_table->field[ISE_INTERVAL_VALUE]->
6330 store(show_str.ptr(), show_str.length(), scs);
6332 LEX_STRING *ival= &interval_type_to_name[et.interval];
6333 sch_table->field[ISE_INTERVAL_FIELD]->set_notnull();
6334 sch_table->field[ISE_INTERVAL_FIELD]->store(ival->str, ival->length, scs);
6338 sch_table->field[ISE_STARTS]->set_notnull();
6339 sch_table->field[ISE_STARTS]->
store_time(&time);
6344 sch_table->field[ISE_ENDS]->set_notnull();
6345 sch_table->field[ISE_ENDS]->
store_time(&time);
6351 sch_table->field[ISE_EVENT_TYPE]->store(STRING_WITH_LEN(
"ONE TIME"), scs);
6354 sch_table->field[ISE_EXECUTE_AT]->set_notnull();
6355 sch_table->field[ISE_EXECUTE_AT]->
store_time(&time);
6362 case Event_parse_data::ENABLED:
6363 sch_table->field[ISE_STATUS]->store(STRING_WITH_LEN(
"ENABLED"), scs);
6365 case Event_parse_data::SLAVESIDE_DISABLED:
6366 sch_table->field[ISE_STATUS]->store(STRING_WITH_LEN(
"SLAVESIDE_DISABLED"),
6369 case Event_parse_data::DISABLED:
6370 sch_table->field[ISE_STATUS]->store(STRING_WITH_LEN(
"DISABLED"), scs);
6375 sch_table->field[ISE_ORIGINATOR]->store(et.originator, TRUE);
6378 if (et.on_completion == Event_parse_data::ON_COMPLETION_DROP)
6379 sch_table->field[ISE_ON_COMPLETION]->
6380 store(STRING_WITH_LEN(
"NOT PRESERVE"), scs);
6382 sch_table->field[ISE_ON_COMPLETION]->
6383 store(STRING_WITH_LEN(
"PRESERVE"), scs);
6385 number_to_datetime(et.created, &time, 0, ¬_used);
6386 DBUG_ASSERT(not_used==0);
6387 sch_table->field[ISE_CREATED]->
store_time(&time);
6389 number_to_datetime(et.modified, &time, 0, ¬_used);
6390 DBUG_ASSERT(not_used==0);
6391 sch_table->field[ISE_LAST_ALTERED]->
store_time(&time);
6393 if (et.last_executed)
6396 sch_table->field[ISE_LAST_EXECUTED]->set_notnull();
6397 sch_table->field[ISE_LAST_EXECUTED]->
store_time(&time);
6400 sch_table->field[ISE_EVENT_COMMENT]->
6401 store(et.comment.str, et.comment.length, scs);
6403 sch_table->field[ISE_CLIENT_CS]->set_notnull();
6404 sch_table->field[ISE_CLIENT_CS]->store(
6405 et.creation_ctx->get_client_cs()->csname,
6406 strlen(et.creation_ctx->get_client_cs()->csname),
6409 sch_table->field[ISE_CONNECTION_CL]->set_notnull();
6410 sch_table->field[ISE_CONNECTION_CL]->store(
6411 et.creation_ctx->get_connection_cl()->name,
6412 strlen(et.creation_ctx->get_connection_cl()->name),
6415 sch_table->field[ISE_DB_CL]->set_notnull();
6416 sch_table->field[ISE_DB_CL]->store(
6417 et.creation_ctx->get_db_cl()->name,
6418 strlen(et.creation_ctx->get_db_cl()->name),
6421 if (schema_table_store_record(thd, sch_table))
6430 DBUG_ENTER(
"fill_open_tables");
6431 const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS;
6432 TABLE *table= tables->table;
6435 if (!(open_list=list_open_tables(thd,thd->lex->select_lex.db, wild))
6436 && thd->is_fatal_error)
6439 for (; open_list ; open_list=open_list->next)
6441 restore_record(table, s->default_values);
6442 table->field[0]->store(open_list->db, strlen(open_list->db), cs);
6443 table->field[1]->store(open_list->table, strlen(open_list->table), cs);
6444 table->field[2]->store((longlong) open_list->in_use, TRUE);
6445 table->field[3]->store((longlong) open_list->locked, TRUE);
6446 if (schema_table_store_record(thd, table))
6455 DBUG_ENTER(
"fill_variables");
6458 const char *wild= lex->wild ? lex->wild->ptr() : NullS;
6459 enum enum_schema_tables schema_table_idx=
6460 get_schema_table_idx(tables->schema_table);
6461 enum enum_var_type option_type= OPT_SESSION;
6462 bool upper_case_names= (schema_table_idx != SCH_VARIABLES);
6463 bool sorted_vars= (schema_table_idx == SCH_VARIABLES);
6465 if (lex->option_type == OPT_GLOBAL ||
6466 schema_table_idx == SCH_GLOBAL_VARIABLES)
6467 option_type= OPT_GLOBAL;
6470 res= show_status_array(thd, wild, enumerate_sys_vars(thd, sorted_vars, option_type),
6471 option_type, NULL,
"", tables->table, upper_case_names, cond);
6479 DBUG_ENTER(
"fill_status");
6481 const char *wild= lex->wild ? lex->wild->ptr() : NullS;
6484 enum enum_schema_tables schema_table_idx=
6485 get_schema_table_idx(tables->schema_table);
6486 enum enum_var_type option_type;
6487 bool upper_case_names= (schema_table_idx != SCH_STATUS);
6489 if (schema_table_idx == SCH_STATUS)
6491 option_type= lex->option_type;
6492 if (option_type == OPT_GLOBAL)
6495 tmp1= thd->initial_status_var;
6497 else if (schema_table_idx == SCH_GLOBAL_STATUS)
6499 option_type= OPT_GLOBAL;
6504 option_type= OPT_SESSION;
6505 tmp1= &thd->status_var;
6512 if (thd->fill_status_recursion_level++ == 0)
6514 if (option_type == OPT_GLOBAL)
6515 calc_sum_of_all_status(&tmp);
6516 res= show_status_array(thd, wild,
6517 (
SHOW_VAR *)all_status_vars.buffer,
6518 option_type, tmp1,
"", tables->table,
6519 upper_case_names, cond);
6520 if (thd->fill_status_recursion_level-- == 1)
6545 get_referential_constraints_record(THD *thd,
TABLE_LIST *tables,
6546 TABLE *table,
bool res,
6550 DBUG_ENTER(
"get_referential_constraints_record");
6554 if (thd->is_error())
6555 push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
6556 thd->get_stmt_da()->sql_errno(), thd->get_stmt_da()->message());
6563 TABLE *show_table= tables->table;
6568 while ((f_key_info= it++))
6570 restore_record(table, s->default_values);
6571 table->field[0]->store(STRING_WITH_LEN(
"def"), cs);
6572 table->field[1]->store(db_name->str, db_name->length, cs);
6573 table->field[9]->store(table_name->str, table_name->length, cs);
6574 table->field[2]->store(f_key_info->foreign_id->str,
6575 f_key_info->foreign_id->length, cs);
6576 table->field[3]->store(STRING_WITH_LEN(
"def"), cs);
6577 table->field[4]->store(f_key_info->referenced_db->str,
6578 f_key_info->referenced_db->length, cs);
6579 table->field[10]->store(f_key_info->referenced_table->str,
6580 f_key_info->referenced_table->length, cs);
6581 if (f_key_info->referenced_key_name)
6583 table->field[5]->store(f_key_info->referenced_key_name->str,
6584 f_key_info->referenced_key_name->length, cs);
6585 table->field[5]->set_notnull();
6588 table->field[5]->set_null();
6589 table->field[6]->store(STRING_WITH_LEN(
"NONE"), cs);
6590 table->field[7]->store(f_key_info->update_method->str,
6591 f_key_info->update_method->length, cs);
6592 table->field[8]->store(f_key_info->delete_method->str,
6593 f_key_info->delete_method->length, cs);
6594 if (schema_table_store_record(thd, table))
6603 const char *table_name;
6621 static my_bool find_schema_table_in_plugin(THD *thd,
plugin_ref plugin,
6625 const char* table_name= p_schema_table->table_name;
6627 DBUG_ENTER(
"find_schema_table_in_plugin");
6629 if (!my_strcasecmp(system_charset_info,
6630 schema_table->table_name,
6632 p_schema_table->schema_table= schema_table;
6657 DBUG_ENTER(
"find_schema_table");
6659 for (; schema_table->table_name; schema_table++)
6661 if (!my_strcasecmp(system_charset_info,
6662 schema_table->table_name,
6664 DBUG_RETURN(schema_table);
6668 if (plugin_foreach(thd, find_schema_table_in_plugin,
6669 MYSQL_INFORMATION_SCHEMA_PLUGIN, &schema_table_a))
6670 DBUG_RETURN(schema_table_a.schema_table);
6676 ST_SCHEMA_TABLE *get_schema_table(
enum enum_schema_tables schema_table_idx)
6678 return &schema_tables[schema_table_idx];
6712 DBUG_ENTER(
"create_schema_table");
6714 for (; fields_info->
field_name; fields_info++)
6717 case MYSQL_TYPE_TINY:
6718 case MYSQL_TYPE_LONG:
6719 case MYSQL_TYPE_SHORT:
6720 case MYSQL_TYPE_LONGLONG:
6721 case MYSQL_TYPE_INT24:
6725 fields_info->value)))
6729 item->unsigned_flag= (fields_info->
field_flags & MY_I_S_UNSIGNED);
6731 case MYSQL_TYPE_DATE:
6732 case MYSQL_TYPE_TIME:
6733 case MYSQL_TYPE_TIMESTAMP:
6734 case MYSQL_TYPE_DATETIME:
6742 case MYSQL_TYPE_FLOAT:
6743 case MYSQL_TYPE_DOUBLE:
6747 if ((item=
new Item_float(field_name, 0.0, NOT_FIXED_DEC,
6752 case MYSQL_TYPE_DECIMAL:
6753 case MYSQL_TYPE_NEWDECIMAL:
6754 if (!(item=
new Item_decimal((longlong) fields_info->value,
false)))
6758 item->unsigned_flag= (fields_info->
field_flags & MY_I_S_UNSIGNED);
6761 if (item->unsigned_flag == 0)
6762 item->max_length+= 1;
6763 if (item->decimals > 0)
6764 item->max_length+= 1;
6767 case MYSQL_TYPE_TINY_BLOB:
6768 case MYSQL_TYPE_MEDIUM_BLOB:
6769 case MYSQL_TYPE_LONG_BLOB:
6770 case MYSQL_TYPE_BLOB:
6779 DBUG_ASSERT(fields_info->
field_type == MYSQL_TYPE_STRING);
6788 field_list.push_back(item);
6789 item->maybe_null= (fields_info->
field_flags & MY_I_S_MAYBE_NULL);
6792 TMP_TABLE_PARAM *tmp_table_param =
6793 (TMP_TABLE_PARAM*) (thd->alloc(
sizeof(TMP_TABLE_PARAM)));
6794 tmp_table_param->init();
6795 tmp_table_param->table_charset= cs;
6796 tmp_table_param->field_count= field_count;
6797 tmp_table_param->schema_table= 1;
6798 SELECT_LEX *select_lex= thd->lex->current_select;
6799 if (!(table= create_tmp_table(thd, tmp_table_param,
6800 field_list, (
ORDER*) 0, 0, 0,
6801 (select_lex->options | thd->variables.option_bits |
6802 TMP_TABLE_ALL_COLUMNS),
6803 HA_POS_ERROR, table_list->alias)))
6805 my_bitmap_map* bitmaps=
6806 (my_bitmap_map*) thd->alloc(bitmap_buffer_size(field_count));
6807 bitmap_init(&table->def_read_set, (my_bitmap_map*) bitmaps, field_count,
6809 table->read_set= &table->def_read_set;
6810 bitmap_clear_all(table->read_set);
6811 table_list->schema_table_param= tmp_table_param;
6837 if (field_info->old_name)
6843 field->item_name.
copy(field_info->old_name);
6844 if (add_item_to_list(thd, field))
6857 SELECT_LEX *sel= lex->current_select;
6860 if (!sel->item_list.elements)
6863 String buffer(tmp,
sizeof(tmp), system_charset_info);
6866 if (!field || add_item_to_list(thd, field))
6869 buffer.append(field_info->old_name);
6870 if (lex->wild && lex->wild->ptr())
6872 buffer.append(STRING_WITH_LEN(
" ("));
6873 buffer.append(lex->wild->ptr());
6876 field->item_name.
copy(buffer.ptr(), buffer.length(), system_charset_info);
6882 int make_table_names_old_format(THD *thd,
ST_SCHEMA_TABLE *schema_table)
6885 String buffer(tmp,
sizeof(tmp), thd->charset());
6891 buffer.append(field_info->old_name);
6892 buffer.append(lex->select_lex.db);
6893 if (lex->wild && lex->wild->ptr())
6895 buffer.append(STRING_WITH_LEN(
" ("));
6896 buffer.append(lex->wild->ptr());
6901 if (add_item_to_list(thd, field))
6903 field->item_name.
copy(buffer.ptr(), buffer.length(), system_charset_info);
6904 if (thd->lex->verbose)
6906 field->item_name.
copy(buffer.ptr(), buffer.length(), system_charset_info);
6907 field_info= &schema_table->fields_info[3];
6909 if (add_item_to_list(thd, field))
6911 field->item_name.
copy(field_info->old_name);
6919 int fields_arr[]= {IS_COLUMNS_COLUMN_NAME,
6920 IS_COLUMNS_COLUMN_TYPE,
6921 IS_COLUMNS_COLLATION_NAME,
6922 IS_COLUMNS_IS_NULLABLE,
6923 IS_COLUMNS_COLUMN_KEY,
6924 IS_COLUMNS_COLUMN_DEFAULT,
6926 IS_COLUMNS_PRIVILEGES,
6927 IS_COLUMNS_COLUMN_COMMENT,
6929 int *field_num= fields_arr;
6933 for (; *field_num >= 0; field_num++)
6935 field_info= &schema_table->fields_info[*field_num];
6936 if (!thd->lex->verbose && (*field_num == IS_COLUMNS_COLLATION_NAME ||
6937 *field_num == IS_COLUMNS_PRIVILEGES ||
6938 *field_num == IS_COLUMNS_COLUMN_COMMENT))
6944 field->item_name.
copy(field_info->old_name);
6945 if (add_item_to_list(thd, field))
6953 int make_character_sets_old_format(THD *thd,
ST_SCHEMA_TABLE *schema_table)
6955 int fields_arr[]= {0, 2, 1, 3, -1};
6956 int *field_num= fields_arr;
6960 for (; *field_num >= 0; field_num++)
6962 field_info= &schema_table->fields_info[*field_num];
6967 field->item_name.
copy(field_info->old_name);
6968 if (add_item_to_list(thd, field))
6978 int fields_arr[]= {IS_ROUTINES_ROUTINE_SCHEMA,
6979 IS_ROUTINES_ROUTINE_NAME,
6980 IS_ROUTINES_ROUTINE_TYPE,
6981 IS_ROUTINES_DEFINER,
6982 IS_ROUTINES_LAST_ALTERED,
6983 IS_ROUTINES_CREATED,
6984 IS_ROUTINES_SECURITY_TYPE,
6985 IS_ROUTINES_ROUTINE_COMMENT,
6986 IS_ROUTINES_CHARACTER_SET_CLIENT,
6987 IS_ROUTINES_COLLATION_CONNECTION,
6988 IS_ROUTINES_DATABASE_COLLATION,
6990 int *field_num= fields_arr;
6994 for (; *field_num >= 0; field_num++)
6996 field_info= &schema_table->fields_info[*field_num];
7001 field->item_name.
copy(field_info->old_name);
7002 if (add_item_to_list(thd, field))
7024 int mysql_schema_table(THD *thd, LEX *lex,
TABLE_LIST *table_list)
7027 DBUG_ENTER(
"mysql_schema_table");
7028 if (!(table= table_list->schema_table->create_table(thd, table_list)))
7030 table->s->tmp_table= SYSTEM_TMP_TABLE;
7039 if (table_list->schema_table_name)
7040 table->alias_name_used= my_strcasecmp(table_alias_charset,
7041 table_list->schema_table_name,
7043 table_list->table_name= table->s->table_name.str;
7044 table_list->table_name_length= table->s->table_name.length;
7045 table_list->table=
table;
7046 table->next= thd->derived_tables;
7047 thd->derived_tables=
table;
7048 table_list->select_lex->options |= OPTION_SCHEMA_TABLE;
7049 lex->safe_to_cache_query= 0;
7051 if (table_list->schema_table_reformed)
7053 SELECT_LEX *sel= lex->current_select;
7057 if (table_list->field_translation)
7060 for (transl= table_list->field_translation; transl < end; transl++)
7062 if (!transl->item->fixed &&
7063 transl->item->fix_fields(thd, &transl->item))
7071 alloc(sel->item_list.elements *
7076 for (org_transl= transl; (item= it++); transl++)
7079 transl->name= item->item_name.
ptr();
7080 if (!item->fixed && item->fix_fields(thd, &transl->item))
7085 table_list->field_translation= org_transl;
7086 table_list->field_translation_end= transl;
7107 int make_schema_select(THD *thd, SELECT_LEX *sel,
7108 enum enum_schema_tables schema_table_idx)
7112 DBUG_ENTER(
"make_schema_select");
7113 DBUG_PRINT(
"enter", (
"mysql_schema_select: %s", schema_table->table_name));
7118 thd->make_lex_string(&db, INFORMATION_SCHEMA_NAME.str,
7119 INFORMATION_SCHEMA_NAME.length, 0);
7120 thd->make_lex_string(&table, schema_table->table_name,
7121 strlen(schema_table->table_name), 0);
7122 if (schema_table->old_format(thd, schema_table) ||
7123 !sel->add_table_to_list(thd,
new Table_ident(thd, db, table, 0),
7124 0, 0, TL_READ, MDL_SHARED_READ))
7166 static bool do_fill_table(THD *thd,
7181 da->push_warning_info(&wi_tmp);
7183 bool res= table_list->schema_table->fill_table(
7186 da->pop_warning_info();
7192 da->push_warning(thd,
7195 Sql_condition::WARN_LEVEL_ERROR,
7222 bool get_schema_tables_result(
JOIN *join,
7223 enum enum_schema_table_state executed_place)
7225 THD *thd= join->thd;
7228 DBUG_ENTER(
"get_schema_tables_result");
7231 if (!join->join_tab)
7232 DBUG_RETURN(result);
7234 for (uint i= 0; i < join->
tables; i++)
7236 JOIN_TAB *
const tab= join->join_tab +
i;
7237 if (!tab->table || !tab->table->pos_in_table_list)
7240 TABLE_LIST *table_list= tab->table->pos_in_table_list;
7241 if (table_list->schema_table && thd->fill_information_schema_tables())
7243 bool is_subselect= (&lex->unit != lex->current_select->master_unit() &&
7244 lex->current_select->master_unit()->item);
7247 if (table_list->schema_table->fill_table == 0)
7251 if (thd->lex->describe &&
7252 (table_list->schema_table->fill_table != get_all_tables))
7264 if (table_list->schema_table_state &&
7265 (!is_subselect || table_list->schema_table_state != executed_place))
7273 if (table_list->schema_table_state && is_subselect)
7275 table_list->table->file->extra(HA_EXTRA_NO_CACHE);
7276 table_list->table->file->extra(HA_EXTRA_RESET_STATE);
7278 free_io_cache(table_list->table);
7279 filesort_free_buffers(table_list->table,1);
7280 table_list->table->null_row= 0;
7283 table_list->table->file->stats.records= 0;
7285 if (do_fill_table(thd, table_list, tab))
7289 table_list->schema_table_state= executed_place;
7292 table_list->schema_table_state= executed_place;
7295 DBUG_RETURN(result);
7304 static my_bool run_hton_fill_schema_table(THD *thd,
plugin_ref plugin,
7310 if (hton->fill_is_table && hton->state == SHOW_OPTION_YES)
7311 hton->fill_is_table(hton, thd, args->tables, args->cond,
7312 get_schema_table_idx(args->tables->schema_table));
7316 int hton_fill_schema_table(THD *thd,
TABLE_LIST *tables,
Item *cond)
7318 DBUG_ENTER(
"hton_fill_schema_table");
7321 args.tables= tables;
7324 plugin_foreach(thd, run_hton_fill_schema_table,
7325 MYSQL_STORAGE_ENGINE_PLUGIN, &args);
7333 {
"CATALOG_NAME", FN_REFLEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7334 {
"SCHEMA_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0,
"Database",
7336 {
"DEFAULT_CHARACTER_SET_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, 0,
7338 {
"DEFAULT_COLLATION_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, 0,
7340 {
"SQL_PATH", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
7341 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7347 {
"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7348 {
"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7349 {
"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0,
"Name",
7351 {
"TABLE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
7352 {
"ENGINE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1,
"Engine", OPEN_FRM_ONLY},
7353 {
"VERSION", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
7354 (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED),
"Version", OPEN_FRM_ONLY},
7355 {
"ROW_FORMAT", 10, MYSQL_TYPE_STRING, 0, 1,
"Row_format", OPEN_FULL_TABLE},
7356 {
"TABLE_ROWS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
7357 (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED),
"Rows", OPEN_FULL_TABLE},
7358 {
"AVG_ROW_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
7359 (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED),
"Avg_row_length", OPEN_FULL_TABLE},
7360 {
"DATA_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
7361 (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED),
"Data_length", OPEN_FULL_TABLE},
7362 {
"MAX_DATA_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
7363 (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED),
"Max_data_length", OPEN_FULL_TABLE},
7364 {
"INDEX_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
7365 (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED),
"Index_length", OPEN_FULL_TABLE},
7366 {
"DATA_FREE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
7367 (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED),
"Data_free", OPEN_FULL_TABLE},
7368 {
"AUTO_INCREMENT", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONGLONG, 0,
7369 (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED),
"Auto_increment", OPEN_FULL_TABLE},
7370 {
"CREATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1,
"Create_time", OPEN_FULL_TABLE},
7371 {
"UPDATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1,
"Update_time", OPEN_FULL_TABLE},
7372 {
"CHECK_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1,
"Check_time", OPEN_FULL_TABLE},
7373 {
"TABLE_COLLATION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 1,
"Collation",
7375 {
"CHECKSUM", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
7376 (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED),
"Checksum", OPEN_FULL_TABLE},
7377 {
"CREATE_OPTIONS", 255, MYSQL_TYPE_STRING, 0, 1,
"Create_options",
7379 {
"TABLE_COMMENT", TABLE_COMMENT_MAXLEN, MYSQL_TYPE_STRING, 0, 0,
7380 "Comment", OPEN_FRM_ONLY},
7381 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7387 {
"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
7388 {
"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
7389 {
"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
7390 {
"COLUMN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0,
"Field",
7392 {
"ORDINAL_POSITION", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
7393 MY_I_S_UNSIGNED, 0, OPEN_FRM_ONLY},
7394 {
"COLUMN_DEFAULT", MAX_FIELD_VARCHARLENGTH, MYSQL_TYPE_STRING, 0,
7395 1,
"Default", OPEN_FRM_ONLY},
7396 {
"IS_NULLABLE", 3, MYSQL_TYPE_STRING, 0, 0,
"Null", OPEN_FRM_ONLY},
7397 {
"DATA_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
7398 {
"CHARACTER_MAXIMUM_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG,
7399 0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
7400 {
"CHARACTER_OCTET_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONGLONG,
7401 0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
7402 {
"NUMERIC_PRECISION", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG,
7403 0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
7404 {
"NUMERIC_SCALE", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONGLONG,
7405 0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY},
7406 {
"DATETIME_PRECISION", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONGLONG,
7407 0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FULL_TABLE},
7408 {
"CHARACTER_SET_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 1, 0,
7410 {
"COLLATION_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 1,
"Collation",
7412 {
"COLUMN_TYPE", 65535, MYSQL_TYPE_STRING, 0, 0,
"Type", OPEN_FRM_ONLY},
7413 {
"COLUMN_KEY", 3, MYSQL_TYPE_STRING, 0, 0,
"Key", OPEN_FRM_ONLY},
7414 {
"EXTRA", 30, MYSQL_TYPE_STRING, 0, 0,
"Extra", OPEN_FRM_ONLY},
7415 {
"PRIVILEGES", 80, MYSQL_TYPE_STRING, 0, 0,
"Privileges", OPEN_FRM_ONLY},
7416 {
"COLUMN_COMMENT", COLUMN_COMMENT_MAXLEN, MYSQL_TYPE_STRING, 0, 0,
7417 "Comment", OPEN_FRM_ONLY},
7418 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7424 {
"CHARACTER_SET_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
"Charset",
7426 {
"DEFAULT_COLLATE_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
7427 "Default collation", SKIP_OPEN_TABLE},
7428 {
"DESCRIPTION", 60, MYSQL_TYPE_STRING, 0, 0,
"Description",
7430 {
"MAXLEN", 3, MYSQL_TYPE_LONGLONG, 0, 0,
"Maxlen", SKIP_OPEN_TABLE},
7431 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7437 {
"COLLATION_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
"Collation",
7439 {
"CHARACTER_SET_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
"Charset",
7441 {
"ID", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0,
"Id",
7443 {
"IS_DEFAULT", 3, MYSQL_TYPE_STRING, 0, 0,
"Default", SKIP_OPEN_TABLE},
7444 {
"IS_COMPILED", 3, MYSQL_TYPE_STRING, 0, 0,
"Compiled", SKIP_OPEN_TABLE},
7445 {
"SORTLEN", 3, MYSQL_TYPE_LONGLONG, 0, 0,
"Sortlen", SKIP_OPEN_TABLE},
7446 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7452 {
"ENGINE", 64, MYSQL_TYPE_STRING, 0, 0,
"Engine", SKIP_OPEN_TABLE},
7453 {
"SUPPORT", 8, MYSQL_TYPE_STRING, 0, 0,
"Support", SKIP_OPEN_TABLE},
7454 {
"COMMENT", 80, MYSQL_TYPE_STRING, 0, 0,
"Comment", SKIP_OPEN_TABLE},
7455 {
"TRANSACTIONS", 3, MYSQL_TYPE_STRING, 0, 1,
"Transactions", SKIP_OPEN_TABLE},
7456 {
"XA", 3, MYSQL_TYPE_STRING, 0, 1,
"XA", SKIP_OPEN_TABLE},
7457 {
"SAVEPOINTS", 3 ,MYSQL_TYPE_STRING, 0, 1,
"Savepoints", SKIP_OPEN_TABLE},
7458 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7464 {
"EVENT_CATALOG", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7465 {
"EVENT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0,
"Db",
7467 {
"EVENT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0,
"Name",
7469 {
"DEFINER", 77, MYSQL_TYPE_STRING, 0, 0,
"Definer", SKIP_OPEN_TABLE},
7470 {
"TIME_ZONE", 64, MYSQL_TYPE_STRING, 0, 0,
"Time zone", SKIP_OPEN_TABLE},
7471 {
"EVENT_BODY", 8, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7472 {
"EVENT_DEFINITION", 65535, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7473 {
"EVENT_TYPE", 9, MYSQL_TYPE_STRING, 0, 0,
"Type", SKIP_OPEN_TABLE},
7474 {
"EXECUTE_AT", 0, MYSQL_TYPE_DATETIME, 0, 1,
"Execute at", SKIP_OPEN_TABLE},
7475 {
"INTERVAL_VALUE", 256, MYSQL_TYPE_STRING, 0, 1,
"Interval value",
7477 {
"INTERVAL_FIELD", 18, MYSQL_TYPE_STRING, 0, 1,
"Interval field",
7479 {
"SQL_MODE", 32*256, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7480 {
"STARTS", 0, MYSQL_TYPE_DATETIME, 0, 1,
"Starts", SKIP_OPEN_TABLE},
7481 {
"ENDS", 0, MYSQL_TYPE_DATETIME, 0, 1,
"Ends", SKIP_OPEN_TABLE},
7482 {
"STATUS", 18, MYSQL_TYPE_STRING, 0, 0,
"Status", SKIP_OPEN_TABLE},
7483 {
"ON_COMPLETION", 12, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7484 {
"CREATED", 0, MYSQL_TYPE_DATETIME, 0, 0, 0, SKIP_OPEN_TABLE},
7485 {
"LAST_ALTERED", 0, MYSQL_TYPE_DATETIME, 0, 0, 0, SKIP_OPEN_TABLE},
7486 {
"LAST_EXECUTED", 0, MYSQL_TYPE_DATETIME, 0, 1, 0, SKIP_OPEN_TABLE},
7487 {
"EVENT_COMMENT", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7488 {
"ORIGINATOR", 10, MYSQL_TYPE_LONGLONG, 0, 0,
"Originator", SKIP_OPEN_TABLE},
7489 {
"CHARACTER_SET_CLIENT", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
7490 "character_set_client", SKIP_OPEN_TABLE},
7491 {
"COLLATION_CONNECTION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
7492 "collation_connection", SKIP_OPEN_TABLE},
7493 {
"DATABASE_COLLATION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
7494 "Database Collation", SKIP_OPEN_TABLE},
7495 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7502 {
"COLLATION_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, 0,
7504 {
"CHARACTER_SET_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, 0,
7506 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7512 {
"SPECIFIC_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7513 {
"ROUTINE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7514 {
"ROUTINE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0,
"Db",
7516 {
"ROUTINE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0,
"Name",
7518 {
"ROUTINE_TYPE", 9, MYSQL_TYPE_STRING, 0, 0,
"Type", SKIP_OPEN_TABLE},
7519 {
"DATA_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7520 {
"CHARACTER_MAXIMUM_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, 0, SKIP_OPEN_TABLE},
7521 {
"CHARACTER_OCTET_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, 0, SKIP_OPEN_TABLE},
7522 {
"NUMERIC_PRECISION", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG,
7523 0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, SKIP_OPEN_TABLE},
7524 {
"NUMERIC_SCALE", 21 , MYSQL_TYPE_LONG, 0, 1, 0, SKIP_OPEN_TABLE},
7525 {
"DATETIME_PRECISION", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONGLONG,
7526 0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, SKIP_OPEN_TABLE},
7527 {
"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
7528 {
"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
7529 {
"DTD_IDENTIFIER", 65535, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
7530 {
"ROUTINE_BODY", 8, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7531 {
"ROUTINE_DEFINITION", 65535, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
7532 {
"EXTERNAL_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
7533 {
"EXTERNAL_LANGUAGE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0,
7535 {
"PARAMETER_STYLE", 8, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7536 {
"IS_DETERMINISTIC", 3, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7537 {
"SQL_DATA_ACCESS", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
7539 {
"SQL_PATH", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
7540 {
"SECURITY_TYPE", 7, MYSQL_TYPE_STRING, 0, 0,
"Security_type",
7542 {
"CREATED", 0, MYSQL_TYPE_DATETIME, 0, 0,
"Created", SKIP_OPEN_TABLE},
7543 {
"LAST_ALTERED", 0, MYSQL_TYPE_DATETIME, 0, 0,
"Modified", SKIP_OPEN_TABLE},
7544 {
"SQL_MODE", 32*256, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7545 {
"ROUTINE_COMMENT", 65535, MYSQL_TYPE_STRING, 0, 0,
"Comment",
7547 {
"DEFINER", 77, MYSQL_TYPE_STRING, 0, 0,
"Definer", SKIP_OPEN_TABLE},
7548 {
"CHARACTER_SET_CLIENT", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
7549 "character_set_client", SKIP_OPEN_TABLE},
7550 {
"COLLATION_CONNECTION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
7551 "collation_connection", SKIP_OPEN_TABLE},
7552 {
"DATABASE_COLLATION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
7553 "Database Collation", SKIP_OPEN_TABLE},
7554 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7560 {
"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
7561 {
"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
7562 {
"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0,
"Table", OPEN_FRM_ONLY},
7563 {
"NON_UNIQUE", 1, MYSQL_TYPE_LONGLONG, 0, 0,
"Non_unique", OPEN_FRM_ONLY},
7564 {
"INDEX_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
7565 {
"INDEX_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0,
"Key_name",
7567 {
"SEQ_IN_INDEX", 2, MYSQL_TYPE_LONGLONG, 0, 0,
"Seq_in_index", OPEN_FRM_ONLY},
7568 {
"COLUMN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0,
"Column_name",
7570 {
"COLLATION", 1, MYSQL_TYPE_STRING, 0, 1,
"Collation", OPEN_FRM_ONLY},
7571 {
"CARDINALITY", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 1,
7572 "Cardinality", OPEN_FULL_TABLE},
7573 {
"SUB_PART", 3, MYSQL_TYPE_LONGLONG, 0, 1,
"Sub_part", OPEN_FRM_ONLY},
7574 {
"PACKED", 10, MYSQL_TYPE_STRING, 0, 1,
"Packed", OPEN_FRM_ONLY},
7575 {
"NULLABLE", 3, MYSQL_TYPE_STRING, 0, 0,
"Null", OPEN_FRM_ONLY},
7576 {
"INDEX_TYPE", 16, MYSQL_TYPE_STRING, 0, 0,
"Index_type", OPEN_FULL_TABLE},
7577 {
"COMMENT", 16, MYSQL_TYPE_STRING, 0, 1,
"Comment", OPEN_FRM_ONLY},
7578 {
"INDEX_COMMENT", INDEX_COMMENT_MAXLEN, MYSQL_TYPE_STRING, 0, 0,
7579 "Index_comment", OPEN_FRM_ONLY},
7580 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7586 {
"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
7587 {
"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
7588 {
"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
7589 {
"VIEW_DEFINITION", 65535, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
7590 {
"CHECK_OPTION", 8, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
7591 {
"IS_UPDATABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
7592 {
"DEFINER", 77, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
7593 {
"SECURITY_TYPE", 7, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
7594 {
"CHARACTER_SET_CLIENT", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, 0,
7596 {
"COLLATION_CONNECTION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, 0,
7598 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7604 {
"GRANTEE", 81, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7605 {
"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7606 {
"PRIVILEGE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7607 {
"IS_GRANTABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7608 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7614 {
"GRANTEE", 81, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7615 {
"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7616 {
"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7617 {
"PRIVILEGE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7618 {
"IS_GRANTABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7619 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7625 {
"GRANTEE", 81, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7626 {
"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7627 {
"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7628 {
"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7629 {
"PRIVILEGE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7630 {
"IS_GRANTABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7631 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7637 {
"GRANTEE", 81, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7638 {
"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7639 {
"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7640 {
"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7641 {
"COLUMN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7642 {
"PRIVILEGE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7643 {
"IS_GRANTABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7644 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7650 {
"CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
7651 {
"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
7653 {
"CONSTRAINT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
7655 {
"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
7656 {
"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
7657 {
"CONSTRAINT_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
7659 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7665 {
"CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
7666 {
"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
7668 {
"CONSTRAINT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
7670 {
"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
7671 {
"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
7672 {
"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
7673 {
"COLUMN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
7674 {
"ORDINAL_POSITION", 10 ,MYSQL_TYPE_LONGLONG, 0, 0, 0, OPEN_FULL_TABLE},
7675 {
"POSITION_IN_UNIQUE_CONSTRAINT", 10 ,MYSQL_TYPE_LONGLONG, 0, 1, 0,
7677 {
"REFERENCED_TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0,
7679 {
"REFERENCED_TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0,
7681 {
"REFERENCED_COLUMN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0,
7683 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7689 {
"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7690 {
"TABLE_SCHEMA",NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7691 {
"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0,
"Tables_in_",
7693 {
"TABLE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0,
"Table_type",
7695 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7701 {
"Database", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0,
"Database",
7703 {
"Table",NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0,
"Table", SKIP_OPEN_TABLE},
7704 {
"In_use", 1, MYSQL_TYPE_LONGLONG, 0, 0,
"In_use", SKIP_OPEN_TABLE},
7705 {
"Name_locked", 4, MYSQL_TYPE_LONGLONG, 0, 0,
"Name_locked", SKIP_OPEN_TABLE},
7706 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7712 {
"TRIGGER_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
7713 {
"TRIGGER_SCHEMA",NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
7714 {
"TRIGGER_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0,
"Trigger",
7716 {
"EVENT_MANIPULATION", 6, MYSQL_TYPE_STRING, 0, 0,
"Event", OPEN_FRM_ONLY},
7717 {
"EVENT_OBJECT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 0, 0,
7719 {
"EVENT_OBJECT_SCHEMA",NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
7721 {
"EVENT_OBJECT_TABLE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0,
"Table",
7723 {
"ACTION_ORDER", 4, MYSQL_TYPE_LONGLONG, 0, 0, 0, OPEN_FRM_ONLY},
7724 {
"ACTION_CONDITION", 65535, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FRM_ONLY},
7725 {
"ACTION_STATEMENT", 65535, MYSQL_TYPE_STRING, 0, 0,
"Statement",
7727 {
"ACTION_ORIENTATION", 9, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
7728 {
"ACTION_TIMING", 6, MYSQL_TYPE_STRING, 0, 0,
"Timing", OPEN_FRM_ONLY},
7729 {
"ACTION_REFERENCE_OLD_TABLE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0,
7731 {
"ACTION_REFERENCE_NEW_TABLE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0,
7733 {
"ACTION_REFERENCE_OLD_ROW", 3, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
7734 {
"ACTION_REFERENCE_NEW_ROW", 3, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
7735 {
"CREATED", 0, MYSQL_TYPE_DATETIME, 0, 1,
"Created", OPEN_FRM_ONLY},
7736 {
"SQL_MODE", 32*256, MYSQL_TYPE_STRING, 0, 0,
"sql_mode", OPEN_FRM_ONLY},
7737 {
"DEFINER", 77, MYSQL_TYPE_STRING, 0, 0,
"Definer", OPEN_FRM_ONLY},
7738 {
"CHARACTER_SET_CLIENT", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
7739 "character_set_client", OPEN_FRM_ONLY},
7740 {
"COLLATION_CONNECTION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
7741 "collation_connection", OPEN_FRM_ONLY},
7742 {
"DATABASE_COLLATION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
7743 "Database Collation", OPEN_FRM_ONLY},
7744 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7750 {
"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
7751 {
"TABLE_SCHEMA",NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
7752 {
"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
7753 {
"PARTITION_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
7754 {
"SUBPARTITION_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0,
7756 {
"PARTITION_ORDINAL_POSITION", 21 , MYSQL_TYPE_LONGLONG, 0,
7757 (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FULL_TABLE},
7758 {
"SUBPARTITION_ORDINAL_POSITION", 21 , MYSQL_TYPE_LONGLONG, 0,
7759 (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FULL_TABLE},
7760 {
"PARTITION_METHOD", 18, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
7761 {
"SUBPARTITION_METHOD", 12, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
7762 {
"PARTITION_EXPRESSION", 65535, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
7763 {
"SUBPARTITION_EXPRESSION", 65535, MYSQL_TYPE_STRING, 0, 1, 0,
7765 {
"PARTITION_DESCRIPTION", 65535, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
7766 {
"TABLE_ROWS", 21 , MYSQL_TYPE_LONGLONG, 0, MY_I_S_UNSIGNED, 0,
7768 {
"AVG_ROW_LENGTH", 21 , MYSQL_TYPE_LONGLONG, 0, MY_I_S_UNSIGNED, 0,
7770 {
"DATA_LENGTH", 21 , MYSQL_TYPE_LONGLONG, 0, MY_I_S_UNSIGNED, 0,
7772 {
"MAX_DATA_LENGTH", 21 , MYSQL_TYPE_LONGLONG, 0,
7773 (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FULL_TABLE},
7774 {
"INDEX_LENGTH", 21 , MYSQL_TYPE_LONGLONG, 0, MY_I_S_UNSIGNED, 0,
7776 {
"DATA_FREE", 21 , MYSQL_TYPE_LONGLONG, 0, MY_I_S_UNSIGNED, 0,
7778 {
"CREATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, 0, OPEN_FULL_TABLE},
7779 {
"UPDATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, 0, OPEN_FULL_TABLE},
7780 {
"CHECK_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, 0, OPEN_FULL_TABLE},
7781 {
"CHECKSUM", 21 , MYSQL_TYPE_LONGLONG, 0,
7782 (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FULL_TABLE},
7783 {
"PARTITION_COMMENT", 80, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
7784 {
"NODEGROUP", 12 , MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
7785 {
"TABLESPACE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0,
7787 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7793 {
"VARIABLE_NAME", 64, MYSQL_TYPE_STRING, 0, 0,
"Variable_name",
7795 {
"VARIABLE_VALUE", 1024, MYSQL_TYPE_STRING, 0, 1,
"Value", SKIP_OPEN_TABLE},
7796 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7802 {
"ID", 21, MYSQL_TYPE_LONGLONG, 0, MY_I_S_UNSIGNED,
"Id", SKIP_OPEN_TABLE},
7803 {
"USER", 16, MYSQL_TYPE_STRING, 0, 0,
"User", SKIP_OPEN_TABLE},
7804 {
"HOST", LIST_PROCESS_HOST_LEN, MYSQL_TYPE_STRING, 0, 0,
"Host",
7806 {
"DB", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1,
"Db", SKIP_OPEN_TABLE},
7807 {
"COMMAND", 16, MYSQL_TYPE_STRING, 0, 0,
"Command", SKIP_OPEN_TABLE},
7808 {
"TIME", 7, MYSQL_TYPE_LONG, 0, 0,
"Time", SKIP_OPEN_TABLE},
7809 {
"STATE", 64, MYSQL_TYPE_STRING, 0, 1,
"State", SKIP_OPEN_TABLE},
7810 {
"INFO", PROCESS_LIST_INFO_WIDTH, MYSQL_TYPE_STRING, 0, 1,
"Info",
7812 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7818 {
"PLUGIN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0,
"Name",
7820 {
"PLUGIN_VERSION", 20, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7821 {
"PLUGIN_STATUS", 10, MYSQL_TYPE_STRING, 0, 0,
"Status", SKIP_OPEN_TABLE},
7822 {
"PLUGIN_TYPE", 80, MYSQL_TYPE_STRING, 0, 0,
"Type", SKIP_OPEN_TABLE},
7823 {
"PLUGIN_TYPE_VERSION", 20, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7824 {
"PLUGIN_LIBRARY", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1,
"Library",
7826 {
"PLUGIN_LIBRARY_VERSION", 20, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
7827 {
"PLUGIN_AUTHOR", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
7828 {
"PLUGIN_DESCRIPTION", 65535, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
7829 {
"PLUGIN_LICENSE", 80, MYSQL_TYPE_STRING, 0, 1,
"License", SKIP_OPEN_TABLE},
7830 {
"LOAD_OPTION", 64, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7831 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7836 {
"FILE_ID", 4, MYSQL_TYPE_LONGLONG, 0, 0, 0, SKIP_OPEN_TABLE},
7837 {
"FILE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
7838 {
"FILE_TYPE", 20, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7839 {
"TABLESPACE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0,
7841 {
"TABLE_CATALOG", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7842 {
"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
7843 {
"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
7844 {
"LOGFILE_GROUP_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0,
7846 {
"LOGFILE_GROUP_NUMBER", 4, MYSQL_TYPE_LONGLONG, 0, 1, 0, SKIP_OPEN_TABLE},
7847 {
"ENGINE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7848 {
"FULLTEXT_KEYS", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
7849 {
"DELETED_ROWS", 4, MYSQL_TYPE_LONGLONG, 0, 1, 0, SKIP_OPEN_TABLE},
7850 {
"UPDATE_COUNT", 4, MYSQL_TYPE_LONGLONG, 0, 1, 0, SKIP_OPEN_TABLE},
7851 {
"FREE_EXTENTS", 4, MYSQL_TYPE_LONGLONG, 0, 1, 0, SKIP_OPEN_TABLE},
7852 {
"TOTAL_EXTENTS", 4, MYSQL_TYPE_LONGLONG, 0, 1, 0, SKIP_OPEN_TABLE},
7853 {
"EXTENT_SIZE", 4, MYSQL_TYPE_LONGLONG, 0, 0, 0, SKIP_OPEN_TABLE},
7854 {
"INITIAL_SIZE", 21, MYSQL_TYPE_LONGLONG, 0,
7855 (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, SKIP_OPEN_TABLE},
7856 {
"MAXIMUM_SIZE", 21, MYSQL_TYPE_LONGLONG, 0,
7857 (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, SKIP_OPEN_TABLE},
7858 {
"AUTOEXTEND_SIZE", 21, MYSQL_TYPE_LONGLONG, 0,
7859 (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, SKIP_OPEN_TABLE},
7860 {
"CREATION_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, 0, SKIP_OPEN_TABLE},
7861 {
"LAST_UPDATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, 0, SKIP_OPEN_TABLE},
7862 {
"LAST_ACCESS_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, 0, SKIP_OPEN_TABLE},
7863 {
"RECOVER_TIME", 4, MYSQL_TYPE_LONGLONG, 0, 1, 0, SKIP_OPEN_TABLE},
7864 {
"TRANSACTION_COUNTER", 4, MYSQL_TYPE_LONGLONG, 0, 1, 0, SKIP_OPEN_TABLE},
7865 {
"VERSION", 21 , MYSQL_TYPE_LONGLONG, 0,
7866 (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED),
"Version", SKIP_OPEN_TABLE},
7867 {
"ROW_FORMAT", 10, MYSQL_TYPE_STRING, 0, 1,
"Row_format", SKIP_OPEN_TABLE},
7868 {
"TABLE_ROWS", 21 , MYSQL_TYPE_LONGLONG, 0,
7869 (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED),
"Rows", SKIP_OPEN_TABLE},
7870 {
"AVG_ROW_LENGTH", 21 , MYSQL_TYPE_LONGLONG, 0,
7871 (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED),
"Avg_row_length", SKIP_OPEN_TABLE},
7872 {
"DATA_LENGTH", 21 , MYSQL_TYPE_LONGLONG, 0,
7873 (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED),
"Data_length", SKIP_OPEN_TABLE},
7874 {
"MAX_DATA_LENGTH", 21 , MYSQL_TYPE_LONGLONG, 0,
7875 (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED),
"Max_data_length", SKIP_OPEN_TABLE},
7876 {
"INDEX_LENGTH", 21 , MYSQL_TYPE_LONGLONG, 0,
7877 (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED),
"Index_length", SKIP_OPEN_TABLE},
7878 {
"DATA_FREE", 21 , MYSQL_TYPE_LONGLONG, 0,
7879 (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED),
"Data_free", SKIP_OPEN_TABLE},
7880 {
"CREATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1,
"Create_time", SKIP_OPEN_TABLE},
7881 {
"UPDATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1,
"Update_time", SKIP_OPEN_TABLE},
7882 {
"CHECK_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1,
"Check_time", SKIP_OPEN_TABLE},
7883 {
"CHECKSUM", 21 , MYSQL_TYPE_LONGLONG, 0,
7884 (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED),
"Checksum", SKIP_OPEN_TABLE},
7885 {
"STATUS", 20, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7886 {
"EXTRA", 255, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE},
7887 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7890 void init_fill_schema_files_row(
TABLE* table)
7893 for(i=0; files_fields_info[
i].
field_name!=NULL; i++)
7894 table->field[i]->set_null();
7896 table->field[IS_FILES_STATUS]->set_notnull();
7897 table->field[IS_FILES_STATUS]->store(
"NORMAL", 6, system_charset_info);
7902 {
"CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
7903 {
"CONSTRAINT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
7905 {
"CONSTRAINT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
7907 {
"UNIQUE_CONSTRAINT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 0, 0,
7909 {
"UNIQUE_CONSTRAINT_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
7911 {
"UNIQUE_CONSTRAINT_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0,
7912 MY_I_S_MAYBE_NULL, 0, OPEN_FULL_TABLE},
7913 {
"MATCH_OPTION", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
7914 {
"UPDATE_RULE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
7915 {
"DELETE_RULE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
7916 {
"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
7917 {
"REFERENCED_TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
7919 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7925 {
"SPECIFIC_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
7926 {
"SPECIFIC_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
7928 {
"SPECIFIC_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
7929 {
"ORDINAL_POSITION", 21 , MYSQL_TYPE_LONG, 0, 0, 0, OPEN_FULL_TABLE},
7930 {
"PARAMETER_MODE", 5, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
7931 {
"PARAMETER_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
7932 {
"DATA_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
7933 {
"CHARACTER_MAXIMUM_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, 0, OPEN_FULL_TABLE},
7934 {
"CHARACTER_OCTET_LENGTH", 21 , MYSQL_TYPE_LONG, 0, 1, 0, OPEN_FULL_TABLE},
7935 {
"NUMERIC_PRECISION", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG,
7936 0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FULL_TABLE},
7937 {
"NUMERIC_SCALE", 21 , MYSQL_TYPE_LONG, 0, 1, 0, OPEN_FULL_TABLE},
7938 {
"DATETIME_PRECISION", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONGLONG,
7939 0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FULL_TABLE},
7940 {
"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
7941 {
"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
7942 {
"DTD_IDENTIFIER", 65535, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
7943 {
"ROUTINE_TYPE", 9, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
7944 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE}
7950 {
"TABLESPACE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
7952 {
"ENGINE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE},
7953 {
"TABLESPACE_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, MY_I_S_MAYBE_NULL,
7954 0, SKIP_OPEN_TABLE},
7955 {
"LOGFILE_GROUP_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, MY_I_S_MAYBE_NULL,
7956 0, SKIP_OPEN_TABLE},
7957 {
"EXTENT_SIZE", 21, MYSQL_TYPE_LONGLONG, 0,
7958 MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED, 0, SKIP_OPEN_TABLE},
7959 {
"AUTOEXTEND_SIZE", 21, MYSQL_TYPE_LONGLONG, 0,
7960 MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED, 0, SKIP_OPEN_TABLE},
7961 {
"MAXIMUM_SIZE", 21, MYSQL_TYPE_LONGLONG, 0,
7962 MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED, 0, SKIP_OPEN_TABLE},
7963 {
"NODEGROUP_ID", 21, MYSQL_TYPE_LONGLONG, 0,
7964 MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED, 0, SKIP_OPEN_TABLE},
7965 {
"TABLESPACE_COMMENT", 2048, MYSQL_TYPE_STRING, 0, MY_I_S_MAYBE_NULL, 0,
7967 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
7983 {
"CHARACTER_SETS", charsets_fields_info, create_schema_table,
7984 fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0, 0},
7985 {
"COLLATIONS", collation_fields_info, create_schema_table,
7986 fill_schema_collation, make_old_format, 0, -1, -1, 0, 0},
7987 {
"COLLATION_CHARACTER_SET_APPLICABILITY", coll_charset_app_fields_info,
7988 create_schema_table, fill_schema_coll_charset_app, 0, 0, -1, -1, 0, 0},
7989 {
"COLUMNS", columns_fields_info, create_schema_table,
7990 get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0,
7991 OPTIMIZE_I_S_TABLE|OPEN_VIEW_FULL},
7992 {
"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table,
7993 fill_schema_column_privileges, 0, 0, -1, -1, 0, 0},
7994 {
"ENGINES", engines_fields_info, create_schema_table,
7995 fill_schema_engines, make_old_format, 0, -1, -1, 0, 0},
7996 #ifdef HAVE_EVENT_SCHEDULER
7997 {
"EVENTS", events_fields_info, create_schema_table,
7999 #else // for alignment with enum_schema_tables
8000 {
"EVENTS", events_fields_info, create_schema_table,
8001 0, make_old_format, 0, -1, -1, 0, 0},
8003 {
"FILES", files_fields_info, create_schema_table,
8004 hton_fill_schema_table, 0, 0, -1, -1, 0, 0},
8005 {
"GLOBAL_STATUS", variables_fields_info, create_schema_table,
8006 fill_status, make_old_format, 0, 0, -1, 0, 0},
8007 {
"GLOBAL_VARIABLES", variables_fields_info, create_schema_table,
8008 fill_variables, make_old_format, 0, 0, -1, 0, 0},
8009 {
"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
8010 get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0,
8011 OPTIMIZE_I_S_TABLE|OPEN_TABLE_ONLY},
8012 {
"OPEN_TABLES", open_tables_fields_info, create_schema_table,
8013 fill_open_tables, make_old_format, 0, -1, -1, 1, 0},
8014 #ifdef OPTIMIZER_TRACE
8016 fill_optimizer_trace_info, NULL, NULL, -1, -1,
false, 0},
8017 #else // for alignment with enum_schema_tables
8019 NULL, NULL, NULL, -1, -1,
false, 0},
8021 {
"PARAMETERS", parameters_fields_info, create_schema_table,
8022 fill_schema_proc, 0, 0, -1, -1, 0, 0},
8023 {
"PARTITIONS", partitions_fields_info, create_schema_table,
8024 get_all_tables, 0, get_schema_partitions_record, 1, 2, 0,
8025 OPTIMIZE_I_S_TABLE|OPEN_TABLE_ONLY},
8026 {
"PLUGINS", plugin_fields_info, create_schema_table,
8027 fill_plugins, make_old_format, 0, -1, -1, 0, 0},
8028 {
"PROCESSLIST", processlist_fields_info, create_schema_table,
8029 fill_schema_processlist, make_old_format, 0, -1, -1, 0, 0},
8030 {
"PROFILING", query_profile_statistics_info, create_schema_table,
8032 NULL, -1, -1,
false, 0},
8033 {
"REFERENTIAL_CONSTRAINTS", referential_constraints_fields_info,
8034 create_schema_table, get_all_tables, 0, get_referential_constraints_record,
8035 1, 9, 0, OPTIMIZE_I_S_TABLE|OPEN_TABLE_ONLY},
8036 {
"ROUTINES", proc_fields_info, create_schema_table,
8037 fill_schema_proc, make_proc_old_format, 0, -1, -1, 0, 0},
8038 {
"SCHEMATA", schema_fields_info, create_schema_table,
8039 fill_schema_schemata, make_schemata_old_format, 0, 1, -1, 0, 0},
8040 {
"SCHEMA_PRIVILEGES", schema_privileges_fields_info, create_schema_table,
8041 fill_schema_schema_privileges, 0, 0, -1, -1, 0, 0},
8042 {
"SESSION_STATUS", variables_fields_info, create_schema_table,
8043 fill_status, make_old_format, 0, 0, -1, 0, 0},
8044 {
"SESSION_VARIABLES", variables_fields_info, create_schema_table,
8045 fill_variables, make_old_format, 0, 0, -1, 0, 0},
8046 {
"STATISTICS", stat_fields_info, create_schema_table,
8047 get_all_tables, make_old_format, get_schema_stat_record, 1, 2, 0,
8048 OPEN_TABLE_ONLY|OPTIMIZE_I_S_TABLE},
8049 {
"STATUS", variables_fields_info, create_schema_table, fill_status,
8050 make_old_format, 0, 0, -1, 1, 0},
8051 {
"TABLES", tables_fields_info, create_schema_table,
8052 get_all_tables, make_old_format, get_schema_tables_record, 1, 2, 0,
8053 OPTIMIZE_I_S_TABLE},
8054 {
"TABLESPACES", tablespaces_fields_info, create_schema_table,
8055 hton_fill_schema_table, 0, 0, -1, -1, 0, 0},
8056 {
"TABLE_CONSTRAINTS", table_constraints_fields_info, create_schema_table,
8057 get_all_tables, 0, get_schema_constraints_record, 3, 4, 0,
8058 OPTIMIZE_I_S_TABLE|OPEN_TABLE_ONLY},
8059 {
"TABLE_NAMES", table_names_fields_info, create_schema_table,
8060 get_all_tables, make_table_names_old_format, 0, 1, 2, 1, 0},
8061 {
"TABLE_PRIVILEGES", table_privileges_fields_info, create_schema_table,
8062 fill_schema_table_privileges, 0, 0, -1, -1, 0, 0},
8063 {
"TRIGGERS", triggers_fields_info, create_schema_table,
8064 get_all_tables, make_old_format, get_schema_triggers_record, 5, 6, 0,
8065 OPEN_TRIGGER_ONLY|OPTIMIZE_I_S_TABLE},
8066 {
"USER_PRIVILEGES", user_privileges_fields_info, create_schema_table,
8067 fill_schema_user_privileges, 0, 0, -1, -1, 0, 0},
8068 {
"VARIABLES", variables_fields_info, create_schema_table, fill_variables,
8069 make_old_format, 0, 0, -1, 1, 0},
8070 {
"VIEWS", view_fields_info, create_schema_table,
8071 get_all_tables, 0, get_schema_views_record, 1, 2, 0,
8072 OPEN_VIEW_ONLY|OPTIMIZE_I_S_TABLE},
8073 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
8080 DBUG_ENTER(
"initialize_schema_table");
8083 MYF(MY_WME | MY_ZEROFILL))))
8086 plugin->data= schema_table;
8087 if (plugin->plugin->init)
8089 schema_table->create_table= create_schema_table;
8090 schema_table->old_format= make_old_format;
8091 schema_table->idx_field1= -1,
8092 schema_table->idx_field2= -1;
8095 schema_table->table_name= plugin->name.str;
8097 if (plugin->plugin->init(schema_table))
8099 sql_print_error(
"Plugin '%s' init function returned error.",
8102 my_free(schema_table);
8107 schema_table->table_name= plugin->name.str;
8115 DBUG_ENTER(
"finalize_schema_table");
8119 if (plugin->plugin->deinit)
8121 DBUG_PRINT(
"info", (
"Deinitializing plugin: '%s'", plugin->name.str));
8122 if (plugin->plugin->deinit(NULL))
8124 DBUG_PRINT(
"warning", (
"Plugin '%s' deinit function returned error.",
8128 my_free(schema_table);
8146 static bool show_create_trigger_impl(THD *thd,
8156 sql_mode_t trg_sql_mode;
8181 &trg_sql_original_stmt,
8182 &trg_client_cs_name,
8183 &trg_connection_cl_name,
8186 sql_mode_string_representation(thd, trg_sql_mode, &trg_sql_mode_str);
8190 if (resolve_charset(trg_client_cs_name.str, NULL, &trg_client_cs))
8206 max<size_t>(trg_sql_original_stmt.length, 1024));
8208 stmt_fld->maybe_null= TRUE;
8210 fields.push_back(stmt_fld);
8227 p->prepare_for_resend();
8229 p->
store(trg_name.str,
8231 system_charset_info);
8233 p->
store(trg_sql_mode_str.str,
8234 trg_sql_mode_str.length,
8235 system_charset_info);
8237 p->
store(trg_sql_original_stmt.str,
8238 trg_sql_original_stmt.length,
8241 p->
store(trg_client_cs_name.str,
8242 trg_client_cs_name.length,
8243 system_charset_info);
8245 p->
store(trg_connection_cl_name.str,
8246 trg_connection_cl_name.length,
8247 system_charset_info);
8249 p->
store(trg_db_cl_name.str,
8250 trg_db_cl_name.length,
8251 system_charset_info);
8253 ret_code= p->write();
8258 return ret_code != 0;
8289 char trn_path_buff[FN_REFLEN];
8295 build_trn_path(thd, trg_name, &trn_path);
8297 if (check_trn_exists(&trn_path))
8299 my_error(ER_TRG_DOES_NOT_EXIST, MYF(0));
8303 if (load_table_name_for_trigger(thd, trg_name, &trn_path, &tbl_name))
8312 db.str= thd->strmake(db.str, db.length);
8313 tbl_name.str= thd->strmake(tbl_name.str, tbl_name.length);
8315 if (db.str == NULL || tbl_name.str == NULL)
8318 table->
init_one_table(db.str, db.length, tbl_name.str, tbl_name.length,
8319 tbl_name.str, TL_IGNORE);
8336 bool show_create_trigger(THD *thd,
const sp_name *trg_name)
8338 TABLE_LIST *lst= get_trigger_table(thd, trg_name);
8349 my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0),
"TRIGGER");
8357 MDL_savepoint mdl_savepoint= thd->mdl_context.mdl_savepoint();
8363 MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL))
8365 my_error(ER_TRG_CANT_OPEN_TABLE, MYF(0),
8366 (
const char *) trg_name->m_db.str,
8367 (
const char *) lst->table_name);
8374 triggers= lst->table->triggers;
8378 my_error(ER_TRG_DOES_NOT_EXIST, MYF(0));
8382 trigger_idx= triggers->find_trigger_by_name(&trg_name->m_name);
8384 if (trigger_idx < 0)
8386 my_error(ER_TRG_CORRUPTED_FILE, MYF(0),
8387 (
const char *) trg_name->m_db.str,
8388 (
const char *) lst->table_name);
8393 error= show_create_trigger_impl(thd, triggers, trigger_idx);
8402 close_thread_tables(thd);
8404 thd->mdl_context.rollback_to_savepoint(mdl_savepoint);
8417 ACL_internal_access_result
check(ulong want_access,
8418 ulong *save_priv)
const;
8423 ACL_internal_access_result
8425 ulong *save_priv)
const
8427 want_access &= ~SELECT_ACL;
8433 if (unlikely(want_access & DB_ACLS))
8434 return ACL_INTERNAL_ACCESS_DENIED;
8437 *save_priv|= SELECT_ACL;
8439 return want_access ? ACL_INTERNAL_ACCESS_CHECK_GRANT :
8440 ACL_INTERNAL_ACCESS_GRANTED;
8452 void initialize_information_schema_acl()
8455 &is_internal_schema_access);
8458 #ifdef WITH_PARTITION_STORAGE_ENGINE
8489 static void get_cs_converted_string_value(THD *thd,
8496 output_str->length(0);
8497 if (input_str->length() == 0)
8499 output_str->append(
"''");
8505 uint try_conv_error= 0;
8507 try_val.copy(input_str->ptr(), input_str->length(), cs,
8508 thd->variables.character_set_client, &try_conv_error);
8509 if (!try_conv_error)
8514 val.copy(input_str->ptr(), input_str->length(), cs,
8515 system_charset_info, &conv_error);
8518 append_unescaped(output_str, val.ptr(), val.length());
8529 output_str->append(
"_");
8530 output_str->append(cs->csname);
8531 output_str->append(
" ");
8532 output_str->append(
"0x");
8533 len= input_str->length();
8534 ptr= (uchar*)input_str->ptr();
8535 for (i= 0; i < len; i++)
8541 buf[0]= _dig_vec_upper[high];
8542 buf[1]= _dig_vec_upper[low];
8544 output_str->append((
const char*)buf);