196
196
code in handler/i_s.cc. */
197
197
UNIV_INTERN trx_i_s_cache_t* trx_i_s_cache = &trx_i_s_cache_static;
199
/* Key to register the lock/mutex with performance schema */
200
#ifdef UNIV_PFS_RWLOCK
201
UNIV_INTERN mysql_pfs_key_t trx_i_s_cache_lock_key;
202
#endif /* UNIV_PFS_RWLOCK */
204
#ifdef UNIV_PFS_MUTEX
205
UNIV_INTERN mysql_pfs_key_t cache_last_read_mutex_key;
206
#endif /* UNIV_PFS_MUTEX */
199
208
/*******************************************************************//**
200
209
For a record lock that is in waiting state retrieves the only bit that
201
210
is set, for a table lock returns ULINT_UNDEFINED.
456
462
row->trx_weight = (ullint) ut_conv_dulint_to_longlong(TRX_WEIGHT(trx));
458
if (trx->mysql_thd == NULL) {
464
if (trx->mysql_thd != NULL) {
465
row->trx_mysql_thread_id
466
= session_get_thread_id(trx->mysql_thd);
459
468
/* For internal transactions e.g., purge and transactions
460
469
being recovered at startup there is no associated MySQL
461
470
thread data structure. */
462
471
row->trx_mysql_thread_id = 0;
463
row->trx_query = NULL;
467
row->trx_mysql_thread_id = session_get_thread_id(trx->mysql_thd);
468
stmt = innobase_get_stmt(trx->mysql_thd, &stmt_len);
472
char query[TRX_I_S_TRX_QUERY_MAX_LEN + 1];
474
if (stmt_len > TRX_I_S_TRX_QUERY_MAX_LEN) {
475
stmt_len = TRX_I_S_TRX_QUERY_MAX_LEN;
474
if (trx->mysql_query_str != NULL && *trx->mysql_query_str != NULL) {
475
if (strlen(*trx->mysql_query_str)
476
> TRX_I_S_TRX_QUERY_MAX_LEN) {
478
char query[TRX_I_S_TRX_QUERY_MAX_LEN + 1];
480
memcpy(query, *trx->mysql_query_str,
481
TRX_I_S_TRX_QUERY_MAX_LEN);
482
query[TRX_I_S_TRX_QUERY_MAX_LEN] = '\0';
484
row->trx_query = ha_storage_put_memlim(
485
cache->storage, query,
486
TRX_I_S_TRX_QUERY_MAX_LEN + 1,
487
MAX_ALLOWED_FOR_STORAGE(cache));
489
row->trx_query = ha_storage_put_str_memlim(
490
cache->storage, *trx->mysql_query_str,
491
MAX_ALLOWED_FOR_STORAGE(cache));
478
memcpy(query, stmt, stmt_len);
479
query[stmt_len] = '\0';
481
row->trx_query = ha_storage_put_memlim(
482
cache->storage, stmt, stmt_len + 1,
483
MAX_ALLOWED_FOR_STORAGE(cache));
485
494
if (row->trx_query == NULL) {
1254
1263
release trx_i_s_cache_t::last_read_mutex
1255
1264
release trx_i_s_cache_t::rw_lock */
1257
rw_lock_create(&cache->rw_lock, SYNC_TRX_I_S_RWLOCK);
1266
rw_lock_create(trx_i_s_cache_lock_key, &cache->rw_lock,
1267
SYNC_TRX_I_S_RWLOCK);
1259
1269
cache->last_read = 0;
1261
mutex_create(&cache->last_read_mutex, SYNC_TRX_I_S_LAST_READ);
1271
mutex_create(cache_last_read_mutex_key,
1272
&cache->last_read_mutex, SYNC_TRX_I_S_LAST_READ);
1263
1274
table_cache_init(&cache->innodb_trx, sizeof(i_s_trx_row_t));
1264
1275
table_cache_init(&cache->innodb_locks, sizeof(i_s_locks_row_t));