diff options
author | unknown <heikki@hundin.mysql.fi> | 2002-07-08 19:34:49 +0300 |
---|---|---|
committer | unknown <heikki@hundin.mysql.fi> | 2002-07-08 19:34:49 +0300 |
commit | c0e8c9a11f0427fe6e0604eaeef5988abdb55210 (patch) | |
tree | b4e7fbd4d1817aa205132578bc6b11e6dd0fad86 /sql | |
parent | 9eef017c5750b26b75252a2ac0679f761404d136 (diff) | |
download | mariadb-git-c0e8c9a11f0427fe6e0604eaeef5988abdb55210.tar.gz |
Many files:
Merge InnoDB-3.23.52b
innobase/btr/btr0btr.c:
Merge InnoDB-3.23.52b
innobase/btr/btr0cur.c:
Merge InnoDB-3.23.52b
innobase/btr/btr0sea.c:
Merge InnoDB-3.23.52b
innobase/buf/buf0buf.c:
Merge InnoDB-3.23.52b
innobase/ha/ha0ha.c:
Merge InnoDB-3.23.52b
innobase/ibuf/ibuf0ibuf.c:
Merge InnoDB-3.23.52b
innobase/include/btr0cur.h:
Merge InnoDB-3.23.52b
innobase/include/buf0buf.h:
Merge InnoDB-3.23.52b
innobase/include/ha0ha.h:
Merge InnoDB-3.23.52b
innobase/include/ibuf0ibuf.h:
Merge InnoDB-3.23.52b
innobase/include/lock0lock.h:
Merge InnoDB-3.23.52b
innobase/include/log0log.h:
Merge InnoDB-3.23.52b
innobase/include/os0file.h:
Merge InnoDB-3.23.52b
innobase/include/rem0rec.ic:
Merge InnoDB-3.23.52b
innobase/include/srv0srv.h:
Merge InnoDB-3.23.52b
innobase/include/sync0arr.h:
Merge InnoDB-3.23.52b
innobase/include/sync0sync.h:
Merge InnoDB-3.23.52b
innobase/include/trx0trx.h:
Merge InnoDB-3.23.52b
innobase/lock/lock0lock.c:
Merge InnoDB-3.23.52b
innobase/log/log0log.c:
Merge InnoDB-3.23.52b
innobase/os/os0file.c:
Merge InnoDB-3.23.52b
innobase/row/row0mysql.c:
Merge InnoDB-3.23.52b
innobase/row/row0umod.c:
Merge InnoDB-3.23.52b
innobase/row/row0upd.c:
Merge InnoDB-3.23.52b
innobase/srv/srv0srv.c:
Merge InnoDB-3.23.52b
innobase/srv/srv0start.c:
Merge InnoDB-3.23.52b
innobase/sync/sync0arr.c:
Merge InnoDB-3.23.52b
innobase/sync/sync0sync.c:
Merge InnoDB-3.23.52b
innobase/trx/trx0trx.c:
Merge InnoDB-3.23.52b
sql/ha_innobase.h:
Merge InnoDB-3.23.52b
sql/ha_innobase.cc:
Merge InnoDB-3.23.52b
sql/sql_lex.h:
Merge InnoDB-3.23.52b
sql/mysqld.cc:
Merge InnoDB-3.23.52b
sql/sql_parse.cc:
Merge InnoDB-3.23.52b
sql/sql_yacc.yy:
Merge InnoDB-3.23.52b
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_innobase.cc | 94 | ||||
-rw-r--r-- | sql/ha_innobase.h | 1 | ||||
-rw-r--r-- | sql/mysqld.cc | 1 | ||||
-rw-r--r-- | sql/sql_lex.h | 1 | ||||
-rw-r--r-- | sql/sql_parse.cc | 13 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 2 |
6 files changed, 103 insertions, 9 deletions
diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index 0975cdce290..f5b80241f9a 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -269,35 +269,37 @@ the prototype for this function! */ void innobase_mysql_print_thd( /*=====================*/ + char* buf, /* in/out: buffer where to print, must be at least + 300 bytes */ void* input_thd)/* in: pointer to a MySQL THD object */ { THD* thd; thd = (THD*) input_thd; - printf("MySQL thread id %lu, query id %lu", + buf += sprintf(buf, "MySQL thread id %lu, query id %lu", thd->thread_id, thd->query_id); if (thd->host) { - printf(" %s", thd->host); + buf += sprintf(buf, " %.30s", thd->host); } if (thd->ip) { - printf(" %s", thd->ip); + buf += sprintf(buf, " %.20s", thd->ip); } if (thd->user) { - printf(" %s", thd->user); + buf += sprintf(buf, " %.20s", thd->user); } if (thd->proc_info) { - printf(" %s", thd->proc_info); + buf += sprintf(buf, " %.50s", thd->proc_info); } if (thd->query) { - printf("\n%.100s", thd->query); + buf += sprintf(buf, "\n%.150s", thd->query); } - printf("\n"); + buf += sprintf(buf, "\n"); } } @@ -314,10 +316,12 @@ check_trx_exists( { trx_t* trx; + ut_a(thd == current_thd); + trx = (trx_t*) thd->transaction.all.innobase_tid; if (trx == NULL) { - dbug_assert(thd != NULL); + ut_a(thd != NULL); trx = trx_allocate_for_mysql(); trx->mysql_thd = thd; @@ -368,7 +372,7 @@ ha_innobase::update_thd( { row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; trx_t* trx; - + trx = check_trx_exists(thd); if (prebuilt->trx != trx) { @@ -1378,6 +1382,9 @@ ha_innobase::write_row( DBUG_ENTER("ha_innobase::write_row"); + ut_a(prebuilt->trx == + (trx_t*) current_thd->transaction.all.innobase_tid); + statistic_increment(ha_write_count, &LOCK_status); if (table->time_stamp) { @@ -1718,6 +1725,9 @@ ha_innobase::update_row( DBUG_ENTER("ha_innobase::update_row"); + ut_a(prebuilt->trx == + (trx_t*) current_thd->transaction.all.innobase_tid); + if (table->time_stamp) { update_timestamp(new_row + table->time_stamp - 1); } @@ -1775,6 +1785,9 @@ ha_innobase::delete_row( DBUG_ENTER("ha_innobase::delete_row"); + ut_a(prebuilt->trx == + (trx_t*) current_thd->transaction.all.innobase_tid); + if (last_query_id != user_thd->query_id) { prebuilt->sql_stat_start = TRUE; last_query_id = user_thd->query_id; @@ -1888,6 +1901,10 @@ ha_innobase::index_read( ulint ret; DBUG_ENTER("index_read"); + + ut_a(prebuilt->trx == + (trx_t*) current_thd->transaction.all.innobase_tid); + statistic_increment(ha_read_key_count, &LOCK_status); if (last_query_id != user_thd->query_id) { @@ -2062,6 +2079,9 @@ ha_innobase::general_fetch( DBUG_ENTER("general_fetch"); + ut_a(prebuilt->trx == + (trx_t*) current_thd->transaction.all.innobase_tid); + srv_conc_enter_innodb(prebuilt->trx); ret = row_search_for_mysql((byte*)buf, 0, prebuilt, match_mode, @@ -2272,6 +2292,9 @@ ha_innobase::rnd_pos( DBUG_ENTER("rnd_pos"); statistic_increment(ha_read_rnd_count, &LOCK_status); + ut_a(prebuilt->trx == + (trx_t*) current_thd->transaction.all.innobase_tid); + if (prebuilt->clust_index_was_generated) { /* No primary key was defined for the table and we generated the clustered index from the row id: the @@ -2310,6 +2333,9 @@ ha_innobase::position( row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; uint len; + ut_a(prebuilt->trx == + (trx_t*) current_thd->transaction.all.innobase_tid); + if (prebuilt->clust_index_was_generated) { /* No primary key was defined for the table and we generated the clustered index from row id: the @@ -3067,6 +3093,8 @@ ha_innobase::check( ulint ret; ut_a(prebuilt->trx && prebuilt->trx->magic_n == TRX_MAGIC_N); + ut_a(prebuilt->trx == + (trx_t*) current_thd->transaction.all.innobase_tid); if (prebuilt->mysql_template == NULL) { /* Build the template; we will use a dummy template @@ -3302,6 +3330,51 @@ ha_innobase::external_lock( } /**************************************************************************** +Implements the SHOW INNODB STATUS command. Send the output of the InnoDB +Monitor to the client. */ + +int +innodb_show_status( +/*===============*/ + THD* thd) /* in: the MySQL query thread of the caller */ +{ + String* packet = &thd->packet; + char* buf; + + DBUG_ENTER("innodb_show_status"); + + /* We let the InnoDB Monitor to output at most 100 kB of text */ + buf = (char*)ut_malloc(100 * 1024); + + srv_sprintf_innodb_monitor(buf, 100 * 1024); + + List<Item> field_list; + + field_list.push_back(new Item_empty_string("Status", strlen(buf))); + + if(send_fields(thd, field_list, 1)) { + DBUG_RETURN(-1); + } + + packet->length(0); + + net_store_data(packet, buf); + + if (my_net_write(&thd->net, (char*)thd->packet.ptr(), + packet->length())) { + ut_free(buf); + + DBUG_RETURN(-1); + } + + ut_free(buf); + + send_eof(&thd->net); + + DBUG_RETURN(0); +} + +/**************************************************************************** Handling the shared INNOBASE_SHARE structure that is needed to provide table locking. ****************************************************************************/ @@ -3424,6 +3497,9 @@ ha_innobase::get_auto_increment() longlong nr; int error; + ut_a(prebuilt->trx == + (trx_t*) current_thd->transaction.all.innobase_tid); + /* Also SHOW TABLE STATUS calls this function. Previously, when we did always read the max autoinc key value, setting x-locks, users were surprised that SHOW TABLE STATUS could end up in a deadlock with diff --git a/sql/ha_innobase.h b/sql/ha_innobase.h index 9f752dd2eda..aa497132b25 100644 --- a/sql/ha_innobase.h +++ b/sql/ha_innobase.h @@ -195,4 +195,5 @@ int innobase_report_binlog_offset_and_commit( int innobase_rollback(THD *thd, void* trx_handle); int innobase_close_connection(THD *thd); int innobase_drop_database(char *path); +int innodb_show_status(THD* thd); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 4d9336afb1d..a810219da15 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3155,6 +3155,7 @@ struct show_var_st status_vars[]= { {"Com_show_processlist", (char*) (com_stat+(uint) SQLCOM_SHOW_PROCESSLIST),SHOW_LONG}, {"Com_show_slave_status", (char*) (com_stat+(uint) SQLCOM_SHOW_SLAVE_STAT),SHOW_LONG}, {"Com_show_status", (char*) (com_stat+(uint) SQLCOM_SHOW_STATUS),SHOW_LONG}, + {"Com_show_innodb_status", (char*) (com_stat+(uint) SQLCOM_SHOW_INNODB_STATUS),SHOW_LONG}, {"Com_show_tables", (char*) (com_stat+(uint) SQLCOM_SHOW_TABLES),SHOW_LONG}, {"Com_show_variables", (char*) (com_stat+(uint) SQLCOM_SHOW_VARIABLES),SHOW_LONG}, {"Com_slave_start", (char*) (com_stat+(uint) SQLCOM_SLAVE_START),SHOW_LONG}, diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 2b889d356bb..7d1df04b852 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -40,6 +40,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_PROCESSLIST, SQLCOM_SHOW_MASTER_STAT, SQLCOM_SHOW_SLAVE_STAT, SQLCOM_SHOW_GRANTS, SQLCOM_SHOW_CREATE, diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 21590f743a5..9cca8c8fa58 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -24,6 +24,10 @@ #include <my_dir.h> #include <assert.h> +#ifdef HAVE_INNOBASE_DB +#include "ha_innobase.h" +#endif + #define SCRAMBLE_LENGTH 8 @@ -1232,6 +1236,15 @@ mysql_execute_command(void) res = show_binlog_info(thd); break; } +#ifdef HAVE_INNOBASE_DB + case SQLCOM_SHOW_INNODB_STATUS: + { + if (check_process_priv(thd)) + goto error; + res = innodb_show_status(thd); + break; + } +#endif case SQLCOM_LOAD_MASTER_TABLE: if (!tables->db) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 07a0263dd88..e258f5d3827 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -2242,6 +2242,8 @@ show_param: } | STATUS_SYM wild { Lex->sql_command= SQLCOM_SHOW_STATUS; } + | INNOBASE_SYM STATUS_SYM + { Lex->sql_command = SQLCOM_SHOW_INNODB_STATUS;} | opt_full PROCESSLIST_SYM { Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;} | VARIABLES wild |