~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/trx/trx0i_s.c

Merge initial InnoDB+ import.

This was applied by generating a patch between MySQL 5.1.50 InnoDB plugin and
the just-merged innodb+ from mysql-trunk revision-id: vasil.dimov@oracle.com-20100422110752-1zowoqxel5xx3z2e

Then, some manual merge resolving and it worked. This should make it much
easier to merge the rest of InnoDB 1.1 and 1.2 from the mysql tree using
my bzr-reapply script.

This takes us to InnoDB 1.1.1(ish).

Show diffs side-by-side

added added

removed removed

Lines of Context:
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;
198
198
 
 
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 */
 
203
 
 
204
#ifdef UNIV_PFS_MUTEX
 
205
UNIV_INTERN mysql_pfs_key_t     cache_last_read_mutex_key;
 
206
#endif /* UNIV_PFS_MUTEX */
 
207
 
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.
432
441
                                                which to copy volatile
433
442
                                                strings */
434
443
{
435
 
        const char*     stmt;
436
 
        size_t          stmt_len;
437
 
 
438
444
        row->trx_id = trx_get_id(trx);
439
445
        row->trx_started = (ib_time_t) trx->start_time;
440
446
        row->trx_state = trx_get_que_state_str(trx);
455
461
 
456
462
        row->trx_weight = (ullint) ut_conv_dulint_to_longlong(TRX_WEIGHT(trx));
457
463
 
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);
 
467
        } else {
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;
464
 
                return(TRUE);
465
472
        }
466
473
 
467
 
        row->trx_mysql_thread_id = session_get_thread_id(trx->mysql_thd);
468
 
        stmt = innobase_get_stmt(trx->mysql_thd, &stmt_len);
469
 
 
470
 
        if (stmt != NULL) {
471
 
 
472
 
                char    query[TRX_I_S_TRX_QUERY_MAX_LEN + 1];
473
 
 
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) {
 
477
 
 
478
                        char    query[TRX_I_S_TRX_QUERY_MAX_LEN + 1];
 
479
 
 
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';
 
483
 
 
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));
 
488
                } else {
 
489
                        row->trx_query = ha_storage_put_str_memlim(
 
490
                                cache->storage, *trx->mysql_query_str,
 
491
                                MAX_ALLOWED_FOR_STORAGE(cache));
476
492
                }
477
493
 
478
 
                memcpy(query, stmt, stmt_len);
479
 
                query[stmt_len] = '\0';
480
 
 
481
 
                row->trx_query = ha_storage_put_memlim(
482
 
                        cache->storage, stmt, stmt_len + 1,
483
 
                        MAX_ALLOWED_FOR_STORAGE(cache));
484
 
 
485
494
                if (row->trx_query == NULL) {
486
495
 
487
496
                        return(FALSE);
1254
1263
        release trx_i_s_cache_t::last_read_mutex
1255
1264
        release trx_i_s_cache_t::rw_lock */
1256
1265
 
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);
1258
1268
 
1259
1269
        cache->last_read = 0;
1260
1270
 
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);
1262
1273
 
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));