diff options
| author | Sergei Golubchik <serg@mariadb.org> | 2014-08-25 19:08:01 +0200 |
|---|---|---|
| committer | Sergei Golubchik <serg@mariadb.org> | 2014-10-11 18:53:04 +0200 |
| commit | db8af31831beb949dfcf7675b3c6392dc52dc38c (patch) | |
| tree | 875eb553866accbb0f05bfe8cbe3a789752d86f2 /sql | |
| parent | 932eaf31e91cf875e336b8d9332682aca03c6e58 (diff) | |
| download | mariadb-git-db8af31831beb949dfcf7675b3c6392dc52dc38c.tar.gz | |
SHOW and FLUSH for I_S tables.
Extend existing plugins to support
* SHOW QUERY_RESPONSE_TIME
* FLUSH QUERY_RESPONSE_TIME
* SHOW LOCALE
move userstat tables to use the new API instead of
hand-coded syntax
Diffstat (limited to 'sql')
| -rw-r--r-- | sql/lex.h | 4 | ||||
| -rw-r--r-- | sql/mysqld.cc | 5 | ||||
| -rw-r--r-- | sql/sql_cmd.h | 6 | ||||
| -rw-r--r-- | sql/sql_parse.cc | 35 | ||||
| -rw-r--r-- | sql/sql_reload.cc | 41 | ||||
| -rw-r--r-- | sql/sql_show.cc | 162 | ||||
| -rw-r--r-- | sql/sql_show.h | 3 | ||||
| -rw-r--r-- | sql/sql_yacc.yy | 123 | ||||
| -rw-r--r-- | sql/table.h | 4 |
9 files changed, 185 insertions, 198 deletions
diff --git a/sql/lex.h b/sql/lex.h index 41be9b2673d..fe6298a2611 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -116,7 +116,6 @@ static SYMBOL symbols[] = { { "CIPHER", SYM(CIPHER_SYM)}, { "CLASS_ORIGIN", SYM(CLASS_ORIGIN_SYM)}, { "CLIENT", SYM(CLIENT_SYM)}, - { "CLIENT_STATISTICS", SYM(CLIENT_STATS_SYM)}, { "CLOSE", SYM(CLOSE_SYM)}, { "COALESCE", SYM(COALESCE)}, { "CODE", SYM(CODE_SYM)}, @@ -279,7 +278,6 @@ static SYMBOL symbols[] = { { "IN", SYM(IN_SYM)}, { "INDEX", SYM(INDEX_SYM)}, { "INDEXES", SYM(INDEXES)}, - { "INDEX_STATISTICS", SYM(INDEX_STATS_SYM)}, { "INFILE", SYM(INFILE)}, { "INITIAL_SIZE", SYM(INITIAL_SIZE_SYM)}, { "INNER", SYM(INNER_SYM)}, @@ -591,7 +589,6 @@ static SYMBOL symbols[] = { { "TABLE_NAME", SYM(TABLE_NAME_SYM)}, { "TABLES", SYM(TABLES)}, { "TABLESPACE", SYM(TABLESPACE)}, - { "TABLE_STATISTICS", SYM(TABLE_STATS_SYM)}, { "TABLE_CHECKSUM", SYM(TABLE_CHECKSUM_SYM)}, { "TEMPORARY", SYM(TEMPORARY)}, { "TEMPTABLE", SYM(TEMPTABLE_SYM)}, @@ -635,7 +632,6 @@ static SYMBOL symbols[] = { { "USE", SYM(USE_SYM)}, { "USER", SYM(USER)}, { "USER_RESOURCES", SYM(RESOURCES)}, - { "USER_STATISTICS", SYM(USER_STATS_SYM)}, { "USE_FRM", SYM(USE_FRM)}, { "USING", SYM(USING)}, { "UTC_DATE", SYM(UTC_DATE_SYM)}, diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b21c588abe1..38f91967312 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3781,7 +3781,6 @@ SHOW_VAR com_status_vars[]= { {"show_binlog_events", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_BINLOG_EVENTS]), SHOW_LONG_STATUS}, {"show_binlogs", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_BINLOGS]), SHOW_LONG_STATUS}, {"show_charsets", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CHARSETS]), SHOW_LONG_STATUS}, - {"show_client_statistics", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CLIENT_STATS]), SHOW_LONG_STATUS}, {"show_collations", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_COLLATIONS]), SHOW_LONG_STATUS}, {"show_contributors", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CONTRIBUTORS]), SHOW_LONG_STATUS}, {"show_create_db", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CREATE_DB]), SHOW_LONG_STATUS}, @@ -3802,8 +3801,8 @@ SHOW_VAR com_status_vars[]= { {"show_function_code", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_FUNC_CODE]), SHOW_LONG_STATUS}, #endif {"show_function_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_STATUS_FUNC]), SHOW_LONG_STATUS}, + {"show_generic", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_GENERIC]), SHOW_LONG_STATUS}, {"show_grants", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_GRANTS]), SHOW_LONG_STATUS}, - {"show_index_statistics", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_INDEX_STATS]), SHOW_LONG_STATUS}, {"show_keys", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_KEYS]), SHOW_LONG_STATUS}, {"show_master_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_MASTER_STAT]), SHOW_LONG_STATUS}, {"show_open_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_OPEN_TABLES]), SHOW_LONG_STATUS}, @@ -3821,11 +3820,9 @@ SHOW_VAR com_status_vars[]= { {"show_slave_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_STAT]), SHOW_LONG_STATUS}, {"show_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_STATUS]), SHOW_LONG_STATUS}, {"show_storage_engines", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_STORAGE_ENGINES]), SHOW_LONG_STATUS}, - {"show_table_statistics", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TABLE_STATS]), SHOW_LONG_STATUS}, {"show_table_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TABLE_STATUS]), SHOW_LONG_STATUS}, {"show_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TABLES]), SHOW_LONG_STATUS}, {"show_triggers", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TRIGGERS]), SHOW_LONG_STATUS}, - {"show_user_statistics", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_USER_STATS]), SHOW_LONG_STATUS}, {"show_variables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_VARIABLES]), SHOW_LONG_STATUS}, {"show_warnings", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_WARNS]), SHOW_LONG_STATUS}, {"shutdown", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHUTDOWN]), SHOW_LONG_STATUS}, diff --git a/sql/sql_cmd.h b/sql/sql_cmd.h index 09b3d927d92..dcc0b3303d8 100644 --- a/sql/sql_cmd.h +++ b/sql/sql_cmd.h @@ -78,8 +78,7 @@ enum enum_sql_command { SQLCOM_ALTER_TABLESPACE, SQLCOM_INSTALL_PLUGIN, SQLCOM_UNINSTALL_PLUGIN, SQLCOM_SHOW_AUTHORS, SQLCOM_BINLOG_BASE64_EVENT, - SQLCOM_SHOW_PLUGINS, - SQLCOM_SHOW_CONTRIBUTORS, + SQLCOM_SHOW_PLUGINS, SQLCOM_SHOW_CONTRIBUTORS, SQLCOM_CREATE_SERVER, SQLCOM_DROP_SERVER, SQLCOM_ALTER_SERVER, SQLCOM_CREATE_EVENT, SQLCOM_ALTER_EVENT, SQLCOM_DROP_EVENT, SQLCOM_SHOW_CREATE_EVENT, SQLCOM_SHOW_EVENTS, @@ -89,12 +88,11 @@ enum enum_sql_command { SQLCOM_SIGNAL, SQLCOM_RESIGNAL, SQLCOM_SHOW_RELAYLOG_EVENTS, SQLCOM_GET_DIAGNOSTICS, - SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS, - SQLCOM_SHOW_CLIENT_STATS, SQLCOM_SLAVE_ALL_START, SQLCOM_SLAVE_ALL_STOP, SQLCOM_SHOW_EXPLAIN, SQLCOM_SHUTDOWN, SQLCOM_CREATE_ROLE, SQLCOM_DROP_ROLE, SQLCOM_GRANT_ROLE, SQLCOM_REVOKE_ROLE, SQLCOM_COMPOUND, + SQLCOM_SHOW_GENERIC, /* When a command is added here, be sure it's also added in mysqld.cc diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 262301b21da..452252788a9 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -390,6 +390,7 @@ void init_update_queries(void) sql_command_flags[SQLCOM_SHOW_EVENTS]= CF_STATUS_COMMAND | CF_REEXECUTION_FRAGILE; sql_command_flags[SQLCOM_SHOW_OPEN_TABLES]= CF_STATUS_COMMAND | CF_REEXECUTION_FRAGILE; sql_command_flags[SQLCOM_SHOW_PLUGINS]= CF_STATUS_COMMAND; + sql_command_flags[SQLCOM_SHOW_GENERIC]= CF_STATUS_COMMAND; sql_command_flags[SQLCOM_SHOW_FIELDS]= CF_STATUS_COMMAND | CF_REEXECUTION_FRAGILE; sql_command_flags[SQLCOM_SHOW_KEYS]= CF_STATUS_COMMAND | CF_REEXECUTION_FRAGILE; sql_command_flags[SQLCOM_SHOW_VARIABLES]= CF_STATUS_COMMAND | CF_REEXECUTION_FRAGILE; @@ -424,10 +425,6 @@ void init_update_queries(void) sql_command_flags[SQLCOM_SHOW_PROFILES]= CF_STATUS_COMMAND; sql_command_flags[SQLCOM_SHOW_PROFILE]= CF_STATUS_COMMAND; sql_command_flags[SQLCOM_BINLOG_BASE64_EVENT]= CF_STATUS_COMMAND | CF_CAN_GENERATE_ROW_EVENTS; - sql_command_flags[SQLCOM_SHOW_CLIENT_STATS]= CF_STATUS_COMMAND; - sql_command_flags[SQLCOM_SHOW_USER_STATS]= CF_STATUS_COMMAND; - sql_command_flags[SQLCOM_SHOW_TABLE_STATS]= CF_STATUS_COMMAND; - sql_command_flags[SQLCOM_SHOW_INDEX_STATS]= CF_STATUS_COMMAND; sql_command_flags[SQLCOM_SHOW_TABLES]= (CF_STATUS_COMMAND | CF_SHOW_TABLE_COMMAND | CF_REEXECUTION_FRAGILE); sql_command_flags[SQLCOM_SHOW_TABLE_STATUS]= (CF_STATUS_COMMAND | CF_SHOW_TABLE_COMMAND | CF_REEXECUTION_FRAGILE); @@ -2122,32 +2119,15 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident, case SCH_CLIENT_STATS: if (check_global_access(thd, SUPER_ACL | PROCESS_ACL, true)) DBUG_RETURN(1); - case SCH_TABLE_STATS: - case SCH_INDEX_STATS: - case SCH_OPEN_TABLES: - case SCH_PROCEDURES: - case SCH_CHARSETS: - case SCH_ENGINES: - case SCH_COLLATIONS: - case SCH_COLLATION_CHARACTER_SET_APPLICABILITY: - case SCH_USER_PRIVILEGES: - case SCH_SCHEMA_PRIVILEGES: - case SCH_TABLE_PRIVILEGES: - case SCH_COLUMN_PRIVILEGES: - case SCH_TABLE_CONSTRAINTS: - case SCH_KEY_COLUMN_USAGE: default: break; } SELECT_LEX *select_lex= lex->current_select; - if (make_schema_select(thd, select_lex, schema_table_idx)) - { + if (make_schema_select(thd, select_lex, get_schema_table(schema_table_idx))) DBUG_RETURN(1); - } - TABLE_LIST *table_list= select_lex->table_list.first; - table_list->schema_select_lex= schema_select_lex; - table_list->schema_table_reformed= 1; + + select_lex->table_list.first->schema_select_lex= schema_select_lex; DBUG_RETURN(0); } @@ -2794,17 +2774,14 @@ mysql_execute_command(THD *thd) case SQLCOM_SHOW_TRIGGERS: case SQLCOM_SHOW_TABLE_STATUS: case SQLCOM_SHOW_OPEN_TABLES: - case SQLCOM_SHOW_PLUGINS: + case SQLCOM_SHOW_GENERIC: case SQLCOM_SHOW_FIELDS: case SQLCOM_SHOW_KEYS: - case SQLCOM_SHOW_CLIENT_STATS: - case SQLCOM_SHOW_USER_STATS: - case SQLCOM_SHOW_TABLE_STATS: - case SQLCOM_SHOW_INDEX_STATS: case SQLCOM_SELECT: if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd)) goto error; + case SQLCOM_SHOW_PLUGINS: case SQLCOM_SHOW_VARIABLES: case SQLCOM_SHOW_CHARSETS: case SQLCOM_SHOW_COLLATIONS: diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index 91d412a0c39..24e5d053145 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -25,6 +25,7 @@ #include "hostname.h" // hostname_cache_refresh #include "sql_repl.h" // reset_master, reset_slave #include "rpl_mi.h" // Master_info::data_lock +#include "sql_show.h" #include "debug_sync.h" #include "rpl_mi.h" @@ -377,35 +378,17 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options, #endif if (options & REFRESH_USER_RESOURCES) reset_mqh((LEX_USER *) NULL, 0); /* purecov: inspected */ - if (options & REFRESH_TABLE_STATS) - { - mysql_mutex_lock(&LOCK_global_table_stats); - free_global_table_stats(); - init_global_table_stats(); - mysql_mutex_unlock(&LOCK_global_table_stats); - } - if (options & REFRESH_INDEX_STATS) - { - mysql_mutex_lock(&LOCK_global_index_stats); - free_global_index_stats(); - init_global_index_stats(); - mysql_mutex_unlock(&LOCK_global_index_stats); - } - if (options & (REFRESH_USER_STATS | REFRESH_CLIENT_STATS)) - { - mysql_mutex_lock(&LOCK_global_user_client_stats); - if (options & REFRESH_USER_STATS) - { - free_global_user_stats(); - init_global_user_stats(); - } - if (options & REFRESH_CLIENT_STATS) - { - free_global_client_stats(); - init_global_client_stats(); - } - mysql_mutex_unlock(&LOCK_global_user_client_stats); - } + if (options & REFRESH_GENERIC) + { + List_iterator_fast<LEX_STRING> li(thd->lex->view_list); + LEX_STRING *ls; + while ((ls= li++)) + { + ST_SCHEMA_TABLE *table= find_schema_table(thd, ls->str); + if (table->reset_table()) + result= 1; + } + } if (*write_to_binlog != -1) *write_to_binlog= tmp_write_to_binlog; /* diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 3caef3b7c44..07ddb3fbea7 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -3350,6 +3350,41 @@ int fill_schema_index_stats(THD *thd, TABLE_LIST *tables, COND *cond) DBUG_RETURN(0); } +static int reset_schema_user_stats() +{ + mysql_mutex_lock(&LOCK_global_user_client_stats); + free_global_user_stats(); + init_global_user_stats(); + mysql_mutex_unlock(&LOCK_global_user_client_stats); + return 0; +} + +static int reset_schema_client_stats() +{ + mysql_mutex_lock(&LOCK_global_user_client_stats); + free_global_client_stats(); + init_global_client_stats(); + mysql_mutex_unlock(&LOCK_global_user_client_stats); + return 0; +} + +static int reset_schema_table_stats() +{ + mysql_mutex_lock(&LOCK_global_table_stats); + free_global_table_stats(); + init_global_table_stats(); + mysql_mutex_unlock(&LOCK_global_table_stats); + return 0; +} + +static int reset_schema_index_stats() +{ + mysql_mutex_lock(&LOCK_global_index_stats); + free_global_index_stats(); + init_global_index_stats(); + mysql_mutex_unlock(&LOCK_global_index_stats); + return 0; +} /* collect status for all running threads */ @@ -3677,6 +3712,15 @@ bool get_lookup_field_values(THD *thd, COND *cond, TABLE_LIST *tables, bzero((char*) lookup_field_values, sizeof(LOOKUP_FIELD_VALUES)); switch (lex->sql_command) { + case SQLCOM_SHOW_PLUGINS: + if (lex->ident.str) + { + thd->make_lex_string(&lookup_field_values->db_value, + lex->ident.str, lex->ident.length); + break; + } + /* fall through */ + case SQLCOM_SHOW_GENERIC: case SQLCOM_SHOW_DATABASES: if (wild) { @@ -3698,17 +3742,6 @@ bool get_lookup_field_values(THD *thd, COND *cond, TABLE_LIST *tables, lookup_field_values->wild_table_value= 1; } break; - case SQLCOM_SHOW_PLUGINS: - if (lex->ident.str) - thd->make_lex_string(&lookup_field_values->db_value, - lex->ident.str, lex->ident.length); - else if (lex->wild) - { - thd->make_lex_string(&lookup_field_values->db_value, - lex->wild->ptr(), lex->wild->length()); - lookup_field_values->wild_db_value= 1; - } - break; default: /* The "default" is for queries over I_S. @@ -7593,7 +7626,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list) 0 success */ -int make_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table) +static int make_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table) { ST_FIELD_INFO *field_info= schema_table->fields_info; Name_resolution_context *context= &thd->lex->select_lex.context; @@ -7779,7 +7812,7 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list) { TABLE *table; DBUG_ENTER("mysql_schema_table"); - if (!(table= table_list->schema_table->create_table(thd, table_list))) + if (!(table= create_schema_table(thd, table_list))) DBUG_RETURN(1); table->s->tmp_table= SYSTEM_TMP_TABLE; table->grant.privilege= SELECT_ACL; @@ -7859,9 +7892,8 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list) */ int make_schema_select(THD *thd, SELECT_LEX *sel, - enum enum_schema_tables schema_table_idx) + ST_SCHEMA_TABLE *schema_table) { - ST_SCHEMA_TABLE *schema_table= get_schema_table(schema_table_idx); LEX_STRING db, table; DBUG_ENTER("make_schema_select"); DBUG_PRINT("enter", ("mysql_schema_select: %s", schema_table->table_name)); @@ -7878,13 +7910,13 @@ int make_schema_select(THD *thd, SELECT_LEX *sel, DBUG_RETURN(1); if (schema_table->old_format(thd, schema_table)) - DBUG_RETURN(1); if (!sel->add_table_to_list(thd, new Table_ident(thd, db, table, 0), 0, 0, TL_READ, MDL_SHARED_READ)) DBUG_RETURN(1); + sel->table_list.first->schema_table_reformed= 1; DBUG_RETURN(0); } @@ -9024,103 +9056,103 @@ ST_FIELD_INFO show_explain_fields_info[]= ST_SCHEMA_TABLE schema_tables[]= { - {"ALL_PLUGINS", plugin_fields_info, create_schema_table, + {"ALL_PLUGINS", plugin_fields_info, 0, fill_all_plugins, make_old_format, 0, 5, -1, 0, 0}, - {"APPLICABLE_ROLES", applicable_roles_fields_info, create_schema_table, + {"APPLICABLE_ROLES", applicable_roles_fields_info, 0, fill_schema_applicable_roles, 0, 0, -1, -1, 0, 0}, - {"CHARACTER_SETS", charsets_fields_info, create_schema_table, + {"CHARACTER_SETS", charsets_fields_info, 0, fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0, 0}, - {"CLIENT_STATISTICS", client_stats_fields_info, create_schema_table, + {"CLIENT_STATISTICS", client_stats_fields_info, reset_schema_client_stats, fill_schema_client_stats, make_old_format, 0, -1, -1, 0, 0}, - {"COLLATIONS", collation_fields_info, create_schema_table, + {"COLLATIONS", collation_fields_info, 0, fill_schema_collation, make_old_format, 0, -1, -1, 0, 0}, {"COLLATION_CHARACTER_SET_APPLICABILITY", coll_charset_app_fields_info, - create_schema_table, fill_schema_coll_charset_app, 0, 0, -1, -1, 0, 0}, - {"COLUMNS", columns_fields_info, create_schema_table, + 0, fill_schema_coll_charset_app, 0, 0, -1, -1, 0, 0}, + {"COLUMNS", columns_fields_info, 0, get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0, OPTIMIZE_I_S_TABLE|OPEN_VIEW_FULL}, - {"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table, + {"COLUMN_PRIVILEGES", column_privileges_fields_info, 0, fill_schema_column_privileges, 0, 0, -1, -1, 0, 0}, - {"ENABLED_ROLES", enabled_roles_fields_info, create_schema_table, + {"ENABLED_ROLES", enabled_roles_fields_info, 0, fill_schema_enabled_roles, 0, 0, -1, -1, 0, 0}, - {"ENGINES", engines_fields_info, create_schema_table, + {"ENGINES", engines_fields_info, 0, fill_schema_engines, make_old_format, 0, -1, -1, 0, 0}, #ifdef HAVE_EVENT_SCHEDULER - {"EVENTS", events_fields_info, create_schema_table, + {"EVENTS", events_fields_info, 0, Events::fill_schema_events, make_old_format, 0, -1, -1, 0, 0}, #else - {"EVENTS", events_fields_info, create_schema_table, + {"EVENTS", events_fields_info, 0, 0, make_old_format, 0, -1, -1, 0, 0}, #endif - {"EXPLAIN", show_explain_fields_info, create_schema_table, fill_show_explain, + {"EXPLAIN", show_explain_fields_info, 0, fill_show_explain, make_old_format, 0, -1, -1, TRUE /*hidden*/ , 0}, - {"FILES", files_fields_info, create_schema_table, + {"FILES", files_fields_info, 0, hton_fill_schema_table, 0, 0, -1, -1, 0, 0}, - {"GLOBAL_STATUS", variables_fields_info, create_schema_table, + {"GLOBAL_STATUS", variables_fields_info, 0, fill_status, make_old_format, 0, 0, -1, 0, 0}, - {"GLOBAL_VARIABLES", variables_fields_info, create_schema_table, + {"GLOBAL_VARIABLES", variables_fields_info, 0, fill_variables, make_old_format, 0, 0, -1, 0, 0}, - {"INDEX_STATISTICS", index_stats_fields_info, create_schema_table, + {"INDEX_STATISTICS", index_stats_fields_info, reset_schema_index_stats, fill_schema_index_stats, make_old_format, 0, -1, -1, 0, 0}, - {"KEY_CACHES", keycache_fields_info, create_schema_table, - fill_key_cache_tables, make_old_format, 0, -1,-1, 0, 0}, - {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table, + {"KEY_CACHES", keycache_fields_info, 0, + fill_key_cache_tables, 0, 0, -1,-1, 0, 0}, + {"KEY_COLUMN_USAGE", key_column_usage_fields_info, 0, get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0, OPTIMIZE_I_S_TABLE|OPEN_TABLE_ONLY}, - {"OPEN_TABLES", open_tables_fields_info, create_schema_table, + {"OPEN_TABLES", open_tables_fields_info, 0, fill_open_tables, make_old_format, 0, -1, -1, 1, 0}, - {"PARAMETERS", parameters_fields_info, create_schema_table, + {"PARAMETERS", parameters_fields_info, 0, fill_schema_proc, 0, 0, -1, -1, 0, 0}, - {"PARTITIONS", partitions_fields_info, create_schema_table, + {"PARTITIONS", partitions_fields_info, 0, get_all_tables, 0, get_schema_partitions_record, 1, 2, 0, OPTIMIZE_I_S_TABLE|OPEN_TABLE_ONLY}, - {"PLUGINS", plugin_fields_info, create_schema_table, + {"PLUGINS", plugin_fields_info, 0, fill_plugins, make_old_format, 0, -1, -1, 0, 0}, - {"PROCESSLIST", processlist_fields_info, create_schema_table, + {"PROCESSLIST", processlist_fields_info, 0, fill_schema_processlist, make_old_format, 0, -1, -1, 0, 0}, - {"PROFILING", query_profile_statistics_info, create_schema_table, + {"PROFILING", query_profile_statistics_info, 0, fill_query_profile_statistics_info, make_profile_table_for_show, NULL, -1, -1, false, 0}, {"REFERENTIAL_CONSTRAINTS", referential_constraints_fields_info, - create_schema_table, get_all_tables, 0, get_referential_constraints_record, + 0, get_all_tables, 0, get_referential_constraints_record, 1, 9, 0, OPTIMIZE_I_S_TABLE|OPEN_TABLE_ONLY}, - {"ROUTINES", proc_fields_info, create_schema_table, + {"ROUTINES", proc_fields_info, 0, fill_schema_proc, make_proc_old_format, 0, -1, -1, 0, 0}, - {"SCHEMATA", schema_fields_info, create_schema_table, + {"SCHEMATA", schema_fields_info, 0, fill_schema_schemata, make_schemata_old_format, 0, 1, -1, 0, 0}, - {"SCHEMA_PRIVILEGES", schema_privileges_fields_info, create_schema_table, + {"SCHEMA_PRIVILEGES", schema_privileges_fields_info, 0, fill_schema_schema_privileges, 0, 0, -1, -1, 0, 0}, - {"SESSION_STATUS", variables_fields_info, create_schema_table, + {"SESSION_STATUS", variables_fields_info, 0, fill_status, make_old_format, 0, 0, -1, 0, 0}, - {"SESSION_VARIABLES", variables_fields_info, create_schema_table, + {"SESSION_VARIABLES", variables_fields_info, 0, fill_variables, make_old_format, 0, 0, -1, 0, 0}, - {"STATISTICS", stat_fields_info, create_schema_table, + {"STATISTICS", stat_fields_info, 0, get_all_tables, make_old_format, get_schema_stat_record, 1, 2, 0, OPEN_TABLE_ONLY|OPTIMIZE_I_S_TABLE}, - {"SYSTEM_VARIABLES", sysvars_fields_info, create_schema_table, + {"SYSTEM_VARIABLES", sysvars_fields_info, 0, fill_sysvars, make_old_format, 0, 0, -1, 0, 0}, - {"TABLES", tables_fields_info, create_schema_table, + {"TABLES", tables_fields_info, 0, get_all_tables, make_old_format, get_schema_tables_record, 1, 2, 0, OPTIMIZE_I_S_TABLE}, - {"TABLESPACES", tablespaces_fields_info, create_schema_table, + {"TABLESPACES", tablespaces_fields_info, 0, hton_fill_schema_table, 0, 0, -1, -1, 0, 0}, - {"TABLE_CONSTRAINTS", table_constraints_fields_info, create_schema_table, + {"TABLE_CONSTRAINTS", table_constraints_fields_info, 0, get_all_tables, 0, get_schema_constraints_record, 3, 4, 0, OPTIMIZE_I_S_TABLE|OPEN_TABLE_ONLY}, - {"TABLE_NAMES", table_names_fields_info, create_schema_table, + {"TABLE_NAMES", table_names_fields_info, 0, get_all_tables, make_table_names_old_format, 0, 1, 2, 1, OPTIMIZE_I_S_TABLE}, - {"TABLE_PRIVILEGES", table_privileges_fields_info, create_schema_table, + {"TABLE_PRIVILEGES", table_privileges_fields_info, 0, fill_schema_table_privileges, 0, 0, -1, -1, 0, 0}, - {"TABLE_STATISTICS", table_stats_fields_info, create_schema_table, + {"TABLE_STATISTICS", table_stats_fields_info, reset_schema_table_stats, fill_schema_table_stats, make_old_format, 0, -1, -1, 0, 0}, - {"TRIGGERS", triggers_fields_info, create_schema_table, + {"TRIGGERS", triggers_fields_info, 0, get_all_tables, make_old_format, get_schema_triggers_record, 5, 6, 0, OPEN_TRIGGER_ONLY|OPTIMIZE_I_S_TABLE}, - {"USER_PRIVILEGES", user_privileges_fields_info, create_schema_table, + {"USER_PRIVILEGES", user_privileges_fields_info, 0, fill_schema_user_privileges, 0, 0, -1, -1, 0, 0}, - {"USER_STATISTICS", user_stats_fields_info, create_schema_table, + {"USER_STATISTICS", user_stats_fields_info, reset_schema_user_stats, fill_schema_user_stats, make_old_format, 0, -1, -1, 0, 0}, - {"VIEWS", view_fields_info, create_schema_table, + {"VIEWS", view_fields_info, 0, get_all_tables, 0, get_schema_views_record, 1, 2, 0, OPEN_VIEW_ONLY|OPTIMIZE_I_S_TABLE}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} @@ -9139,8 +9171,6 @@ int initialize_schema_table(st_plugin_int *plugin) plugin->data= schema_table; // shortcut for the future if (plugin->plugin->init) { - schema_table->create_table= create_schema_table; - schema_table->old_format= make_old_format; schema_table->idx_field1= -1, schema_table->idx_field2= -1; @@ -9156,6 +9186,14 @@ int initialize_schema_table(st_plugin_int *plugin) DBUG_RETURN(1); } + if (!schema_table->old_format) + for (ST_FIELD_INFO *f= schema_table->fields_info; f->field_name; f++) + if (f->old_name && f->old_name[0]) + { + schema_table->old_format= make_old_format; + break; + } + /* Make sure the plugin name is not set inside the init() function. */ schema_table->table_name= plugin->name.str; } diff --git a/sql/sql_show.h b/sql/sql_show.h index 6373978ef49..a759c8d94f5 100644 --- a/sql/sql_show.h +++ b/sql/sql_show.h @@ -117,11 +117,12 @@ COND *make_cond_for_info_schema(COND *cond, TABLE_LIST *table); ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name); ST_SCHEMA_TABLE *get_schema_table(enum enum_schema_tables schema_table_idx); int make_schema_select(THD *thd, SELECT_LEX *sel, - enum enum_schema_tables schema_table_idx); + ST_SCHEMA_TABLE *schema_table); int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list); bool get_schema_tables_result(JOIN *join, enum enum_schema_table_state executed_place); enum enum_schema_tables get_schema_table_idx(ST_SCHEMA_TABLE *schema_table); +TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list); /* These functions were under INNODB_COMPATIBILITY_HOOKS */ int get_quote_char_for_identifier(THD *thd, const char *name, uint length); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 417110de76a..edc8e47a2b5 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -48,6 +48,7 @@ #include "sp_pcontext.h" #include "sp_rcontext.h" #include "sp.h" +#include "sql_show.h" #include "sql_alter.h" // Sql_cmd_alter_table* #include "sql_truncate.h" // Sql_cmd_truncate_table #include "sql_admin.h" // Sql_cmd_analyze/Check..._table @@ -139,12 +140,13 @@ int yylex(void *yylval, void *yythd); parser. */ -void my_parse_error(const char *s) +void my_parse_error(const char *s, const char *yytext=0) { THD *thd= current_thd; Lex_input_stream *lip= & thd->m_parser_state->m_lip; - const char *yytext= lip->get_tok_start(); + if (!yytext) + yytext= lip->get_tok_start(); if (!yytext) yytext= ""; @@ -1009,7 +1011,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token CIPHER_SYM %token CLASS_ORIGIN_SYM /* SQL-2003-N */ %token CLIENT_SYM -%token CLIENT_STATS_SYM %token CLOSE_SYM /* SQL-2003-R */ %token COALESCE /* SQL-2003-N */ %token CODE_SYM @@ -1180,7 +1181,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token IMPORT %token INDEXES %token INDEX_SYM -%token INDEX_STATS_SYM %token INFILE %token INITIAL_SIZE_SYM %token INNER_SYM /* SQL-2003-R */ @@ -1497,7 +1497,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token TABLES %token TABLESPACE %token TABLE_REF_PRIORITY -%token TABLE_STATS_SYM %token TABLE_SYM /* SQL-2003-R */ %token TABLE_CHECKSUM_SYM %token TABLE_NAME_SYM /* SQL-2003-N */ @@ -1546,7 +1545,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token UPGRADE_SYM %token USAGE /* SQL-2003-N */ %token USER /* SQL-2003-R */ -%token USER_STATS_SYM %token USE_FRM %token USE_SYM %token USING /* SQL-2003-R */ @@ -1624,7 +1622,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); table_ident_opt_wild create_like %type <simple_string> - remember_name remember_end opt_db text_or_password + remember_name remember_end opt_db text_or_password remember_tok_start + wild_and_where %type <string> text_string opt_gconcat_separator @@ -2076,7 +2075,7 @@ execute_var_ident: '@' ident_or_text { LEX *lex=Lex; - LEX_STRING *lexstr= (LEX_STRING*)sql_memdup(&$2, sizeof(LEX_STRING)); + LEX_STRING *lexstr= (LEX_STRING*)thd->memdup(&$2, sizeof(LEX_STRING)); if (!lexstr || lex->prepared_stmt_params.push_back(lexstr)) MYSQL_YYABORT; } @@ -6093,7 +6092,7 @@ virtual_column_func: MYSQL_YYABORT; } uint expr_len= (uint)($3 - $1) - 1; - Lex->vcol_info->expr_str.str= (char* ) sql_memdup($1 + 1, expr_len); + Lex->vcol_info->expr_str.str= (char* ) thd->memdup($1 + 1, expr_len); Lex->vcol_info->expr_str.length= expr_len; Lex->vcol_info->expr_item= $2; } @@ -8019,12 +8018,12 @@ table_column_list: | ident { Lex->column_list->push_back((LEX_STRING*) - sql_memdup(&$1, sizeof(LEX_STRING))); + thd->memdup(&$1, sizeof(LEX_STRING))); } | table_column_list ',' ident { Lex->column_list->push_back((LEX_STRING*) - sql_memdup(&$3, sizeof(LEX_STRING))); + thd->memdup(&$3, sizeof(LEX_STRING))); } ; @@ -8039,14 +8038,14 @@ table_index_name: ident { Lex->index_list->push_back( - (LEX_STRING*) sql_memdup(&$1, sizeof(LEX_STRING))); + (LEX_STRING*) thd->memdup(&$1, sizeof(LEX_STRING))); } | PRIMARY_SYM { LEX_STRING str= {(char*) "PRIMARY", 7}; Lex->index_list->push_back( - (LEX_STRING*) sql_memdup(&str, sizeof(LEX_STRING))); + (LEX_STRING*) thd->memdup(&str, sizeof(LEX_STRING))); } ; @@ -8527,6 +8526,12 @@ select_item: } ; +remember_tok_start: + { + $$= (char*) YYLIP->get_tok_start(); + } + ; + remember_name: { $$= (char*) YYLIP->get_cpp_tok_start(); @@ -11079,7 +11084,7 @@ opt_table_alias: /* empty */ { $$=0; } | table_alias ident { - $$= (LEX_STRING*) sql_memdup(&$2,sizeof(LEX_STRING)); + $$= (LEX_STRING*) thd->memdup(&$2,sizeof(LEX_STRING)); if ($$ == NULL) MYSQL_YYABORT; } @@ -12555,34 +12560,6 @@ show_param: Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT; Lex->verbose= 0; } - | CLIENT_STATS_SYM - { - LEX *lex= Lex; - lex->sql_command= SQLCOM_SHOW_CLIENT_STATS; - if (prepare_schema_table(thd, lex, 0, SCH_CLIENT_STATS)) - MYSQL_YYABORT; - } - | USER_STATS_SYM - { - LEX *lex= Lex; - lex->sql_command= SQLCOM_SHOW_USER_STATS; - if (prepare_schema_table(thd, lex, 0, SCH_USER_STATS)) - MYSQL_YYABORT; - } - | TABLE_STATS_SYM - { - LEX *lex= Lex; - lex->sql_command= SQLCOM_SHOW_TABLE_STATS; - if (prepare_schema_table(thd, lex, 0, SCH_TABLE_STATS)) - MYSQL_YYABORT; - } - | INDEX_STATS_SYM - { - LEX *lex= Lex; - lex->sql_command= SQLCOM_SHOW_INDEX_STATS; - if (prepare_schema_table(thd, lex, 0, SCH_INDEX_STATS)) - MYSQL_YYABORT; - } | CREATE PROCEDURE_SYM sp_name { LEX *lex= Lex; @@ -12639,6 +12616,24 @@ show_param: MYSQL_YYABORT; add_value_to_list(thd, $3); } + | IDENT_sys remember_tok_start wild_and_where + { + LEX *lex= Lex; + lex->sql_command= SQLCOM_SHOW_GENERIC; + ST_SCHEMA_TABLE *table= find_schema_table(thd, $1.str); + if (!table || !table->old_format) + { + my_parse_error(ER(ER_SYNTAX_ERROR), $2); + MYSQL_YYABORT; + } + if (lex->wild && table->idx_field1 < 0) + { + my_parse_error(ER(ER_SYNTAX_ERROR), $3); + MYSQL_YYABORT; + } + if (make_schema_select(thd, Lex->current_select, table)) + MYSQL_YYABORT; + } ; show_engine_param: @@ -12686,19 +12681,21 @@ binlog_from: ; wild_and_where: - /* empty */ - | LIKE TEXT_STRING_sys + /* empty */ { $$= 0; } + | LIKE remember_tok_start TEXT_STRING_sys { - Lex->wild= new (thd->mem_root) String($2.str, $2.length, + Lex->wild= new (thd->mem_root) String($3.str, $3.length, system_charset_info); if (Lex->wild == NULL) MYSQL_YYABORT; + $$= $2; } - | WHERE expr + | WHERE remember_tok_start expr { - Select->where= normalize_cond($2); - if ($2) - $2->top_level_item(); + Select->where= normalize_cond($3); + if ($3) + $3->top_level_item(); + $$= $2; } ; @@ -12877,20 +12874,24 @@ flush_option: lex->type|= REFRESH_SLAVE; lex->reset_slave_info.all= false; } - | CLIENT_STATS_SYM - { Lex->type|= REFRESH_CLIENT_STATS; } - | USER_STATS_SYM - { Lex->type|= REFRESH_USER_STATS; } - | TABLE_STATS_SYM - { Lex->type|= REFRESH_TABLE_STATS; } - | INDEX_STATS_SYM - { Lex->type|= REFRESH_INDEX_STATS; } | MASTER_SYM { Lex->type|= REFRESH_MASTER; } | DES_KEY_FILE { Lex->type|= REFRESH_DES_KEY_FILE; } | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; } + | IDENT_sys remember_tok_start + { + Lex->type|= REFRESH_GENERIC; + ST_SCHEMA_TABLE *table= find_schema_table(thd, $1.str); + if (!table || !table->reset_table) + { + my_parse_error(ER(ER_SYNTAX_ERROR), $2); + MYSQL_YYABORT; + } + Lex->view_list.push_back( + (LEX_STRING*)thd->memdup(&$1, sizeof(LEX_STRING))); + } ; opt_table_list: @@ -14111,7 +14112,6 @@ keyword_sp: | CHAIN_SYM {} | CHANGED {} | CIPHER_SYM {} - | CLIENT_STATS_SYM {} | CLIENT_SYM {} | CLASS_ORIGIN_SYM {} | COALESCE {} @@ -14193,7 +14193,6 @@ keyword_sp: | ID_SYM {} | IDENTIFIED_SYM {} | IGNORE_SERVER_IDS_SYM {} - | INDEX_STATS_SYM {} | INVOKER_SYM {} | IMPORT {} | INDEXES {} @@ -14358,7 +14357,6 @@ keyword_sp: | SWAPS_SYM {} | SWITCHES_SYM {} | TABLE_NAME_SYM {} - | TABLE_STATS_SYM {} | TABLES {} | TABLE_CHECKSUM_SYM {} | TABLESPACE {} @@ -14384,7 +14382,6 @@ keyword_sp: | UNKNOWN_SYM {} | UNTIL_SYM {} | USER {} - | USER_STATS_SYM {} | USE_FRM {} | VARIABLES {} | VIEW_SYM {} @@ -15994,12 +15991,12 @@ view_list: ident { Lex->view_list.push_back((LEX_STRING*) - sql_memdup(&$1, sizeof(LEX_STRING))); + thd->memdup(&$1, sizeof(LEX_STRING))); } | view_list ',' ident { Lex->view_list.push_back((LEX_STRING*) - sql_memdup(&$3, sizeof(LEX_STRING))); + thd->memdup(&$3, sizeof(LEX_STRING))); } ; diff --git a/sql/table.h b/sql/table.h index bbe4b181339..eca35d6c52c 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1487,8 +1487,8 @@ typedef struct st_schema_table { const char* table_name; ST_FIELD_INFO *fields_info; - /* Create information_schema table */ - TABLE *(*create_table) (THD *thd, TABLE_LIST *table_list); + /* for FLUSH table_name */ + int (*reset_table) (); /* Fill table with data */ int (*fill_table) (THD *thd, TABLE_LIST *tables, COND *cond); /* Handle fileds for old SHOW */ |
