diff --git a/handler/i_s.cc b/handler/i_s.cc index 7729a615195..10ba8fb468a 100644 --- a/handler/i_s.cc +++ b/handler/i_s.cc @@ -241,6 +241,15 @@ static ST_FIELD_INFO innodb_trx_fields_info[] = STRUCT_FLD(old_name, ""), STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, +#define IDX_TRX_QUERY 6 + {STRUCT_FLD(field_name, "trx_query"), + STRUCT_FLD(field_length, TRX_I_S_TRX_QUERY_MAX_LEN), + STRUCT_FLD(field_type, MYSQL_TYPE_STRING), + STRUCT_FLD(value, 0), + STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), + STRUCT_FLD(old_name, ""), + STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + END_OF_ST_FIELD_INFO }; @@ -313,6 +322,10 @@ fill_innodb_trx_from_cache( OK(fields[IDX_TRX_MYSQL_THREAD_ID]->store( row->trx_mysql_thread_id)); + /* trx_query */ + OK(field_store_string(fields[IDX_TRX_QUERY], + row->trx_query)); + OK(schema_table_store_record(thd, table)); } diff --git a/include/trx0i_s.h b/include/trx0i_s.h index 4587b8cf7c5..3642727f18a 100644 --- a/include/trx0i_s.h +++ b/include/trx0i_s.h @@ -18,6 +18,10 @@ Created July 17, 2007 Vasil Dimov i_s_locks_row_t::lock_data */ #define TRX_I_S_LOCK_DATA_MAX_LEN 8192 +/* the maximum length of a string that can be stored in +i_s_trx_row_t::trx_query */ +#define TRX_I_S_TRX_QUERY_MAX_LEN 1024 + typedef struct i_s_locks_row_struct i_s_locks_row_t; typedef struct i_s_hash_chain_struct i_s_hash_chain_t; @@ -55,6 +59,7 @@ typedef struct i_s_trx_row_struct { const i_s_locks_row_t* wait_lock_row; ib_time_t trx_wait_started; ulint trx_mysql_thread_id; + const char* trx_query; } i_s_trx_row_t; /* This structure represents INFORMATION_SCHEMA.innodb_lock_waits row */ diff --git a/trx/trx0i_s.c b/trx/trx0i_s.c index 4a67fa0d892..2a95a8de192 100644 --- a/trx/trx0i_s.c +++ b/trx/trx0i_s.c @@ -333,11 +333,14 @@ fill_trx_row( that's filled */ const trx_t* trx, /* in: transaction to get data from */ - const i_s_locks_row_t* wait_lock_row) /* in: pointer to the + const i_s_locks_row_t* wait_lock_row, /* in: pointer to the corresponding row in innodb_locks if trx is waiting or NULL if trx is not waiting */ + trx_i_s_cache_t* cache) /* in/out: cache into + which to copy volatile + strings */ { row->trx_id = trx_get_id(trx); row->trx_started = (ib_time_t) trx->start_time; @@ -359,6 +362,30 @@ fill_trx_row( row->trx_mysql_thread_id = ib_thd_get_thread_id(trx->mysql_thd); + if (trx->mysql_query_str != NULL && *trx->mysql_query_str != NULL) { + + if (strlen(*trx->mysql_query_str) + > TRX_I_S_TRX_QUERY_MAX_LEN) { + + char query[TRX_I_S_TRX_QUERY_MAX_LEN + 1]; + + memcpy(query, *trx->mysql_query_str, + TRX_I_S_TRX_QUERY_MAX_LEN); + query[TRX_I_S_TRX_QUERY_MAX_LEN] = '\0'; + + row->trx_query = ha_storage_put( + cache->storage, query, + TRX_I_S_TRX_QUERY_MAX_LEN + 1); + } else { + + row->trx_query = ha_storage_put_str( + cache->storage, *trx->mysql_query_str); + } + } else { + + row->trx_query = NULL; + } + return(row); } @@ -960,7 +987,7 @@ fetch_data_into_cache( trx_row = (i_s_trx_row_t*) table_cache_create_empty_row(&cache->innodb_trx); - fill_trx_row(trx_row, trx, wait_lock_row); + fill_trx_row(trx_row, trx, wait_lock_row, cache); } }