MySQL  8.0.12
Source Code Documentation
trx0trx.h File Reference

The transaction. More...

#include <list>
#include <set>
#include "ha_prototypes.h"
#include "dict0types.h"
#include "sql/handler.h"
#include "trx0types.h"
#include "ut0new.h"
#include "lock0types.h"
#include "log0log.h"
#include "mem0mem.h"
#include "que0types.h"
#include "trx0xa.h"
#include "usr0types.h"
#include "ut0vec.h"
#include "fts0fts.h"
#include "srv0srv.h"
#include "trx0trx.ic"

Go to the source code of this file.

Classes

struct  trx_lock_t
 Latching protocol for trx_lock_t::que_state. More...
 
struct  trx_undo_ptr_t
 The transaction handle. More...
 
struct  trx_rsegs_t
 Rollback segments assigned to a transaction for undo logging. More...
 
struct  TrxVersion
 
struct  trx_t
 
struct  commit_node_t
 Commit command node in a query graph. More...
 
class  TrxInInnoDB
 Track if a transaction is executing inside InnoDB code. More...
 

Macros

#define trx_start_if_not_started_xa(t, rw)
 
#define trx_start_if_not_started(t, rw)
 
#define trx_start_internal(t)
 
#define trx_start_internal_read_only(t)
 
#define TRX_WEIGHT(t)   ((t)->undo_no + UT_LIST_GET_LEN((t)->lock.trx_locks))
 Calculates the "weight" of a transaction. More...
 
#define TRX_QUE_STATE_STR_MAX_LEN   12 /* "ROLLING BACK" */
 
#define trx_is_referenced(t)   ((t)->n_ref > 0)
 Check if the transaction is being referenced. More...
 
#define trx_lock_wait_timeout_get(t)   ((t)->mysql_thd != NULL ? thd_lock_wait_timeout((t)->mysql_thd) : 0)
 Transactions that aren't started by the MySQL server don't set the trx_t::mysql_thd field. More...
 
#define trx_is_autocommit_non_locking(t)   ((t)->auto_commit && (t)->will_lock == 0)
 Determine if the transaction is a non-locking autocommit select (implied read-only). More...
 
#define trx_is_ac_nl_ro(t)   ((t)->read_only && trx_is_autocommit_non_locking((t)))
 Determine if the transaction is a non-locking autocommit select with an explicit check for the read-only status. More...
 
#define assert_trx_in_rw_list(t)
 Assert that the transaction is in the trx_sys_t::rw_trx_list. More...
 
#define check_trx_state(t)
 Check transaction state. More...
 
#define assert_trx_is_free(t)
 Check if transaction is free so that it can be re-initialized. More...
 
#define assert_trx_is_inactive(t)
 Check if transaction is in-active so that it can be freed and put back to transaction pool. More...
 
#define assert_trx_nonlocking_or_in_list(t)
 Assert that an autocommit non-locking select cannot be in the rw_trx_list and that it is a read-only transaction. More...
 
#define TRX_ISO_READ_UNCOMMITTED   trx_t::READ_UNCOMMITTED
 
#define TRX_ISO_READ_COMMITTED   trx_t::READ_COMMITTED
 
#define TRX_ISO_REPEATABLE_READ   trx_t::REPEATABLE_READ
 
#define TRX_ISO_SERIALIZABLE   trx_t::SERIALIZABLE
 
#define TRX_DUP_IGNORE   1 /* duplicate rows are to be updated */
 
#define TRX_DUP_REPLACE   2 /* duplicate rows are to be replaced */
 
#define trx_mutex_own(t)   mutex_own(&t->mutex)
 Test if trx->mutex is owned. More...
 
#define trx_mutex_enter(t)
 Acquire the trx->mutex. More...
 
#define trx_mutex_exit(t)
 Release the trx->mutex. More...
 

Typedefs

typedef std::vector< ib_lock_t *, ut_allocator< ib_lock_t * > > lock_pool_t
 
typedef std::set< dict_table_t *, std::less< dict_table_t * >, ut_allocator< dict_table_t * > > trx_mod_tables_t
 Type used to store the list of tables that are modified by a given transaction. More...
 
typedef std::list< TrxVersion, ut_allocator< TrxVersion > > hit_list_t
 

Enumerations

enum  trx_rseg_type_t { TRX_RSEG_TYPE_NONE = 0, TRX_RSEG_TYPE_REDO, TRX_RSEG_TYPE_NOREDO }
 
enum  commit_node_state { COMMIT_NODE_SEND = 1, COMMIT_NODE_WAIT }
 Commit node states. More...
 

Functions

void trx_set_flush_observer (trx_t *trx, FlushObserver *observer)
 Set flush observer for the transaction. More...
 
void trx_set_detailed_error (trx_t *trx, const char *msg)
 Set detailed error message for the transaction. More...
 
void trx_set_detailed_error_from_file (trx_t *trx, FILE *file)
 Set detailed error message for the transaction from a file. More...
 
UNIV_INLINE const dict_index_ttrx_get_error_info (const trx_t *trx)
 Retrieves the error_info field from a trx. More...
 
trx_ttrx_allocate_for_mysql (void)
 Creates a transaction object for MySQL. More...
 
trx_ttrx_allocate_for_background (void)
 Creates a transaction object for background operations by the master thread. More...
 
void trx_resurrect_locks ()
 Resurrect table locks for resurrected transactions. More...
 
void trx_free_resurrected (trx_t *trx)
 Free and initialize a transaction object instantiated during recovery. More...
 
void trx_free_for_background (trx_t *trx)
 Free a transaction that was allocated by background or user threads. More...
 
void trx_free_prepared (trx_t *trx)
 At shutdown, frees a transaction object that is in the PREPARED state. More...
 
void trx_free_for_mysql (trx_t *trx)
 Free a transaction object for MySQL. More...
 
void trx_disconnect_plain (trx_t *trx)
 Disconnect a transaction from MySQL. More...
 
void trx_disconnect_prepared (trx_t *trx)
 Disconnect a prepared transaction from MySQL. More...
 
void trx_lists_init_at_db_start (void)
 Creates trx objects for transactions and initializes the trx list of trx_sys at database start. More...
 
void trx_start_if_not_started_xa_low (trx_t *trx, bool read_write)
 Starts the transaction if it is not yet started. More...
 
void trx_start_if_not_started_low (trx_t *trx, bool read_write)
 Starts the transaction if it is not yet started. More...
 
void trx_start_internal_low (trx_t *trx)
 Starts a transaction for internal processing. More...
 
void trx_start_internal_read_only_low (trx_t *trx)
 Starts a read-only transaction for internal processing. More...
 
void trx_commit (trx_t *trx)
 Commits a transaction. More...
 
void trx_commit_low (trx_t *trx, mtr_t *mtr)
 Commits a transaction and a mini-transaction. More...
 
void trx_cleanup_at_db_startup (trx_t *trx)
 Cleans up a transaction at database startup. More...
 
dberr_t trx_commit_for_mysql (trx_t *trx)
 Does the transaction commit for MySQL. More...
 
dberr_t trx_prepare_for_mysql (trx_t *trx)
 Does the transaction prepare for MySQL. More...
 
int trx_recover_for_mysql (XID *xid_list, ulint len)
 This function is used to find number of prepared transactions and their transaction objects for a recovery. More...
 
trx_ttrx_get_trx_by_xid (const XID *xid)
 This function is used to find one X/Open XA distributed transaction which is in the prepared state. More...
 
void trx_commit_complete_for_mysql (trx_t *trx)
 If required, flushes the log to disk if we called trx_commit_for_mysql() with trx->flush_log_later == TRUE. More...
 
void trx_mark_sql_stat_end (trx_t *trx)
 Marks the latest SQL statement ended. More...
 
ReadViewtrx_assign_read_view (trx_t *trx)
 Assigns a read view for a consistent read query. More...
 
UNIV_INLINE ReadViewtrx_get_read_view (trx_t *trx)
 
UNIV_INLINE const ReadViewtrx_get_read_view (const trx_t *trx)
 
void trx_commit_or_rollback_prepare (trx_t *trx)
 Prepares a transaction for commit/rollback. More...
 
commit_node_ttrx_commit_node_create (mem_heap_t *heap)
 Creates a commit command node struct. More...
 
que_thr_ttrx_commit_step (que_thr_t *thr)
 Performs an execution step for a commit type node in a query graph. More...
 
void trx_print_low (FILE *f, const trx_t *trx, ulint max_query_len, ulint n_rec_locks, ulint n_trx_locks, ulint heap_size)
 Prints info about a transaction. More...
 
void trx_print_latched (FILE *f, const trx_t *trx, ulint max_query_len)
 Prints info about a transaction. More...
 
void trx_print (FILE *f, const trx_t *trx, ulint max_query_len)
 Prints info about a transaction. More...
 
UNIV_INLINE enum trx_dict_op_t trx_get_dict_operation (const trx_t *trx)
 Determine if a transaction is a dictionary operation. More...
 
UNIV_INLINE void trx_set_dict_operation (trx_t *trx, enum trx_dict_op_t op)
 Flag a transaction a dictionary operation. More...
 
UNIV_INLINE bool trx_state_eq (const trx_t *trx, trx_state_t state)
 Determines if a transaction is in the given state. More...
 
ibool trx_assert_started (const trx_t *trx)
 Asserts that a transaction has been started. More...
 
ibool trx_is_interrupted (const trx_t *trx)
 Determines if the currently running transaction has been interrupted. More...
 
ibool trx_is_strict (trx_t *trx)
 Determines if the currently running transaction is in strict mode. More...
 
bool trx_weight_ge (const trx_t *a, const trx_t *b)
 Compares the "weight" (or size) of two transactions. More...
 
UNIV_INLINE const char * trx_get_que_state_str (const trx_t *trx)
 Retrieves transaction's que state in a human readable string. More...
 
UNIV_INLINE trx_id_t trx_get_id_for_print (const trx_t *trx)
 Retreieves the transaction ID. More...
 
void trx_assign_rseg_temp (trx_t *trx)
 Assign a temp-tablespace bound rollback-segment to a transaction. More...
 
void trx_pool_init ()
 Create the trx_t pool. More...
 
void trx_pool_close ()
 Destroy the trx_t pool. More...
 
void trx_set_rw_mode (trx_t *trx)
 Set the transaction as a read-write transaction if it is not already tagged as such. More...
 
UNIV_INLINE trx_ttrx_reference (trx_t *trx, bool do_ref_count)
 Increase the reference count. More...
 
UNIV_INLINE void trx_release_reference (trx_t *trx)
 Release the transaction. More...
 
UNIV_INLINE const trx_ttrx_arbitrate (const trx_t *requestor, const trx_t *holder)
 
UNIV_INLINE bool trx_is_high_priority (const trx_t *trx)
 
void trx_kill_blocking (trx_t *trx)
 Kill all transactions that are blocking this transaction from acquiring locks. More...
 
UNIV_INLINE bool trx_is_rseg_updated (const trx_t *trx)
 Check if redo/noredo rseg is modified for insert/update. More...
 
bool trx_is_started (const trx_t *trx)
 Check if transaction is started. More...
 

Variables

sess_ttrx_dummy_sess
 Dummy session used currently in MySQL interface. More...
 

Detailed Description

The transaction.

Created 3/26/1996 Heikki Tuuri

Macro Definition Documentation

◆ assert_trx_in_rw_list

#define assert_trx_in_rw_list (   t)
Value:
do { \
ut_ad(!(t)->read_only); \
ut_ad((t)->in_rw_trx_list == \
!((t)->read_only || !(t)->rsegs.m_redo.rseg)); \
check_trx_state(t); \
} while (0)
bool read_only
Definition: mysqld.cc:889
t
Definition: dbug_analyze.cc:147

Assert that the transaction is in the trx_sys_t::rw_trx_list.

◆ assert_trx_is_free

#define assert_trx_is_free (   t)
Value:
do { \
ut_ad(!trx_is_rseg_updated(trx)); \
ut_ad((t)->lock.wait_thr == NULL); \
ut_ad(UT_LIST_GET_LEN((t)->lock.trx_locks) == 0); \
ut_ad((t)->dict_operation == TRX_DICT_OP_NONE); \
} while (0)
UNIV_INLINE bool trx_state_eq(const trx_t *trx, trx_state_t state)
Determines if a transaction is in the given state.
Same as not started but with additional semantics that it was rolled back asynchronously the last tim...
Definition: trx0types.h:96
Sergei Dialog Client Authentication NULL
Definition: dialog.cc:352
Definition: trx0types.h:92
static bool is_view_active(ReadView *view)
Definition: read0read.h:85
bool read_view(TABLE_LIST *view, const dd::View &view_obj, MEM_ROOT *mem_root)
Read view metadata from dd.views into TABLE_LIST.
Definition: dd_view.cc:623
t
Definition: dbug_analyze.cc:147
The transaction is not modifying the data dictionary.
Definition: trx0types.h:109
UNIV_INLINE bool trx_is_rseg_updated(const trx_t *trx)
Check if redo/noredo rseg is modified for insert/update.
#define UT_LIST_GET_LEN(BASE)
Definition: innodb_utility.h:113

Check if transaction is free so that it can be re-initialized.

Parameters
ttransaction handle

◆ assert_trx_is_inactive

#define assert_trx_is_inactive (   t)
Value:
do { \
assert_trx_is_free((t)); \
ut_ad((t)->dict_operation_lock_mode == 0); \
} while (0)
t
Definition: dbug_analyze.cc:147

Check if transaction is in-active so that it can be freed and put back to transaction pool.

Parameters
ttransaction handle

◆ assert_trx_nonlocking_or_in_list

#define assert_trx_nonlocking_or_in_list (   t)
Value:
do { \
trx_state_t t_state = (t)->state; \
ut_ad((t)->read_only); \
ut_ad(!(t)->is_recovered); \
ut_ad(!(t)->in_rw_trx_list); \
ut_ad((t)->in_mysql_trx_list); \
ut_ad(t_state == TRX_STATE_NOT_STARTED || \
t_state == TRX_STATE_FORCED_ROLLBACK || \
t_state == TRX_STATE_ACTIVE); \
} else { \
check_trx_state(t); \
} \
} while (0)
#define trx_is_autocommit_non_locking(t)
Determine if the transaction is a non-locking autocommit select (implied read-only).
Definition: trx0trx.h:424
Same as not started but with additional semantics that it was rolled back asynchronously the last tim...
Definition: trx0types.h:96
Definition: trx0types.h:92
bool read_only
Definition: mysqld.cc:889
t
Definition: dbug_analyze.cc:147
Definition: trx0types.h:98

Assert that an autocommit non-locking select cannot be in the rw_trx_list and that it is a read-only transaction.

The tranasction must be in the mysql_trx_list.

◆ check_trx_state

#define check_trx_state (   t)
Value:
do { \
switch ((t)->state) { \
/* fall through */ \
continue; \
break; \
} \
ut_error; \
} while (0)
Support for 2PC/XA.
Definition: trx0types.h:101
Definition: trx0types.h:103
#define trx_is_autocommit_non_locking(t)
Determine if the transaction is a non-locking autocommit select (implied read-only).
Definition: trx0trx.h:424
Same as not started but with additional semantics that it was rolled back asynchronously the last tim...
Definition: trx0types.h:96
Definition: trx0types.h:92
t
Definition: dbug_analyze.cc:147
Definition: trx0types.h:98

Check transaction state.

◆ TRX_DUP_IGNORE

#define TRX_DUP_IGNORE   1 /* duplicate rows are to be updated */

◆ TRX_DUP_REPLACE

#define TRX_DUP_REPLACE   2 /* duplicate rows are to be replaced */

◆ trx_is_ac_nl_ro

#define trx_is_ac_nl_ro (   t)    ((t)->read_only && trx_is_autocommit_non_locking((t)))

Determine if the transaction is a non-locking autocommit select with an explicit check for the read-only status.

Parameters
ttransaction
Returns
true if non-locking autocommit read-only transaction.

◆ trx_is_autocommit_non_locking

#define trx_is_autocommit_non_locking (   t)    ((t)->auto_commit && (t)->will_lock == 0)

Determine if the transaction is a non-locking autocommit select (implied read-only).

Parameters
ttransaction
Returns
true if non-locking autocommit select transaction.

◆ trx_is_referenced

#define trx_is_referenced (   t)    ((t)->n_ref > 0)

Check if the transaction is being referenced.

◆ TRX_ISO_READ_COMMITTED

#define TRX_ISO_READ_COMMITTED   trx_t::READ_COMMITTED

◆ TRX_ISO_READ_UNCOMMITTED

#define TRX_ISO_READ_UNCOMMITTED   trx_t::READ_UNCOMMITTED

◆ TRX_ISO_REPEATABLE_READ

#define TRX_ISO_REPEATABLE_READ   trx_t::REPEATABLE_READ

◆ TRX_ISO_SERIALIZABLE

#define TRX_ISO_SERIALIZABLE   trx_t::SERIALIZABLE

◆ trx_lock_wait_timeout_get

#define trx_lock_wait_timeout_get (   t)    ((t)->mysql_thd != NULL ? thd_lock_wait_timeout((t)->mysql_thd) : 0)

Transactions that aren't started by the MySQL server don't set the trx_t::mysql_thd field.

For such transactions we set the lock wait timeout to 0 instead of the user configured value that comes from innodb_lock_wait_timeout via trx_t::mysql_thd.

Parameters
ttransaction
Returns
lock wait timeout in seconds

◆ trx_mutex_enter

#define trx_mutex_enter (   t)
Value:
do { \
mutex_enter(&t->mutex); \
} while (0)
t
Definition: dbug_analyze.cc:147

Acquire the trx->mutex.

◆ trx_mutex_exit

#define trx_mutex_exit (   t)
Value:
do { \
mutex_exit(&t->mutex); \
} while (0)
t
Definition: dbug_analyze.cc:147

Release the trx->mutex.

◆ trx_mutex_own

#define trx_mutex_own (   t)    mutex_own(&t->mutex)

Test if trx->mutex is owned.

◆ TRX_QUE_STATE_STR_MAX_LEN

#define TRX_QUE_STATE_STR_MAX_LEN   12 /* "ROLLING BACK" */

◆ trx_start_if_not_started

#define trx_start_if_not_started (   t,
  rw 
)
Value:
do { \
(t)->start_line = __LINE__; \
(t)->start_file = __FILE__; \
trx_start_if_not_started_low((t), rw); \
} while (false)
t
Definition: dbug_analyze.cc:147

◆ trx_start_if_not_started_xa

#define trx_start_if_not_started_xa (   t,
  rw 
)
Value:
do { \
(t)->start_line = __LINE__; \
(t)->start_file = __FILE__; \
trx_start_if_not_started_xa_low((t), rw); \
} while (false)
t
Definition: dbug_analyze.cc:147

◆ trx_start_internal

#define trx_start_internal (   t)
Value:
do { \
(t)->start_line = __LINE__; \
(t)->start_file = __FILE__; \
trx_start_internal_low((t)); \
} while (false)
t
Definition: dbug_analyze.cc:147

◆ trx_start_internal_read_only

#define trx_start_internal_read_only (   t)
Value:
do { \
(t)->start_line = __LINE__; \
(t)->start_file = __FILE__; \
trx_start_internal_read_only_low(t); \
} while (false)
t
Definition: dbug_analyze.cc:147

◆ TRX_WEIGHT

#define TRX_WEIGHT (   t)    ((t)->undo_no + UT_LIST_GET_LEN((t)->lock.trx_locks))

Calculates the "weight" of a transaction.

The weight of one transaction is estimated as the number of altered rows + the number of locked rows.

Parameters
ttransaction
Returns
transaction weight

Typedef Documentation

◆ hit_list_t

◆ lock_pool_t

typedef std::vector<ib_lock_t *, ut_allocator<ib_lock_t *> > lock_pool_t

◆ trx_mod_tables_t

Type used to store the list of tables that are modified by a given transaction.

We store pointers to the table objects in memory because we know that a table object will not be destroyed while a transaction that modified it is running.

Enumeration Type Documentation

◆ commit_node_state

Commit node states.

Enumerator
COMMIT_NODE_SEND 

about to send a commit signal to the transaction

COMMIT_NODE_WAIT 

commit signal sent to the transaction, waiting for completion

◆ trx_rseg_type_t

Enumerator
TRX_RSEG_TYPE_NONE 

void rollback segment type.

TRX_RSEG_TYPE_REDO 

redo rollback segment.

TRX_RSEG_TYPE_NOREDO 

non-redo rollback segment.

Function Documentation

◆ trx_allocate_for_background()

trx_t* trx_allocate_for_background ( void  )

Creates a transaction object for background operations by the master thread.

Returns
own: transaction object

◆ trx_allocate_for_mysql()

trx_t* trx_allocate_for_mysql ( void  )

Creates a transaction object for MySQL.

Returns
own: transaction object

◆ trx_arbitrate()

UNIV_INLINE const trx_t* trx_arbitrate ( const trx_t requestor,
const trx_t holder 
)
Parameters
[in]requestorTransaction requesting the lock
[in]holderTransaction holding the lock
Returns
the transaction that will be rolled back, null don't care

◆ trx_assert_started()

ibool trx_assert_started ( const trx_t trx)

Asserts that a transaction has been started.

The caller must hold trx_sys->mutex.

Returns
true if started
Parameters
trxin: transaction

◆ trx_assign_read_view()

ReadView* trx_assign_read_view ( trx_t trx)

Assigns a read view for a consistent read query.

All the consistent reads within the same transaction will get the same read view, which is created when this function is first called for a new started transaction. in: active transaction

All the consistent reads within the same transaction will get the same read view, which is created when this function is first called for a new started transaction.

Returns
consistent read view
Parameters
trxin/out: active transaction

◆ trx_assign_rseg_temp()

void trx_assign_rseg_temp ( trx_t trx)

Assign a temp-tablespace bound rollback-segment to a transaction.

Parameters
[in,out]trxtransaction that involves write to temp-table.

◆ trx_cleanup_at_db_startup()

void trx_cleanup_at_db_startup ( trx_t trx)

Cleans up a transaction at database startup.

The cleanup is needed if the transaction already got to the middle of a commit when the database crashed, and we cannot roll it back. in: transaction

The cleanup is needed if the transaction already got to the middle of a commit when the database crashed, and we cannot roll it back.

Parameters
trxin: transaction

◆ trx_commit()

void trx_commit ( trx_t trx)

Commits a transaction.

in/out: transaction

Parameters
trxin/out: transaction

◆ trx_commit_complete_for_mysql()

void trx_commit_complete_for_mysql ( trx_t trx)

If required, flushes the log to disk if we called trx_commit_for_mysql() with trx->flush_log_later == TRUE.

in/out: transaction

Parameters
trxin/out: transaction

◆ trx_commit_for_mysql()

dberr_t trx_commit_for_mysql ( trx_t trx)

Does the transaction commit for MySQL.

Returns
DB_SUCCESS or error number in/out: transaction
DB_SUCCESS or error number
Parameters
trxin/out: transaction

◆ trx_commit_low()

void trx_commit_low ( trx_t trx,
mtr_t mtr 
)

Commits a transaction and a mini-transaction.

in/out: mini-transaction (will be committed), or NULL if trx made no modifications

Parameters
trxin/out: transaction
mtrin/out: mini-transaction (will be committed), or NULL if trx made no modifications

◆ trx_commit_node_create()

commit_node_t* trx_commit_node_create ( mem_heap_t heap)

Creates a commit command node struct.

Returns
own: commit node struct in: mem heap where created
own: commit node struct
Parameters
heapin: mem heap where created

◆ trx_commit_or_rollback_prepare()

void trx_commit_or_rollback_prepare ( trx_t trx)

Prepares a transaction for commit/rollback.

in/out: transaction

Parameters
trxin/out: transaction

◆ trx_commit_step()

que_thr_t* trx_commit_step ( que_thr_t thr)

Performs an execution step for a commit type node in a query graph.

Returns
query thread to run next, or NULL in: query thread
query thread to run next, or NULL
Parameters
thrin: query thread

◆ trx_disconnect_plain()

void trx_disconnect_plain ( trx_t trx)
inline

Disconnect a transaction from MySQL.

Parameters
[in,out]trxtransaction

◆ trx_disconnect_prepared()

void trx_disconnect_prepared ( trx_t trx)

Disconnect a prepared transaction from MySQL.

Parameters
[in,out]trxtransaction

◆ trx_free_for_background()

void trx_free_for_background ( trx_t trx)

Free a transaction that was allocated by background or user threads.

Parameters
[in,out]trxtransaction object to free

◆ trx_free_for_mysql()

void trx_free_for_mysql ( trx_t trx)

Free a transaction object for MySQL.

Parameters
[in,out]trxtransaction

◆ trx_free_prepared()

void trx_free_prepared ( trx_t trx)

At shutdown, frees a transaction object that is in the PREPARED state.

in, own: trx object

Parameters
trxin, own: trx object

◆ trx_free_resurrected()

void trx_free_resurrected ( trx_t trx)

Free and initialize a transaction object instantiated during recovery.

Parameters
[in,out]trxtransaction object to free and initialize

◆ trx_get_dict_operation()

UNIV_INLINE enum trx_dict_op_t trx_get_dict_operation ( const trx_t trx)

Determine if a transaction is a dictionary operation.

Returns
dictionary operation mode
Parameters
trxin: transaction

◆ trx_get_error_info()

UNIV_INLINE const dict_index_t* trx_get_error_info ( const trx_t trx)

Retrieves the error_info field from a trx.

Returns
the error info in: trx object

◆ trx_get_id_for_print()

UNIV_INLINE trx_id_t trx_get_id_for_print ( const trx_t trx)

Retreieves the transaction ID.

In a given point in time it is guaranteed that IDs of the running transactions are unique. The values returned by this function for readonly transactions may be reused, so a subsequent RO transaction may get the same ID as a RO transaction that existed in the past. The values returned by this function should be used for printing purposes only.

Parameters
[in]trxtransaction whose id to retrieve
Returns
transaction id

◆ trx_get_que_state_str()

UNIV_INLINE const char* trx_get_que_state_str ( const trx_t trx)

Retrieves transaction's que state in a human readable string.

The string should not be free()'d or modified.

Returns
string in the data segment in: transaction

◆ trx_get_read_view() [1/2]

UNIV_INLINE ReadView* trx_get_read_view ( trx_t trx)
Returns
the transaction's read view or NULL if one not assigned.

◆ trx_get_read_view() [2/2]

UNIV_INLINE const ReadView* trx_get_read_view ( const trx_t trx)
Returns
the transaction's read view or NULL if one not assigned.

◆ trx_get_trx_by_xid()

trx_t* trx_get_trx_by_xid ( const XID xid)

This function is used to find one X/Open XA distributed transaction which is in the prepared state.

Returns
trx or NULL; on match, the trx->xid will be invalidated; note that the trx may have been committed, unless the caller is holding lock_sys->mutex in: X/Open XA transaction identifier
trx or NULL; on match, the trx->xid will be invalidated; note that the trx may have been committed, unless the caller is holding lock_sys->mutex
Parameters
xidin: X/Open XA transaction identifier

◆ trx_is_high_priority()

UNIV_INLINE bool trx_is_high_priority ( const trx_t trx)
Parameters
[in]trxTransaction to check
Returns
true if the transaction is a high priority transaction.

◆ trx_is_interrupted()

ibool trx_is_interrupted ( const trx_t trx)

Determines if the currently running transaction has been interrupted.

Returns
true if interrupted in: transaction
true if interrupted
Parameters
trxin: transaction

◆ trx_is_rseg_updated()

UNIV_INLINE bool trx_is_rseg_updated ( const trx_t trx)

Check if redo/noredo rseg is modified for insert/update.

Parameters
[in]trxTransaction to check

◆ trx_is_started()

bool trx_is_started ( const trx_t trx)
inline

Check if transaction is started.

Parameters
[in]trxTransaction whose state we need to check
Returns
true if transaction is in state started

◆ trx_is_strict()

ibool trx_is_strict ( trx_t trx)

Determines if the currently running transaction is in strict mode.

Returns
true if strict in: transaction
true if strict
Parameters
trxin: transaction

◆ trx_kill_blocking()

void trx_kill_blocking ( trx_t trx)

Kill all transactions that are blocking this transaction from acquiring locks.

Parameters
[in,out]trxHigh priority transaction

Kill the transactions in the lock acquisition order old -> new.

◆ trx_lists_init_at_db_start()

void trx_lists_init_at_db_start ( void  )

Creates trx objects for transactions and initializes the trx list of trx_sys at database start.

Rollback segment and undo log lists must already exist when this function is called, because the lists of transactions to be rolled back or cleaned up are built based on the undo log lists.

Rollback segments and undo log lists must already exist when this function is called, because the lists of transactions to be rolled back or cleaned up are built based on the undo log lists.

◆ trx_mark_sql_stat_end()

void trx_mark_sql_stat_end ( trx_t trx)

Marks the latest SQL statement ended.

in: trx handle

Parameters
trxin: trx handle

◆ trx_pool_close()

void trx_pool_close ( )

Destroy the trx_t pool.

◆ trx_pool_init()

void trx_pool_init ( )

Create the trx_t pool.

◆ trx_prepare_for_mysql()

dberr_t trx_prepare_for_mysql ( trx_t trx)

Does the transaction prepare for MySQL.

Parameters
[in,out]trxTransaction instance to prepare

◆ trx_print()

void trx_print ( FILE *  f,
const trx_t trx,
ulint  max_query_len 
)

Prints info about a transaction.

Acquires and releases lock_sys->mutex and trx_sys->mutex. in: max query length to print, or 0 to use the default max length

Acquires and releases lock_sys->mutex and trx_sys->mutex.

Parameters
fin: output stream
trxin: transaction
max_query_lenin: max query length to print, or 0 to use the default max length

◆ trx_print_latched()

void trx_print_latched ( FILE *  f,
const trx_t trx,
ulint  max_query_len 
)

Prints info about a transaction.

The caller must hold lock_sys->mutex and trx_sys->mutex. When possible, use trx_print() instead. in: max query length to print, or 0 to use the default max length

The caller must hold lock_sys->mutex and trx_sys->mutex. When possible, use trx_print() instead.

Parameters
fin: output stream
trxin: transaction
max_query_lenin: max query length to print, or 0 to use the default max length

◆ trx_print_low()

void trx_print_low ( FILE *  f,
const trx_t trx,
ulint  max_query_len,
ulint  n_rec_locks,
ulint  n_trx_locks,
ulint  heap_size 
)

Prints info about a transaction.

Caller must hold trx_sys->mutex. in: mem_heap_get_size(trx->lock.lock_heap)

Caller must hold trx_sys->mutex.

Parameters
fin: output stream
trxin: transaction
max_query_lenin: max query length to print, or 0 to use the default max length
n_rec_locksin: lock_number_of_rows_locked(&trx->lock)
n_trx_locksin: length of trx->lock.trx_locks
heap_sizein: mem_heap_get_size(trx->lock.lock_heap)

◆ trx_recover_for_mysql()

int trx_recover_for_mysql ( XID xid_list,
ulint  len 
)

This function is used to find number of prepared transactions and their transaction objects for a recovery.

Returns
number of prepared transactions in: number of slots in xid_list
number of prepared transactions stored in xid_list
Parameters
xid_listin/out: prepared transactions
lenin: number of slots in xid_list

◆ trx_reference()

UNIV_INLINE trx_t* trx_reference ( trx_t trx,
bool  do_ref_count 
)

Increase the reference count.

If the transaction is in state TRX_STATE_COMMITTED_IN_MEMORY then the transaction is considered committed and the reference count is not incremented.

Parameters
trxTransaction that is being referenced
do_ref_countIncrement the reference iff this is true
Returns
transaction instance if it is not committed

◆ trx_release_reference()

UNIV_INLINE void trx_release_reference ( trx_t trx)

Release the transaction.

Decrease the reference count.

Parameters
trxTransaction that is being released

◆ trx_resurrect_locks()

void trx_resurrect_locks ( )

Resurrect table locks for resurrected transactions.

◆ trx_set_detailed_error()

void trx_set_detailed_error ( trx_t trx,
const char *  msg 
)

Set detailed error message for the transaction.

in: detailed error message

Parameters
trxin: transaction struct
msgin: detailed error message

◆ trx_set_detailed_error_from_file()

void trx_set_detailed_error_from_file ( trx_t trx,
FILE *  file 
)

Set detailed error message for the transaction from a file.

Note that the file is rewinded before reading from it. in: file to read message from

Note that the file is rewinded before reading from it.

Parameters
trxin: transaction struct
filein: file to read message from

◆ trx_set_dict_operation()

UNIV_INLINE void trx_set_dict_operation ( trx_t trx,
enum trx_dict_op_t  op 
)

Flag a transaction a dictionary operation.

Parameters
[in,out]trxtransaction
[in]opoperation, not TRX_DICT_OP_NONE

◆ trx_set_flush_observer()

void trx_set_flush_observer ( trx_t trx,
FlushObserver observer 
)

Set flush observer for the transaction.

Parameters
[in,out]trxtransaction struct
[in]observerflush observer

◆ trx_set_rw_mode()

void trx_set_rw_mode ( trx_t trx)

Set the transaction as a read-write transaction if it is not already tagged as such.

Parameters
[in,out]trxTransaction that needs to be "upgraded" to RW from RO

Read-only transactions that are writing to temporary tables are assigned an ID and a rollback segment but are not added to the trx read-write list because their updates should not be visible to other transactions and therefore their changes can be ignored by by MVCC.

Parameters
trxin/out: transaction that is RW

◆ trx_start_if_not_started_low()

void trx_start_if_not_started_low ( trx_t trx,
bool  read_write 
)

Starts the transaction if it is not yet started.

in: true if read write transaction

Parameters
trxin: transaction
read_writein: true if read write transaction

◆ trx_start_if_not_started_xa_low()

void trx_start_if_not_started_xa_low ( trx_t trx,
bool  read_write 
)

Starts the transaction if it is not yet started.

in: true if read write transaction

Parameters
trxin/out: transaction
read_writein: true if read write transaction

◆ trx_start_internal_low()

void trx_start_internal_low ( trx_t trx)

Starts a transaction for internal processing.

in/out: transaction

Parameters
trxin/out: transaction

◆ trx_start_internal_read_only_low()

void trx_start_internal_read_only_low ( trx_t trx)

Starts a read-only transaction for internal processing.

Parameters
[in,out]trxtransaction to be started

◆ trx_state_eq()

UNIV_INLINE bool trx_state_eq ( const trx_t trx,
trx_state_t  state 
)

Determines if a transaction is in the given state.

The caller must hold trx_sys->mutex, or it must be the thread that is serving a running transaction. A running RW transaction must be in trx_sys->rw_trx_list.

Returns
true if trx->state == state
Parameters
trxin: transaction
statein: state

◆ trx_weight_ge()

bool trx_weight_ge ( const trx_t a,
const trx_t b 
)

Compares the "weight" (or size) of two transactions.

Transactions that have edited non-transactional tables are considered heavier than ones that have not.

Returns
true if weight(a) >= weight(b) in: the transaction to be compared

Transactions that have edited non-transactional tables are considered heavier than ones that have not.

Returns
true if weight(a) >= weight(b)
Parameters
ain: transaction to be compared
bin: transaction to be compared

Variable Documentation

◆ trx_dummy_sess

sess_t* trx_dummy_sess

Dummy session used currently in MySQL interface.