Commit d4db2cf5 authored by vasil's avatar vasil

branches/zip:

Add the transaction's weight to information_schema.innodb_trx table.

Suggested by:	Ken
Approved by:	Heikki
parent 2bf6fc8f
...@@ -197,7 +197,16 @@ static ST_FIELD_INFO innodb_trx_fields_info[] = ...@@ -197,7 +197,16 @@ static ST_FIELD_INFO innodb_trx_fields_info[] =
STRUCT_FLD(old_name, ""), STRUCT_FLD(old_name, ""),
STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
#define IDX_TRX_STATE 1 #define IDX_TRX_WEIGHT 1
{STRUCT_FLD(field_name, "trx_weight"),
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_STATE 2
{STRUCT_FLD(field_name, "trx_state"), {STRUCT_FLD(field_name, "trx_state"),
STRUCT_FLD(field_length, TRX_QUE_STATE_STR_MAX_LEN + 1), STRUCT_FLD(field_length, TRX_QUE_STATE_STR_MAX_LEN + 1),
STRUCT_FLD(field_type, MYSQL_TYPE_STRING), STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
...@@ -206,7 +215,7 @@ static ST_FIELD_INFO innodb_trx_fields_info[] = ...@@ -206,7 +215,7 @@ static ST_FIELD_INFO innodb_trx_fields_info[] =
STRUCT_FLD(old_name, ""), STRUCT_FLD(old_name, ""),
STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
#define IDX_TRX_STARTED 2 #define IDX_TRX_STARTED 3
{STRUCT_FLD(field_name, "trx_started"), {STRUCT_FLD(field_name, "trx_started"),
STRUCT_FLD(field_length, 0), STRUCT_FLD(field_length, 0),
STRUCT_FLD(field_type, MYSQL_TYPE_DATETIME), STRUCT_FLD(field_type, MYSQL_TYPE_DATETIME),
...@@ -215,7 +224,7 @@ static ST_FIELD_INFO innodb_trx_fields_info[] = ...@@ -215,7 +224,7 @@ static ST_FIELD_INFO innodb_trx_fields_info[] =
STRUCT_FLD(old_name, ""), STRUCT_FLD(old_name, ""),
STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
#define IDX_TRX_WAIT_LOCK_ID 3 #define IDX_TRX_WAIT_LOCK_ID 4
{STRUCT_FLD(field_name, "trx_wait_lock_id"), {STRUCT_FLD(field_name, "trx_wait_lock_id"),
STRUCT_FLD(field_length, TRX_I_S_LOCK_ID_MAX_LEN), STRUCT_FLD(field_length, TRX_I_S_LOCK_ID_MAX_LEN),
STRUCT_FLD(field_type, MYSQL_TYPE_STRING), STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
...@@ -224,7 +233,7 @@ static ST_FIELD_INFO innodb_trx_fields_info[] = ...@@ -224,7 +233,7 @@ static ST_FIELD_INFO innodb_trx_fields_info[] =
STRUCT_FLD(old_name, ""), STRUCT_FLD(old_name, ""),
STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
#define IDX_TRX_WAIT_STARTED 4 #define IDX_TRX_WAIT_STARTED 5
{STRUCT_FLD(field_name, "trx_wait_started"), {STRUCT_FLD(field_name, "trx_wait_started"),
STRUCT_FLD(field_length, 0), STRUCT_FLD(field_length, 0),
STRUCT_FLD(field_type, MYSQL_TYPE_DATETIME), STRUCT_FLD(field_type, MYSQL_TYPE_DATETIME),
...@@ -233,7 +242,7 @@ static ST_FIELD_INFO innodb_trx_fields_info[] = ...@@ -233,7 +242,7 @@ static ST_FIELD_INFO innodb_trx_fields_info[] =
STRUCT_FLD(old_name, ""), STRUCT_FLD(old_name, ""),
STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
#define IDX_TRX_MYSQL_THREAD_ID 5 #define IDX_TRX_MYSQL_THREAD_ID 6
{STRUCT_FLD(field_name, "trx_mysql_thread_id"), {STRUCT_FLD(field_name, "trx_mysql_thread_id"),
STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
...@@ -242,7 +251,7 @@ static ST_FIELD_INFO innodb_trx_fields_info[] = ...@@ -242,7 +251,7 @@ static ST_FIELD_INFO innodb_trx_fields_info[] =
STRUCT_FLD(old_name, ""), STRUCT_FLD(old_name, ""),
STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
#define IDX_TRX_QUERY 6 #define IDX_TRX_QUERY 7
{STRUCT_FLD(field_name, "trx_query"), {STRUCT_FLD(field_name, "trx_query"),
STRUCT_FLD(field_length, TRX_I_S_TRX_QUERY_MAX_LEN), STRUCT_FLD(field_length, TRX_I_S_TRX_QUERY_MAX_LEN),
STRUCT_FLD(field_type, MYSQL_TYPE_STRING), STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
...@@ -290,6 +299,9 @@ fill_innodb_trx_from_cache( ...@@ -290,6 +299,9 @@ fill_innodb_trx_from_cache(
/* trx_id */ /* trx_id */
OK(fields[IDX_TRX_ID]->store(row->trx_id)); OK(fields[IDX_TRX_ID]->store(row->trx_id));
/* trx_weight */
OK(fields[IDX_TRX_WEIGHT]->store(row->trx_weight));
/* trx_state */ /* trx_state */
OK(field_store_string(fields[IDX_TRX_STATE], OK(field_store_string(fields[IDX_TRX_STATE],
row->trx_state)); row->trx_state));
......
...@@ -58,6 +58,7 @@ struct i_s_locks_row_struct { ...@@ -58,6 +58,7 @@ struct i_s_locks_row_struct {
/* This structure represents INFORMATION_SCHEMA.innodb_trx row */ /* This structure represents INFORMATION_SCHEMA.innodb_trx row */
typedef struct i_s_trx_row_struct { typedef struct i_s_trx_row_struct {
ullint trx_id; ullint trx_id;
ullint trx_weight;
const char* trx_state; const char* trx_state;
ib_time_t trx_started; ib_time_t trx_started;
const i_s_locks_row_t* wait_lock_row; const i_s_locks_row_t* wait_lock_row;
......
...@@ -410,10 +410,17 @@ trx_is_interrupted( ...@@ -410,10 +410,17 @@ trx_is_interrupted(
#endif /* !UNIV_HOTBACKUP */ #endif /* !UNIV_HOTBACKUP */
/*********************************************************************** /***********************************************************************
Compares the "weight" (or size) of two transactions. The weight of one Calculates the "weight" of a transaction. The weight of one transaction
transaction is estimated as the number of altered rows + the number of is estimated as the number of altered rows + the number of locked rows.
locked rows. Transactions that have edited non-transactional tables are */
considered heavier than ones that have not. */
#define TRX_WEIGHT(t) \
ut_dulint_add((t)->undo_no, UT_LIST_GET_LEN((t)->trx_locks))
/***********************************************************************
Compares the "weight" (or size) of two transactions. Transactions that
have edited non-transactional tables are considered heavier than ones
that have not. */
int int
trx_weight_cmp( trx_weight_cmp(
......
...@@ -371,6 +371,7 @@ fill_trx_row( ...@@ -371,6 +371,7 @@ fill_trx_row(
strings */ strings */
{ {
row->trx_id = trx_get_id(trx); row->trx_id = trx_get_id(trx);
row->trx_weight = (ullint) ut_conv_dulint_to_longlong(TRX_WEIGHT(trx));
row->trx_started = (ib_time_t) trx->start_time; row->trx_started = (ib_time_t) trx->start_time;
row->trx_state = trx_get_que_state_str(trx); row->trx_state = trx_get_que_state_str(trx);
......
...@@ -1707,10 +1707,9 @@ trx_print( ...@@ -1707,10 +1707,9 @@ trx_print(
} }
/*********************************************************************** /***********************************************************************
Compares the "weight" (or size) of two transactions. The weight of one Compares the "weight" (or size) of two transactions. Transactions that
transaction is estimated as the number of altered rows + the number of have edited non-transactional tables are considered heavier than ones
locked rows. Transactions that have edited non-transactional tables are that have not. */
considered heavier than ones that have not. */
int int
trx_weight_cmp( trx_weight_cmp(
...@@ -1755,9 +1754,6 @@ trx_weight_cmp( ...@@ -1755,9 +1754,6 @@ trx_weight_cmp(
UT_LIST_GET_LEN(b->trx_locks)); UT_LIST_GET_LEN(b->trx_locks));
#endif #endif
#define TRX_WEIGHT(t) \
ut_dulint_add((t)->undo_no, UT_LIST_GET_LEN((t)->trx_locks))
return(ut_dulint_cmp(TRX_WEIGHT(a), TRX_WEIGHT(b))); return(ut_dulint_cmp(TRX_WEIGHT(a), TRX_WEIGHT(b)));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment