The world's most popular open source database
#include "mysql_priv.h"#include "sql_select.h"#include "sql_show.h"#include "repl_failsafe.h"#include "sp.h"#include "sp_head.h"#include "sql_trigger.h"#include "authors.h"#include "contributors.h"#include "events.h"#include "event_timed.h"#include <my_dir.h>Include dependency graph for sql_show.cc:

Go to the source code of this file.
| #define LIST_PROCESS_HOST_LEN 64 |
Definition at line 985 of file sql_show.cc.
Referenced by fill_schema_processlist(), and mysqld_list_processes().
| typedef struct st_index_field_values INDEX_FIELD_VALUES |
Definition at line 37 of file sql_show.cc.
00038 { 00039 ISE_EVENT_CATALOG= 0, 00040 ISE_EVENT_SCHEMA, 00041 ISE_EVENT_NAME, 00042 ISE_DEFINER, 00043 ISE_EVENT_BODY, 00044 ISE_EVENT_DEFINITION, 00045 ISE_EVENT_TYPE, 00046 ISE_EXECUTE_AT, 00047 ISE_INTERVAL_VALUE, 00048 ISE_INTERVAL_FIELD, 00049 ISE_SQL_MODE, 00050 ISE_STARTS, 00051 ISE_ENDS, 00052 ISE_STATUS, 00053 ISE_ON_COMPLETION, 00054 ISE_CREATED, 00055 ISE_LAST_ALTERED, 00056 ISE_LAST_EXECUTED, 00057 ISE_EVENT_COMMENT 00058 };
| enum find_files_result |
Definition at line 477 of file sql_show.cc.
00477 { 00478 FIND_FILES_OK, 00479 FIND_FILES_OOM, 00480 FIND_FILES_DIR 00481 };
| int add_status_vars | ( | SHOW_VAR * | list | ) |
Definition at line 1886 of file sql_show.cc.
References all_status_vars, st_dynamic_array::buffer, st_dynamic_array::elements, err, insert_dynamic(), list(), LOCK_status, my_init_dynamic_array, pthread_mutex_lock, pthread_mutex_unlock, show_var_cmp(), and sort_dynamic.
Referenced by init_common_variables(), and plugin_add().
01887 { 01888 int res= 0; 01889 if (status_vars_inited) 01890 pthread_mutex_lock(&LOCK_status); 01891 if (!all_status_vars.buffer && // array is not allocated yet - do it now 01892 my_init_dynamic_array(&all_status_vars, sizeof(SHOW_VAR), 200, 20)) 01893 { 01894 res= 1; 01895 goto err; 01896 } 01897 while (list->name) 01898 res|= insert_dynamic(&all_status_vars, (gptr)list++); 01899 res|= insert_dynamic(&all_status_vars, (gptr)list); // appending NULL-element 01900 all_status_vars.elements--; // but next insert_dynamic should overwite it 01901 if (status_vars_inited) 01902 sort_dynamic(&all_status_vars, show_var_cmp); 01903 err: 01904 if (status_vars_inited) 01905 pthread_mutex_unlock(&LOCK_status); 01906 return res; 01907 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void append_algorithm | ( | TABLE_LIST * | table, | |
| String * | buff | |||
| ) | [static] |
Definition at line 1469 of file sql_show.cc.
References st_table_list::algorithm, String::append(), DBUG_ASSERT, STRING_WITH_LEN, VIEW_ALGORITHM_MERGE, VIEW_ALGORITHM_TMPTABLE, and VIEW_ALGORITHM_UNDEFINED.
Referenced by get_schema_views_record(), and view_store_options().
01470 { 01471 buff->append(STRING_WITH_LEN("ALGORITHM=")); 01472 switch ((int8)table->algorithm) { 01473 case VIEW_ALGORITHM_UNDEFINED: 01474 buff->append(STRING_WITH_LEN("UNDEFINED ")); 01475 break; 01476 case VIEW_ALGORITHM_TMPTABLE: 01477 buff->append(STRING_WITH_LEN("TEMPTABLE ")); 01478 break; 01479 case VIEW_ALGORITHM_MERGE: 01480 buff->append(STRING_WITH_LEN("MERGE ")); 01481 break; 01482 default: 01483 DBUG_ASSERT(0); // never should happen 01484 } 01485 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void append_definer | ( | THD * | thd, | |
| String * | buffer, | |||
| const LEX_STRING * | definer_user, | |||
| const LEX_STRING * | definer_host | |||
| ) |
Definition at line 1498 of file sql_show.cc.
References append_identifier(), buffer, LEX_STRING::length, LEX_STRING::str, and STRING_WITH_LEN.
Referenced by create_string(), db_create_routine(), mysql_create_or_drop_trigger(), and view_store_options().
01500 { 01501 buffer->append(STRING_WITH_LEN("DEFINER=")); 01502 append_identifier(thd, buffer, definer_user->str, definer_user->length); 01503 buffer->append('@'); 01504 append_identifier(thd, buffer, definer_host->str, definer_host->length); 01505 buffer->append(' '); 01506 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void append_directory | ( | THD * | thd, | |
| String * | packet, | |||
| const char * | dir_type, | |||
| const char * | filename | |||
| ) | [static] |
Definition at line 959 of file sql_show.cc.
References String::append(), dirname_length(), MODE_NO_DIR_IN_CREATE, pos(), and STRING_WITH_LEN.
Referenced by store_create_info().
00961 { 00962 if (filename && !(thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE)) 00963 { 00964 uint length= dirname_length(filename); 00965 packet->append(' '); 00966 packet->append(dir_type); 00967 packet->append(STRING_WITH_LEN(" DIRECTORY='")); 00968 #ifdef __WIN__ 00969 /* Convert \ to / to be able to create table on unix */ 00970 char *winfilename= (char*) thd->memdup(filename, length); 00971 char *pos, *end; 00972 for (pos= winfilename, end= pos+length ; pos < end ; pos++) 00973 { 00974 if (*pos == '\\') 00975 *pos = '/'; 00976 } 00977 filename= winfilename; 00978 #endif 00979 packet->append(filename, length); 00980 packet->append('\''); 00981 } 00982 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 879 of file sql_show.cc.
References String::append(), String::charset(), get_quote_char_for_identifier(), my_mbcharlen, String::reserve(), system_charset_info, and VOID.
Referenced by ha_myisammrg::append_create_info(), append_definer(), Table_triggers_list::change_table_name_in_triggers(), close_temporary_tables(), create_string(), evex_print_warnings(), sp_head::execute_function(), Item_func_sp::func_name(), Event_timed::get_create_event(), mysql_execute_command(), mysql_show_grants(), mysqld_show_create_db(), st_table_list::print(), Item_ref::print(), Item_ident::print(), Item::print_item_w_name(), show_routine_grants(), and store_create_info().
00880 { 00881 const char *name_end; 00882 char quote_char; 00883 int q= get_quote_char_for_identifier(thd, name, length); 00884 00885 if (q == EOF) 00886 { 00887 packet->append(name, length, system_charset_info); 00888 return; 00889 } 00890 00891 /* 00892 The identifier must be quoted as it includes a quote character or 00893 it's a keyword 00894 */ 00895 00896 VOID(packet->reserve(length*2 + 2)); 00897 quote_char= (char) q; 00898 packet->append("e_char, 1, system_charset_info); 00899 00900 for (name_end= name+length ; name < name_end ; name+= length) 00901 { 00902 uchar chr= (uchar) *name; 00903 length= my_mbcharlen(system_charset_info, chr); 00904 /* 00905 my_mbcharlen can retur 0 on a wrong multibyte 00906 sequence. It is possible when upgrading from 4.0, 00907 and identifier contains some accented characters. 00908 The manual says it does not work. So we'll just 00909 change length to 1 not to hang in the endless loop. 00910 */ 00911 if (!length) 00912 length= 1; 00913 if (length == 1 && chr == (uchar) quote_char) 00914 packet->append("e_char, 1, system_charset_info); 00915 packet->append(name, length, packet->charset()); 00916 } 00917 packet->append("e_char, 1, system_charset_info); 00918 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void calc_sum_of_all_status | ( | STATUS_VAR * | to | ) |
Definition at line 2137 of file sql_show.cc.
References add_to_status(), DBUG_ENTER, DBUG_VOID_RETURN, global_status_var, LOCK_thread_count, pthread_mutex_lock, pthread_mutex_unlock, threads, to, and VOID.
Referenced by dispatch_command(), fill_status(), and mysql_print_status().
02138 { 02139 DBUG_ENTER("calc_sum_of_all_status"); 02140 02141 /* Ensure that thread id not killed during loop */ 02142 VOID(pthread_mutex_lock(&LOCK_thread_count)); // For unlink from list 02143 02144 I_List_iterator<THD> it(threads); 02145 THD *tmp; 02146 02147 /* Get global values as base */ 02148 *to= global_status_var; 02149 02150 /* Add to this status from existing threads */ 02151 while ((tmp= it++)) 02152 add_to_status(to, &tmp->status_var); 02153 02154 VOID(pthread_mutex_unlock(&LOCK_thread_count)); 02155 DBUG_VOID_RETURN; 02156 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3873 of file sql_show.cc.
References String::append(), base_list::elements, and String::length().
Referenced by get_schema_partitions_record().
03874 { 03875 List_iterator<char> part_it(field_list); 03876 ulong no_fields= field_list.elements; 03877 const char *field_str; 03878 str->length(0); 03879 while ((field_str= part_it++)) 03880 { 03881 str->append(field_str); 03882 if (--no_fields != 0) 03883 str->append(","); 03884 } 03885 return; 03886 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static int copy_event_to_schema_table | ( | THD * | thd, | |
| TABLE * | sch_table, | |||
| TABLE * | event_table | |||
| ) | [static] |
Definition at line 4221 of file sql_show.cc.
References Event_timed::body, check_access(), Event_timed::comment, Event_timed::created, Event_timed::dbname, DBUG_ASSERT, DBUG_ENTER, DBUG_RETURN, Event_timed::definer, Event_timed::ENABLED, Event_timed::ends, Event_timed::ends_null, ER_CANNOT_LOAD_FROM_TABLE, EVENT_ACL, Event_timed::execute_at, Event_timed::expression, st_table::field, Event_timed::interval, interval_type_to_name, ISE_CREATED, ISE_DEFINER, ISE_ENDS, ISE_EVENT_BODY, ISE_EVENT_COMMENT, ISE_EVENT_DEFINITION, ISE_EVENT_NAME, ISE_EVENT_SCHEMA, ISE_EVENT_TYPE, ISE_EXECUTE_AT, ISE_INTERVAL_FIELD, ISE_INTERVAL_VALUE, ISE_LAST_ALTERED, ISE_LAST_EXECUTED, ISE_ON_COMPLETION, ISE_SQL_MODE, ISE_STARTS, ISE_STATUS, Event_timed::last_executed, LEX_STRING::length, Event_timed::load_from_row(), Event_timed::modified, my_error(), MYF, MYSQL_TIMESTAMP_DATETIME, Event_timed::name, NullS, number_to_datetime(), Event_timed::on_completion, Event_timed::ON_COMPLETION_DROP, Events::reconstruct_interval_expression(), restore_record, schema_table_store_record(), Field::set_notnull(), Event_timed::sql_mode, sql_mode_str, SQLCOM_SHOW_EVENTS, Event_timed::starts, Event_timed::status, Field::store(), Field::store_time(), LEX_STRING::str, STRING_WITH_LEN, sys_var_thd_sql_mode::symbolic_mode_representation(), system_charset_info, wild_compare(), and st_mysql_time::year.
Referenced by events_table_index_read_for_db(), and events_table_scan_all().
04222 { 04223 const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS; 04224 CHARSET_INFO *scs= system_charset_info; 04225 TIME time; 04226 Event_timed et; 04227 DBUG_ENTER("fill_events_copy_to_schema_tab"); 04228 04229 restore_record(sch_table, s->default_values); 04230 04231 if (et.load_from_row(thd->mem_root, event_table)) 04232 { 04233 my_error(ER_CANNOT_LOAD_FROM_TABLE, MYF(0)); 04234 DBUG_RETURN(1); 04235 } 04236 04237 if (!(!wild || !wild[0] || !wild_compare(et.name.str, wild, 0))) 04238 DBUG_RETURN(0); 04239 04240 /* 04241 Skip events in schemas one does not have access to. The check is 04242 optimized. It's guaranteed in case of SHOW EVENTS that the user 04243 has access. 04244 */ 04245 if (thd->lex->sql_command != SQLCOM_SHOW_EVENTS && 04246 check_access(thd, EVENT_ACL, et.dbname.str, 0, 0, 1, 04247 is_schema_db(et.dbname.str))) 04248 DBUG_RETURN(0); 04249 04250 /* ->field[0] is EVENT_CATALOG and is by default NULL */ 04251 04252 sch_table->field[ISE_EVENT_SCHEMA]-> 04253 store(et.dbname.str, et.dbname.length,scs); 04254 sch_table->field[ISE_EVENT_NAME]-> 04255 store(et.name.str, et.name.length, scs); 04256 sch_table->field[ISE_DEFINER]-> 04257 store(et.definer.str, et.definer.length, scs); 04258 sch_table->field[ISE_EVENT_BODY]-> 04259 store(STRING_WITH_LEN("SQL"), scs); 04260 sch_table->field[ISE_EVENT_DEFINITION]-> 04261 store(et.body.str, et.body.length, scs); 04262 04263 /* SQL_MODE */ 04264 { 04265 byte *sql_mode_str; 04266 ulong sql_mode_len= 0; 04267 sql_mode_str= 04268 sys_var_thd_sql_mode::symbolic_mode_representation(thd, et.sql_mode, 04269 &sql_mode_len); 04270 sch_table->field[ISE_SQL_MODE]-> 04271 store((const char*)sql_mode_str, sql_mode_len, scs); 04272 } 04273 04274 if (et.expression) 04275 { 04276 String show_str; 04277 /* type */ 04278 sch_table->field[ISE_EVENT_TYPE]->store(STRING_WITH_LEN("RECURRING"), scs); 04279 04280 if (Events::reconstruct_interval_expression(&show_str, et.interval, 04281 et.expression)) 04282 DBUG_RETURN(1); 04283 04284 sch_table->field[ISE_INTERVAL_VALUE]->set_notnull(); 04285 sch_table->field[ISE_INTERVAL_VALUE]-> 04286 store(show_str.ptr(), show_str.length(), scs); 04287 04288 LEX_STRING *ival= &interval_type_to_name[et.interval]; 04289 sch_table->field[ISE_INTERVAL_FIELD]->set_notnull(); 04290 sch_table->field[ISE_INTERVAL_FIELD]->store(ival->str, ival->length, scs); 04291 04292 /* starts & ends . STARTS is always set - see sql_yacc.yy */ 04293 sch_table->field[ISE_STARTS]->set_notnull(); 04294 sch_table->field[ISE_STARTS]-> 04295 store_time(&et.starts, MYSQL_TIMESTAMP_DATETIME); 04296 04297 if (!et.ends_null) 04298 { 04299 sch_table->field[ISE_ENDS]->set_notnull(); 04300 sch_table->field[ISE_ENDS]-> 04301 store_time(&et.ends, MYSQL_TIMESTAMP_DATETIME); 04302 } 04303 } 04304 else 04305 { 04306 /* type */ 04307 sch_table->field[ISE_EVENT_TYPE]->store(STRING_WITH_LEN("ONE TIME"), scs); 04308 04309 sch_table->field[ISE_EXECUTE_AT]->set_notnull(); 04310 sch_table->field[ISE_EXECUTE_AT]-> 04311 store_time(&et.execute_at, MYSQL_TIMESTAMP_DATETIME); 04312 } 04313 04314 /* status */ 04315 if (et.status == Event_timed::ENABLED) 04316 sch_table->field[ISE_STATUS]->store(STRING_WITH_LEN("ENABLED"), scs); 04317 else 04318 sch_table->field[ISE_STATUS]->store(STRING_WITH_LEN("DISABLED"), scs); 04319 04320 /* on_completion */ 04321 if (et.on_completion == Event_timed::ON_COMPLETION_DROP) 04322 sch_table->field[ISE_ON_COMPLETION]-> 04323 store(STRING_WITH_LEN("NOT PRESERVE"), scs); 04324 else 04325 sch_table->field[ISE_ON_COMPLETION]-> 04326 store(STRING_WITH_LEN("PRESERVE"), scs); 04327 04328 int not_used=0; 04329 number_to_datetime(et.created, &time, 0, ¬_used); 04330 DBUG_ASSERT(not_used==0); 04331 sch_table->field[ISE_CREATED]->store_time(&time, MYSQL_TIMESTAMP_DATETIME); 04332 04333 number_to_datetime(et.modified, &time, 0, ¬_used); 04334 DBUG_ASSERT(not_used==0); 04335 sch_table->field[ISE_LAST_ALTERED]-> 04336 store_time(&time, MYSQL_TIMESTAMP_DATETIME); 04337 04338 if (et.last_executed.year) 04339 { 04340 sch_table->field[ISE_LAST_EXECUTED]->set_notnull(); 04341 sch_table->field[ISE_LAST_EXECUTED]-> 04342 store_time(&et.last_executed, MYSQL_TIMESTAMP_DATETIME); 04343 } 04344 04345 sch_table->field[ISE_EVENT_COMMENT]-> 04346 store(et.comment.str, et.comment.length, scs); 04347 04348 if (schema_table_store_record(thd, sch_table)) 04349 DBUG_RETURN(1); 04350 04351 DBUG_RETURN(0); 04352 }
Here is the call graph for this function:

Here is the caller graph for this function:

| TABLE* create_schema_table | ( | THD * | thd, | |
| TABLE_LIST * | table_list | |||
| ) |
Definition at line 4706 of file sql_show.cc.
References DBUG_ENTER, DBUG_RETURN, st_field_info::field_length, st_field_info::field_name, st_field_info::field_type, st_schema_table::fields_info, MYSQL_TYPE_LONG, MYSQL_TYPE_TIMESTAMP, st_table_list::schema_table, system_charset_info, and st_field_info::value.
04707 { 04708 int field_count= 0; 04709 Item *item; 04710 TABLE *table; 04711 List<Item> field_list; 04712 ST_SCHEMA_TABLE *schema_table= table_list->schema_table; 04713 ST_FIELD_INFO *fields_info= schema_table->fields_info; 04714 CHARSET_INFO *cs= system_charset_info; 04715 DBUG_ENTER("create_schema_table"); 04716 04717 for (; fields_info->field_name; fields_info++) 04718 { 04719 switch (fields_info->field_type) { 04720 case MYSQL_TYPE_LONG: 04721 if (!(item= new Item_int(fields_info->field_name, 04722 fields_info->value, 04723 fields_info->field_length))) 04724 { 04725 DBUG_RETURN(0); 04726 } 04727 break; 04728 case MYSQL_TYPE_TIMESTAMP: 04729 if (!(item=new Item_datetime(fields_info->field_name))) 04730 { 04731 DBUG_RETURN(0); 04732 } 04733 break; 04734 default: 04735 /* this should be changed when Item_empty_string is fixed(in 4.1) */ 04736 if (!(item= new Item_empty_string("", 0, cs))) 04737 { 04738 DBUG_RETURN(0); 04739 } 04740 item->max_length= fields_info->field_length * cs->mbmaxlen; 04741 item->set_name(fields_info->field_name, 04742 strlen(fields_info->field_name), cs); 04743 break; 04744 } 04745 field_list.push_back(item); 04746 item->maybe_null= fields_info->maybe_null; 04747 field_count++; 04748 } 04749 TMP_TABLE_PARAM *tmp_table_param = 04750 (TMP_TABLE_PARAM*) (thd->alloc(sizeof(TMP_TABLE_PARAM))); 04751 tmp_table_param->init(); 04752 tmp_table_param->table_charset= cs; 04753 tmp_table_param->field_count= field_count; 04754 tmp_table_param->schema_table= 1; 04755 SELECT_LEX *select_lex= thd->lex->current_select; 04756 if (!(table= create_tmp_table(thd, tmp_table_param, 04757 field_list, (ORDER*) 0, 0, 0, 04758 (select_lex->options | thd->options | 04759 TMP_TABLE_ALL_COLUMNS), 04760 HA_POS_ERROR, table_list->alias))) 04761 DBUG_RETURN(0); 04762 table_list->schema_table_param= tmp_table_param; 04763 DBUG_RETURN(table); 04764 }
| static int events_table_index_read_for_db | ( | THD * | thd, | |
| TABLE * | schema_table, | |||
| TABLE * | event_table | |||
| ) | [static] |
Definition at line 4370 of file sql_show.cc.
References alloc_root(), copy_event_to_schema_table(), DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, st_table::field, Events::FIELD_DB, st_table::file, HA_ERR_END_OF_FILE, HA_ERR_KEY_NOT_FOUND, handler::ha_index_end(), handler::ha_index_init(), HA_READ_PREFIX, handler::index_next_same(), handler::index_read(), key_copy(), st_table::key_info, st_key::key_part, LINT_INIT, NULL, st_table::record, st_key_part_info::store_length, strlen(), and system_charset_info.
Referenced by fill_schema_events().
04372 { 04373 int ret=0; 04374 CHARSET_INFO *scs= system_charset_info; 04375 KEY *key_info; 04376 uint key_len; 04377 byte *key_buf= NULL; 04378 LINT_INIT(key_buf); 04379 04380 DBUG_ENTER("schema_events_do_index_scan"); 04381 04382 DBUG_PRINT("info", ("Using prefix scanning on PK")); 04383 event_table->file->ha_index_init(0, 1); 04384 event_table->field[Events::FIELD_DB]-> 04385 store(thd->lex->select_lex.db, strlen(thd->lex->select_lex.db), scs); 04386 key_info= event_table->key_info; 04387 key_len= key_info->key_part[0].store_length; 04388 04389 if (!(key_buf= (byte *)alloc_root(thd->mem_root, key_len))) 04390 { 04391 ret= 1; 04392 /* don't send error, it would be done by sql_alloc_error_handler() */ 04393 } 04394 else 04395 { 04396 key_copy(key_buf, event_table->record[0], key_info, key_len); 04397 if (!(ret= event_table->file->index_read(event_table->record[0], key_buf, 04398 key_len, HA_READ_PREFIX))) 04399 { 04400 DBUG_PRINT("info",("Found rows. Let's retrieve them. ret=%d", ret)); 04401 do 04402 { 04403 ret= copy_event_to_schema_table(thd, schema_table, event_table); 04404 if (ret == 0) 04405 ret= event_table->file->index_next_same(event_table->record[0], 04406 key_buf, key_len); 04407 } while (ret == 0); 04408 } 04409 DBUG_PRINT("info", ("Scan finished. ret=%d", ret)); 04410 } 04411 event_table->file->ha_index_end(); 04412 /* ret is guaranteed to be != 0 */ 04413 if (ret == HA_ERR_END_OF_FILE || ret == HA_ERR_KEY_NOT_FOUND) 04414 DBUG_RETURN(0); 04415 DBUG_RETURN(1); 04416 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4434 of file sql_show.cc.
References copy_event_to_schema_table(), DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, end_read_record(), init_read_record(), NULL, and st_read_record::read_record.
Referenced by fill_schema_events().
04436 { 04437 int ret; 04438 READ_RECORD read_record_info; 04439 04440 DBUG_ENTER("schema_events_do_table_scan"); 04441 init_read_record(&read_record_info, thd, event_table, NULL, 1, 0); 04442 04443 /* 04444 rr_sequential, in read_record(), returns 137==HA_ERR_END_OF_FILE, 04445 but rr_handle_error returns -1 for that reason. Thus, read_record() 04446 returns -1 eventually. 04447 */ 04448 do 04449 { 04450 ret= read_record_info.read_record(&read_record_info); 04451 if (ret == 0) 04452 ret= copy_event_to_schema_table(thd, schema_table, event_table); 04453 } 04454 while (ret == 0); 04455 04456 DBUG_PRINT("info", ("Scan finished. ret=%d", ret)); 04457 end_read_record(&read_record_info); 04458 04459 /* ret is guaranteed to be != 0 */ 04460 DBUG_RETURN(ret == -1? 0:1); 04461 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int fill_open_tables | ( | THD * | thd, | |
| TABLE_LIST * | tables, | |||
| COND * | cond | |||
| ) |
Definition at line 4532 of file sql_show.cc.
References st_open_table_list::db, DBUG_ENTER, DBUG_RETURN, st_table::field, st_open_table_list::in_use, list_open_tables(), st_open_table_list::locked, st_open_table_list::next, NullS, restore_record, schema_table_store_record(), Field::store(), strlen(), system_charset_info, st_open_table_list::table, st_table_list::table, and TRUE.
04533 { 04534 DBUG_ENTER("fill_open_tables"); 04535 const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS; 04536 TABLE *table= tables->table; 04537 CHARSET_INFO *cs= system_charset_info; 04538 OPEN_TABLE_LIST *open_list; 04539 if (!(open_list=list_open_tables(thd,thd->lex->select_lex.db, wild)) 04540 && thd->is_fatal_error) 04541 DBUG_RETURN(1); 04542 04543 for (; open_list ; open_list=open_list->next) 04544 { 04545 restore_record(table, s->default_values); 04546 table->field[0]->store(open_list->db, strlen(open_list->db), cs); 04547 table->field[1]->store(open_list->table, strlen(open_list->table), cs); 04548 table->field[2]->store((longlong) open_list->in_use, TRUE); 04549 table->field[3]->store((longlong) open_list->locked, TRUE); 04550 if (schema_table_store_record(thd, table)) 04551 DBUG_RETURN(1); 04552 } 04553 DBUG_RETURN(0); 04554 }
Here is the call graph for this function:

| int fill_plugins | ( | THD * | thd, | |
| TABLE_LIST * | tables, | |||
| COND * | cond | |||
| ) |
Definition at line 218 of file sql_show.cc.
References DBUG_ENTER, DBUG_RETURN, MYSQL_ANY_PLUGIN, plugin_foreach(), show_plugins(), and st_table_list::table.
00219 { 00220 DBUG_ENTER("fill_plugins"); 00221 TABLE *table= tables->table; 00222 00223 if (plugin_foreach(thd, show_plugins, MYSQL_ANY_PLUGIN, table)) 00224 DBUG_RETURN(1); 00225 00226 DBUG_RETURN(0); 00227 }
Here is the call graph for this function:

| int fill_schema_charsets | ( | THD * | thd, | |
| TABLE_LIST * | tables, | |||
| COND * | cond | |||
| ) |
Definition at line 3170 of file sql_show.cc.
References all_charsets, comment, charset_info_st::csname, MY_CS_AVAILABLE, MY_CS_HIDDEN, MY_CS_PRIMARY, NullS, restore_record, schema_table_store_record(), strlen(), system_charset_info, st_table_list::table, TRUE, and wild_case_compare().
03171 { 03172 CHARSET_INFO **cs; 03173 const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS; 03174 TABLE *table= tables->table; 03175 CHARSET_INFO *scs= system_charset_info; 03176 03177 for (cs= all_charsets ; cs < all_charsets+255 ; cs++) 03178 { 03179 CHARSET_INFO *tmp_cs= cs[0]; 03180 if (tmp_cs && (tmp_cs->state & MY_CS_PRIMARY) && 03181 (tmp_cs->state & MY_CS_AVAILABLE) && 03182 !(tmp_cs->state & MY_CS_HIDDEN) && 03183 !(wild && wild[0] && 03184 wild_case_compare(scs, tmp_cs->csname,wild))) 03185 { 03186 const char *comment; 03187 restore_record(table, s->default_values); 03188 table->field[0]->store(tmp_cs->csname, strlen(tmp_cs->csname), scs); 03189 table->field[1]->store(tmp_cs->name, strlen(tmp_cs->name), scs); 03190 comment= tmp_cs->comment ? tmp_cs->comment : ""; 03191 table->field[2]->store(comment, strlen(comment), scs); 03192 table->field[3]->store((longlong) tmp_cs->mbmaxlen, TRUE); 03193 if (schema_table_store_record(thd, table)) 03194 return 1; 03195 } 03196 } 03197 return 0; 03198 }
Here is the call graph for this function:

| int fill_schema_coll_charset_app | ( | THD * | thd, | |
| TABLE_LIST * | tables, | |||
| COND * | cond | |||
| ) |
Definition at line 3291 of file sql_show.cc.
References all_charsets, my_charset_same(), MY_CS_AVAILABLE, MY_CS_PRIMARY, restore_record, schema_table_store_record(), charset_info_st::state, strlen(), system_charset_info, and st_table_list::table.
03292 { 03293 CHARSET_INFO **cs; 03294 TABLE *table= tables->table; 03295 CHARSET_INFO *scs= system_charset_info; 03296 for (cs= all_charsets ; cs < all_charsets+255 ; cs++ ) 03297 { 03298 CHARSET_INFO **cl; 03299 CHARSET_INFO *tmp_cs= cs[0]; 03300 if (!tmp_cs || !(tmp_cs->state & MY_CS_AVAILABLE) || 03301 !(tmp_cs->state & MY_CS_PRIMARY)) 03302 continue; 03303 for (cl= all_charsets; cl < all_charsets+255 ;cl ++) 03304 { 03305 CHARSET_INFO *tmp_cl= cl[0]; 03306 if (!tmp_cl || !(tmp_cl->state & MY_CS_AVAILABLE) || 03307 !my_charset_same(tmp_cs,tmp_cl)) 03308 continue; 03309 restore_record(table, s->default_values); 03310 table->field[0]->store(tmp_cl->name, strlen(tmp_cl->name), scs); 03311 table->field[1]->store(tmp_cl->csname , strlen(tmp_cl->csname), scs); 03312 if (schema_table_store_record(thd, table)) 03313 return 1; 03314 } 03315 } 03316 return 0; 03317 }
Here is the call graph for this function:

| int fill_schema_collation | ( | THD * | thd, | |
| TABLE_LIST * | tables, | |||
| COND * | cond | |||
| ) |
Definition at line 3249 of file sql_show.cc.
References all_charsets, my_charset_same(), MY_CS_AVAILABLE, MY_CS_COMPILED, MY_CS_HIDDEN, MY_CS_PRIMARY, charset_info_st::name, NullS, restore_record, schema_table_store_record(), charset_info_st::state, strlen(), system_charset_info, st_table_list::table, TRUE, and wild_case_compare().
03250 { 03251 CHARSET_INFO **cs; 03252 const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS; 03253 TABLE *table= tables->table; 03254 CHARSET_INFO *scs= system_charset_info; 03255 for (cs= all_charsets ; cs < all_charsets+255 ; cs++ ) 03256 { 03257 CHARSET_INFO **cl; 03258 CHARSET_INFO *tmp_cs= cs[0]; 03259 if (!tmp_cs || !(tmp_cs->state & MY_CS_AVAILABLE) || 03260 (tmp_cs->state & MY_CS_HIDDEN) || 03261 !(tmp_cs->state & MY_CS_PRIMARY)) 03262 continue; 03263 for (cl= all_charsets; cl < all_charsets+255 ;cl ++) 03264 { 03265 CHARSET_INFO *tmp_cl= cl[0]; 03266 if (!tmp_cl || !(tmp_cl->state & MY_CS_AVAILABLE) || 03267 !my_charset_same(tmp_cs, tmp_cl)) 03268 continue; 03269 if (!(wild && wild[0] && 03270 wild_case_compare(scs, tmp_cl->name,wild))) 03271 { 03272 const char *tmp_buff; 03273 restore_record(table, s->default_values); 03274 table->field[0]->store(tmp_cl->name, strlen(tmp_cl->name), scs); 03275 table->field[1]->store(tmp_cl->csname , strlen(tmp_cl->csname), scs); 03276 table->field[2]->store((longlong) tmp_cl->number, TRUE); 03277 tmp_buff= (tmp_cl->state & MY_CS_PRIMARY) ? "Yes" : ""; 03278 table->field[3]->store(tmp_buff, strlen(tmp_buff), scs); 03279 tmp_buff= (tmp_cl->state & MY_CS_COMPILED)? "Yes" : ""; 03280 table->field[4]->store(tmp_buff, strlen(tmp_buff), scs); 03281 table->field[5]->store((longlong) tmp_cl->strxfrm_multiply, TRUE); 03282 if (schema_table_store_record(thd, table)) 03283 return 1; 03284 } 03285 } 03286 } 03287 return 0; 03288 }
Here is the call graph for this function:

| int fill_schema_engines | ( | THD * | thd, | |
| TABLE_LIST * | tables, | |||
| COND * | cond | |||
| ) |
Definition at line 3242 of file sql_show.cc.
References iter_schema_engines(), MYSQL_STORAGE_ENGINE_PLUGIN, plugin_foreach(), and st_table_list::table.
03243 { 03244 return plugin_foreach(thd, iter_schema_engines, 03245 MYSQL_STORAGE_ENGINE_PLUGIN, tables->table); 03246 }
Here is the call graph for this function:

| int fill_schema_events | ( | THD * | thd, | |
| TABLE_LIST * | tables, | |||
| COND * | ||||
| ) |
Definition at line 4479 of file sql_show.cc.
References backup, check_access(), close_thread_tables(), DBUG_ASSERT, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, EVENT_ACL, events_table_index_read_for_db(), events_table_scan_all(), NULL, Events::open_event_table(), sql_print_error(), SQLCOM_SHOW_EVENTS, st_table_list::table, and TL_READ.
04480 { 04481 TABLE *schema_table= tables->table; 04482 TABLE *event_table= NULL; 04483 Open_tables_state backup; 04484 int ret= 0; 04485 04486 DBUG_ENTER("fill_schema_events"); 04487 /* 04488 If it's SHOW EVENTS then thd->lex->select_lex.db is guaranteed not to 04489 be NULL. Let's do an assert anyway. 04490 */ 04491 if (thd->lex->sql_command == SQLCOM_SHOW_EVENTS) 04492 { 04493 DBUG_ASSERT(thd->lex->select_lex.db); 04494 if (check_access(thd, EVENT_ACL, thd->lex->select_lex.db, 0, 0, 0, 04495 is_schema_db(thd->lex->select_lex.db))) 04496 DBUG_RETURN(1); 04497 } 04498 04499 DBUG_PRINT("info",("db=%s", thd->lex->select_lex.db? 04500 thd->lex->select_lex.db:"(null)")); 04501 04502 thd->reset_n_backup_open_tables_state(&backup); 04503 if (Events::open_event_table(thd, TL_READ, &event_table)) 04504 { 04505 sql_print_error("Table mysql.event is damaged."); 04506 thd->restore_backup_open_tables_state(&backup); 04507 DBUG_RETURN(1); 04508 } 04509 04510 /* 04511 1. SELECT I_S => use table scan. I_S.EVENTS does not guarantee order 04512 thus we won't order it. OTOH, SHOW EVENTS will be 04513 ordered. 04514 2. SHOW EVENTS => PRIMARY KEY with prefix scanning on (db) 04515 Reasoning: Events are per schema, therefore a scan over an index 04516 will save use from doing a table scan and comparing 04517 every single row's `db` with the schema which we show. 04518 */ 04519 if (thd->lex->sql_command == SQLCOM_SHOW_EVENTS) 04520 ret= events_table_index_read_for_db(thd, schema_table, event_table); 04521 else 04522 ret= events_table_scan_all(thd, schema_table, event_table); 04523 04524 close_thread_tables(thd); 04525 thd->restore_backup_open_tables_state(&backup); 04526 04527 DBUG_PRINT("info", ("Return code=%d", ret)); 04528 DBUG_RETURN(ret); 04529 }
Here is the call graph for this function:

| int fill_schema_files | ( | THD * | thd, | |
| TABLE_LIST * | tables, | |||
| COND * | cond | |||
| ) |
Definition at line 5157 of file sql_show.cc.
References args, cond, DBUG_ENTER, DBUG_RETURN, MYSQL_STORAGE_ENGINE_PLUGIN, plugin_foreach(), run_hton_fill_schema_files(), st_table_list::table, and run_hton_fill_schema_files_args::tables.
05158 { 05159 int i; 05160 TABLE *table= tables->table; 05161 DBUG_ENTER("fill_schema_files"); 05162 05163 struct run_hton_fill_schema_files_args args; 05164 args.tables= tables; 05165 args.cond= cond; 05166 05167 plugin_foreach(thd, run_hton_fill_schema_files, 05168 MYSQL_STORAGE_ENGINE_PLUGIN, &args); 05169 05170 DBUG_RETURN(0); 05171 }
Here is the call graph for this function:

| int fill_schema_proc | ( | THD * | thd, | |
| TABLE_LIST * | tables, | |||
| COND * | cond | |||
| ) |
Definition at line 3394 of file sql_show.cc.
References bzero, check_table_access(), close_proc_table(), DBUG_ENTER, DBUG_RETURN, err, st_table::file, HA_ERR_END_OF_FILE, handler::ha_index_end(), handler::ha_index_init(), handler::index_first(), handler::index_next(), NullS, open_proc_table_for_read(), st_table::record, SELECT_ACL, store_schema_proc(), strxmov(), st_table_list::table, TL_READ, and USER_HOST_BUFF_SIZE.
03395 { 03396 TABLE *proc_table; 03397 TABLE_LIST proc_tables; 03398 const char *wild= thd->lex->wild ? thd->lex->wild->ptr() : NullS; 03399 int res= 0; 03400 TABLE *table= tables->table; 03401 bool full_access; 03402 char definer[USER_HOST_BUFF_SIZE]; 03403 Open_tables_state open_tables_state_backup; 03404 DBUG_ENTER("fill_schema_proc"); 03405 03406 strxmov(definer, thd->security_ctx->priv_user, "@", 03407 thd->security_ctx->priv_host, NullS); 03408 /* We use this TABLE_LIST instance only for checking of privileges. */ 03409 bzero((char*) &proc_tables,sizeof(proc_tables)); 03410 proc_tables.db= (char*) "mysql"; 03411 proc_tables.db_length= 5; 03412 proc_tables.table_name= proc_tables.alias= (char*) "proc"; 03413 proc_tables.table_name_length= 4; 03414 proc_tables.lock_type= TL_READ; 03415 full_access= !check_table_access(thd, SELECT_ACL, &proc_tables, 1); 03416 if (!(proc_table= open_proc_table_for_read(thd, &open_tables_state_backup))) 03417 { 03418 DBUG_RETURN(1); 03419 } 03420 proc_table->file->ha_index_init(0, 1); 03421 if ((res= proc_table->file->index_first(proc_table->record[0]))) 03422 { 03423 res= (res == HA_ERR_END_OF_FILE) ? 0 : 1; 03424 goto err; 03425 } 03426 if (store_schema_proc(thd, table, proc_table, wild, full_access, definer)) 03427 { 03428 res= 1; 03429 goto err; 03430 } 03431 while (!proc_table->file->index_next(proc_table->record[0])) 03432 { 03433 if (store_schema_proc(thd, table, proc_table, wild, full_access, definer)) 03434 { 03435 res= 1; 03436 goto err; 03437 } 03438 } 03439 03440 err: 03441 proc_table->file->ha_index_end(); 03442 close_proc_table(thd, &open_tables_state_backup); 03443 DBUG_RETURN(res); 03444 }
Here is the call graph for this function:

| int fill_schema_processlist | ( | THD * | thd, | |
| TABLE_LIST * | tables, | |||
| COND * | cond | |||
| ) |
Definition at line 1725 of file sql_show.cc.
References COM_SLEEP, command_name, DBUG_ENTER, DBUG_RETURN, host, KILL_CONNECTION, LEX_STRING::length, LIST_PROCESS_HOST_LEN, LOCK_thread_count, min, st_my_thread_var::mutex, my_snprintf(), NullS, PROCESS_ACL, PROCESS_LIST_INFO_WIDTH, pthread_mutex_lock, pthread_mutex_unlock, restore_record, schema_table_store_record(), LEX_STRING::str, strcmp(), strlen(), system_charset_info, st_table_list::table, threads, TRUE, user, and VOID.
01726 { 01727 TABLE *table= tables->table; 01728 CHARSET_INFO *cs= system_charset_info; 01729 char *user; 01730 time_t now= time(0); 01731 DBUG_ENTER("fill_process_list"); 01732 01733 user= thd->security_ctx->master_access & PROCESS_ACL ? 01734 NullS : thd->security_ctx->priv_user; 01735 01736 VOID(pthread_mutex_lock(&LOCK_thread_count)); 01737 01738 if (!thd->killed) 01739 { 01740 I_List_iterator<THD> it(threads); 01741 THD* tmp; 01742 01743 while ((tmp= it++)) 01744 { 01745 Security_context *tmp_sctx= tmp->security_ctx; 01746 struct st_my_thread_var *mysys_var; 01747 const char *val; 01748 01749 if ((!tmp->vio_ok() && !tmp->system_thread) || 01750 (user && (!tmp_sctx->user || strcmp(tmp_sctx->user, user)))) 01751 continue; 01752 01753 restore_record(table, s->default_values); 01754 /* ID */ 01755 table->field[0]->store((longlong) tmp->thread_id, TRUE); 01756 /* USER */ 01757 val= tmp_sctx->user ? tmp_sctx->user : 01758 (tmp->system_thread ? "system user" : "unauthenticated user"); 01759 table->field[1]->store(val, strlen(val), cs); 01760 /* HOST */ 01761 if (tmp->peer_port && (tmp_sctx->host || tmp_sctx->ip) && 01762 thd->security_ctx->host_or_ip[0]) 01763 { 01764 char host[LIST_PROCESS_HOST_LEN + 1]; 01765 my_snprintf(host, LIST_PROCESS_HOST_LEN, "%s:%u", 01766 tmp_sctx->host_or_ip, tmp->peer_port); 01767 table->field[2]->store(host, strlen(host), cs); 01768 } 01769 else 01770 table->field[2]->store(tmp_sctx->host_or_ip, 01771 strlen(tmp_sctx->host_or_ip), cs); 01772 /* DB */ 01773 if (tmp->db) 01774 { 01775 table->field[3]->store(tmp->db, strlen(tmp->db), cs); 01776 table->field[3]->set_notnull(); 01777 } 01778 01779 if ((mysys_var= tmp->mysys_var)) 01780 pthread_mutex_lock(&mysys_var->mutex); 01781 /* COMMAND */ 01782 if ((val= (char *) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0))) 01783 table->field[4]->store(val, strlen(val), cs); 01784 else 01785 table->field[4]->store(command_name[tmp->command].str, 01786 command_name[tmp->command].length, cs); 01787 /* TIME */ 01788 table->field[5]->store((uint32)(tmp->start_time ? 01789 now - tmp->start_time : 0), TRUE); 01790 /* STATE */ 01791 #ifndef EMBEDDED_LIBRARY 01792 val= (char*) (tmp->locked ? "Locked" : 01793 tmp->net.reading_or_writing ? 01794 (tmp->net.reading_or_writing == 2 ? 01795 "Writing to net" : 01796 tmp->command == COM_SLEEP ? "" : 01797 "Reading from net") : 01798 tmp->proc_info ? tmp->proc_info : 01799 tmp->mysys_var && 01800 tmp->mysys_var->current_cond ? 01801 "Waiting on cond" : NullS); 01802 #else 01803 val= (char *) "Writing to net"; 01804 #endif 01805 if (val) 01806 { 01807 table->field[6]->store(val, strlen(val), cs); 01808 table->field[6]->set_notnull(); 01809 } 01810 01811 if (mysys_var) 01812 pthread_mutex_unlock(&mysys_var->mutex); 01813 01814 /* INFO */ 01815 if (tmp->query) 01816 { 01817 table->field[7]->store(tmp->query, 01818 min(PROCESS_LIST_INFO_WIDTH, 01819 tmp->query_length), cs); 01820 table->field[7]->set_notnull(); 01821 } 01822 01823 if (schema_table_store_record(thd, table)) 01824 { 01825 VOID(pthread_mutex_unlock(&LOCK_thread_count)); 01826 DBUG_RETURN(1); 01827 } 01828 } 01829 } 01830 01831 VOID(pthread_mutex_unlock(&LOCK_thread_count)); 01832 DBUG_RETURN(0); 01833 }
Here is the call graph for this function:

| int fill_schema_shemata | ( | THD * | thd, | |
| TABLE_LIST * | tables, | |||
| COND * | cond | |||
| ) |
Definition at line 2712 of file sql_show.cc.
References acl_get(), check_grant_db(), DB_ACLS, DBUG_ENTER, DBUG_RETURN, st_ha_create_information::default_table_charset, files, grant_option, load_db_opt_by_name(), make_db_list(), SHOW_DB_ACL, store_schema_shemata(), system_charset_info, and st_table_list::table.
02713 { 02714 /* 02715 TODO: fill_schema_shemata() is called when new client is connected. 02716 Returning error status in this case leads to client hangup. 02717 */ 02718 02719 INDEX_FIELD_VALUES idx_field_vals; 02720 List<char> files; 02721 char *file_name; 02722 uint length; 02723 bool with_i_schema; 02724 HA_CREATE_INFO create; 02725 TABLE *table= tables->table; 02726 Security_context *sctx= thd->security_ctx; 02727 DBUG_ENTER("fill_schema_shemata"); 02728 02729 if (make_db_list(thd, &files, &idx_field_vals, 02730 &with_i_schema, 1)) 02731 DBUG_RETURN(1); 02732 02733 List_iterator_fast<char> it(files); 02734 while ((file_name=it++)) 02735 { 02736 if (with_i_schema) // information schema name is always first in list 02737 { 02738 if (store_schema_shemata(thd, table, file_name, 02739 system_charset_info)) 02740 DBUG_RETURN(1); 02741 with_i_schema= 0; 02742 continue; 02743 } 02744 #ifndef NO_EMBEDDED_ACCESS_CHECKS 02745 if (sctx->master_access & (DB_ACLS | SHOW_DB_ACL) || 02746 acl_get(sctx->host, sctx->ip, sctx->priv_user, file_name,0) || 02747 (grant_option && !check_grant_db(thd, file_name))) 02748 #endif 02749 { 02750 load_db_opt_by_name(thd, file_name, &create); 02751 02752 if (store_schema_shemata(thd, table, file_name, 02753 create.default_table_charset)) 02754 DBUG_RETURN(1); 02755 } 02756 } 02757 DBUG_RETURN(0); 02758 }
Here is the call graph for this function:

| int fill_status | ( | THD * | thd, | |
| TABLE_LIST * | tables, | |||
| COND * | cond | |||
| ) |
Definition at line 4571 of file sql_show.cc.
References all_status_vars, st_dynamic_array::buffer, calc_sum_of_all_status(), DBUG_ENTER, DBUG_RETURN, LOCK_status, NullS, OPT_GLOBAL, pthread_mutex_lock, pthread_mutex_unlock, show_status_array(), and st_table_list::table.
04572 { 04573 DBUG_ENTER("fill_status"); 04574 LEX *lex= thd->lex; 04575 const char *wild= lex->wild ? lex->wild->ptr() : NullS; 04576 int res= 0; 04577 STATUS_VAR tmp; 04578 pthread_mutex_lock(&LOCK_status); 04579 if (lex->option_type == OPT_GLOBAL) 04580 calc_sum_of_all_status(&tmp); 04581 res= show_status_array(thd, wild, 04582 (SHOW_VAR *)all_status_vars.buffer, 04583 OPT_GLOBAL, 04584 (lex->option_type == OPT_GLOBAL ? 04585 &tmp: thd->initial_status_var), "",tables->table); 04586 pthread_mutex_unlock(&LOCK_status); 04587 DBUG_RETURN(res); 04588 }
Here is the call graph for this function:

| int fill_variables | ( | THD * | thd, | |
| TABLE_LIST * | tables, | |||
| COND * | cond | |||
| ) |
Definition at line 4557 of file sql_show.cc.
References DBUG_ENTER, DBUG_RETURN, init_vars, LOCK_global_system_variables, NullS, pthread_mutex_lock, pthread_mutex_unlock, show_status_array(), and st_table_list::table.
04558 { 04559 DBUG_ENTER("fill_variables"); 04560 int res= 0; 04561 LEX *lex= thd->lex; 04562 const char *wild= lex->wild ? lex->wild->ptr() : NullS; 04563 pthread_mutex_lock(&LOCK_global_system_variables); 04564 res= show_status_array(thd, wild, init_vars, 04565 lex->option_type, 0, "", tables->table); 04566 pthread_mutex_unlock(&LOCK_global_system_variables); 04567 DBUG_RETURN(res); 04568 }
Here is the call graph for this function:

| static find_files_result find_files | ( | THD * | thd, | |
| List< char > * | files, | |||
| const char * | db, | |||
| const char * | path, | |||
| const char * | wild, | |||
| bool | dir | |||
| ) | [static] |
Definition at line 485 of file sql_show.cc.
References bzero, check_grant(), DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, st_my_dir::dir_entry, ER_BAD_DB_ERROR, ER_CANT_READ_DIR, filename_to_tablename(), files, files_charset_info, FIND_FILES_DIR, FIND_FILES_OK, FIND_FILES_OOM, fn_ext(), FN_LIBCHAR, FN_REFLEN, fn_rext(), ha_find_files(), is_prefix(), lower_case_table_names, ME_BELL, ME_WAITTANG, my_dir(), my_dirend(), my_errno, my_error(), MY_S_ISDIR, my_stat(), my_strcasecmp, my_use_symdir, MY_WANT_STAT, MYF, fileinfo::mystat, fileinfo::name, NAME_LEN, st_my_dir::number_off_files, reg_ext, strcmp(), strend(), strlen(), system_charset_info, TABLE_ACLS, tmp_file_prefix, unpack_dirname(), VOID, wild_case_compare(), and wild_compare().
Referenced by get_all_tables(), and make_db_list().
00487 { 00488 uint i; 00489 char *ext; 00490 MY_DIR *dirp; 00491 FILEINFO *file; 00492 #ifndef NO_EMBEDDED_ACCESS_CHECKS 00493 uint col_access=thd->col_access; 00494 #endif 00495 TABLE_LIST table_list; 00496 DBUG_ENTER("find_files"); 00497 00498 if (wild && !wild[0]) 00499 wild=0; 00500 00501 bzero((char*) &table_list,sizeof(table_list)); 00502 00503 if (!(dirp = my_dir(path,MYF(dir ? MY_WANT_STAT : 0)))) 00504 { 00505 if (my_errno == ENOENT) 00506 my_error(ER_BAD_DB_ERROR, MYF(ME_BELL+ME_WAITTANG), db); 00507 else 00508 my_error(ER_CANT_READ_DIR, MYF(ME_BELL+ME_WAITTANG), path, my_errno); 00509 DBUG_RETURN(FIND_FILES_DIR); 00510 } 00511 00512 for (i=0 ; i < (uint) dirp->number_off_files ; i++) 00513 { 00514 char uname[NAME_LEN*3+1]; /* Unencoded name */ 00515 file=dirp->dir_entry+i; 00516 if (dir) 00517 { /* Return databases */ 00518 if ((file->name[0] == '.' && 00519 ((file->name[1] == '.' && file->name[2] == '\0') || 00520 file->name[1] == '\0'))) 00521 continue; /* . or .. */ 00522 #ifdef USE_SYMDIR 00523 char *ext; 00524 char buff[FN_REFLEN]; 00525 if (my_use_symdir && !strcmp(ext=fn_ext(file->name), ".sym")) 00526 { 00527 /* Only show the sym file if it points to a directory */ 00528 char *end; 00529 *ext=0; /* Remove extension */ 00530 unpack_dirname(buff, file->name); 00531 end= strend(buff); 00532 if (end != buff && end[-1] == FN_LIBCHAR) 00533 end[-1]= 0; // Remove end FN_LIBCHAR 00534 if (!my_stat(buff, file->mystat, MYF(0))) 00535 continue; 00536 } 00537 #endif 00538 if (!MY_S_ISDIR(file->mystat->st_mode)) 00539 continue; 00540 VOID(filename_to_tablename(file->name, uname, sizeof(uname))); 00541 if (wild && wild_compare(uname, wild, 0)) 00542 continue; 00543 file->name= uname; 00544 } 00545 else 00546 { 00547 // Return only .frm files which aren't temp files. 00548 if (my_strcasecmp(system_charset_info, ext=fn_rext(file->name),reg_ext) || 00549 is_prefix(file->name, tmp_file_prefix)) 00550 continue; 00551 *ext=0; 00552 VOID(filename_to_tablename(file->name, uname, sizeof(uname))); 00553 file->name= uname; 00554 if (wild) 00555 { 00556 if (lower_case_table_names) 00557 { 00558 if (wild_case_compare(files_charset_info, file->name, wild)) 00559 continue; 00560 } 00561 else if (wild_compare(file->name,wild,0)) 00562 continue; 00563 } 00564 } 00565 #ifndef NO_EMBEDDED_ACCESS_CHECKS 00566 /* Don't show tables where we don't have any privileges */ 00567 if (db && !(col_access & TABLE_ACLS)) 00568 { 00569 table_list.db= (char*) db; 00570 table_list.db_length= strlen(db); 00571 table_list.table_name= file->name; 00572 table_list.table_name_length= strlen(file->name); 00573 table_list.grant.privilege=col_access; 00574 if (check_grant(thd, TABLE_ACLS, &table_list, 1, 1, 1)) 00575 continue; 00576 } 00577 #endif 00578 if (files->push_back(thd->strdup(file->name))) 00579 { 00580 my_dirend(dirp); 00581 DBUG_RETURN(FIND_FILES_OOM); 00582 } 00583 } 00584 DBUG_PRINT("info",("found: %d files", files->elements)); 00585 my_dirend(dirp); 00586 00587 VOID(ha_find_files(thd,db,path,wild,dir,files)); 00588 00589 DBUG_RETURN(FIND_FILES_OK); 00590 }
Here is the call graph for this function:

Here is the caller graph for this function:

| ST_SCHEMA_TABLE* find_schema_table | ( | THD * | thd, | |
| const char * | table_name | |||
| ) |
Definition at line 4673 of file sql_show.cc.
References my_strcasecmp, schema_tables, system_charset_info, and st_schema_table::table_name.
Referenced by dispatch_command().
04674 { 04675 ST_SCHEMA_TABLE *schema_table= schema_tables; 04676 for (; schema_table->table_name; schema_table++) 04677 { 04678 if (!my_strcasecmp(system_charset_info, 04679 schema_table->table_name, 04680 table_name)) 04681 return schema_table; 04682 } 04683 return 0; 04684 }
Here is the caller graph for this function:

| void free_status_vars | ( | ) |
Definition at line 1932 of file sql_show.cc.
References all_status_vars, and delete_dynamic().
Referenced by clean_up().
01933 { 01934 delete_dynamic(&all_status_vars); 01935 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int get_all_tables | ( | THD * | thd, | |
| TABLE_LIST * | tables, | |||
| COND * | cond | |||
| ) |
Definition at line 2456 of file sql_show.cc.
References acl_get(), st_table_list::alias, base_name, build_table_filename(), check_access(), check_grant_db(), close_tables_for_reopen(), cond, st_table_list::db, DB_ACLS, DBUG_ASSERT, DBUG_ENTER, DBUG_RETURN, base_list::elements, err, error, st_table::field, files, find_files(), FIND_FILES_DIR, FIND_FILES_OK, FN_LEN, FN_REFLEN, FRMTYPE_ERROR, FRMTYPE_TABLE, FRMTYPE_VIEW, get_schema_table_idx(), grant_option, st_schema_table::idx_field1, st_schema_table::idx_field2, LINT_INIT, lower_case_table_names, make_cond_for_info_schema(), make_db_list(), make_table_list(), my_snprintf(), mysql_frm_type(), open_normal_and_derived_tables(), path, st_schema_table::process_table, push_warning(), reg_ext, restore_record, List_iterator_fast< T >::rewind(), SCH_TABLE_NAMES, st_table_list::schema_select_lex, st_table_list::schema_table, schema_table_store_record(), schema_tables_add(), sel, SELECT_ACL, SHOW_DB_ACL, sql_command_flags, SQLCOM_END, SQLCOM_SHOW_FIELDS, Field::store(), LEX_STRING::str, STRING_WITH_LEN, strlen(), system_charset_info, st_table_list::table, st_index_field_values::table_value, test, TRUE, Item::val_int(), st_table_list::view, st_table_list::view_db, and MYSQL_ERROR::WARN_LEVEL_WARN.
02457 { 02458 LEX *lex= thd->lex; 02459 TABLE *table= tables->table; 02460 SELECT_LEX *select_lex= &lex->select_lex; 02461 SELECT_LEX *old_all_select_lex= lex->all_selects_list; 02462 enum_sql_command save_sql_command= lex->sql_command; 02463 SELECT_LEX *lsel= tables->schema_select_lex; 02464 ST_SCHEMA_TABLE *schema_table= tables->schema_table; 02465 SELECT_LEX sel; 02466 INDEX_FIELD_VALUES idx_field_vals; 02467 char path[FN_REFLEN], *end, *base_name, *orig_base_name, *file_name; 02468 uint len; 02469 bool with_i_schema; 02470 enum enum_schema_tables schema_table_idx; 02471 List<char> bases; 02472 List_iterator_fast<char> it(bases); 02473 COND *partial_cond; 02474 Security_context *sctx= thd->security_ctx; 02475 uint derived_tables= lex->derived_tables; 02476 int error= 1; 02477 enum legacy_db_type not_used; 02478 Open_tables_state open_tables_state_backup; 02479 bool save_view_prepare_mode= lex->view_prepare_mode; 02480 Query_tables_list query_tables_list_backup; 02481 lex->view_prepare_mode= TRUE; 02482 DBUG_ENTER("get_all_tables"); 02483 02484 LINT_INIT(end); 02485 LINT_INIT(len); 02486 02487 lex->reset_n_backup_query_tables_list(&query_tables_list_backup); 02488 02489 /* 02490 We should not introduce deadlocks even if we already have some 02491 tables open and locked, since we won't lock tables which we will 02492 open and will ignore possible name-locks for these tables. 02493 */ 02494 thd->reset_n_backup_open_tables_state(&open_tables_state_backup); 02495 02496 if (lsel) 02497 { 02498 TABLE_LIST *show_table_list= (TABLE_LIST*) lsel->table_list.first; 02499 bool res; 02500 02501 lex->all_selects_list= lsel; 02502 /* 02503 Restore thd->temporary_tables to be able to process 02504 temporary tables(only for 'show index' & 'show columns'). 02505 This should be changed when processing of temporary tables for 02506 I_S tables will be done. 02507 */ 02508 thd->temporary_tables= open_tables_state_backup.temporary_tables; 02509 /* 02510 Let us set fake sql_command so views won't try to merge 02511 themselves into main statement. If we don't do this, 02512 SELECT * from information_schema.xxxx will cause problems. 02513 SQLCOM_SHOW_FIELDS is used because it satisfies 'only_view_structure()' 02514 */ 02515 lex->sql_command= SQLCOM_SHOW_FIELDS; 02516 res= open_normal_and_derived_tables(thd, show_table_list, 02517 MYSQL_LOCK_IGNORE_FLUSH); 02518 lex->sql_command= save_sql_command; 02519 /* 02520 get_all_tables() returns 1 on failure and 0 on success thus 02521 return only these and not the result code of ::process_table() 02522 02523 We should use show_table_list->alias instead of 02524 show_table_list->table_name because table_name 02525 could be changed during opening of I_S tables. It's safe 02526 to use alias because alias contains original table name 02527 in this case(this part of code is used only for 02528 'show columns' & 'show statistics' commands). 02529 */ 02530 error= test(schema_table->process_table(thd, show_table_list, 02531 table, res, 02532 (show_table_list->view ? 02533 show_table_list->view_db.str : 02534 show_table_list->db), 02535 show_table_list->alias)); 02536 thd->temporary_tables= 0; 02537 close_tables_for_reopen(thd, &show_table_list); 02538 goto err; 02539 } 02540 02541 schema_table_idx= get_schema_table_idx(schema_table); 02542 02543 if (make_db_list(thd, &bases, &idx_field_vals, 02544 &with_i_schema, 0)) 02545 goto err; 02546 02547 partial_cond= make_cond_for_info_schema(cond, tables); 02548 it.rewind(); /* To get access to new elements in basis list */ 02549 02550 /* 02551 Below we generate error for non existing database. 02552 (to save old behaviour for SHOW TABLES FROM db) 02553 */ 02554 while ((orig_base_name= base_name= it++) || 02555 ((sql_command_flags[save_sql_command] & CF_SHOW_TABLE_COMMAND) && 02556 (base_name= select_lex->db) && !bases.elements)) 02557 { 02558 #ifndef NO_EMBEDDED_ACCESS_CHECKS 02559 if (!check_access(thd,SELECT_ACL, base_name, 02560 &thd->col_access, 0, 1, with_i_schema) || 02561 sctx->master_access & (DB_ACLS | SHOW_DB_ACL) || 02562 acl_get(sctx->host, sctx->ip, sctx->priv_user, base_name,0) || 02563 (grant_option && !check_grant_db(thd, base_name))) 02564 #endif 02565 { 02566 List<char> files; 02567 if (with_i_schema) // information schema table names 02568 { 02569 if (schema_tables_add(thd, &files, idx_field_vals.table_value)) 02570 goto err; 02571 } 02572 else 02573 { 02574 len= build_table_filename(path, sizeof(path), base_name, "", "", 0); 02575 end= path + len; 02576 len= FN_LEN - len; 02577 find_files_result res= find_files(thd, &files, base_name, 02578 path, idx_field_vals.table_value, 0); 02579 if (res != FIND_FILES_OK) 02580 { 02581 /* 02582 Downgrade errors about problems with database directory to 02583 warnings if this is not a 'SHOW' command. Another thread 02584 may have dropped database, and we may still have a name 02585 for that directory. 02586 */ 02587 if (res == FIND_FILES_DIR && lex->sql_command == SQLCOM_END) 02588 { 02589 push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 02590 thd->net.last_errno, thd->net.last_error); 02591 thd->clear_error(); 02592 continue; 02593 } 02594 else 02595 { 02596 goto err; 02597 } 02598 } 02599 if (lower_case_table_names) 02600 orig_base_name= thd->strdup(base_name); 02601 } 02602 02603 List_iterator_fast<char> it_files(files); 02604 while ((file_name= it_files++)) 02605 { 02606 restore_record(table, s->default_values); 02607 table->field[schema_table->idx_field1]-> 02608 store(base_name, strlen(base_name), system_charset_info); 02609 table->field[schema_table->idx_field2]-> 02610 store(file_name, strlen(file_name),system_charset_info); 02611 if (!partial_cond || partial_cond->val_int()) 02612 { 02613 if (schema_table_idx == SCH_TABLE_NAMES) 02614 { 02615 if (lex->verbose || 02616 (sql_command_flags[save_sql_command] & CF_STATUS_COMMAND) == 0) 02617 { 02618 if (with_i_schema) 02619 { 02620 table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"), 02621 system_charset_info); 02622 } 02623 else 02624 { 02625 my_snprintf(end, len, "/%s%s", file_name, reg_ext); 02626 switch (mysql_frm_type(thd, path, ¬_used)) { 02627 case FRMTYPE_ERROR: 02628 table->field[3]->store(STRING_WITH_LEN("ERROR"), 02629 system_charset_info); 02630 break; 02631 case FRMTYPE_TABLE: 02632 table->field[3]->store(STRING_WITH_LEN("BASE TABLE"), 02633 system_charset_info); 02634 break; 02635 case FRMTYPE_VIEW: 02636 table->field[3]->store(STRING_WITH_LEN("VIEW"), 02637 system_charset_info); 02638 break; 02639 default: 02640 DBUG_ASSERT(0); 02641 } 02642 } 02643 } 02644 if (schema_table_store_record(thd, table)) 02645 goto err; 02646 } 02647 else 02648 { 02649 int res; 02650 /* 02651 Set the parent lex of 'sel' because it is needed by 02652 sel.init_query() which is called inside make_table_list. 02653 */ 02654 sel.parent_lex= lex; 02655 if (make_table_list(thd, &sel, base_name, file_name)) 02656 goto err; 02657 TABLE_LIST *show_table_list= (TABLE_LIST*) sel.table_list.first; 02658 lex->all_selects_list= &sel; 02659 lex->derived_tables= 0; 02660 lex->sql_command= SQLCOM_SHOW_FIELDS; 02661 res= open_normal_and_derived_tables(thd, show_table_list, 02662 MYSQL_LOCK_IGNORE_FLUSH); 02663 lex->sql_command= save_sql_command; 02664 /* 02665 We should use show_table_list->alias instead of 02666 show_table_list->table_name because table_name 02667 could be changed during opening of I_S tables. It's safe 02668 to use alias because alias contains original table name 02669 in this case. 02670 */ 02671 res= schema_table->process_table(thd, show_table_list, table, 02672 res, orig_base_name, 02673 show_table_list->alias); 02674 close_tables_for_reopen(thd, &show_table_list); 02675 DBUG_ASSERT(!lex->query_tables_own_last); 02676 if (res) 02677 goto err; 02678 } 02679 } 02680 } 02681 /* 02682 If we have information schema its always the first table and only 02683 the first table. Reset for other tables. 02684 */ 02685 with_i_schema= 0; 02686 } 02687 } 02688 02689 error= 0; 02690 err: 02691 thd->restore_backup_open_tables_state(&open_tables_state_backup); 02692 lex->restore_backup_query_tables_list(&query_tables_list_backup); 02693 lex->derived_tables= derived_tables; 02694 lex->all_selects_list= old_all_select_lex; 02695 lex->view_prepare_mode= save_view_prepare_mode; 02696 lex->sql_command= save_sql_command; 02697 DBUG_RETURN(error); 02698 }
Here is the call graph for this function:

| void get_index_field_values | ( | LEX * | lex, | |
| INDEX_FIELD_VALUES * | index_field_values | |||
| ) |
Definition at line 2213 of file sql_show.cc.
References st_index_field_values::db_value, NullS, SQLCOM_SHOW_DATABASES, SQLCOM_SHOW_EVENTS, SQLCOM_SHOW_TABLE_STATUS, SQLCOM_SHOW_TABLES, SQLCOM_SHOW_TRIGGERS, and st_index_field_values::table_value.
Referenced by make_db_list().
02214 { 02215 const char *wild= lex->wild ? lex->wild->ptr() : NullS; 02216 switch (lex->sql_command) { 02217 case SQLCOM_SHOW_DATABASES: 02218 index_field_values->db_value= wild; 02219 break; 02220 case SQLCOM_SHOW_TABLES: 02221 case SQLCOM_SHOW_TABLE_STATUS: 02222 case SQLCOM_SHOW_TRIGGERS: 02223 case SQLCOM_SHOW_EVENTS: 02224 index_field_values->db_value= lex->select_lex.db; 02225 index_field_values->table_value= wild; 02226 break; 02227 default: 02228 index_field_values->db_value= NullS; 02229 index_field_values->table_value= NullS; 02230 break; 02231 } 02232 }
Here is the caller graph for this function:

| int get_quote_char_for_identifier | ( | THD * | thd, | |
| const char * | name, | |||
| uint | length | |||
| ) |
Definition at line 944 of file sql_show.cc.
References is_keyword(), MODE_ANSI_QUOTES, OPTION_QUOTE_SHOW_CREATE, and require_quotes().
Referenced by append_identifier().
00945 { 00946 if (length && 00947 !is_keyword(name,length) && 00948 !require_quotes(name, length) && 00949 !(thd->options & OPTION_QUOTE_SHOW_CREATE)) 00950 return EOF; 00951 if (thd->variables.sql_mode & MODE_ANSI_QUOTES) 00952 return '"'; 00953 return '`'; 00954 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static interval_type get_real_interval_type | ( | interval_type | i_type | ) | [static] |
Definition at line 4159 of file sql_show.cc.
References DBUG_ASSERT, INTERVAL_DAY, INTERVAL_DAY_HOUR, INTERVAL_DAY_MICROSECOND, INTERVAL_DAY_MINUTE, INTERVAL_DAY_SECOND, INTERVAL_HOUR, INTERVAL_HOUR_MICROSECOND, INTERVAL_HOUR_MINUTE, INTERVAL_HOUR_SECOND, INTERVAL_LAST, INTERVAL_MICROSECOND, INTERVAL_MINUTE, INTERVAL_MINUTE_MICROSECOND, INTERVAL_MINUTE_SECOND, INTERVAL_MONTH, INTERVAL_QUARTER, INTERVAL_SECOND, INTERVAL_SECOND_MICROSECOND, INTERVAL_WEEK, INTERVAL_YEAR, and INTERVAL_YEAR_MONTH.
04160 { 04161 switch (i_type) { 04162 case INTERVAL_YEAR: 04163 return INTERVAL_YEAR; 04164 04165 case INTERVAL_QUARTER: 04166 case INTERVAL_YEAR_MONTH: 04167 case INTERVAL_MONTH: 04168 return INTERVAL_MONTH; 04169 04170 case INTERVAL_WEEK: 04171 case INTERVAL_DAY: 04172 return INTERVAL_DAY; 04173 04174 case INTERVAL_DAY_HOUR: 04175 case INTERVAL_HOUR: 04176 return INTERVAL_HOUR; 04177 04178 case INTERVAL_DAY_MINUTE: 04179 case INTERVAL_HOUR_MINUTE: 04180 case INTERVAL_MINUTE: 04181 return INTERVAL_MINUTE; 04182 04183 case INTERVAL_DAY_SECOND: 04184 case INTERVAL_HOUR_SECOND: 04185 case INTERVAL_MINUTE_SECOND: 04186 case INTERVAL_SECOND: 04187 return INTERVAL_SECOND; 04188 04189 case INTERVAL_DAY_MICROSECOND: 04190 case INTERVAL_HOUR_MICROSECOND: 04191 case INTERVAL_MINUTE_MICROSECOND: 04192 case INTERVAL_SECOND_MICROSECOND: 04193 case INTERVAL_MICROSECOND: 04194 return INTERVAL_MICROSECOND; 04195 case INTERVAL_LAST: 04196 DBUG_ASSERT(0); 04197 } 04198 DBUG_ASSERT(0); 04199 return INTERVAL_SECOND; 04200 }
| static int get_referential_constraints_record | ( | THD * | thd, | |
| struct st_table_list * | tables, | |||
| TABLE * | table, | |||
| bool | res, | |||
| const char * | base_name, | |||
| const char * | file_name | |||
| ) | [static] |
Definition at line 4610 of file sql_show.cc.
References DBUG_ENTER, DBUG_RETURN, st_foreign_key_info::delete_method, st_table::field, st_table::file, st_foreign_key_info::forein_id, handler::get_foreign_key_list(), HA_STATUS_NO_LOCK, HA_STATUS_TIME, HA_STATUS_VARIABLE, handler::info(), LEX_STRING::length, push_warning(), st_foreign_key_info::referenced_db, st_foreign_key_info::referenced_table, restore_record, schema_table_store_record(), Field::store(), LEX_STRING::str, STRING_WITH_LEN, strlen(), system_charset_info, st_table_list::table, st_foreign_key_info::update_method, st_table_list::view, and MYSQL_ERROR::WARN_LEVEL_WARN.
04613 { 04614 CHARSET_INFO *cs= system_charset_info; 04615 DBUG_ENTER("get_referential_constraints_record"); 04616 04617 if (res) 04618 { 04619 if (!tables->view) 04620 push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 04621 thd->net.last_errno, thd->net.last_error); 04622 thd->clear_error(); 04623 DBUG_RETURN(0); 04624 } 04625 if (!tables->view) 04626 { 04627 List<FOREIGN_KEY_INFO> f_key_list; 04628 TABLE *show_table= tables->table; 04629 show_table->file->info(HA_STATUS_VARIABLE | 04630 HA_STATUS_NO_LOCK | 04631 HA_STATUS_TIME); 04632 04633 show_table->file->get_foreign_key_list(thd, &f_key_list); 04634 FOREIGN_KEY_INFO *f_key_info; 04635 List_iterator_fast<FOREIGN_KEY_INFO> it(f_key_list); 04636 while ((f_key_info= it++)) 04637 { 04638 restore_record(table, s->default_values); 04639 table->field[1]->store(base_name, strlen(base_name), cs); 04640 table->field[9]->store(file_name, strlen(file_name), cs); 04641 table->field[2]->store(f_key_info->forein_id->str, 04642 f_key_info->forein_id->length, cs); 04643 table->field[4]->store(f_key_info->referenced_db->str, 04644 f_key_info->referenced_db->length, cs); 04645 table->field[5]->store(f_key_info->referenced_table->str, 04646 f_key_info->referenced_table->length, cs); 04647 table->field[6]->store(STRING_WITH_LEN("NONE"), cs); 04648 table->field[7]->store(f_key_info->update_method->str, 04649 f_key_info->update_method->length, cs); 04650 table->field[8]->store(f_key_info->delete_method->str, 04651 f_key_info->delete_method->length, cs); 04652 if (schema_table_store_record(thd, table)) 04653 DBUG_RETURN(1); 04654 } 04655 } 04656 DBUG_RETURN(0); 04657 }
Here is the call graph for this function:

| static int get_schema_column_record | ( | THD * | thd, | |
| struct st_table_list * | tables, | |||
| TABLE * | table, | |||
| bool | res, | |||
| const char * | base_name, | |||
| const char * | file_name | |||
| ) | [static] |
Definition at line 2952 of file sql_show.cc.
References String::charset(), Field::charset(), check_access(), COL_ACLS, Field::comment, String::copy(), count, charset_info_st::csname, DBUG_ENTER, DBUG_RETURN, Field::decimals(), EXTRA_ACL, st_table::field, Field::field_length, Field::field_name, FIELD_TYPE_BIT, FIELD_TYPE_BLOB, FIELD_TYPE_DECIMAL, FIELD_TYPE_DOUBLE, FIELD_TYPE_FLOAT, FIELD_TYPE_INT24, FIELD_TYPE_LONG, FIELD_TYPE_LONGLONG, FIELD_TYPE_NEWDECIMAL, FIELD_TYPE_SHORT, FIELD_TYPE_TINY, st_table::file, Field::flags, flags, get_column_grant(), st_table_list::grant, grant_types, HA_STATUS_NO_LOCK, HA_STATUS_VARIABLE, Field::has_charset(), handler::info(), Field::is_null(), LEX_STRING::length, String::length(), MAX_FIELD_WIDTH, Field_new_decimal::max_length(), Field::max_length(), Field::maybe_null(), charset_info_st::mbmaxlen, charset_info_st::mbminlen, MULTIPLE_KEY_FLAG, MYSQL_TYPE_STRING, MYSQL_TYPE_VARCHAR, charset_info_st::name, Field::NEXT_NUMBER, NO_DEFAULT_VALUE_FLAG, NOT_FIXED_DEC, NOT_NULL_FLAG, NullS, pos(), PRI_KEY_FLAG, st_grant_info::privilege, String::ptr(), push_warning(), Field::real_type(), restore_record, st_table_list::schema_table, schema_table_store_record(), SELECT_ACL, String::set(), Field::set_notnull(), Field::set_null(), Field::sql_type(), SQLCOM_SHOW_FIELDS, Field::store(), LEX_STRING::str, strchr(), STRING_WITH_LEN, strlen(), strmov(), system_charset_info, st_table_list::table, test, st_table::timestamp_field, Field::TIMESTAMP_UN_FIELD, TRUE, Field::type(), st_typelib::type_names, UNIQUE_KEY_FLAG, Field::unireg_check, st_table::use_all_columns(), Field::val_str(), MYSQL_ERROR::WARN_LEVEL_WARN, and wild_case_compare().
02956 { 02957 LEX *lex= thd->lex; 02958 const char *wild= lex->wild ? lex->wild->ptr() : NullS; 02959 CHARSET_INFO *cs= system_charset_info; 02960 TABLE *show_table; 02961 handler *file; 02962 Field **ptr,*field; 02963 int count; 02964 uint base_name_length, file_name_length; 02965 DBUG_ENTER("get_schema_column_record"); 02966 02967 if (res) 02968 { 02969 if (lex->sql_command != SQLCOM_SHOW_FIELDS) 02970 { 02971 /* 02972 I.e. we are in SELECT FROM INFORMATION_SCHEMA.COLUMS 02973 rather than in SHOW COLUMNS 02974 */ 02975 push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 02976 thd->net.last_errno, thd->net.last_error); 02977 thd->clear_error(); 02978 res= 0; 02979 } 02980 DBUG_RETURN(res); 02981 } 02982 02983 show_table= tables->table; 02984 file= show_table->file; 02985 count= 0; 02986 file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK); 02987 restore_record(show_table, s->default_values); 02988 base_name_length= strlen(base_name); 02989 file_name_length= strlen(file_name); 02990 show_table->use_all_columns(); // Required for default 02991 02992 for (ptr=show_table->field; (field= *ptr) ; ptr++) 02993 { 02994 const char *tmp_buff; 02995 byte *pos; 02996 bool is_blob; 02997 uint flags=field->flags; 02998 char tmp[MAX_FIELD_WIDTH]; 02999 char tmp1[MAX_FIELD_WIDTH]; 03000 String type(tmp,sizeof(tmp), system_charset_info); 03001 char *end; 03002 int decimals, field_length; 03003 03004 if (wild && wild[0] && 03005 wild_case_compare(system_charset_info, field->field_name,wild)) 03006 continue; 03007 03008 flags= field->flags; 03009 count++; 03010 /* Get default row, with all NULL fields set to NULL */ 03011 restore_record(table, s->default_values); 03012 03013 #ifndef NO_EMBEDDED_ACCESS_CHECKS 03014 uint col_access; 03015 check_access(thd,SELECT_ACL | EXTRA_ACL, base_name, 03016 &tables->grant.privilege, 0, 0, test(tables->schema_table)); 03017 col_access= get_column_grant(thd, &tables->grant, 03018 base_name, file_name, 03019 field->field_name) & COL_ACLS; 03020 if (lex->sql_command != SQLCOM_SHOW_FIELDS && 03021 !tables->schema_table && !col_access) 03022 continue; 03023 end= tmp; 03024 for (uint bitnr=0; col_access ; col_access>>=1,bitnr++) 03025 { 03026 if (col_access & 1) 03027 { 03028 *end++=','; 03029 end=strmov(end,grant_types.type_names[bitnr]); 03030 } 03031 } 03032 table->field[17]->store(tmp+1,end == tmp ? 0 : (uint) (end-tmp-1), cs); 03033 03034 #endif 03035 table->field[1]->store(base_name, base_name_length, cs); 03036 table->field[2]->store(file_name, file_name_length, cs); 03037 table->field[3]->store(field->field_name, strlen(field->field_name), 03038 cs); 03039 table->field[4]->store((longlong) count, TRUE); 03040 field->sql_type(type); 03041 table->field[14]->store(type.ptr(), type.length(), cs); 03042 tmp_buff= strchr(type.ptr(), '('); 03043 table->field[7]->store(type.ptr(), 03044 (tmp_buff ? tmp_buff - type.ptr() : 03045 type.length()), cs); 03046 if (show_table->timestamp_field == field && 03047 field->unireg_check != Field::TIMESTAMP_UN_FIELD) 03048 { 03049 table->field[5]->store(STRING_WITH_LEN("CURRENT_TIMESTAMP"), cs); 03050 table->field[5]->set_notnull(); 03051 } 03052 else if (field->unireg_check != Field::NEXT_NUMBER && 03053 !field->is_null() && 03054 !(field->flags & NO_DEFAULT_VALUE_FLAG)) 03055 { 03056 String def(tmp1,sizeof(tmp1), cs); 03057 type.set(tmp, sizeof(tmp), field->charset()); 03058 field->val_str(&type); 03059 uint dummy_errors; 03060 def.copy(type.ptr(), type.length(), type.charset(), cs, &dummy_errors); 03061 table->field[5]->store(def.ptr(), def.length(), def.charset()); 03062 table->field[5]->set_notnull(); 03063 } 03064 else if (field->unireg_check == Field::NEXT_NUMBER || 03065 lex->sql_command != SQLCOM_SHOW_FIELDS || 03066 field->maybe_null()) 03067 table->field[5]->set_null(); // Null as default 03068 else 03069 { 03070 table->field[5]->store("",0, cs); 03071 table->field[5]->set_notnull(); 03072 } 03073 pos=(byte*) ((flags & NOT_NULL_FLAG) ? "NO" : "YES"); 03074 table->field[6]->store((const char*) pos, 03075 strlen((const char*) pos), cs); 03076 is_blob= (field->type() == FIELD_TYPE_BLOB); 03077 if (field->has_charset() || is_blob || 03078 field->real_type() == MYSQL_TYPE_VARCHAR || // For varbinary type 03079 field->real_type() == MYSQL_TYPE_STRING) // For binary type 03080 { 03081 uint32 octet_max_length= field->max_length(); 03082 if (is_blob && octet_max_length != (uint32) 4294967295U) 03083 octet_max_length /= field->charset()->mbmaxlen; 03084 longlong char_max_len= is_blob ? 03085 (longlong) octet_max_length / field->charset()->mbminlen : 03086 (longlong) octet_max_length / field->charset()->mbmaxlen; 03087 table->field[8]->store(char_max_len, TRUE); 03088 table->field[8]->set_notnull(); 03089 table->field[9]->store((longlong) octet_max_length, TRUE); 03090 table->field[9]->set_notnull(); 03091 } 03092 03093 /* 03094 Calculate field_length and decimals. 03095 They are set to -1 if they should not be set (we should return NULL) 03096 */ 03097 03098 decimals= field->decimals(); 03099 switch (field->type()) { 03100 case FIELD_TYPE_NEWDECIMAL: 03101 field_length= ((Field_new_decimal*) field)->precision; 03102 break; 03103 case FIELD_TYPE_DECIMAL: 03104 field_length= field->field_length - (decimals ? 2 : 1); 03105 break; 03106 case FIELD_TYPE_TINY: 03107 case FIELD_TYPE_SHORT: 03108 case FIELD_TYPE_LONG: 03109 case FIELD_TYPE_LONGLONG: 03110 case FIELD_TYPE_INT24: 03111 field_length= field->max_length() - 1; 03112 break; 03113 case FIELD_TYPE_BIT: 03114 field_length= field->max_length(); 03115 decimals= -1; // return NULL 03116 break; 03117 case FIELD_TYPE_FLOAT: 03118 case FIELD_TYPE_DOUBLE: 03119 field_length= field->field_length; 03120 if (decimals == NOT_FIXED_DEC) 03121 decimals= -1; // return NULL 03122 break; 03123 default: 03124 field_length= decimals= -1; 03125 break; 03126 } 03127 03128 if (field_length >= 0) 03129 { 03130 table->field[10]->store((longlong) field_length, TRUE); 03131 table->field[10]->set_notnull(); 03132 } 03133 if (decimals >= 0) 03134 { 03135 table->field[11]->store((longlong) decimals, TRUE); 03136 table->field[11]->set_notnull(); 03137 } 03138 03139 if (field->has_charset()) 03140 { 03141 pos=(byte*) field->charset()->csname; 03142 table->field[12]->store((const char*) pos, 03143 strlen((const char*) pos), cs); 03144 table->field[12]->set_notnull(); 03145 pos=(byte*) field->charset()->name; 03146 table->field[13]->store((const char*) pos, 03147 strlen((const char*) pos), cs); 03148 table->field[13]->set_notnull(); 03149 } 03150 pos=(byte*) ((field->flags & PRI_KEY_FLAG) ? "PRI" : 03151 (field->flags & UNIQUE_KEY_FLAG) ? "UNI" : 03152 (field->flags & MULTIPLE_KEY_FLAG) ? "MUL":""); 03153 table->field[15]->store((const char*) pos, 03154 strlen((const char*) pos), cs); 03155 03156 end= tmp; 03157 if (field->unireg_check == Field::NEXT_NUMBER) 03158 end=strmov(tmp,"auto_increment"); 03159 table->field[16]->store(tmp, (uint) (end-tmp), cs); 03160 03161 table->field[18]->store(field->comment.str, field->comment.length, cs); 03162 if (schema_table_store_record(thd, table)) 03163 DBUG_RETURN(1); 03164 } 03165 DBUG_RETURN(0); 03166 }
Here is the call graph for this function:

| static int get_schema_constraints_record | ( | THD * | thd, | |
| struct st_table_list * | tables, | |||
| TABLE * | table, | |||
| bool | res, | |||
| const char * | base_name, | |||
| const char * | file_name | |||
| ) | [static] |
Definition at line 3621 of file sql_show.cc.
References DBUG_ENTER, DBUG_RETURN, st_table::file, st_key::flags, HA_NOSAME, HA_STATUS_NO_LOCK, HA_STATUS_TIME, HA_STATUS_VARIABLE, handler::info(), st_table::key_info, st_table_share::keys, st_key::name, st_table_share::primary_key, primary_key_name, push_warning(), st_table::s, store_constraints(), strcmp(), STRING_WITH_LEN, strlen(), st_table_list::table, st_table_list::view, and MYSQL_ERROR::WARN_LEVEL_WARN.
03625 { 03626 DBUG_ENTER("get_schema_constraints_record"); 03627 if (res) 03628 { 03629 if (!tables->view) 03630 push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 03631 thd->net.last_errno, thd->net.last_error); 03632 thd->clear_error(); 03633 DBUG_RETURN(0); 03634 } 03635 else if (!tables->view) 03636 { 03637 List<FOREIGN_KEY_INFO> f_key_list; 03638 TABLE *show_table= tables->table; 03639 KEY *key_info=show_table->key_info; 03640 uint primary_key= show_table->s->primary_key; 03641 show_table->file->info(HA_STATUS_VARIABLE | 03642 HA_STATUS_NO_LOCK | 03643 HA_STATUS_TIME); 03644 for (uint i=0 ; i < show_table->s->keys ; i++, key_info++) 03645 { 03646 if (i != primary_key && !(key_info->flags & HA_NOSAME)) 03647 continue; 03648 03649 if (i == primary_key && !strcmp(key_info->name, primary_key_name)) 03650 { 03651 if (store_constraints(thd, table, base_name, file_name, key_info->name, 03652 strlen(key_info->name), 03653 STRING_WITH_LEN("PRIMARY KEY"))) 03654 DBUG_RETURN(1); 03655 } 03656 else if (key_info->flags & HA_NOSAME) 03657 { 03658 if (store_constraints(thd, table, base_name, file_name, key_info->name, 03659 strlen(key_info->name), 03660 STRING_WITH_LEN("UNIQUE"))) 03661 DBUG_RETURN(1); 03662 } 03663 } 03664 03665 show_table->file->get_foreign_key_list(thd, &f_key_list); 03666 FOREIGN_KEY_INFO *f_key_info; 03667 List_iterator_fast<FOREIGN_KEY_INFO> it(f_key_list); 03668 while ((f_key_info=it++)) 03669 { 03670 if (store_constraints(thd, table, base_name, file_name, 03671 f_key_info->forein_id->str, 03672 strlen(f_key_info->forein_id->str), 03673 "FOREIGN KEY", 11)) 03674 DBUG_RETURN(1); 03675 } 03676 } 03677 DBUG_RETURN(res); 03678 }
Here is the call graph for this function:

| static int get_schema_key_column_usage_record | ( | THD * | thd, | |
| struct st_table_list * | tables, | |||
| TABLE * | table, | |||
| bool | res, | |||
| const char * | base_name, | |||
| const char * | file_name | |||
| ) | [static] |
Definition at line 3783 of file sql_show.cc.
References DBUG_ENTER, DBUG_RETURN, st_table::field, st_table::file, st_key::flags, st_foreign_key_info::foreign_fields, st_foreign_key_info::forein_id, HA_NOSAME, HA_STATUS_NO_LOCK, HA_STATUS_TIME, HA_STATUS_VARIABLE, handler::info(), st_table::key_info, st_key::key_part, st_key::key_parts, st_table_share::keys, LEX_STRING::length, st_key::name, st_table_share::primary_key, push_warning(), st_foreign_key_info::referenced_db, st_foreign_key_info::referenced_fields, st_foreign_key_info::referenced_table, restore_record, st_table::s, schema_table_store_record(), Field::set_notnull(), Field::store(), store_key_column_usage(), LEX_STRING::str, strlen(), system_charset_info, st_table_list::table, TRUE, st_table_list::view, and MYSQL_ERROR::WARN_LEVEL_WARN.
03788 { 03789 DBUG_ENTER("get_schema_key_column_usage_record"); 03790 if (res) 03791 { 03792 if (!tables->view) 03793 push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 03794 thd->net.last_errno, thd->net.last_error); 03795 thd->clear_error(); 03796 DBUG_RETURN(0); 03797 } 03798 else if (!tables->view) 03799 { 03800 List<FOREIGN_KEY_INFO> f_key_list; 03801 TABLE *show_table= tables->table; 03802 KEY *key_info=show_table->key_info; 03803 uint primary_key= show_table->s->primary_key; 03804 show_table->file->info(HA_STATUS_VARIABLE | 03805 HA_STATUS_NO_LOCK | 03806 HA_STATUS_TIME); 03807 for (uint i=0 ; i < show_table->s->keys ; i++, key_info++) 03808 { 03809 if (i != primary_key && !(key_info->flags & HA_NOSAME)) 03810 continue; 03811 uint f_idx= 0; 03812 KEY_PART_INFO *key_part= key_info->key_part; 03813 for (uint j=0 ; j < key_info->key_parts ; j++,key_part++) 03814 { 03815 if (key_part->field) 03816 { 03817 f_idx++; 03818 restore_record(table, s->default_values); 03819 store_key_column_usage(table, base_name, file_name, 03820 key_info->name, 03821 strlen(key_info->name), 03822 key_part->field->field_name, 03823 strlen(key_part->field->field_name), 03824 (longlong) f_idx); 03825 if (schema_table_store_record(thd, table)) 03826 DBUG_RETURN(1); 03827 } 03828 } 03829 } 03830 03831 show_table->file->get_foreign_key_list(thd, &f_key_list); 03832 FOREIGN_KEY_INFO *f_key_info; 03833 List_iterator_fast<FOREIGN_KEY_INFO> it(f_key_list); 03834 while ((f_key_info= it++)) 03835 { 03836 LEX_STRING *f_info; 03837 LEX_STRING *r_info; 03838 List_iterator_fast<LEX_STRING> it(f_key_info->foreign_fields), 03839 it1(f_key_info->referenced_fields); 03840 uint f_idx= 0; 03841 while ((f_info= it++)) 03842 { 03843 r_info= it1++; 03844 f_idx++; 03845 restore_record(table, s->default_values); 03846 store_key_column_usage(table, base_name, file_name, 03847 f_key_info->forein_id->str, 03848 f_key_info->forein_id->length, 03849 f_info->str, f_info->length, 03850 (longlong) f_idx); 03851 table->field[8]->store((longlong) f_idx, TRUE); 03852 table->field[8]->set_notnull(); 03853 table->field[9]->store(f_key_info->referenced_db->str, 03854 f_key_info->referenced_db->length, 03855 system_charset_info); 03856 table->field[9]->set_notnull(); 03857 table->field[10]->store(f_key_info->referenced_table->str, 03858 f_key_info->referenced_table->length, 03859 system_charset_info); 03860 table->field[10]->set_notnull(); 03861 table->field[11]->store(r_info->str, r_info->length, 03862 system_charset_info); 03863 table->field[11]->set_notnull(); 03864 if (schema_table_store_record(thd, table)) 03865 DBUG_RETURN(1); 03866 } 03867 } 03868 } 03869 DBUG_RETURN(res); 03870 }
Here is the call graph for this function:

| static int get_schema_partitions_record | ( | THD * | thd, | |
| struct st_table_list * | tables, | |||
| TABLE * | table, | |||
| bool | res, | |||
| const char * | base_name, | |||
| const char * | file_name | |||
| ) | [static] |
Definition at line 3953 of file sql_show.cc.
References String::append(), collect_partition_expr(), current_thd, DBUG_ASSERT, DBUG_ENTER, DBUG_RETURN, base_list::elements, FALSE, st_table::field, st_table::file, partition_element::has_null_value, HASH_PARTITION, partition_info::is_sub_partitioned(), String::length(), partition_info::linear_hash_ind, partition_info::list_of_part_fields, partition_info::list_of_subpart_fields, LIST_PARTITION, partition_element::list_val_list, LONGLONG_MAX, partition_info::no_parts, partition_info::part_expr, partition_info::part_field_list, partition_info::part_func_len, partition_info::part_func_string, partition_info::part_type, partition_element::partition_name, partition_info::partitions, PKW_HASH, PKW_KEY, PKW_LINEAR, PKW_LIST, PKW_MAXVALUE, PKW_RANGE, String::ptr(), push_warning(), RANGE_PARTITION, partition_element::range_value, restore_record, schema_table_store_record(), String::set(), Field::set_notnull(), Field::store(), store_schema_partitions_record(), strlen(), partition_info::subpart_expr, partition_info::subpart_field_list, partition_info::subpart_func_len, partition_info::subpart_func_string, partition_element::subpartitions, system_charset_info, st_table_list::table, TRUE, p_elem_val::unsigned_flag, p_elem_val::value, st_table_list::view, and MYSQL_ERROR::WARN_LEVEL_WARN.
03957 { 03958 CHARSET_INFO *cs= system_charset_info; 03959 char buff[61]; 03960 String tmp_res(buff, sizeof(buff), cs); 03961 String tmp_str; 03962 TIME time; 03963 TABLE *show_table= tables->table; 03964 handler *file; 03965 #ifdef WITH_PARTITION_STORAGE_ENGINE 03966 partition_info *part_info; 03967 #endif 03968 DBUG_ENTER("get_schema_partitions_record"); 03969 03970 if (res) 03971 { 03972 if (!tables->view) 03973 push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 03974 thd->net.last_errno, thd->net.last_error); 03975 thd->clear_error(); 03976 DBUG_RETURN(0); 03977 } 03978 file= show_table->file; 03979 #ifdef WITH_PARTITION_STORAGE_ENGINE 03980 part_info= show_table->part_info; 03981 if (part_info) 03982 { 03983 partition_element *part_elem; 03984 List_iterator<partition_element> part_it(part_info->partitions); 03985 uint part_pos= 0, part_id= 0; 03986 uint no_parts= part_info->no_parts; 03987 handler *part_file; 03988 03989 restore_record(table, s->default_values); 03990 table->field[1]->store(base_name, strlen(base_name), cs); 03991 table->field[2]->store(file_name, strlen(file_name), cs); 03992 03993 03994 /* Partition method*/ 03995 switch (part_info->part_type) { 03996 case RANGE_PARTITION: 03997 table->field[7]->store(partition_keywords[PKW_RANGE].str, 03998 partition_keywords[PKW_RANGE].length, cs); 03999 break; 04000 case LIST_PARTITION: 04001 table->field[7]->store(partition_keywords[PKW_LIST].str, 04002 partition_keywords[PKW_LIST].length, cs); 04003 break; 04004 case HASH_PARTITION: 04005 tmp_res.length(0); 04006 if (part_info->linear_hash_ind) 04007 tmp_res.append(partition_keywords[PKW_LINEAR].str, 04008 partition_keywords[PKW_LINEAR].length); 04009 if (part_info->list_of_part_fields) 04010 tmp_res.append(partition_keywords[PKW_KEY].str, 04011 partition_keywords[PKW_KEY].length); 04012 else 04013 tmp_res.append(partition_keywords[PKW_HASH].str, 04014 partition_keywords[PKW_HASH].length); 04015 table->field[7]->store(tmp_res.ptr(), tmp_res.length(), cs); 04016 break; 04017 default: 04018 DBUG_ASSERT(0); 04019 current_thd->fatal_error(); 04020 DBUG_RETURN(1); 04021 } 04022 table->field[7]->set_notnull(); 04023 04024 /* Partition expression */ 04025 if (part_info->part_expr) 04026 { 04027 table->field[9]->store(part_info->part_func_string, 04028 part_info->part_func_len, cs); 04029 } 04030 else if (part_info->list_of_part_fields) 04031 { 04032 collect_partition_expr(part_info->part_field_list, &tmp_str); 04033 table->field[9]->store(tmp_str.ptr(), tmp_str.length(), cs); 04034 } 04035 table->field[9]->set_notnull(); 04036 04037 if (part_info->is_sub_partitioned()) 04038 { 04039 /* Subpartition method */ 04040 tmp_res.length(0); 04041 if (part_info->linear_hash_ind) 04042 tmp_res.append(partition_keywords[PKW_LINEAR].str, 04043 partition_keywords[PKW_LINEAR].length); 04044 if (part_info->list_of_subpart_fields) 04045 tmp_res.append(partition_keywords[PKW_KEY].str, 04046 partition_keywords[PKW_KEY].length); 04047 else 04048 tmp_res.append(partition_keywords[PKW_HASH].str, 04049 partition_keywords[PKW_HASH].length); 04050 table->field[8]->store(tmp_res.ptr(), tmp_res.length(), cs); 04051 table->field[8]->set_notnull(); 04052 04053 /* Subpartition expression */ 04054 if (part_info->subpart_expr) 04055 { 04056 table->field[10]->store(part_info->subpart_func_string, 04057 part_info->subpart_func_len, cs); 04058 } 04059 else if (part_info->list_of_subpart_fields) 04060 { 04061 collect_partition_expr(part_info->subpart_field_list, &tmp_str); 04062 table->field[10]->store(tmp_str.ptr(), tmp_str.length(), cs); 04063 } 04064 table->field[10]->set_notnull(); 04065 } 04066 04067 while ((part_elem= part_it++)) 04068 { 04069 04070 04071 table->field[3]->store(part_elem->partition_name, 04072 strlen(part_elem->partition_name), cs); 04073 table->field[3]->set_notnull(); 04074 /* PARTITION_ORDINAL_POSITION */ 04075 table->field[5]->store((longlong) ++part_pos, TRUE); 04076 table->field[5]->set_notnull(); 04077 04078 /* Partition description */ 04079 if (part_info->part_type == RANGE_PARTITION) 04080 { 04081 if (part_elem->range_value != LONGLONG_MAX) 04082 table->field[11]->store((longlong) part_elem->range_value, FALSE); 04083 else 04084 table->field[11]->store(partition_keywords[PKW_MAXVALUE].str, 04085 partition_keywords[PKW_MAXVALUE].length, cs); 04086 table->field[11]->set_notnull(); 04087 } 04088 else if (part_info->part_type == LIST_PARTITION) 04089 { 04090 List_iterator<part_elem_value> list_val_it(part_elem->list_val_list); 04091 part_elem_value *list_value; 04092 uint no_items= part_elem->list_val_list.elements; 04093 tmp_str.length(0); 04094 tmp_res.length(0); 04095 if (part_elem->has_null_value) 04096 { 04097 tmp_str.append("NULL"); 04098 if (no_items > 0) 04099 tmp_str.append(","); 04100 } 04101 while ((list_value= list_val_it++)) 04102 { 04103 if (!list_value->unsigned_flag) 04104 tmp_res.set(list_value->value, cs); 04105 else 04106 tmp_res.set((ulonglong)list_value->value, cs); 04107 tmp_str.append(tmp_res); 04108 if (--no_items != 0) 04109 tmp_str.append(","); 04110 }; 04111 table->field[11]->store(tmp_str.ptr(), tmp_str.length(), cs); 04112 table->field[11]->set_notnull(); 04113 } 04114 04115 if (part_elem->subpartitions.elements) 04116 { 04117 List_iterator<partition_element> sub_it(part_elem->subpartitions); 04118 partition_element *subpart_elem; 04119 uint subpart_pos= 0; 04120 04121 while ((subpart_elem= sub_it++)) 04122 { 04123 table->field[4]->store(subpart_elem->partition_name, 04124 strlen(subpart_elem->partition_name), cs); 04125 table->field[4]->set_notnull(); 04126 /* SUBPARTITION_ORDINAL_POSITION */ 04127 table->field[6]->store((longlong) ++subpart_pos, TRUE); 04128 table->field[6]->set_notnull(); 04129 04130 store_schema_partitions_record(thd, table, subpart_elem, 04131 file, part_id); 04132 part_id++; 04133 if(schema_table_store_record(thd, table)) 04134 DBUG_RETURN(1); 04135 } 04136 } 04137 else 04138 { 04139 store_schema_partitions_record(thd, table, part_elem, 04140 file, part_id); 04141 part_id++; 04142 if(schema_table_store_record(thd, table)) 04143 DBUG_RETURN(1); 04144 } 04145 } 04146 DBUG_RETURN(0); 04147 } 04148 else 04149 #endif 04150 {

