80
74
FILE* file); /* in: file to read message from */
81
75
/********************************************************************
82
76
Retrieves the error_info field from a trx. */
85
79
trx_get_error_info(
86
80
/*===============*/
87
/* out: the error info */
88
const trx_t* trx); /* in: trx object */
81
/* out: the error info */
82
trx_t* trx); /* in: trx object */
89
83
/********************************************************************
90
84
Creates and initializes a transaction object. */
95
89
/* out, own: the transaction */
96
sess_t* sess) /* in: session */
97
__attribute__((nonnull));
90
sess_t* sess); /* in: session or NULL */
98
91
/************************************************************************
99
92
Creates a transaction object for MySQL. */
102
95
trx_allocate_for_mysql(void);
103
96
/*========================*/
104
97
/* out, own: transaction object */
105
98
/************************************************************************
106
99
Creates a transaction object for background operations by the master thread. */
109
102
trx_allocate_for_background(void);
110
103
/*=============================*/
111
104
/* out, own: transaction object */
112
105
/************************************************************************
113
106
Frees a transaction object. */
118
111
trx_t* trx); /* in, own: trx object */
119
112
/************************************************************************
120
113
Frees a transaction object for MySQL. */
123
116
trx_free_for_mysql(
124
117
/*===============*/
125
118
trx_t* trx); /* in, own: trx object */
126
119
/************************************************************************
127
120
Frees a transaction object of a background operation of the master thread. */
130
123
trx_free_for_background(
131
124
/*====================*/
359
358
ulint max_query_len); /* in: max query length to print, or 0 to
360
359
use the default max length */
362
/** Type of data dictionary operation */
364
/** The transaction is not modifying the data dictionary. */
365
TRX_DICT_OP_NONE = 0,
366
/** The transaction is creating a table or an index, or
367
dropping a table. The table must be dropped in crash
368
recovery. This and TRX_DICT_OP_NONE are the only possible
369
operation modes in crash recovery. */
370
TRX_DICT_OP_TABLE = 1,
371
/** The transaction is creating or dropping an index in an
372
existing table. In crash recovery, the the data dictionary
373
must be locked, but the table must not be dropped. */
374
TRX_DICT_OP_INDEX = 2
377
/**************************************************************************
378
Determine if a transaction is a dictionary operation. */
381
trx_get_dict_operation(
382
/*===================*/
383
/* out: dictionary operation mode */
384
const trx_t* trx) /* in: transaction */
385
__attribute__((pure));
386
/**************************************************************************
387
Flag a transaction a dictionary operation. */
390
trx_set_dict_operation(
391
/*===================*/
392
trx_t* trx, /* in/out: transaction */
393
enum trx_dict_op op); /* in: operation, not
396
361
#ifndef UNIV_HOTBACKUP
397
362
/**************************************************************************
398
363
Determines if the currently running transaction has been interrupted. */
401
366
trx_is_interrupted(
402
367
/*===============*/
407
372
#endif /* !UNIV_HOTBACKUP */
409
374
/***********************************************************************
410
Calculates the "weight" of a transaction. The weight of one transaction
411
is estimated as the number of altered rows + the number of locked rows.
414
#define TRX_WEIGHT(t) \
415
ut_dulint_add((t)->undo_no, UT_LIST_GET_LEN((t)->trx_locks))
417
/***********************************************************************
418
Compares the "weight" (or size) of two transactions. Transactions that
419
have edited non-transactional tables are considered heavier than ones
375
Compares the "weight" (or size) of two transactions. The weight of one
376
transaction is estimated as the number of altered rows + the number of
377
locked rows. Transactions that have edited non-transactional tables are
378
considered heavier than ones that have not. */
425
/* out: <0, 0 or >0; similar to strcmp(3) */
426
const trx_t* a, /* in: the first transaction to be compared */
427
const trx_t* b); /* in: the second transaction to be compared */
429
/***********************************************************************
430
Retrieves transacion's id, represented as unsigned long long. */
435
/* out: transaction's id */
436
const trx_t* trx); /* in: transaction */
438
/* Maximum length of a string that can be returned by
439
trx_get_que_state_str(). */
440
#define TRX_QUE_STATE_STR_MAX_LEN 12 /* "ROLLING BACK" */
442
/***********************************************************************
443
Retrieves transaction's que state in a human readable string. The string
444
should not be free()'d or modified. */
447
trx_get_que_state_str(
448
/*==================*/
449
/* out: string in the data segment */
450
const trx_t* trx); /* in: transaction */
383
/* out: <0, 0 or >0; similar to strcmp(3) */
384
trx_t* a, /* in: the first transaction to be compared */
385
trx_t* b); /* in: the second transaction to be compared */
452
387
/* Signal to a transaction */
453
388
struct trx_sig_struct{
454
unsigned type:3; /* signal type */
455
unsigned sender:1; /* TRX_SIG_SELF or
389
ulint type; /* signal type */
390
ulint sender; /* TRX_SIG_SELF or
456
391
TRX_SIG_OTHER_SESS */
457
392
que_thr_t* receiver; /* non-NULL if the sender of the signal
458
393
wants reply after the operation induced
480
415
current operation, or an empty
482
417
unsigned is_purge:1; /* 0=user transaction, 1=purge */
483
unsigned is_recovered:1; /* 0=normal transaction,
484
1=recovered, must be rolled back */
485
unsigned conc_state:2; /* state of the trx from the point
418
ulint conc_state; /* state of the trx from the point
486
419
of view of concurrency control:
487
420
TRX_ACTIVE, TRX_COMMITTED_IN_MEMORY,
489
unsigned que_state:2; /* valid when conc_state == TRX_ACTIVE:
490
TRX_QUE_RUNNING, TRX_QUE_LOCK_WAIT,
492
unsigned isolation_level:2;/* TRX_ISO_REPEATABLE_READ, ... */
493
unsigned check_foreigns:1;/* normally TRUE, but if the user
422
time_t start_time; /* time the trx object was created
423
or the state last time became
425
ulint isolation_level;/* TRX_ISO_REPEATABLE_READ, ... */
426
ibool check_foreigns; /* normally TRUE, but if the user
494
427
wants to suppress foreign key checks,
495
428
(in table imports, for example) we
496
429
set this FALSE */
497
unsigned check_unique_secondary:1;
430
ibool check_unique_secondary;
498
431
/* normally TRUE, but if the user
499
432
wants to speed up inserts by
500
433
suppressing unique key checks
501
434
for secondary indexes when we decide
502
435
if we can use the insert buffer for
503
436
them, we set this FALSE */
504
unsigned support_xa:1; /* normally we do the XA two-phase
437
dulint id; /* transaction id */
438
XID xid; /* X/Open XA transaction
439
identification to identify a
440
transaction branch */
441
ibool support_xa; /* normally we do the XA two-phase
505
442
commit steps, but by setting this to
506
443
FALSE, one can save CPU time and about
507
444
150 bytes in the undo log size as then
508
445
we skip XA steps */
509
unsigned flush_log_later:1;/* when we commit the transaction
446
dulint no; /* transaction serialization number ==
447
max trx id when the transaction is
448
moved to COMMITTED_IN_MEMORY state */
449
ibool flush_log_later;/* when we commit the transaction
510
450
in MySQL's binlog write, we will
511
451
flush the log to disk later in
512
452
a separate call */
513
unsigned must_flush_log_later:1;/* this flag is set to TRUE in
453
ibool must_flush_log_later;/* this flag is set to TRUE in
514
454
trx_commit_off_kernel() if
515
455
flush_log_later was TRUE, and there
516
456
were modifications by the transaction;
517
457
in that case we must flush the log
518
458
in trx_commit_complete_for_mysql() */
519
unsigned dict_operation:2;/**< @see enum trx_dict_op */
459
dulint commit_lsn; /* lsn at the time of the commit */
460
ibool dict_operation; /* TRUE if the trx is used to create
461
a table, create an index, or drop a
462
table. This is a hint that the table
463
may need to be dropped in crash
465
dulint table_id; /* table id if the preceding field is
467
/*------------------------------*/
520
468
unsigned duplicates:2; /* TRX_DUP_IGNORE | TRX_DUP_REPLACE */
521
469
unsigned active_trans:2; /* 1 - if a transaction in MySQL
522
470
is active. 2 - if prepare_commit_mutex
524
unsigned has_search_latch:1;
525
/* TRUE if this trx has latched the
526
search system latch in S-mode */
527
unsigned declared_to_be_inside_innodb:1;
528
/* this is TRUE if we have declared
530
srv_conc_enter_innodb to be inside the
532
unsigned handling_signals:1;/* this is TRUE as long as the trx
533
is handling signals */
534
unsigned dict_operation_lock_mode:2;
535
/* 0, RW_S_LATCH, or RW_X_LATCH:
536
the latch mode trx currently holds
537
on dict_operation_lock */
538
time_t start_time; /* time the trx object was created
539
or the state last time became
541
dulint id; /* transaction id */
542
XID xid; /* X/Open XA transaction
543
identification to identify a
544
transaction branch */
545
dulint no; /* transaction serialization number ==
546
max trx id when the transaction is
547
moved to COMMITTED_IN_MEMORY state */
548
ib_uint64_t commit_lsn; /* lsn at the time of the commit */
549
dulint table_id; /* Table to drop iff dict_operation
550
is TRUE, or ut_dulint_zero. */
551
/*------------------------------*/
552
472
void* mysql_thd; /* MySQL thread handle corresponding
553
473
to this trx, or NULL */
554
474
char** mysql_query_str;/* pointer to the field in mysqld_thd
620
552
doing the transaction is allowed to
621
553
set this field: this is NOT protected
622
554
by the kernel mutex */
623
const dict_index_t*error_info; /* if the error number indicates a
555
void* error_info; /* if the error number indicates a
624
556
duplicate key error, a pointer to
625
557
the problematic index is stored here */
626
ulint error_key_num; /* if the index creation fails to a
627
duplicate key error, a mysql key
628
number of that index is stored here */
629
558
sess_t* sess; /* session of the trx, NULL if none */
559
ulint que_state; /* TRX_QUE_RUNNING, TRX_QUE_LOCK_WAIT,
630
561
que_t* graph; /* query currently run in the session,
631
562
or NULL if none; NOTE that the query
632
563
belongs to the session, and it can
740
670
transaction, e.g., a parallel
742
672
/* Transaction concurrency states (trx->conc_state) */
743
#define TRX_NOT_STARTED 0
745
#define TRX_COMMITTED_IN_MEMORY 2
746
#define TRX_PREPARED 3 /* Support for 2PC/XA */
673
#define TRX_NOT_STARTED 1
675
#define TRX_COMMITTED_IN_MEMORY 3
676
#define TRX_PREPARED 4 /* Support for 2PC/XA */
748
678
/* Transaction execution states when trx->conc_state == TRX_ACTIVE */
749
#define TRX_QUE_RUNNING 0 /* transaction is running */
750
#define TRX_QUE_LOCK_WAIT 1 /* transaction is waiting for a lock */
751
#define TRX_QUE_ROLLING_BACK 2 /* transaction is rolling back */
752
#define TRX_QUE_COMMITTING 3 /* transaction is committing */
679
#define TRX_QUE_RUNNING 1 /* transaction is running */
680
#define TRX_QUE_LOCK_WAIT 2 /* transaction is waiting for a lock */
681
#define TRX_QUE_ROLLING_BACK 3 /* transaction is rolling back */
682
#define TRX_QUE_COMMITTING 4 /* transaction is committing */
754
684
/* Transaction isolation levels (trx->isolation_level) */
755
#define TRX_ISO_READ_UNCOMMITTED 0 /* dirty read: non-locking
685
#define TRX_ISO_READ_UNCOMMITTED 1 /* dirty read: non-locking
756
686
SELECTs are performed so that
757
687
we do not look at a possible
758
688
earlier version of a record;