418
402
is estimated as the number of altered rows + the number of locked rows.
419
403
@param t transaction
420
404
@return transaction weight */
421
#define TRX_WEIGHT(t) ((t)->undo_no + UT_LIST_GET_LEN((t)->trx_locks))
405
#define TRX_WEIGHT(t) \
406
ut_dulint_add((t)->undo_no, UT_LIST_GET_LEN((t)->trx_locks))
423
408
/*******************************************************************//**
424
409
Compares the "weight" (or size) of two transactions. Transactions that
425
410
have edited non-transactional tables are considered heavier than ones
427
@return TRUE if weight(a) >= weight(b) */
412
@return <0, 0 or >0; similar to strcmp(3) */
432
417
const trx_t* a, /*!< in: the first transaction to be compared */
433
418
const trx_t* b); /*!< in: the second transaction to be compared */
420
/*******************************************************************//**
421
Retrieves transacion's id, represented as unsigned long long.
422
@return transaction's id */
427
const trx_t* trx); /*!< in: transaction */
435
429
/* Maximum length of a string that can be returned by
436
430
trx_get_que_state_str(). */
437
431
#define TRX_QUE_STATE_STR_MAX_LEN 12 /* "ROLLING BACK" */
472
466
struct trx_struct{
475
/* These fields are not protected by any mutex. */
468
/* All the next fields are protected by the kernel mutex, except the
469
undo logs which are protected by undo_mutex */
476
470
const char* op_info; /*!< English text describing the
477
471
current operation, or an empty
479
ulint conc_state; /*!< state of the trx from the point
473
unsigned is_purge:1; /*!< 0=user transaction, 1=purge */
474
unsigned is_recovered:1; /*!< 0=normal transaction,
475
1=recovered, must be rolled back */
476
unsigned conc_state:2; /*!< state of the trx from the point
480
477
of view of concurrency control:
481
478
TRX_ACTIVE, TRX_COMMITTED_IN_MEMORY,
483
ulint isolation_level;/* TRX_ISO_REPEATABLE_READ, ... */
484
ulint check_foreigns; /* normally TRUE, but if the user
480
unsigned que_state:2; /*!< valid when conc_state == TRX_ACTIVE:
481
TRX_QUE_RUNNING, TRX_QUE_LOCK_WAIT,
483
unsigned isolation_level:2;/* TRX_ISO_REPEATABLE_READ, ... */
484
unsigned check_foreigns:1;/* normally TRUE, but if the user
485
485
wants to suppress foreign key checks,
486
486
(in table imports, for example) we
487
487
set this FALSE */
488
unsigned check_unique_secondary;
488
unsigned check_unique_secondary:1;
489
489
/* normally TRUE, but if the user
490
490
wants to speed up inserts by
491
491
suppressing unique key checks
492
492
for secondary indexes when we decide
493
493
if we can use the insert buffer for
494
494
them, we set this FALSE */
495
unsigned support_xa; /*!< normally we do the XA two-phase
495
unsigned support_xa:1; /*!< normally we do the XA two-phase
496
496
commit steps, but by setting this to
497
497
FALSE, one can save CPU time and about
498
498
150 bytes in the undo log size as then
499
499
we skip XA steps */
500
unsigned flush_log_later;/* In 2PC, we hold the
500
unsigned flush_log_later:1;/* In 2PC, we hold the
501
501
prepare_commit mutex across
502
502
both phases. In that case, we
503
503
defer flush of the logs to disk
504
504
until after we release the
506
unsigned must_flush_log_later;/* this flag is set to TRUE in
506
unsigned must_flush_log_later:1;/* this flag is set to TRUE in
507
507
trx_commit_off_kernel() if
508
508
flush_log_later was TRUE, and there
509
509
were modifications by the transaction;
510
510
in that case we must flush the log
511
511
in trx_commit_complete_for_mysql() */
512
ulint duplicates; /*!< TRX_DUP_IGNORE | TRX_DUP_REPLACE */
513
unsigned has_search_latch;
512
unsigned dict_operation:2;/**< @see enum trx_dict_op */
513
unsigned duplicates:2; /*!< TRX_DUP_IGNORE | TRX_DUP_REPLACE */
514
unsigned has_search_latch:1;
514
515
/* TRUE if this trx has latched the
515
516
search system latch in S-mode */
516
ulint deadlock_mark; /*!< a mark field used in deadlock
517
checking algorithm. */
518
trx_dict_op_t dict_operation; /**< @see enum trx_dict_op */
520
/* Fields protected by the srv_conc_mutex. */
521
ulint declared_to_be_inside_innodb;
517
unsigned declared_to_be_inside_innodb:1;
522
518
/* this is TRUE if we have declared
523
519
this transaction in
524
520
srv_conc_enter_innodb to be inside the
527
/* Fields protected by dict_operation_lock. The very latch
528
it is used to track. */
529
ulint dict_operation_lock_mode;
530
/*!< 0, RW_S_LATCH, or RW_X_LATCH:
522
unsigned handling_signals:1;/* this is TRUE as long as the trx
523
is handling signals */
524
unsigned dict_operation_lock_mode:2;
525
/* 0, RW_S_LATCH, or RW_X_LATCH:
531
526
the latch mode trx currently holds
532
527
on dict_operation_lock */
534
/* All the next fields are protected by the kernel mutex, except the
535
undo logs which are protected by undo_mutex */
536
ulint is_purge; /*!< 0=user transaction, 1=purge */
537
ulint is_recovered; /*!< 0=normal transaction,
538
1=recovered, must be rolled back */
539
ulint que_state; /*!< valid when conc_state
540
== TRX_ACTIVE: TRX_QUE_RUNNING,
541
TRX_QUE_LOCK_WAIT, ... */
542
ulint handling_signals;/* this is TRUE as long as the trx
543
is handling signals */
544
528
time_t start_time; /*!< time the trx object was created
545
529
or the state last time became
552
536
max trx id when the transaction is
553
537
moved to COMMITTED_IN_MEMORY state */
554
538
ib_uint64_t commit_lsn; /*!< lsn at the time of the commit */
555
table_id_t table_id; /*!< Table to drop iff dict_operation
539
trx_id_t table_id; /*!< Table to drop iff dict_operation
540
is TRUE, or ut_dulint_zero. */
557
541
/*------------------------------*/
558
drizzled::Session *mysql_thd; /*!< MySQL thread handle corresponding
542
void* mysql_thd; /*!< MySQL thread handle corresponding
559
543
to this trx, or NULL */
544
const char* mysql_query_str;/* pointer to the field in mysqld_thd
545
which contains the pointer to the
546
current SQL query string */
560
547
const char* mysql_log_file_name;
561
548
/* if MySQL binlog is used, this field
562
549
contains a pointer to the latest file