summaryrefslogtreecommitdiff
path: root/storage/innobase
diff options
context:
space:
mode:
authorJimmy Yang <jimmy.yang@oracle.com>2010-05-12 08:39:45 -0700
committerJimmy Yang <jimmy.yang@oracle.com>2010-05-12 08:39:45 -0700
commitefc32dcf3f9726eb3287a185c7d1a90e91978e62 (patch)
tree4709e6d6d10bde52820c1dcd55626aedf402d864 /storage/innobase
parentf8b9bb194d4bce786bc179a5c61c4fb53a7ba75e (diff)
downloadmariadb-git-efc32dcf3f9726eb3287a185c7d1a90e91978e62.tar.gz
Check in patch for bug #53336, Improved InnoDB Transaction Reporting.
rb://335, Approved by Sunny Bains
Diffstat (limited to 'storage/innobase')
-rw-r--r--storage/innobase/handler/i_s.cc308
-rw-r--r--storage/innobase/include/lock0lock.h2
-rw-r--r--storage/innobase/include/trx0i_s.h87
-rw-r--r--storage/innobase/lock/lock0lock.c2
-rw-r--r--storage/innobase/trx/trx0i_s.c87
5 files changed, 452 insertions, 34 deletions
diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc
index 7a457e6a990..f8b3b71c804 100644
--- a/storage/innobase/handler/i_s.cc
+++ b/storage/innobase/handler/i_s.cc
@@ -288,6 +288,258 @@ static ST_FIELD_INFO innodb_trx_fields_info[] =
STRUCT_FLD(old_name, ""),
STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+#define IDX_TRX_OPERATION_STATE 8
+ {STRUCT_FLD(field_name, "trx_operation_state"),
+ STRUCT_FLD(field_length, TRX_I_S_TRX_OP_STATE_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)},
+
+#define IDX_TRX_TABLES_IN_USE 9
+ {STRUCT_FLD(field_name, "trx_tables_in_use"),
+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_TRX_TABLES_LOCKED 10
+ {STRUCT_FLD(field_name, "trx_tables_locked"),
+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_TRX_LOCK_STRUCTS 11
+ {STRUCT_FLD(field_name, "trx_lock_structs"),
+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_TRX_LOCK_MEMORY_BYTES 12
+ {STRUCT_FLD(field_name, "trx_lock_memory_bytes"),
+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_TRX_ROWS_LOCKED 13
+ {STRUCT_FLD(field_name, "trx_rows_locked"),
+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_TRX_ROWS_MODIFIED 14
+ {STRUCT_FLD(field_name, "trx_rows_modified"),
+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_TRX_CONNCURRENCY_TICKETS 15
+ {STRUCT_FLD(field_name, "trx_concurrency_tickets"),
+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_TRX_ISOLATION_LEVEL 16
+ {STRUCT_FLD(field_name, "trx_isolation_level"),
+ STRUCT_FLD(field_length, TRX_I_S_TRX_ISOLATION_LEVEL_MAX_LEN),
+ STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, 0),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_TRX_UNIQUE_CHECKS 17
+ {STRUCT_FLD(field_name, "trx_unique_checks"),
+ STRUCT_FLD(field_length, 1),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
+ STRUCT_FLD(value, 1),
+ STRUCT_FLD(field_flags, 0),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_TRX_FOREIGN_KEY_CHECKS 18
+ {STRUCT_FLD(field_name, "trx_foreign_key_checks"),
+ STRUCT_FLD(field_length, 1),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
+ STRUCT_FLD(value, 1),
+ STRUCT_FLD(field_flags, 0),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_TRX_LAST_FOREIGN_KEY_ERROR 19
+ {STRUCT_FLD(field_name, "trx_last_foreign_key_error"),
+ STRUCT_FLD(field_length, TRX_I_S_TRX_FK_ERROR_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)},
+
+#define IDX_TRX_ADAPTIVE_HASH_LATCHED 20
+ {STRUCT_FLD(field_name, "trx_apative_hash_latched"),
+ STRUCT_FLD(field_length, 1),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, 0),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_TRX_ADAPTIVE_HASH_TIMEOUT 21
+ {STRUCT_FLD(field_name, "trx_adaptive_hash_timeout"),
+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_TRX_OPERATION_STATE 8
+ {STRUCT_FLD(field_name, "trx_operation_state"),
+ STRUCT_FLD(field_length, TRX_I_S_TRX_OP_STATE_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)},
+
+#define IDX_TRX_TABLES_IN_USE 9
+ {STRUCT_FLD(field_name, "trx_tables_in_use"),
+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_TRX_TABLES_LOCKED 10
+ {STRUCT_FLD(field_name, "trx_tables_locked"),
+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_TRX_LOCK_STRUCTS 11
+ {STRUCT_FLD(field_name, "trx_lock_structs"),
+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_TRX_LOCK_MEMORY_BYTES 12
+ {STRUCT_FLD(field_name, "trx_lock_memory_bytes"),
+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_TRX_ROWS_LOCKED 13
+ {STRUCT_FLD(field_name, "trx_rows_locked"),
+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_TRX_ROWS_MODIFIED 14
+ {STRUCT_FLD(field_name, "trx_rows_modified"),
+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_TRX_CONNCURRENCY_TICKETS 15
+ {STRUCT_FLD(field_name, "trx_concurrency_tickets"),
+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_TRX_ISOLATION_LEVEL 16
+ {STRUCT_FLD(field_name, "trx_isolation_level"),
+ STRUCT_FLD(field_length, TRX_I_S_TRX_ISOLATION_LEVEL_MAX_LEN),
+ STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, 0),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_TRX_UNIQUE_CHECKS 17
+ {STRUCT_FLD(field_name, "trx_unique_checks"),
+ STRUCT_FLD(field_length, 1),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
+ STRUCT_FLD(value, 1),
+ STRUCT_FLD(field_flags, 0),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_TRX_FOREIGN_KEY_CHECKS 18
+ {STRUCT_FLD(field_name, "trx_foreign_key_checks"),
+ STRUCT_FLD(field_length, 1),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
+ STRUCT_FLD(value, 1),
+ STRUCT_FLD(field_flags, 0),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_TRX_LAST_FOREIGN_KEY_ERROR 19
+ {STRUCT_FLD(field_name, "trx_last_foreign_key_error"),
+ STRUCT_FLD(field_length, TRX_I_S_TRX_FK_ERROR_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)},
+
+#define IDX_TRX_ADAPTIVE_HASH_LATCHED 20
+ {STRUCT_FLD(field_name, "trx_apative_hash_latched"),
+ STRUCT_FLD(field_length, 1),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONG),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, 0),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
+#define IDX_TRX_ADAPTIVE_HASH_TIMEOUT 21
+ {STRUCT_FLD(field_name, "trx_adaptive_hash_timeout"),
+ STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
+ STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
+ STRUCT_FLD(value, 0),
+ STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
+ STRUCT_FLD(old_name, ""),
+ STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
+
END_OF_ST_FIELD_INFO
};
@@ -370,6 +622,62 @@ fill_innodb_trx_from_cache(
OK(field_store_string(fields[IDX_TRX_QUERY],
row->trx_query));
+ /* trx_operation_state */
+ OK(field_store_string(fields[IDX_TRX_OPERATION_STATE],
+ row->trx_operation_state));
+
+ /* trx_tables_in_use */
+ OK(fields[IDX_TRX_TABLES_IN_USE]->store(
+ (longlong) row->trx_tables_in_use, true));
+
+ /* trx_tables_locked */
+ OK(fields[IDX_TRX_TABLES_LOCKED]->store(
+ (longlong) row->trx_tables_locked, true));
+
+ /* trx_lock_structs */
+ OK(fields[IDX_TRX_LOCK_STRUCTS]->store(
+ (longlong) row->trx_lock_structs, true));
+
+ /* trx_lock_memory_bytes */
+ OK(fields[IDX_TRX_LOCK_MEMORY_BYTES]->store(
+ (longlong) row->trx_lock_memory_bytes, true));
+
+ /* trx_rows_locked */
+ OK(fields[IDX_TRX_ROWS_LOCKED]->store(
+ (longlong) row->trx_rows_locked, true));
+
+ /* trx_rows_modified */
+ OK(fields[IDX_TRX_ROWS_MODIFIED]->store(
+ (longlong) row->trx_rows_modified, true));
+
+ /* trx_concurrency_tickets */
+ OK(fields[IDX_TRX_CONNCURRENCY_TICKETS]->store(
+ (longlong) row->trx_concurrency_tickets, true));
+
+ /* trx_isolation_level */
+ OK(field_store_string(fields[IDX_TRX_ISOLATION_LEVEL],
+ row->trx_isolation_level));
+
+ /* trx_unique_checks */
+ OK(fields[IDX_TRX_UNIQUE_CHECKS]->store(
+ row->trx_unique_checks));
+
+ /* trx_foreign_key_checks */
+ OK(fields[IDX_TRX_FOREIGN_KEY_CHECKS]->store(
+ row->trx_foreign_key_checks));
+
+ /* trx_last_foreign_key_error */
+ OK(field_store_string(fields[IDX_TRX_LAST_FOREIGN_KEY_ERROR],
+ row->trx_foreign_key_error));
+
+ /* trx_apative_hash_latched */
+ OK(fields[IDX_TRX_ADAPTIVE_HASH_LATCHED]->store(
+ row->trx_has_search_latch));
+
+ /* trx_adaptive_hash_timeout */
+ OK(fields[IDX_TRX_ADAPTIVE_HASH_TIMEOUT]->store(
+ (longlong) row->trx_search_latch_timeout, true));
+
OK(schema_table_store_record(thd, table));
}
diff --git a/storage/innobase/include/lock0lock.h b/storage/innobase/include/lock0lock.h
index ad271a95654..bdc11282dac 100644
--- a/storage/innobase/include/lock0lock.h
+++ b/storage/innobase/include/lock0lock.h
@@ -637,7 +637,7 @@ UNIV_INTERN
ulint
lock_number_of_rows_locked(
/*=======================*/
- trx_t* trx); /*!< in: transaction */
+ const trx_t* trx); /*!< in: transaction */
/*******************************************************************//**
Check if a transaction holds any autoinc locks.
@return TRUE if the transaction holds any AUTOINC locks. */
diff --git a/storage/innobase/include/trx0i_s.h b/storage/innobase/include/trx0i_s.h
index 7bd4e1b88c8..c610782c229 100644
--- a/storage/innobase/include/trx0i_s.h
+++ b/storage/innobase/include/trx0i_s.h
@@ -44,6 +44,37 @@ i_s_locks_row_t::lock_data */
i_s_trx_row_t::trx_query */
#define TRX_I_S_TRX_QUERY_MAX_LEN 1024
+/** The maximum length of a string that can be stored in
+i_s_trx_row_t::trx_operation_state */
+#define TRX_I_S_TRX_OP_STATE_MAX_LEN 64
+
+/** The maximum length of a string that can be stored in
+i_s_trx_row_t::trx_foreign_key_error */
+#define TRX_I_S_TRX_FK_ERROR_MAX_LEN 256
+
+/** The maximum length of a string that can be stored in
+i_s_trx_row_t::trx_isolation_level */
+#define TRX_I_S_TRX_ISOLATION_LEVEL_MAX_LEN 16
+
+/** Safely copy strings in to the INNODB_TRX table's
+string based columns */
+#define TRX_I_S_STRING_COPY(data, field, constraint, tcache) \
+do { \
+ if (strlen(data) > constraint) { \
+ char buff[constraint + 1]; \
+ strncpy(buff, data, constraint); \
+ buff[constraint] = '\0'; \
+ \
+ field = ha_storage_put_memlim( \
+ (tcache)->storage, buff, constraint + 1,\
+ MAX_ALLOWED_FOR_STORAGE(tcache)); \
+ } else { \
+ field = ha_storage_put_str_memlim( \
+ (tcache)->storage, data, \
+ MAX_ALLOWED_FOR_STORAGE(tcache)); \
+ } \
+} while (0)
+
/** A row of INFORMATION_SCHEMA.innodb_locks */
typedef struct i_s_locks_row_struct i_s_locks_row_t;
/** A row of INFORMATION_SCHEMA.innodb_trx */
@@ -95,21 +126,49 @@ struct i_s_locks_row_struct {
/** This structure represents INFORMATION_SCHEMA.innodb_trx row */
struct i_s_trx_row_struct {
- ullint trx_id; /*!< transaction identifier */
- const char* trx_state; /*!< transaction state from
- trx_get_que_state_str() */
- ib_time_t trx_started; /*!< trx_struct::start_time */
+ ullint trx_id; /*!< transaction identifier */
+ const char* trx_state; /*!< transaction state from
+ trx_get_que_state_str() */
+ ib_time_t trx_started; /*!< trx_struct::start_time */
const i_s_locks_row_t* requested_lock_row;
- /*!< pointer to a row
- in innodb_locks if trx
- is waiting, or NULL */
- ib_time_t trx_wait_started;
- /*!< trx_struct::wait_started */
- ullint trx_weight; /*!< TRX_WEIGHT() */
- ulint trx_mysql_thread_id;
- /*!< thd_get_thread_id() */
- const char* trx_query; /*!< MySQL statement being
- executed in the transaction */
+ /*!< pointer to a row
+ in innodb_locks if trx
+ is waiting, or NULL */
+ ib_time_t trx_wait_started; /*!< trx_struct::wait_started */
+ ullint trx_weight; /*!< TRX_WEIGHT() */
+ ulint trx_mysql_thread_id; /*!< thd_get_thread_id() */
+ const char* trx_query; /*!< MySQL statement being
+ executed in the transaction */
+ const char* trx_operation_state; /*!< trx_struct::op_info */
+ ulint trx_tables_in_use;/*!< n_mysql_tables_in_use in
+ trx_struct */
+ ulint trx_tables_locked;
+ /*!< mysql_n_tables_locked in
+ trx_struct */
+ ulint trx_lock_structs;/*!< list len of trx_locks in
+ trx_struct */
+ ulint trx_lock_memory_bytes;
+ /*!< mem_heap_get_size(
+ trx->lock_heap) */
+ ulint trx_rows_locked;/*!< lock_number_of_rows_locked() */
+ ullint trx_rows_modified;/*!< trx_struct::undo_no */
+ ulint trx_concurrency_tickets;
+ /*!< n_tickets_to_enter_innodb in
+ trx_struct */
+ const char* trx_isolation_level;
+ /*!< isolation_level in trx_struct*/
+ ibool trx_unique_checks;
+ /*!< check_unique_secondary in
+ trx_struct*/
+ ibool trx_foreign_key_checks;
+ /*!< check_foreigns in trx_struct */
+ const char* trx_foreign_key_error;
+ /*!< detailed_error in trx_struct */
+ ibool trx_has_search_latch;
+ /*!< has_search_latch in trx_struct */
+ ulint trx_search_latch_timeout;
+ /*!< search_latch_timeout in
+ trx_struct */
};
/** This structure represents INFORMATION_SCHEMA.innodb_lock_waits row */
diff --git a/storage/innobase/lock/lock0lock.c b/storage/innobase/lock/lock0lock.c
index 04e5fe1a65a..8f29948dec7 100644
--- a/storage/innobase/lock/lock0lock.c
+++ b/storage/innobase/lock/lock0lock.c
@@ -1624,7 +1624,7 @@ UNIV_INTERN
ulint
lock_number_of_rows_locked(
/*=======================*/
- trx_t* trx) /*!< in: transaction */
+ const trx_t* trx) /*!< in: transaction */
{
lock_t* lock;
ulint n_records = 0;
diff --git a/storage/innobase/trx/trx0i_s.c b/storage/innobase/trx/trx0i_s.c
index ba8f998affd..937ce1b31f2 100644
--- a/storage/innobase/trx/trx0i_s.c
+++ b/storage/innobase/trx/trx0i_s.c
@@ -427,7 +427,7 @@ fill_trx_row(
/*=========*/
i_s_trx_row_t* row, /*!< out: result object
that's filled */
- const trx_t* trx, /*!< in: transaction to
+ const trx_t* trx, /*!< in: transaction to
get data from */
const i_s_locks_row_t* requested_lock_row,/*!< in: pointer to the
corresponding row in
@@ -470,35 +470,86 @@ fill_trx_row(
if (trx->mysql_query_str != NULL && *trx->mysql_query_str != NULL) {
- if (strlen(*trx->mysql_query_str)
- > TRX_I_S_TRX_QUERY_MAX_LEN) {
+ TRX_I_S_STRING_COPY(*trx->mysql_query_str, row->trx_query,
+ TRX_I_S_TRX_QUERY_MAX_LEN, cache);
- char query[TRX_I_S_TRX_QUERY_MAX_LEN + 1];
+ if (row->trx_query == NULL) {
- memcpy(query, *trx->mysql_query_str,
- TRX_I_S_TRX_QUERY_MAX_LEN);
- query[TRX_I_S_TRX_QUERY_MAX_LEN] = '\0';
+ return(FALSE);
+ }
+ } else {
- row->trx_query = ha_storage_put_memlim(
- cache->storage, query,
- TRX_I_S_TRX_QUERY_MAX_LEN + 1,
- MAX_ALLOWED_FOR_STORAGE(cache));
- } else {
+ row->trx_query = NULL;
+ }
- row->trx_query = ha_storage_put_str_memlim(
- cache->storage, *trx->mysql_query_str,
- MAX_ALLOWED_FOR_STORAGE(cache));
- }
+ if (trx->op_info != NULL && trx->op_info[0] != '\0') {
- if (row->trx_query == NULL) {
+ TRX_I_S_STRING_COPY(trx->op_info, row->trx_operation_state,
+ TRX_I_S_TRX_OP_STATE_MAX_LEN, cache);
+
+ if (row->trx_operation_state == NULL) {
return(FALSE);
}
} else {
- row->trx_query = NULL;
+ row->trx_operation_state = NULL;
}
+ row->trx_tables_in_use = trx->n_mysql_tables_in_use;
+
+ row->trx_tables_locked = trx->mysql_n_tables_locked;
+
+ row->trx_lock_structs = UT_LIST_GET_LEN(trx->trx_locks);
+
+ row->trx_lock_memory_bytes = mem_heap_get_size(trx->lock_heap);
+
+ row->trx_rows_locked = lock_number_of_rows_locked(trx);
+
+ row->trx_rows_modified = ut_conv_dulint_to_longlong(trx->undo_no);
+
+ row->trx_concurrency_tickets = trx->n_tickets_to_enter_innodb;
+
+ switch (trx->isolation_level) {
+ case TRX_ISO_READ_UNCOMMITTED:
+ row->trx_isolation_level = "READ UNCOMMITTED";
+ break;
+ case TRX_ISO_READ_COMMITTED:
+ row->trx_isolation_level = "READ COMMITTED";
+ break;
+ case TRX_ISO_REPEATABLE_READ:
+ row->trx_isolation_level = "REPEATABLE READ";
+ break;
+ case TRX_ISO_SERIALIZABLE:
+ row->trx_isolation_level = "SERIALIZABLE";
+ break;
+ /* Should not happen as TRX_ISO_READ_COMMITTED is default */
+ default:
+ row->trx_isolation_level = "UNKNOWN";
+ }
+
+ row->trx_unique_checks = (ibool) trx->check_unique_secondary;
+
+ row->trx_foreign_key_checks = (ibool) trx->check_foreigns;
+
+ if (trx->detailed_error != NULL && trx->detailed_error[0] != '\0') {
+
+ TRX_I_S_STRING_COPY(trx->detailed_error,
+ row->trx_foreign_key_error,
+ TRX_I_S_TRX_FK_ERROR_MAX_LEN, cache);
+
+ if (row->trx_foreign_key_error == NULL) {
+
+ return(FALSE);
+ }
+ } else {
+ row->trx_foreign_key_error = NULL;
+ }
+
+ row->trx_has_search_latch = (ibool) trx->has_search_latch;
+
+ row->trx_search_latch_timeout = trx->search_latch_timeout;
+
return(TRUE);
}