Commit f062b991 authored by unknown's avatar unknown

cleanup of SHOW STATUS code, as a preparation for WL#2935

(MySQL plugin interface: status variables)

adding SHOW_FUNC, removing SHOW_some_specific_value,
only generic SHOW_LONG/SHOW_CHAR/etc are recognized.
changing to use SHOW_FUNC instead of ha_update_statistics


sql/ha_innodb.h:
  cleanup of SHOW STATUS code, as a preparation for WL#2935
  removing ha_update_statistics().
sql/handler.cc:
  cleanup of SHOW STATUS code, as a preparation for WL#2935
  removing ha_update_statistics().
sql/handler.h:
  cleanup of SHOW STATUS code, as a preparation for WL#2935
  removing ha_update_statistics().
sql/mysqld.cc:
  cleanup of SHOW STATUS code, as a preparation for WL#2935
  adding SHOW_FUNC, removing SHOW_some_specific_variable,
  only generic SHOW_LONG/SHOW_CHAR/etc are recognized.
  changing to use SHOW_FUNC instead of ha_update_statistics
sql/set_var.cc:
  cleanup of SHOW STATUS code, as a preparation for WL#2935
  adding SHOW_FUNC, removing SHOW_some_specific_variable,
  only generic SHOW_LONG/SHOW_CHAR/etc are recognized.
sql/sql_show.cc:
  cleanup of SHOW STATUS code, as a preparation for WL#2935
  adding SHOW_FUNC, removing SHOW_some_specific_variable,
  only generic SHOW_LONG/SHOW_CHAR/etc are recognized.
  changing to use SHOW_FUNC instead of ha_update_statistics
sql/structs.h:
  cleanup of SHOW STATUS code, as a preparation for WL#2935
  adding SHOW_FUNC, removing SHOW_some_specific_variable,
  only generic SHOW_LONG/SHOW_CHAR/etc are recognized.
parent a9f1966f
......@@ -277,7 +277,6 @@ void innobase_store_binlog_offset_and_flush_log(char *binlog_name,longlong offse
void innobase_drop_database(char *path);
bool innobase_show_status(THD* thd, stat_print_fn*, enum ha_stat_type);
int innodb_export_status(void);
int innobase_release_temporary_latches(THD *thd);
......
......@@ -1180,15 +1180,6 @@ int ha_release_temporary_latches(THD *thd)
#endif
}
int ha_update_statistics()
{
#ifdef WITH_INNOBASE_STORAGE_ENGINE
innodb_export_status();
#endif
return 0;
}
int ha_rollback_to_savepoint(THD *thd, SAVEPOINT *sv)
{
int error=0;
......
......@@ -1538,7 +1538,7 @@ inline bool ha_check_storage_engine_flag(const handlerton *db_type, uint32 flag)
inline bool ha_storage_engine_is_enabled(const handlerton *db_type)
{
return (db_type && db_type->create) ?
return (db_type && db_type->create) ?
(db_type->state == SHOW_OPTION_YES) : FALSE;
}
......@@ -1549,7 +1549,6 @@ int ha_initialize_handlerton(handlerton *hton);
TYPELIB *ha_known_exts(void);
int ha_panic(enum ha_panic_function flag);
int ha_update_statistics();
void ha_close_connection(THD* thd);
bool ha_flush_logs(handlerton *db_type);
void ha_drop_database(char* path);
......
......@@ -6186,6 +6186,335 @@ The minimum value for this variable is 4096.",
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
static int show_question(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_LONGLONG;
var->value= (char *)&thd->query_id;
return 0;
}
static int show_net_compression(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_MY_BOOL;
var->value= (char *)&thd->net.compress;
return 0;
}
static int show_starttime(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_LONG;
var->value= buff;
*((long *)buff)= (long) (thd->query_start() - start_time);
return 0;
}
#ifdef HAVE_REPLICATION
static int show_rpl_status(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_CHAR;
var->value= const_cast<char*>(rpl_status_type[(int)rpl_status]);
return 0;
}
static int show_slave_running(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_CHAR;
pthread_mutex_lock(&LOCK_active_mi);
var->value= const_cast<char*>((active_mi && active_mi->slave_running &&
active_mi->rli.slave_running) ? "ON" : "OFF");
pthread_mutex_unlock(&LOCK_active_mi);
return 0;
}
static int show_slave_retried_trans(THD *thd, show_var_st *var, char *buff)
{
/*
TODO: with multimaster, have one such counter per line in
SHOW SLAVE STATUS, and have the sum over all lines here.
*/
pthread_mutex_lock(&LOCK_active_mi);
if (active_mi)
{
var->type=SHOW_LONG;
var->value= buff;
pthread_mutex_lock(&active_mi->rli.data_lock);
*((long *)buff)= (long)active_mi->rli.retried_trans;
pthread_mutex_unlock(&active_mi->rli.data_lock);
}
else
var->type=SHOW_UNDEF;
pthread_mutex_unlock(&LOCK_active_mi);
return 0;
}
#endif /* HAVE_REPLICATION */
static int show_open_tables(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_LONG;
var->value= buff;
*((long *)buff)= (long)cached_open_tables();
return 0;
}
static int show_table_definitions(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_LONG;
var->value= buff;
*((long *)buff)= (long)cached_table_definitions();
return 0;
}
#ifdef HAVE_OPENSSL
/* Functions relying on CTX */
static int show_ssl_ctx_sess_accept(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_LONG;
var->value= buff;
*((long *)buff)= (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_accept(ssl_acceptor_fd->ssl_context));
return 0;
}
static int show_ssl_ctx_sess_accept_good(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_LONG;
var->value= buff;
*((long *)buff)= (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_accept_good(ssl_acceptor_fd->ssl_context));
return 0;
}
static int show_ssl_ctx_sess_connect_good(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_LONG;
var->value= buff;
*((long *)buff)= (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_connect_good(ssl_acceptor_fd->ssl_context));
return 0;
}
static int show_ssl_ctx_sess_accept_renegotiate(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_LONG;
var->value= buff;
*((long *)buff)= (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_accept_renegotiate(ssl_acceptor_fd->ssl_context));
return 0;
}
static int show_ssl_ctx_sess_connect_renegotiate(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_LONG;
var->value= buff;
*((long *)buff)= (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_connect_renegotiate(ssl_acceptor_fd->ssl_context));
return 0;
}
static int show_ssl_ctx_sess_cb_hits(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_LONG;
var->value= buff;
*((long *)buff)= (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_cb_hits(ssl_acceptor_fd->ssl_context));
return 0;
}
static int show_ssl_ctx_sess_hits(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_LONG;
var->value= buff;
*((long *)buff)= (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_hits(ssl_acceptor_fd->ssl_context));
return 0;
}
static int show_ssl_ctx_sess_cache_full(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_LONG;
var->value= buff;
*((long *)buff)= (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_cache_full(ssl_acceptor_fd->ssl_context));
return 0;
}
static int show_ssl_ctx_sess_misses(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_LONG;
var->value= buff;
*((long *)buff)= (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_misses(ssl_acceptor_fd->ssl_context));
return 0;
}
static int show_ssl_ctx_sess_timeouts(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_LONG;
var->value= buff;
*((long *)buff)= (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_timeouts(ssl_acceptor_fd->ssl_context));
return 0;
}
static int show_ssl_ctx_sess_number(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_LONG;
var->value= buff;
*((long *)buff)= (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_number(ssl_acceptor_fd->ssl_context));
return 0;
}
static int show_ssl_ctx_sess_connect(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_LONG;
var->value= buff;
*((long *)buff)= (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_connect(ssl_acceptor_fd->ssl_context));
return 0;
}
static int show_ssl_ctx_sess_get_cache_size(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_LONG;
var->value= buff;
*((long *)buff)= (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_get_cache_size(ssl_acceptor_fd->ssl_context));
return 0;
}
static int show_ssl_ctx_get_verify_mode(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_LONG;
var->value= buff;
*((long *)buff)= (!ssl_acceptor_fd ? 0 :
SSL_CTX_get_verify_mode(ssl_acceptor_fd->ssl_context));
return 0;
}
static int show_ssl_ctx_get_verify_depth(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_LONG;
var->value= buff;
*((long *)buff)= (!ssl_acceptor_fd ? 0 :
SSL_CTX_get_verify_depth(ssl_acceptor_fd->ssl_context));
return 0;
}
static int show_ssl_ctx_get_session_cache_mode(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_CHAR;
if (!ssl_acceptor_fd)
var->value= "NONE";
else
switch (SSL_CTX_get_session_cache_mode(ssl_acceptor_fd->ssl_context))
{
case SSL_SESS_CACHE_OFF:
var->value= "OFF"; break;
case SSL_SESS_CACHE_CLIENT:
var->value= "CLIENT"; break;
case SSL_SESS_CACHE_SERVER:
var->value= "SERVER"; break;
case SSL_SESS_CACHE_BOTH:
var->value= "BOTH"; break;
case SSL_SESS_CACHE_NO_AUTO_CLEAR:
var->value= "NO_AUTO_CLEAR"; break;
case SSL_SESS_CACHE_NO_INTERNAL_LOOKUP:
var->value= "NO_INTERNAL_LOOKUP"; break;
default:
var->value= "Unknown"; break;
}
return 0;
}
/* Functions relying on SSL */
static int show_ssl_get_version(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_CHAR;
var->value= const_cast<char*>(thd->net.vio->ssl_arg ?
SSL_get_version((SSL*) thd->net.vio->ssl_arg) : "");
return 0;
}
static int show_ssl_session_reused(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_LONG;
var->value= buff;
*((long *)buff)= (long)thd->net.vio->ssl_arg ?
SSL_session_reused((SSL*) thd->net.vio->ssl_arg) :
0;
}
static int show_ssl_get_default_timeout(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_LONG;
var->value= buff;
*((long *)buff)= (long)thd->net.vio->ssl_arg ?
SSL_get_default_timeout((SSL*)thd->net.vio->ssl_arg) :
0;
return 0;
}
static int show_ssl_get_verify_mode(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_LONG;
var->value= buff;
*((long *)buff)= (long)thd->net.vio->ssl_arg ?
SSL_get_verify_mode((SSL*)thd->net.vio->ssl_arg) :
0;
return 0;
}
static int show_ssl_get_verify_depth(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_LONG;
var->value= buff;
*((long *)buff)= (long)thd->net.vio->ssl_arg ?
SSL_get_verify_depth((SSL*)thd->net.vio->ssl_arg) :
0;
return 0;
}
static int show_ssl_get_cipher(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_CHAR;
var->value= const_cast<char*>(thd->net.vio->ssl_arg ?
SSL_get_cipher((SSL*) thd->net.vio->ssl_arg) : "");
return 0;
}
static int show_ssl_get_cipher_list(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_CHAR;
var->value= buff;
if (thd->net.vio->ssl_arg)
{
int i;
const char *p;
for (i=0 ; (p= SSL_get_cipher_list((SSL*) thd->net.vio->ssl_arg,i)); i++)
{
buff= strmov(buff, p);
*buff++= ':';
}
if (i)
buff--;
}
*buff=0;
return 0;
}
#endif /* HAVE_OPENSSL */
#ifdef WITH_INNOBASE_STORAGE_ENGINE
int innodb_export_status(void);
static int show_innodb_vars(THD *thd, show_var_st *var, char *buff)
{
innodb_export_status();
var->type= SHOW_ARRAY;
var->value= (char *) &innodb_status_variables;
return 0;
}
#endif
struct show_var_st status_vars[]= {
{"Aborted_clients", (char*) &aborted_threads, SHOW_LONG},
......@@ -6296,7 +6625,7 @@ struct show_var_st status_vars[]= {
{"Com_xa_recover", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_XA_RECOVER]),SHOW_LONG_STATUS},
{"Com_xa_rollback", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_XA_ROLLBACK]),SHOW_LONG_STATUS},
{"Com_xa_start", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_XA_START]),SHOW_LONG_STATUS},
{"Compression", (char*) 0, SHOW_NET_COMPRESSION},
{"Compression", (char*) &show_net_compression, SHOW_FUNC},
{"Connections", (char*) &thread_id, SHOW_LONG_CONST},
{"Created_tmp_disk_tables", (char*) offsetof(STATUS_VAR, created_tmp_disk_tables), SHOW_LONG_STATUS},
{"Created_tmp_files", (char*) &my_tmp_file_created, SHOW_LONG},
......@@ -6321,25 +6650,25 @@ struct show_var_st status_vars[]= {
{"Handler_update", (char*) offsetof(STATUS_VAR, ha_update_count), SHOW_LONG_STATUS},
{"Handler_write", (char*) offsetof(STATUS_VAR, ha_write_count), SHOW_LONG_STATUS},
#ifdef WITH_INNOBASE_STORAGE_ENGINE
{"Innodb_", (char*) &innodb_status_variables, SHOW_VARS},
{"Innodb_", (char*) &show_innodb_vars, SHOW_FUNC},
#endif /* WITH_INNOBASE_STORAGE_ENGINE */
{"Key_blocks_not_flushed", (char*) &dflt_key_cache_var.global_blocks_changed, SHOW_KEY_CACHE_LONG},
{"Key_blocks_unused", (char*) &dflt_key_cache_var.blocks_unused, SHOW_KEY_CACHE_CONST_LONG},
{"Key_blocks_used", (char*) &dflt_key_cache_var.blocks_used, SHOW_KEY_CACHE_CONST_LONG},
{"Key_read_requests", (char*) &dflt_key_cache_var.global_cache_r_requests, SHOW_KEY_CACHE_LONGLONG},
{"Key_reads", (char*) &dflt_key_cache_var.global_cache_read, SHOW_KEY_CACHE_LONGLONG},
{"Key_write_requests", (char*) &dflt_key_cache_var.global_cache_w_requests, SHOW_KEY_CACHE_LONGLONG},
{"Key_writes", (char*) &dflt_key_cache_var.global_cache_write, SHOW_KEY_CACHE_LONGLONG},
{"Key_blocks_not_flushed", (char*) offsetof(KEY_CACHE, global_blocks_changed), SHOW_KEY_CACHE_LONG},
{"Key_blocks_unused", (char*) offsetof(KEY_CACHE, blocks_unused), SHOW_KEY_CACHE_CONST_LONG},
{"Key_blocks_used", (char*) offsetof(KEY_CACHE, blocks_used), SHOW_KEY_CACHE_CONST_LONG},
{"Key_read_requests", (char*) offsetof(KEY_CACHE, global_cache_r_requests), SHOW_KEY_CACHE_LONGLONG},
{"Key_reads", (char*) offsetof(KEY_CACHE, global_cache_read), SHOW_KEY_CACHE_LONGLONG},
{"Key_write_requests", (char*) offsetof(KEY_CACHE, global_cache_w_requests), SHOW_KEY_CACHE_LONGLONG},
{"Key_writes", (char*) offsetof(KEY_CACHE, global_cache_write), SHOW_KEY_CACHE_LONGLONG},
{"Last_query_cost", (char*) offsetof(STATUS_VAR, last_query_cost), SHOW_DOUBLE_STATUS},
{"Max_used_connections", (char*) &max_used_connections, SHOW_LONG},
#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
{"Ndb_", (char*) &ndb_status_variables, SHOW_VARS},
{"Ndb_", (char*) &ndb_status_variables, SHOW_ARRAY},
#endif /* WITH_NDBCLUSTER_STORAGE_ENGINE */
{"Not_flushed_delayed_rows", (char*) &delayed_rows_in_use, SHOW_LONG_CONST},
{"Open_files", (char*) &my_file_opened, SHOW_LONG_CONST},
{"Open_streams", (char*) &my_stream_opened, SHOW_LONG_CONST},
{"Open_table_definitions", (char*) 0, SHOW_TABLE_DEFINITIONS},
{"Open_tables", (char*) 0, SHOW_OPEN_TABLES},
{"Open_table_definitions", (char*) &show_table_definitions, SHOW_FUNC},
{"Open_tables", (char*) &show_open_tables, SHOW_FUNC},
{"Opened_tables", (char*) offsetof(STATUS_VAR, opened_tables), SHOW_LONG_STATUS},
#ifdef HAVE_QUERY_CACHE
{"Qcache_free_blocks", (char*) &query_cache.free_memory_blocks, SHOW_LONG_CONST},
......@@ -6351,16 +6680,20 @@ struct show_var_st status_vars[]= {
{"Qcache_queries_in_cache", (char*) &query_cache.queries_in_cache, SHOW_LONG_CONST},
{"Qcache_total_blocks", (char*) &query_cache.total_blocks, SHOW_LONG_CONST},
#endif /*HAVE_QUERY_CACHE*/
{"Questions", (char*) 0, SHOW_QUESTION},
{"Rpl_status", (char*) 0, SHOW_RPL_STATUS},
{"Questions", (char*) &show_question, SHOW_FUNC},
#ifdef HAVE_REPLICATION
{"Rpl_status", (char*) &show_rpl_status, SHOW_FUNC},
#endif
{"Select_full_join", (char*) offsetof(STATUS_VAR, select_full_join_count), SHOW_LONG_STATUS},
{"Select_full_range_join", (char*) offsetof(STATUS_VAR, select_full_range_join_count), SHOW_LONG_STATUS},
{"Select_range", (char*) offsetof(STATUS_VAR, select_range_count), SHOW_LONG_STATUS},
{"Select_range_check", (char*) offsetof(STATUS_VAR, select_range_check_count), SHOW_LONG_STATUS},
{"Select_scan", (char*) offsetof(STATUS_VAR, select_scan_count), SHOW_LONG_STATUS},
{"Slave_open_temp_tables", (char*) &slave_open_temp_tables, SHOW_LONG},
{"Slave_retried_transactions",(char*) 0, SHOW_SLAVE_RETRIED_TRANS},
{"Slave_running", (char*) 0, SHOW_SLAVE_RUNNING},
#ifdef HAVE_REPLICATION
{"Slave_retried_transactions",(char*) &show_slave_retried_trans, SHOW_FUNC},
{"Slave_running", (char*) &show_slave_running, SHOW_FUNC},
#endif
{"Slow_launch_threads", (char*) &slow_launch_threads, SHOW_LONG},
{"Slow_queries", (char*) offsetof(STATUS_VAR, long_query_count), SHOW_LONG_STATUS},
{"Sort_merge_passes", (char*) offsetof(STATUS_VAR, filesort_merge_passes), SHOW_LONG_STATUS},
......@@ -6368,29 +6701,29 @@ struct show_var_st status_vars[]= {
{"Sort_rows", (char*) offsetof(STATUS_VAR, filesort_rows), SHOW_LONG_STATUS},
{"Sort_scan", (char*) offsetof(STATUS_VAR, filesort_scan_count), SHOW_LONG_STATUS},
#ifdef HAVE_OPENSSL
{"Ssl_accept_renegotiates", (char*) 0, SHOW_SSL_CTX_SESS_ACCEPT_RENEGOTIATE},
{"Ssl_accepts", (char*) 0, SHOW_SSL_CTX_SESS_ACCEPT},
{"Ssl_callback_cache_hits", (char*) 0, SHOW_SSL_CTX_SESS_CB_HITS},
{"Ssl_cipher", (char*) 0, SHOW_SSL_GET_CIPHER},
{"Ssl_cipher_list", (char*) 0, SHOW_SSL_GET_CIPHER_LIST},
{"Ssl_client_connects", (char*) 0, SHOW_SSL_CTX_SESS_CONNECT},
{"Ssl_connect_renegotiates", (char*) 0, SHOW_SSL_CTX_SESS_CONNECT_RENEGOTIATE},
{"Ssl_ctx_verify_depth", (char*) 0, SHOW_SSL_CTX_GET_VERIFY_DEPTH},
{"Ssl_ctx_verify_mode", (char*) 0, SHOW_SSL_CTX_GET_VERIFY_MODE},
{"Ssl_default_timeout", (char*) 0, SHOW_SSL_GET_DEFAULT_TIMEOUT},
{"Ssl_finished_accepts", (char*) 0, SHOW_SSL_CTX_SESS_ACCEPT_GOOD},
{"Ssl_finished_connects", (char*) 0, SHOW_SSL_CTX_SESS_CONNECT_GOOD},
{"Ssl_session_cache_hits", (char*) 0, SHOW_SSL_CTX_SESS_HITS},
{"Ssl_session_cache_misses", (char*) 0, SHOW_SSL_CTX_SESS_MISSES},
{"Ssl_session_cache_mode", (char*) 0, SHOW_SSL_CTX_GET_SESSION_CACHE_MODE},
{"Ssl_session_cache_overflows", (char*) 0, SHOW_SSL_CTX_SESS_CACHE_FULL},
{"Ssl_session_cache_size", (char*) 0, SHOW_SSL_CTX_SESS_GET_CACHE_SIZE},
{"Ssl_session_cache_timeouts", (char*) 0, SHOW_SSL_CTX_SESS_TIMEOUTS},
{"Ssl_sessions_reused", (char*) 0, SHOW_SSL_SESSION_REUSED},
{"Ssl_used_session_cache_entries",(char*) 0, SHOW_SSL_CTX_SESS_NUMBER},
{"Ssl_verify_depth", (char*) 0, SHOW_SSL_GET_VERIFY_DEPTH},
{"Ssl_verify_mode", (char*) 0, SHOW_SSL_GET_VERIFY_MODE},
{"Ssl_version", (char*) 0, SHOW_SSL_GET_VERSION},
{"Ssl_accept_renegotiates", (char*) &show_ssl_ctx_sess_accept_renegotiate, SHOW_FUNC},
{"Ssl_accepts", (char*) &show_ssl_ctx_sess_accept, SHOW_FUNC},
{"Ssl_callback_cache_hits", (char*) &show_ssl_ctx_sess_cb_hits, SHOW_FUNC},
{"Ssl_cipher", (char*) &show_ssl_get_cipher, SHOW_FUNC},
{"Ssl_cipher_list", (char*) &show_ssl_get_cipher_list, SHOW_FUNC},
{"Ssl_client_connects", (char*) &show_ssl_ctx_sess_connect, SHOW_FUNC},
{"Ssl_connect_renegotiates", (char*) &show_ssl_ctx_sess_connect_renegotiate, SHOW_FUNC},
{"Ssl_ctx_verify_depth", (char*) &show_ssl_ctx_get_verify_depth, SHOW_FUNC},
{"Ssl_ctx_verify_mode", (char*) &show_ssl_ctx_get_verify_mode, SHOW_FUNC},
{"Ssl_default_timeout", (char*) &show_ssl_get_default_timeout, SHOW_FUNC},
{"Ssl_finished_accepts", (char*) &show_ssl_ctx_sess_accept_good, SHOW_FUNC},
{"Ssl_finished_connects", (char*) &show_ssl_ctx_sess_connect_good, SHOW_FUNC},
{"Ssl_session_cache_hits", (char*) &show_ssl_ctx_sess_hits, SHOW_FUNC},
{"Ssl_session_cache_misses", (char*) &show_ssl_ctx_sess_misses, SHOW_FUNC},
{"Ssl_session_cache_mode", (char*) &show_ssl_ctx_get_session_cache_mode, SHOW_FUNC},
{"Ssl_session_cache_overflows", (char*) &show_ssl_ctx_sess_cache_full, SHOW_FUNC},
{"Ssl_session_cache_size", (char*) &show_ssl_ctx_sess_get_cache_size, SHOW_FUNC},
{"Ssl_session_cache_timeouts", (char*) &show_ssl_ctx_sess_timeouts, SHOW_FUNC},
{"Ssl_sessions_reused", (char*) &show_ssl_session_reused, SHOW_FUNC},
{"Ssl_used_session_cache_entries",(char*) &show_ssl_ctx_sess_number, SHOW_FUNC},
{"Ssl_verify_depth", (char*) &show_ssl_get_verify_depth, SHOW_FUNC},
{"Ssl_verify_mode", (char*) &show_ssl_get_verify_mode, SHOW_FUNC},
{"Ssl_version", (char*) &show_ssl_get_version, SHOW_FUNC},
#endif /* HAVE_OPENSSL */
{"Table_locks_immediate", (char*) &locks_immediate, SHOW_LONG},
{"Table_locks_waited", (char*) &locks_waited, SHOW_LONG},
......@@ -6403,7 +6736,7 @@ struct show_var_st status_vars[]= {
{"Threads_connected", (char*) &thread_count, SHOW_INT_CONST},
{"Threads_created", (char*) &thread_created, SHOW_LONG_CONST},
{"Threads_running", (char*) &thread_running, SHOW_INT_CONST},
{"Uptime", (char*) 0, SHOW_STARTTIME},
{"Uptime", (char*) &show_starttime, SHOW_FUNC},
{NullS, NullS, SHOW_LONG}
};
......
......@@ -623,6 +623,45 @@ sys_var_have_variable sys_have_row_based_replication("have_row_based_replication
/* Global read-only variable describing server license */
sys_var_const_str sys_license("license", STRINGIFY_ARG(LICENSE));
#ifdef HAVE_REPLICATION
static int show_slave_skip_errors(THD *thd, show_var_st *var, char *buff)
{
var->type=SHOW_CHAR;
var->value= buff;
if (!use_slave_mask || bitmap_is_clear_all(&slave_error_mask))
{
var->value= "OFF";
}
else if (bitmap_is_set_all(&slave_error_mask))
{
var->value= "ALL";
}
else
{
/* 10 is enough assuming errors are max 4 digits */
int i;
var->value= buff;
for (i= 1;
i < MAX_SLAVE_ERROR &&
(buff - var->value) < SHOW_VAR_FUNC_BUFF_SIZE;
i++)
{
if (bitmap_is_set(&slave_error_mask, i))
{
buff= int10_to_str(i, buff, 10);
*buff++= ',';
}
}
if (var->value != buff)
buff--; // Remove last ','
if (i < MAX_SLAVE_ERROR)
buff= strmov(buff, "..."); // Couldn't show all errors
*buff=0;
}
return 0;
}
#endif /* HAVE_REPLICATION */
/*
Variables shown by SHOW variables in alphabetical order
......@@ -863,7 +902,7 @@ struct show_var_st init_vars[]= {
(char*) &sys_slave_compressed_protocol, SHOW_SYS},
{"slave_load_tmpdir", (char*) &slave_load_tmpdir, SHOW_CHAR_PTR},
{sys_slave_net_timeout.name,(char*) &sys_slave_net_timeout, SHOW_SYS},
{"slave_skip_errors", (char*) &slave_error_mask, SHOW_SLAVE_SKIP_ERRORS},
{"slave_skip_errors", (char*) &show_slave_skip_errors, SHOW_FUNC},
{sys_slave_trans_retries.name,(char*) &sys_slave_trans_retries, SHOW_SYS},
#endif
{sys_slow_launch_time.name, (char*) &sys_slow_launch_time, SHOW_SYS},
......
......@@ -1516,18 +1516,18 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
Status functions
*****************************************************************************/
static bool show_status_array(THD *thd, const char *wild,
show_var_st *variables,
enum enum_var_type value_type,
struct system_status_var *status_var,
const char *prefix, TABLE *table)
{
char buff[1024], *prefix_end;
char buff[SHOW_VAR_FUNC_BUFF_SIZE], *prefix_end;
/* the variable name should not be longer then 80 characters */
char name_buffer[80];
int len;
LEX_STRING null_lex_str;
struct show_var_st tmp, *var;
DBUG_ENTER("show_status_array");
null_lex_str.str= 0; // For sys_var->value_ptr()
......@@ -1540,18 +1540,22 @@ static bool show_status_array(THD *thd, const char *wild,
{
strnmov(prefix_end, variables->name, len);
name_buffer[sizeof(name_buffer)-1]=0; /* Safety */
SHOW_TYPE show_type=variables->type;
if (show_type == SHOW_VARS)
for (var=variables; var->type == SHOW_FUNC; var= &tmp)
((show_var_func)(var->value))(thd, &tmp, buff);
SHOW_TYPE show_type=var->type;
if (show_type == SHOW_ARRAY)
{
show_status_array(thd, wild, (show_var_st *) variables->value,
value_type, status_var, variables->name, table);
show_status_array(thd, wild, (show_var_st *) var->value,
value_type, status_var, name_buffer, table);
}
else
{
if (!(wild && wild[0] && wild_case_compare(system_charset_info,
name_buffer, wild)))
{
char *value=variables->value;
char *value=var->value;
const char *pos, *end; // We assign a lot of const's
long nr;
if (show_type == SHOW_SYS)
......@@ -1562,7 +1566,17 @@ static bool show_status_array(THD *thd, const char *wild,
}
pos= end= buff;
/*
note that value may be == buff. All SHOW_xxx code below
should still work in this case
*/
switch (show_type) {
case SHOW_DOUBLE_STATUS:
{
value= ((char *) status_var + (ulong) value);
end= buff + sprintf(buff, "%f", *(double*) value);
break;
}
case SHOW_LONG_STATUS:
case SHOW_LONG_CONST_STATUS:
value= ((char *) status_var + (ulong) value);
......@@ -1601,80 +1615,6 @@ static bool show_status_array(THD *thd, const char *wild,
end= strend(pos);
break;
}
case SHOW_STARTTIME:
nr= (long) (thd->query_start() - start_time);
end= int10_to_str(nr, buff, 10);
break;
case SHOW_QUESTION:
end= int10_to_str((long) thd->query_id, buff, 10);
break;
#ifdef HAVE_REPLICATION
case SHOW_RPL_STATUS:
end= strmov(buff, rpl_status_type[(int)rpl_status]);
break;
case SHOW_SLAVE_RUNNING:
{
pthread_mutex_lock(&LOCK_active_mi);
end= strmov(buff, (active_mi && active_mi->slave_running &&
active_mi->rli.slave_running) ? "ON" : "OFF");
pthread_mutex_unlock(&LOCK_active_mi);
break;
}
case SHOW_SLAVE_RETRIED_TRANS:
{
/*
TODO: in 5.1 with multimaster, have one such counter per line in
SHOW SLAVE STATUS, and have the sum over all lines here.
*/
pthread_mutex_lock(&LOCK_active_mi);
if (active_mi)
{
pthread_mutex_lock(&active_mi->rli.data_lock);
end= int10_to_str(active_mi->rli.retried_trans, buff, 10);
pthread_mutex_unlock(&active_mi->rli.data_lock);
}
pthread_mutex_unlock(&LOCK_active_mi);
break;
}
case SHOW_SLAVE_SKIP_ERRORS:
{
MY_BITMAP *bitmap= (MY_BITMAP *)value;
if (!use_slave_mask || bitmap_is_clear_all(bitmap))
{
end= strmov(buff, "OFF");
}
else if (bitmap_is_set_all(bitmap))
{
end= strmov(buff, "ALL");
}
else
{
/* 10 is enough assuming errors are max 4 digits */
int i;
for (i= 1;
i < MAX_SLAVE_ERROR && (uint) (end-buff) < sizeof(buff)-10;
i++)
{
if (bitmap_is_set(bitmap, i))
{
end= int10_to_str(i, (char*) end, 10);
*(char*) end++= ',';
}
}
if (end != buff)
end--; // Remove last ','
if (i < MAX_SLAVE_ERROR)
end= strmov((char*) end, "..."); // Couldn't show all errors
}
break;
}
#endif /* HAVE_REPLICATION */
case SHOW_OPEN_TABLES:
end= int10_to_str((long) cached_open_tables(), buff, 10);
break;
case SHOW_TABLE_DEFINITIONS:
end= int10_to_str((long) cached_table_definitions(), buff, 10);
break;
case SHOW_CHAR_PTR:
{
if (!(pos= *(char**) value))
......@@ -1682,200 +1622,16 @@ static bool show_status_array(THD *thd, const char *wild,
end= strend(pos);
break;
}
case SHOW_DOUBLE_STATUS:
{
value= ((char *) status_var + (ulong) value);
end= buff + sprintf(buff, "%f", *(double*) value);
break;
}
#ifdef HAVE_OPENSSL
/* First group - functions relying on CTX */
case SHOW_SSL_CTX_SESS_ACCEPT:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_accept(ssl_acceptor_fd->
ssl_context)),
buff, 10);
break;
case SHOW_SSL_CTX_SESS_ACCEPT_GOOD:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_accept_good(ssl_acceptor_fd->
ssl_context)),
buff, 10);
break;
case SHOW_SSL_CTX_SESS_CONNECT_GOOD:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_connect_good(ssl_acceptor_fd->
ssl_context)),
buff, 10);
break;
case SHOW_SSL_CTX_SESS_ACCEPT_RENEGOTIATE:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_accept_renegotiate(ssl_acceptor_fd->ssl_context)),
buff, 10);
break;
case SHOW_SSL_CTX_SESS_CONNECT_RENEGOTIATE:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_connect_renegotiate(ssl_acceptor_fd-> ssl_context)),
buff, 10);
break;
case SHOW_SSL_CTX_SESS_CB_HITS:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_cb_hits(ssl_acceptor_fd->
ssl_context)),
buff, 10);
break;
case SHOW_SSL_CTX_SESS_HITS:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_hits(ssl_acceptor_fd->
ssl_context)),
buff, 10);
break;
case SHOW_SSL_CTX_SESS_CACHE_FULL:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_cache_full(ssl_acceptor_fd->
ssl_context)),
buff, 10);
break;
case SHOW_SSL_CTX_SESS_MISSES:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_misses(ssl_acceptor_fd->
ssl_context)),
buff, 10);
break;
case SHOW_SSL_CTX_SESS_TIMEOUTS:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_timeouts(ssl_acceptor_fd->ssl_context)),
buff,10);
break;
case SHOW_SSL_CTX_SESS_NUMBER:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_number(ssl_acceptor_fd->ssl_context)),
buff,10);
break;
case SHOW_SSL_CTX_SESS_CONNECT:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_connect(ssl_acceptor_fd->ssl_context)),
buff,10);
break;
case SHOW_SSL_CTX_SESS_GET_CACHE_SIZE:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_sess_get_cache_size(ssl_acceptor_fd->ssl_context)),
buff,10);
break;
case SHOW_SSL_CTX_GET_VERIFY_MODE:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_get_verify_mode(ssl_acceptor_fd->ssl_context)),
buff,10);
break;
case SHOW_SSL_CTX_GET_VERIFY_DEPTH:
end= int10_to_str((long) (!ssl_acceptor_fd ? 0 :
SSL_CTX_get_verify_depth(ssl_acceptor_fd->ssl_context)),
buff,10);
break;
case SHOW_SSL_CTX_GET_SESSION_CACHE_MODE:
if (!ssl_acceptor_fd)
{
pos= "NONE";
end= pos+4;
break;
}
switch (SSL_CTX_get_session_cache_mode(ssl_acceptor_fd->ssl_context))
{
case SSL_SESS_CACHE_OFF:
pos= "OFF";
break;
case SSL_SESS_CACHE_CLIENT:
pos= "CLIENT";
break;
case SSL_SESS_CACHE_SERVER:
pos= "SERVER";
break;
case SSL_SESS_CACHE_BOTH:
pos= "BOTH";
break;
case SSL_SESS_CACHE_NO_AUTO_CLEAR:
pos= "NO_AUTO_CLEAR";
break;
case SSL_SESS_CACHE_NO_INTERNAL_LOOKUP:
pos= "NO_INTERNAL_LOOKUP";
break;
default:
pos= "Unknown";
break;
}
end= strend(pos);
break;
/* First group - functions relying on SSL */
case SHOW_SSL_GET_VERSION:
pos= (thd->net.vio->ssl_arg ?
SSL_get_version((SSL*) thd->net.vio->ssl_arg) : "");
end= strend(pos);
break;
case SHOW_SSL_SESSION_REUSED:
end= int10_to_str((long) (thd->net.vio->ssl_arg ?
SSL_session_reused((SSL*) thd->net.vio->
ssl_arg) :
0),
buff, 10);
break;
case SHOW_SSL_GET_DEFAULT_TIMEOUT:
end= int10_to_str((long) (thd->net.vio->ssl_arg ?
SSL_get_default_timeout((SSL*) thd->net.vio->
ssl_arg) :
0),
buff, 10);
break;
case SHOW_SSL_GET_VERIFY_MODE:
end= int10_to_str((long) (thd->net.vio->ssl_arg ?
SSL_get_verify_mode((SSL*) thd->net.vio->
ssl_arg):
0),
buff, 10);
break;
case SHOW_SSL_GET_VERIFY_DEPTH:
end= int10_to_str((long) (thd->net.vio->ssl_arg ?
SSL_get_verify_depth((SSL*) thd->net.vio->
ssl_arg):
0),
buff, 10);
break;
case SHOW_SSL_GET_CIPHER:
pos= (thd->net.vio->ssl_arg ?
SSL_get_cipher((SSL*) thd->net.vio->ssl_arg) : "" );
end= strend(pos);
break;
case SHOW_SSL_GET_CIPHER_LIST:
if (thd->net.vio->ssl_arg)
{
char *to= buff;
for (int i=0 ; i++ ;)
{
const char *p= SSL_get_cipher_list((SSL*) thd->net.vio->ssl_arg,i);
if (p == NULL)
break;
to= strmov(to, p);
*to++= ':';
}
if (to != buff)
to--; // Remove last ':'
end= to;
}
break;
#endif /* HAVE_OPENSSL */
case SHOW_KEY_CACHE_LONG:
case SHOW_KEY_CACHE_CONST_LONG:
value= (value-(char*) &dflt_key_cache_var)+ (char*) dflt_key_cache;
value= (char*) dflt_key_cache + (ulong)value;
end= int10_to_str(*(long*) value, buff, 10);
break;
case SHOW_KEY_CACHE_LONGLONG:
value= (value-(char*) &dflt_key_cache_var)+ (char*) dflt_key_cache;
value= (char*) dflt_key_cache + (ulong)value;
end= longlong10_to_str(*(longlong*) value, buff, 10);
break;
case SHOW_NET_COMPRESSION:
end= strmov(buff, thd->net.compress ? "ON" : "OFF");
break;
case SHOW_UNDEF: // Show never happen
case SHOW_UNDEF:
case SHOW_SYS:
break; // Return empty string
default:
......@@ -3615,7 +3371,6 @@ int fill_status(THD *thd, TABLE_LIST *tables, COND *cond)
const char *wild= lex->wild ? lex->wild->ptr() : NullS;
int res= 0;
STATUS_VAR tmp;
ha_update_statistics(); /* Export engines statistics */
pthread_mutex_lock(&LOCK_status);
if (lex->option_type == OPT_GLOBAL)
calc_sum_of_all_status(&tmp);
......
......@@ -173,29 +173,12 @@ typedef struct st_known_date_time_format {
enum SHOW_TYPE
{
SHOW_UNDEF,
SHOW_LONG, SHOW_LONGLONG, SHOW_INT, SHOW_CHAR, SHOW_CHAR_PTR,
SHOW_LONG, SHOW_LONGLONG, SHOW_INT, SHOW_CHAR, SHOW_CHAR_PTR,
SHOW_DOUBLE_STATUS, SHOW_BOOL, SHOW_MY_BOOL,
SHOW_OPEN_TABLES, SHOW_TABLE_DEFINITIONS, SHOW_STARTTIME, SHOW_QUESTION,
SHOW_LONG_CONST, SHOW_INT_CONST, SHOW_HAVE, SHOW_SYS, SHOW_HA_ROWS,
SHOW_VARS,
#ifdef HAVE_OPENSSL
SHOW_SSL_CTX_SESS_ACCEPT, SHOW_SSL_CTX_SESS_ACCEPT_GOOD,
SHOW_SSL_GET_VERSION, SHOW_SSL_CTX_GET_SESSION_CACHE_MODE,
SHOW_SSL_CTX_SESS_CB_HITS, SHOW_SSL_CTX_SESS_ACCEPT_RENEGOTIATE,
SHOW_SSL_CTX_SESS_NUMBER, SHOW_SSL_SESSION_REUSED,
SHOW_SSL_CTX_SESS_GET_CACHE_SIZE, SHOW_SSL_GET_CIPHER,
SHOW_SSL_GET_DEFAULT_TIMEOUT, SHOW_SSL_GET_VERIFY_MODE,
SHOW_SSL_CTX_GET_VERIFY_MODE, SHOW_SSL_GET_VERIFY_DEPTH,
SHOW_SSL_CTX_GET_VERIFY_DEPTH, SHOW_SSL_CTX_SESS_CONNECT,
SHOW_SSL_CTX_SESS_CONNECT_RENEGOTIATE, SHOW_SSL_CTX_SESS_CONNECT_GOOD,
SHOW_SSL_CTX_SESS_HITS, SHOW_SSL_CTX_SESS_MISSES,
SHOW_SSL_CTX_SESS_TIMEOUTS, SHOW_SSL_CTX_SESS_CACHE_FULL,
SHOW_SSL_GET_CIPHER_LIST,
#endif /* HAVE_OPENSSL */
SHOW_NET_COMPRESSION,
SHOW_RPL_STATUS, SHOW_SLAVE_RUNNING, SHOW_SLAVE_RETRIED_TRANS,
SHOW_ARRAY, SHOW_FUNC,
SHOW_KEY_CACHE_LONG, SHOW_KEY_CACHE_CONST_LONG, SHOW_KEY_CACHE_LONGLONG,
SHOW_LONG_STATUS, SHOW_LONG_CONST_STATUS, SHOW_SLAVE_SKIP_ERRORS
SHOW_LONG_STATUS, SHOW_LONG_CONST_STATUS
};
enum SHOW_COMP_OPTION { SHOW_OPTION_YES, SHOW_OPTION_NO, SHOW_OPTION_DISABLED};
......@@ -204,19 +187,19 @@ extern const char *show_comp_option_name[];
typedef int *(*update_var)(THD *, struct show_var_st *);
typedef struct show_var_st {
const char *name;
char *value;
SHOW_TYPE type;
} SHOW_VAR;
#define SHOW_VAR_FUNC_BUFF_SIZE 1024
typedef int (*show_var_func)(THD *, struct show_var_st *, char *);
typedef struct st_lex_user {
LEX_STRING user, host, password;
} LEX_USER;
/*
This structure specifies the maximum amount of resources which
can be consumed by each account. Zero value of a member means
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment