mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 19:11:46 +01:00
branches/zip:
Add the query in information_schema.innodb_trx.trx_query. Add it even though it is available in information_schema.processlist.info to make inconsistencies between those two tables obvious. It is rather confusting to see a transaction shown in innodb_trx and innodb_locks that holds a lock on one table and the corresponding query in processlist executing INSERT on another table. We do not want users to contact us asking to explain that. It is caused by the fact that the data for innodb_* tables and processlist is fetched at different time. Approved by: Marko
This commit is contained in:
parent
e3c2d27143
commit
e7c63e2c15
3 changed files with 47 additions and 2 deletions
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue