MySQL  8.0.17
Source Code Documentation
xa.h File Reference
#include <string.h>
#include <sys/types.h>
#include <list>
#include "lex_string.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_sqlcommand.h"
#include "sql/malloc_allocator.h"
#include "sql/psi_memory_key.h"
#include "sql/sql_cmd.h"
#include "sql/sql_list.h"
#include "sql/sql_plugin_ref.h"
#include "sql/xa_aux.h"

Go to the source code of this file.

Classes

class  Sql_cmd_xa_start
 This class represents SQL statement which starts an XA transaction with the given xid value. More...
 
class  Sql_cmd_xa_end
 This class represents SQL statement which puts in the IDLE state an XA transaction with the given xid value. More...
 
class  Sql_cmd_xa_prepare
 This class represents SQL statement which puts in the PREPARED state an XA transaction with the given xid value. More...
 
class  Sql_cmd_xa_recover
 This class represents SQL statement which returns to a client a list of XID's prepared to a XA commit/rollback. More...
 
class  Sql_cmd_xa_commit
 This class represents SQL statement which commits and terminates an XA transaction with the given xid value. More...
 
class  Sql_cmd_xa_rollback
 This class represents SQL statement which rollbacks and terminates an XA transaction with the given xid value. More...
 
struct  xid_t
 struct xid_t is binary compatible with the XID structure as in the X/Open CAE Specification, Distributed Transaction Processing: The XA Specification, X/Open Company Ltd., 1991. More...
 
struct  st_xarecover_txn
 Plain structure to store information about XA transaction id and a list of table names involved into XA transaction with specified id. More...
 
class  XID_STATE
 
class  Recovered_xa_transactions
 This class servers as a registry for prepared XA transactions existed before server was shutdown and being resurrected during the server restart. More...
 

Macros

#define MYSQL_XID_PREFIX   "MySQLXid"
 
#define XIDDATASIZE   128
 

Typedefs

typedef int64 query_id_t
 
typedef ulonglong my_xid
 
typedef struct xid_t XID
 struct xid_t is binary compatible with the XID structure as in the X/Open CAE Specification, Distributed Transaction Processing: The XA Specification, X/Open Company Ltd., 1991. More...
 
typedef struct st_xarecover_txn XA_recover_txn
 Plain structure to store information about XA transaction id and a list of table names involved into XA transaction with specified id. More...
 

Enumerations

enum  xa_option_words {
  XA_NONE, XA_JOIN, XA_RESUME, XA_ONE_PHASE,
  XA_SUSPEND, XA_FOR_MIGRATE
}
 

Functions

bool transaction_cache_init ()
 Initialize a cache to store Transaction_ctx and a mutex to protect access to the cache. More...
 
bool transaction_cache_detach (Transaction_ctx *transaction)
 Transaction is marked in the cache as if it's recovered. More...
 
void transaction_cache_delete (Transaction_ctx *transaction)
 Remove information about transaction from a cache. More...
 
void transaction_cache_free ()
 Release resources occupied by transaction cache. More...
 
bool applier_reset_xa_trans (THD *thd)
 This is a specific to "slave" applier collection of standard cleanup actions to reset XA transaction state at the end of XA prepare rather than to do it at the transaction commit, see ha_commit_one_phase. More...
 
struct st_plugin_intplugin_find_by_type (const LEX_CSTRING &plugin, int type)
 Searches for a correctly loaded plugin of a particular type by name. More...
 
bool detach_native_trx (THD *thd, plugin_ref plugin, void *)
 The function detaches existing storage engines transaction context from thd. More...
 
bool reattach_native_trx (THD *thd, plugin_ref plugin, void *)
 The function reattaches existing storage engines transaction context to thd. More...
 
void cleanup_trans_state (THD *thd)
 Reset some transaction state information and delete corresponding Transaction_ctx object from cache. More...
 
bool xa_trans_force_rollback (THD *thd)
 Rollback the active XA transaction. More...
 

Variables

static const int TC_HEURISTIC_NOT_USED = 0
 
static const int TC_HEURISTIC_RECOVER_COMMIT = 1
 
static const int TC_HEURISTIC_RECOVER_ROLLBACK = 2
 

Macro Definition Documentation

◆ MYSQL_XID_PREFIX

#define MYSQL_XID_PREFIX   "MySQLXid"

◆ XIDDATASIZE

#define XIDDATASIZE   128

Typedef Documentation

◆ my_xid

typedef ulonglong my_xid

◆ query_id_t

typedef int64 query_id_t

◆ XA_recover_txn

Plain structure to store information about XA transaction id and a list of table names involved into XA transaction with specified id.

◆ XID

typedef struct xid_t XID

struct xid_t is binary compatible with the XID structure as in the X/Open CAE Specification, Distributed Transaction Processing: The XA Specification, X/Open Company Ltd., 1991.

http://www.opengroup.org/bookstore/catalog/c193.htm

See also
MYSQL_XID in mysql/plugin.h

Enumeration Type Documentation

◆ xa_option_words

Enumerator
XA_NONE 
XA_JOIN 
XA_RESUME 
XA_ONE_PHASE 
XA_SUSPEND 
XA_FOR_MIGRATE 

Function Documentation

◆ applier_reset_xa_trans()

bool applier_reset_xa_trans ( THD thd)

This is a specific to "slave" applier collection of standard cleanup actions to reset XA transaction state at the end of XA prepare rather than to do it at the transaction commit, see ha_commit_one_phase.

THD of the slave applier is dissociated from a transaction object in engine that continues to exist there.

Parameters
thdcurrent thread
Returns
the value of is_error()

This is a specific to "slave" applier collection of standard cleanup actions to reset XA transaction state at the end of XA prepare rather than to do it at the transaction commit, see ha_commit_one_phase.

THD of the slave applier is dissociated from a transaction object in engine that continues to exist there.

Parameters
thdcurrent thread
Returns
the value of is_error()

◆ cleanup_trans_state()

void cleanup_trans_state ( THD thd)

Reset some transaction state information and delete corresponding Transaction_ctx object from cache.

Parameters
thdCurrent thread

◆ detach_native_trx()

bool detach_native_trx ( THD thd,
plugin_ref  plugin,
void *   
)

The function detaches existing storage engines transaction context from thd.

Backup area to save it is provided to low level storage engine function.

is invoked by plugin_foreach() after trans_xa_start() for each storage engine.

Parameters
[in,out]thdThread context
pluginReference to handlerton
Returns
false on success, true otherwise.

◆ plugin_find_by_type()

struct st_plugin_int* plugin_find_by_type ( const LEX_CSTRING plugin,
int  type 
)

Searches for a correctly loaded plugin of a particular type by name.

Parameters
pluginthe name of the plugin we're looking for
typetype of the plugin (0-MYSQL_MAX_PLUGIN_TYPE_NUM)
Returns
plugin, or NULL if not found

◆ reattach_native_trx()

bool reattach_native_trx ( THD thd,
plugin_ref  plugin,
void *   
)

The function reattaches existing storage engines transaction context to thd.

Backup area to save it is provided to low level storage engine function.

is invoked by plugin_foreach() after trans_xa_prepare() for each storage engine.

Parameters
[in,out]thdThread context
pluginReference to handlerton
Returns
false on success, true otherwise.

◆ transaction_cache_delete()

void transaction_cache_delete ( Transaction_ctx transaction)

Remove information about transaction from a cache.

Parameters
transactionPointer to a Transaction_ctx that has to be removed from a cache.

◆ transaction_cache_detach()

bool transaction_cache_detach ( Transaction_ctx transaction)

Transaction is marked in the cache as if it's recovered.

The method allows to sustain prepared transaction disconnection.

Parameters
transactionPointer to Transaction object that is replaced.
Returns
operation result
Return values
falsesuccess or a cache already contains XID_STATE for this XID value
truefailure

◆ transaction_cache_free()

void transaction_cache_free ( )

Release resources occupied by transaction cache.

◆ transaction_cache_init()

bool transaction_cache_init ( )

Initialize a cache to store Transaction_ctx and a mutex to protect access to the cache.

Returns
result of initialization
Return values
falsesuccess
truefailure

◆ xa_trans_force_rollback()

bool xa_trans_force_rollback ( THD thd)

Rollback the active XA transaction.

Note
Resets rm_error before calling ha_rollback(), so the thd->transaction.xid structure gets reset by ha_rollback() / THD::transaction::cleanup().
Returns
true if the rollback failed, false otherwise.

Variable Documentation

◆ TC_HEURISTIC_NOT_USED

const int TC_HEURISTIC_NOT_USED = 0
static

◆ TC_HEURISTIC_RECOVER_COMMIT

const int TC_HEURISTIC_RECOVER_COMMIT = 1
static

◆ TC_HEURISTIC_RECOVER_ROLLBACK

const int TC_HEURISTIC_RECOVER_ROLLBACK = 2
static