diff options
Diffstat (limited to 'sql/sql_show.cc')
-rw-r--r-- | sql/sql_show.cc | 100 |
1 files changed, 62 insertions, 38 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 02cfba8fae0..aa62b98bd13 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -83,6 +83,7 @@ static void store_key_options(THD *thd, String *packet, TABLE *table, static void append_algorithm(TABLE_LIST *table, String *buff); +static COND * make_cond_for_info_schema(COND *cond, TABLE_LIST *table); /*************************************************************************** ** List all table types supported @@ -2072,7 +2073,8 @@ static bool show_status_array(THD *thd, const char *wild, enum enum_var_type value_type, struct system_status_var *status_var, const char *prefix, TABLE *table, - bool ucase_names) + bool ucase_names, + COND *cond) { MY_ALIGNED_BYTE_ARRAY(buff_data, SHOW_VAR_FUNC_BUFF_SIZE, long); char * const buff= (char *) &buff_data; @@ -2082,8 +2084,13 @@ static bool show_status_array(THD *thd, const char *wild, int len; LEX_STRING null_lex_str; SHOW_VAR tmp, *var; + COND *partial_cond= 0; + enum_check_fields save_count_cuted_fields= thd->count_cuted_fields; + bool res= FALSE; + CHARSET_INFO *charset= system_charset_info; DBUG_ENTER("show_status_array"); + thd->count_cuted_fields= CHECK_FIELD_WARN; null_lex_str.str= 0; // For sys_var->value_ptr() null_lex_str.length= 0; @@ -2091,6 +2098,7 @@ static bool show_status_array(THD *thd, const char *wild, if (*prefix) *prefix_end++= '_'; len=name_buffer + sizeof(name_buffer) - prefix_end; + partial_cond= make_cond_for_info_schema(cond, table->pos_in_table_list); for (; variables->name; variables++) { @@ -2099,6 +2107,9 @@ static bool show_status_array(THD *thd, const char *wild, if (ucase_names) make_upper(name_buffer); + restore_record(table, s->default_values); + table->field[0]->store(name_buffer, strlen(name_buffer), + system_charset_info); /* if var->type is SHOW_FUNC, call the function. Repeat as necessary, if new var is again SHOW_FUNC @@ -2110,12 +2121,13 @@ static bool show_status_array(THD *thd, const char *wild, if (show_type == SHOW_ARRAY) { show_status_array(thd, wild, (SHOW_VAR *) var->value, value_type, - status_var, name_buffer, table, ucase_names); + status_var, name_buffer, table, ucase_names, partial_cond); } else { if (!(wild && wild[0] && wild_case_compare(system_charset_info, - name_buffer, wild))) + name_buffer, wild)) && + (!partial_cond || partial_cond->val_int())) { char *value=var->value; const char *pos, *end; // We assign a lot of const's @@ -2124,9 +2136,10 @@ static bool show_status_array(THD *thd, const char *wild, if (show_type == SHOW_SYS) { - show_type= ((sys_var*) value)->show_type(); - value= (char*) ((sys_var*) value)->value_ptr(thd, value_type, - &null_lex_str); + sys_var *var= ((sys_var *) value); + show_type= var->show_type(); + value= (char*) var->value_ptr(thd, value_type, &null_lex_str); + charset= var->charset(thd); } pos= end= buff; @@ -2202,21 +2215,23 @@ static bool show_status_array(THD *thd, const char *wild, DBUG_ASSERT(0); break; } - restore_record(table, s->default_values); - table->field[0]->store(name_buffer, strlen(name_buffer), - system_charset_info); - table->field[1]->store(pos, (uint32) (end - pos), system_charset_info); + table->field[1]->store(pos, (uint32) (end - pos), charset); + thd->count_cuted_fields= CHECK_FIELD_IGNORE; table->field[1]->set_notnull(); pthread_mutex_unlock(&LOCK_global_system_variables); if (schema_table_store_record(thd, table)) - DBUG_RETURN(TRUE); + { + res= TRUE; + goto end; + } } } } - - DBUG_RETURN(FALSE); +end: + thd->count_cuted_fields= save_count_cuted_fields; + DBUG_RETURN(res); } @@ -3498,6 +3513,7 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, TABLE_SHARE *share= show_table->s; handler *file= show_table->file; handlerton *tmp_db_type= share->db_type(); + bool is_partitioned= FALSE; if (share->tmp_table == SYSTEM_TMP_TABLE) table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"), cs); else if (share->tmp_table) @@ -3514,7 +3530,10 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, #ifdef WITH_PARTITION_STORAGE_ENGINE if (share->db_type() == partition_hton && share->partition_info_len) + { tmp_db_type= share->default_part_db_type; + is_partitioned= TRUE; + } #endif tmp_buff= (char *) ha_resolve_storage_engine_name(tmp_db_type); table->field[4]->store(tmp_buff, strlen(tmp_buff), cs); @@ -3559,9 +3578,7 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, NullS); } #ifdef WITH_PARTITION_STORAGE_ENGINE - if (show_table->s->db_type() == partition_hton && - show_table->part_info != NULL && - show_table->part_info->no_parts > 0) + if (is_partitioned) ptr= strmov(ptr, " partitioned"); #endif if (share->transactional != HA_CHOICE_UNDEF) @@ -5244,7 +5261,7 @@ int fill_variables(THD *thd, TABLE_LIST *tables, COND *cond) rw_rdlock(&LOCK_system_variables_hash); res= show_status_array(thd, wild, enumerate_sys_vars(thd, sorted_vars), - option_type, NULL, "", tables->table, upper_case_names); + option_type, NULL, "", tables->table, upper_case_names, cond); rw_unlock(&LOCK_system_variables_hash); DBUG_RETURN(res); } @@ -5287,7 +5304,7 @@ int fill_status(THD *thd, TABLE_LIST *tables, COND *cond) res= show_status_array(thd, wild, (SHOW_VAR *)all_status_vars.buffer, option_type, tmp1, "", tables->table, - upper_case_names); + upper_case_names, cond); pthread_mutex_unlock(&LOCK_status); DBUG_RETURN(res); } @@ -6013,9 +6030,10 @@ ST_FIELD_INFO schema_fields_info[]= {"CATALOG_NAME", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, {"SCHEMA_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Database", SKIP_OPEN_TABLE}, - {"DEFAULT_CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 0, 0, + {"DEFAULT_CHARACTER_SET_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, 0, + SKIP_OPEN_TABLE}, + {"DEFAULT_COLLATION_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, - {"DEFAULT_COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, {"SQL_PATH", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; @@ -6049,7 +6067,8 @@ ST_FIELD_INFO tables_fields_info[]= {"CREATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, "Create_time", OPEN_FULL_TABLE}, {"UPDATE_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, "Update_time", OPEN_FULL_TABLE}, {"CHECK_TIME", 0, MYSQL_TYPE_DATETIME, 0, 1, "Check_time", OPEN_FULL_TABLE}, - {"TABLE_COLLATION", 64, MYSQL_TYPE_STRING, 0, 1, "Collation", OPEN_FRM_ONLY}, + {"TABLE_COLLATION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 1, "Collation", + OPEN_FRM_ONLY}, {"CHECKSUM", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), "Checksum", OPEN_FULL_TABLE}, {"CREATE_OPTIONS", 255, MYSQL_TYPE_STRING, 0, 1, "Create_options", @@ -6080,8 +6099,10 @@ ST_FIELD_INFO columns_fields_info[]= 0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY}, {"NUMERIC_SCALE", MY_INT64_NUM_DECIMAL_DIGITS , MYSQL_TYPE_LONGLONG, 0, (MY_I_S_MAYBE_NULL | MY_I_S_UNSIGNED), 0, OPEN_FRM_ONLY}, - {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FRM_ONLY}, - {"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 1, "Collation", OPEN_FRM_ONLY}, + {"CHARACTER_SET_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 1, 0, + OPEN_FRM_ONLY}, + {"COLLATION_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 1, "Collation", + OPEN_FRM_ONLY}, {"COLUMN_TYPE", 65535, MYSQL_TYPE_STRING, 0, 0, "Type", OPEN_FRM_ONLY}, {"COLUMN_KEY", 3, MYSQL_TYPE_STRING, 0, 0, "Key", OPEN_FRM_ONLY}, {"EXTRA", 27, MYSQL_TYPE_STRING, 0, 0, "Extra", OPEN_FRM_ONLY}, @@ -6093,10 +6114,10 @@ ST_FIELD_INFO columns_fields_info[]= ST_FIELD_INFO charsets_fields_info[]= { - {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Charset", - SKIP_OPEN_TABLE}, - {"DEFAULT_COLLATE_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Default collation", + {"CHARACTER_SET_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, "Charset", SKIP_OPEN_TABLE}, + {"DEFAULT_COLLATE_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, + "Default collation", SKIP_OPEN_TABLE}, {"DESCRIPTION", 60, MYSQL_TYPE_STRING, 0, 0, "Description", SKIP_OPEN_TABLE}, {"MAXLEN", 3, MYSQL_TYPE_LONGLONG, 0, 0, "Maxlen", SKIP_OPEN_TABLE}, @@ -6106,8 +6127,9 @@ ST_FIELD_INFO charsets_fields_info[]= ST_FIELD_INFO collation_fields_info[]= { - {"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Collation", SKIP_OPEN_TABLE}, - {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Charset", + {"COLLATION_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, "Collation", + SKIP_OPEN_TABLE}, + {"CHARACTER_SET_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, "Charset", SKIP_OPEN_TABLE}, {"ID", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Id", SKIP_OPEN_TABLE}, @@ -6170,8 +6192,10 @@ ST_FIELD_INFO events_fields_info[]= ST_FIELD_INFO coll_charset_app_fields_info[]= { - {"COLLATION_NAME", 64, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, - {"CHARACTER_SET_NAME", 64, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"COLLATION_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, 0, + SKIP_OPEN_TABLE}, + {"CHARACTER_SET_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, 0, + SKIP_OPEN_TABLE}, {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; @@ -6200,7 +6224,7 @@ ST_FIELD_INFO proc_fields_info[]= SKIP_OPEN_TABLE}, {"CREATED", 0, MYSQL_TYPE_DATETIME, 0, 0, "Created", SKIP_OPEN_TABLE}, {"LAST_ALTERED", 0, MYSQL_TYPE_DATETIME, 0, 0, "Modified", SKIP_OPEN_TABLE}, - {"SQL_MODE", 65535, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"SQL_MODE", 32*256, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, {"ROUTINE_COMMENT", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Comment", SKIP_OPEN_TABLE}, {"DEFINER", 77, MYSQL_TYPE_STRING, 0, 0, "Definer", SKIP_OPEN_TABLE}, @@ -6449,7 +6473,7 @@ ST_FIELD_INFO variables_fields_info[]= { {"VARIABLE_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Variable_name", SKIP_OPEN_TABLE}, - {"VARIABLE_VALUE", 20480, MYSQL_TYPE_STRING, 0, 1, "Value", SKIP_OPEN_TABLE}, + {"VARIABLE_VALUE", 1024, MYSQL_TYPE_STRING, 0, 1, "Value", SKIP_OPEN_TABLE}, {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; @@ -6608,9 +6632,9 @@ ST_SCHEMA_TABLE schema_tables[]= {"FILES", files_fields_info, create_schema_table, fill_schema_files, 0, 0, -1, -1, 0, 0}, {"GLOBAL_STATUS", variables_fields_info, create_schema_table, - fill_status, make_old_format, 0, -1, -1, 0, 0}, + fill_status, make_old_format, 0, 0, -1, 0, 0}, {"GLOBAL_VARIABLES", variables_fields_info, create_schema_table, - fill_variables, make_old_format, 0, -1, -1, 0, 0}, + fill_variables, make_old_format, 0, 0, -1, 0, 0}, {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table, get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0, OPEN_TABLE_ONLY}, @@ -6635,14 +6659,14 @@ ST_SCHEMA_TABLE schema_tables[]= {"SCHEMA_PRIVILEGES", schema_privileges_fields_info, create_schema_table, fill_schema_schema_privileges, 0, 0, -1, -1, 0, 0}, {"SESSION_STATUS", variables_fields_info, create_schema_table, - fill_status, make_old_format, 0, -1, -1, 0, 0}, + fill_status, make_old_format, 0, 0, -1, 0, 0}, {"SESSION_VARIABLES", variables_fields_info, create_schema_table, - fill_variables, make_old_format, 0, -1, -1, 0, 0}, + fill_variables, make_old_format, 0, 0, -1, 0, 0}, {"STATISTICS", stat_fields_info, create_schema_table, get_all_tables, make_old_format, get_schema_stat_record, 1, 2, 0, OPEN_TABLE_ONLY|OPTIMIZE_I_S_TABLE}, {"STATUS", variables_fields_info, create_schema_table, fill_status, - make_old_format, 0, -1, -1, 1, 0}, + make_old_format, 0, 0, -1, 1, 0}, {"TABLES", tables_fields_info, create_schema_table, get_all_tables, make_old_format, get_schema_tables_record, 1, 2, 0, OPTIMIZE_I_S_TABLE}, @@ -6658,7 +6682,7 @@ ST_SCHEMA_TABLE schema_tables[]= {"USER_PRIVILEGES", user_privileges_fields_info, create_schema_table, fill_schema_user_privileges, 0, 0, -1, -1, 0, 0}, {"VARIABLES", variables_fields_info, create_schema_table, fill_variables, - make_old_format, 0, -1, -1, 1, 0}, + make_old_format, 0, 0, -1, 1, 0}, {"VIEWS", view_fields_info, create_schema_table, get_all_tables, 0, get_schema_views_record, 1, 2, 0, OPEN_VIEW_ONLY|OPTIMIZE_I_S_TABLE}, |