diff options
author | unknown <vtkachenko@intelp4d.mysql.com> | 2004-12-31 09:00:34 +0100 |
---|---|---|
committer | unknown <vtkachenko@intelp4d.mysql.com> | 2004-12-31 09:00:34 +0100 |
commit | c4c2c7bceb3a427fe669bfeec6747a72e404e1ad (patch) | |
tree | 2d4a9134c1f6b640fe3644c0690a6d0f81ec14f5 /sql | |
parent | ee4c910422236fd376df0d9688ce0ca39f61fdfc (diff) | |
parent | af22d870fae05614d893a0acd620e6bb369cc157 (diff) | |
download | mariadb-git-c4c2c7bceb3a427fe669bfeec6747a72e404e1ad.tar.gz |
Merge bk-internal:/home/bk/mysql-5.0
into intelp4d.mysql.com:/users/vtkachenko/bk/mysql-5.0
BitKeeper/etc/logging_ok:
auto-union
innobase/srv/srv0srv.c:
Auto merged
mysql-test/r/variables.result:
Auto merged
mysql-test/t/variables.test:
Auto merged
sql/ha_innodb.cc:
Auto merged
sql/lex.h:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/mysqld.cc:
Auto merged
sql/set_var.cc:
Auto merged
sql/sql_lex.h:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_innodb.cc | 111 | ||||
-rw-r--r-- | sql/ha_innodb.h | 1 | ||||
-rw-r--r-- | sql/lex.h | 1 | ||||
-rw-r--r-- | sql/mysql_priv.h | 1 | ||||
-rw-r--r-- | sql/mysqld.cc | 8 | ||||
-rw-r--r-- | sql/set_var.cc | 4 | ||||
-rw-r--r-- | sql/sql_lex.h | 2 | ||||
-rw-r--r-- | sql/sql_parse.cc | 7 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 4 |
9 files changed, 137 insertions, 2 deletions
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index cb23e31225b..6577590f14a 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -231,6 +231,16 @@ struct show_var_st innodb_status_variables[]= { (char*) &export_vars.innodb_pages_read, SHOW_LONG}, {"pages_written", (char*) &export_vars.innodb_pages_written, SHOW_LONG}, + {"row_lock_waits", + (char*) &export_vars.innodb_row_lock_waits, SHOW_LONG}, + {"row_lock_current_waits", + (char*) &export_vars.innodb_row_lock_current_waits, SHOW_LONG}, + {"row_lock_time", + (char*) &export_vars.innodb_row_lock_time, SHOW_LONGLONG}, + {"row_lock_time_max", + (char*) &export_vars.innodb_row_lock_time_max, SHOW_LONG}, + {"row_lock_time_avg", + (char*) &export_vars.innodb_row_lock_time_avg, SHOW_LONG}, {"rows_deleted", (char*) &export_vars.innodb_rows_deleted, SHOW_LONG}, {"rows_inserted", @@ -5506,6 +5516,107 @@ innodb_show_status( } /**************************************************************************** +Implements the SHOW MUTEX STATUS command. . */ + +bool +innodb_mutex_show_status( +/*===============*/ + THD* thd) /* in: the MySQL query thread of the caller */ +{ + Protocol *protocol= thd->protocol; + List<Item> field_list; + mutex_t* mutex; + const char* file_name; + ulint line; + ulint rw_lock_count= 0; + ulint rw_lock_count_spin_loop= 0; + ulint rw_lock_count_spin_rounds= 0; + ulint rw_lock_count_os_wait= 0; + ulint rw_lock_count_os_yield= 0; + ulonglong rw_lock_wait_time= 0; + + DBUG_ENTER("innodb_mutex_show_status"); + + field_list.push_back(new Item_empty_string("Mutex", FN_REFLEN)); + field_list.push_back(new Item_empty_string("Module", FN_REFLEN)); + field_list.push_back(new Item_uint("Count", 21)); + field_list.push_back(new Item_uint("Spin_waits", 21)); + field_list.push_back(new Item_uint("Spin_rounds", 21)); + field_list.push_back(new Item_uint("OS_waits", 21)); + field_list.push_back(new Item_uint("OS_yields", 21)); + field_list.push_back(new Item_uint("OS_waits_time", 21)); + + if (protocol->send_fields(&field_list, + Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) + DBUG_RETURN(TRUE); + +#ifdef MUTEX_PROTECT_TO_BE_ADDED_LATER + mutex_enter(&mutex_list_mutex); +#endif + + mutex = UT_LIST_GET_FIRST(mutex_list); + + while ( mutex != NULL ) + { + if (mutex->mutex_type != 1) + { + if (mutex->count_using > 0) + { + protocol->prepare_for_resend(); + protocol->store(mutex->cmutex_name, system_charset_info); + protocol->store(mutex->cfile_name, system_charset_info); + protocol->store((ulonglong)mutex->count_using); + protocol->store((ulonglong)mutex->count_spin_loop); + protocol->store((ulonglong)mutex->count_spin_rounds); + protocol->store((ulonglong)mutex->count_os_wait); + protocol->store((ulonglong)mutex->count_os_yield); + protocol->store((ulonglong)mutex->lspent_time/1000); + + if (protocol->write()) + { +#ifdef MUTEX_PROTECT_TO_BE_ADDED_LATER + mutex_exit(&mutex_list_mutex); +#endif + DBUG_RETURN(1); + } + } + } + else + { + rw_lock_count += mutex->count_using; + rw_lock_count_spin_loop += mutex->count_spin_loop; + rw_lock_count_spin_rounds += mutex->count_spin_rounds; + rw_lock_count_os_wait += mutex->count_os_wait; + rw_lock_count_os_yield += mutex->count_os_yield; + rw_lock_wait_time += mutex->lspent_time; + } + + mutex = UT_LIST_GET_NEXT(list, mutex); + } + + protocol->prepare_for_resend(); + protocol->store("rw_lock_mutexes", system_charset_info); + protocol->store("", system_charset_info); + protocol->store((ulonglong)rw_lock_count); + protocol->store((ulonglong)rw_lock_count_spin_loop); + protocol->store((ulonglong)rw_lock_count_spin_rounds); + protocol->store((ulonglong)rw_lock_count_os_wait); + protocol->store((ulonglong)rw_lock_count_os_yield); + protocol->store((ulonglong)rw_lock_wait_time/1000); + + if (protocol->write()) + { + DBUG_RETURN(1); + } + +#ifdef MUTEX_PROTECT_TO_BE_ADDED_LATER + mutex_exit(&mutex_list_mutex); +#endif + send_eof(thd); + DBUG_RETURN(FALSE); +} + +/**************************************************************************** Handling the shared INNOBASE_SHARE structure that is needed to provide table locking. ****************************************************************************/ diff --git a/sql/ha_innodb.h b/sql/ha_innodb.h index bb8823fd1bb..fcb9165de64 100644 --- a/sql/ha_innodb.h +++ b/sql/ha_innodb.h @@ -242,6 +242,7 @@ int innobase_savepoint( int innobase_close_connection(THD *thd); int innobase_drop_database(char *path); bool innodb_show_status(THD* thd); +bool innodb_mutex_show_status(THD* thd); void innodb_export_status(void); my_bool innobase_query_caching_of_table_permitted(THD* thd, char* full_name, diff --git a/sql/lex.h b/sql/lex.h index 5b6c86bf0ed..a1078512b87 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -323,6 +323,7 @@ static SYMBOL symbols[] = { { "MULTILINESTRING", SYM(MULTILINESTRING)}, { "MULTIPOINT", SYM(MULTIPOINT)}, { "MULTIPOLYGON", SYM(MULTIPOLYGON)}, + { "MUTEX", SYM(MUTEX_SYM)}, { "NAME", SYM(NAME_SYM)}, { "NAMES", SYM(NAMES_SYM)}, { "NATIONAL", SYM(NATIONAL_SYM)}, diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 5b819f89afa..83add7f5739 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -996,6 +996,7 @@ extern ulong table_cache_size; extern ulong max_connections,max_connect_errors, connect_timeout; extern ulong slave_net_timeout; extern ulong max_user_connections; +extern my_bool timed_mutexes; extern ulong what_to_log,flush_time; extern ulong query_buff_size, thread_stack,thread_stack_min; extern ulong binlog_cache_size, max_binlog_cache_size, open_files_limit; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 314abcd9745..4b97d96fda5 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -334,6 +334,7 @@ ulong binlog_cache_use= 0, binlog_cache_disk_use= 0; ulong max_connections,max_used_connections, max_connect_errors, max_user_connections = 0; ulong thread_id=1L,current_pid; +my_bool timed_mutexes= 0; ulong slow_launch_threads = 0, sync_binlog_period; ulong expire_logs_days = 0; ulong rpl_recovery_rank=0; @@ -4213,7 +4214,8 @@ enum options_mysqld OPT_UPDATABLE_VIEWS_WITH_LIMIT, OPT_SP_AUTOMATIC_PRIVILEGES, OPT_AUTO_INCREMENT, OPT_AUTO_INCREMENT_OFFSET, - OPT_ENABLE_LARGE_PAGES + OPT_ENABLE_LARGE_PAGES, + OPT_TIMED_MUTEXES }; @@ -4838,6 +4840,10 @@ log and this option does nothing anymore.", "Using this option will cause most temporary files created to use a small set of names, rather than a unique name for each new file.", (gptr*) &use_temp_pool, (gptr*) &use_temp_pool, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, + {"timed_mutexes", OPT_TIMED_MUTEXES, + "Specify whether to time mutexes (only InnoDB mutexes are currently supported)", + (gptr*) &timed_mutexes, (gptr*) &timed_mutexes, 0, GET_BOOL, NO_ARG, 0, + 0, 0, 0, 0, 0}, {"tmpdir", 't', "Path for temporary files. Several paths may be specified, separated by a " #if defined(__WIN__) || defined(OS2) || defined(__NETWARE__) diff --git a/sql/set_var.cc b/sql/set_var.cc index 2d3f6fe7cdd..32d0c50b91a 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -365,6 +365,8 @@ sys_var_thd_enum sys_tx_isolation("tx_isolation", fix_tx_isolation); sys_var_thd_ulong sys_tmp_table_size("tmp_table_size", &SV::tmp_table_size); +sys_var_bool_ptr sys_timed_mutexes("timed_mutexes", + &timed_mutexes); sys_var_thd_ulong sys_net_wait_timeout("wait_timeout", &SV::net_wait_timeout); @@ -636,6 +638,7 @@ sys_var *sys_variables[]= &sys_table_type, &sys_thread_cache_size, &sys_time_format, + &sys_timed_mutexes, &sys_timestamp, &sys_time_zone, &sys_tmp_table_size, @@ -903,6 +906,7 @@ struct show_var_st init_vars[]= { {"thread_stack", (char*) &thread_stack, SHOW_LONG}, {sys_time_format.name, (char*) &sys_time_format, SHOW_SYS}, {"time_zone", (char*) &sys_time_zone, SHOW_SYS}, + {sys_timed_mutexes.name, (char*) &sys_timed_mutexes, SHOW_SYS}, {sys_tmp_table_size.name, (char*) &sys_tmp_table_size, SHOW_SYS}, {"tmpdir", (char*) &opt_mysql_tmpdir, SHOW_CHAR_PTR}, {sys_trans_alloc_block_size.name, (char*) &sys_trans_alloc_block_size, diff --git a/sql/sql_lex.h b/sql/sql_lex.h index f6858583ecd..007a4601338 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -53,7 +53,7 @@ enum enum_sql_command { SQLCOM_SHOW_DATABASES, SQLCOM_SHOW_TABLES, SQLCOM_SHOW_FIELDS, SQLCOM_SHOW_KEYS, SQLCOM_SHOW_VARIABLES, SQLCOM_SHOW_LOGS, SQLCOM_SHOW_STATUS, - SQLCOM_SHOW_INNODB_STATUS, + SQLCOM_SHOW_INNODB_STATUS, SQLCOM_SHOW_MUTEX_STATUS, SQLCOM_SHOW_PROCESSLIST, SQLCOM_SHOW_MASTER_STAT, SQLCOM_SHOW_SLAVE_STAT, SQLCOM_SHOW_GRANTS, SQLCOM_SHOW_CREATE, SQLCOM_SHOW_CHARSETS, SQLCOM_SHOW_COLLATIONS, SQLCOM_SHOW_CREATE_DB, SQLCOM_SHOW_TABLE_STATUS, diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index e43b124a8d9..9b07c786407 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2502,6 +2502,13 @@ mysql_execute_command(THD *thd) res = innodb_show_status(thd); break; } + case SQLCOM_SHOW_MUTEX_STATUS: + { + if (check_global_access(thd, SUPER_ACL)) + goto error; + res = innodb_mutex_show_status(thd); + break; + } #endif #ifdef HAVE_REPLICATION case SQLCOM_LOAD_MASTER_TABLE: diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index a8954426045..70e21b9960e 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -336,6 +336,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token MAX_UPDATES_PER_HOUR %token MEDIUM_SYM %token MIN_ROWS +%token MUTEX_SYM %token NAMES_SYM %token NAME_SYM %token NATIONAL_SYM @@ -5997,6 +5998,8 @@ show_param: } | INNOBASE_SYM STATUS_SYM { Lex->sql_command = SQLCOM_SHOW_INNODB_STATUS; WARN_DEPRECATED("SHOW INNODB STATUS", "SHOW ENGINE INNODB STATUS"); } + | MUTEX_SYM STATUS_SYM + { Lex->sql_command = SQLCOM_SHOW_MUTEX_STATUS; } | opt_full PROCESSLIST_SYM { Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;} | opt_var_type VARIABLES ext_select_item_list wild_and_where @@ -6998,6 +7001,7 @@ keyword: | MULTILINESTRING {} | MULTIPOINT {} | MULTIPOLYGON {} + | MUTEX_SYM {} | NAME_SYM {} | NAMES_SYM {} | NATIONAL_SYM {} |