MySQL 9.1.0
Source Code Documentation
XID_STATE Class Reference

#include <xa.h>

Public Types

enum  xa_states {
  XA_NOTR = 0 , XA_ACTIVE , XA_IDLE , XA_PREPARED ,
  XA_ROLLBACK_ONLY
}
 

Public Member Functions

 XID_STATE ()
 
std::mutex & get_xa_lock ()
 
void set_state (xa_states state)
 
enum xa_states get_state ()
 
bool has_state (xa_states state) const
 
const char * state_name () const
 
const XIDget_xid () const
 
XIDget_xid ()
 
bool has_same_xid (const XID *xid) const
 
void set_query_id (query_id_t query_id)
 
void set_error (THD *thd)
 
void reset_error ()
 
void cleanup ()
 
void reset ()
 
void start_normal_xa (const XID *xid)
 
void start_detached_xa (const XID *xid, bool binlogged_arg=false)
 
bool is_detached () const
 
bool is_binlogged () const
 
void set_binlogged ()
 
void unset_binlogged ()
 
void store_xid_info (Protocol *protocol, bool print_xid_as_hex) const
 
bool xa_trans_rolled_back ()
 Mark a XA transaction as rollback-only if the RM unilaterally rolled back the transaction branch. More...
 
bool check_xa_idle_or_prepared (bool report_error) const
 Check that XA transaction is in state IDLE or PREPARED. More...
 
bool check_has_uncommitted_xa () const
 Check that XA transaction has an uncommitted work. More...
 
bool check_in_xa (bool report_error) const
 Check if an XA transaction has been started. More...
 

Private Attributes

XID m_xid
 
std::mutex m_xa_lock
 This mutex used for eliminating a possibility to run two XA COMMIT/XA ROLLBACK statements concurrently against the same xid value. More...
 
xa_states xa_state
 Used by external XA only. More...
 
bool m_is_detached = false
 
uint rm_error
 Error reported by the Resource Manager (RM) to the Transaction Manager. More...
 
bool m_is_binlogged
 

Static Private Attributes

static const char * xa_state_names []
 Transaction identifier. More...
 

Member Enumeration Documentation

◆ xa_states

Enumerator
XA_NOTR 
XA_ACTIVE 
XA_IDLE 
XA_PREPARED 
XA_ROLLBACK_ONLY 

Constructor & Destructor Documentation

◆ XID_STATE()

XID_STATE::XID_STATE ( )
inline

Member Function Documentation

◆ check_has_uncommitted_xa()

bool XID_STATE::check_has_uncommitted_xa ( ) const

Check that XA transaction has an uncommitted work.

Report an error to a mysql user in case when there is an uncommitted work for XA transaction.

Returns
result of check
Return values
falseXA transaction is NOT in state IDLE, PREPARED or ROLLBACK_ONLY.
trueXA transaction is in state IDLE or PREPARED or ROLLBACK_ONLY.

◆ check_in_xa()

bool XID_STATE::check_in_xa ( bool  report_error) const

Check if an XA transaction has been started.

Parameters
report_errortrue if report an error in case when XA transaction has been stared, else false.
Returns
result of check
Return values
falseXA transaction hasn't been started (XA_NOTR)
trueXA transaction has been started (!XA_NOTR)

◆ check_xa_idle_or_prepared()

bool XID_STATE::check_xa_idle_or_prepared ( bool  report_error) const

Check that XA transaction is in state IDLE or PREPARED.

Parameters
report_errortrue if state IDLE or PREPARED has to be interpreted as an error, else false
Returns
result of check
Return values
falseXA transaction is NOT in state IDLE or PREPARED
trueXA transaction is in state IDLE or PREPARED

◆ cleanup()

void XID_STATE::cleanup ( void  )
inline

◆ get_state()

enum xa_states XID_STATE::get_state ( )
inline

◆ get_xa_lock()

std::mutex & XID_STATE::get_xa_lock ( )
inline

◆ get_xid() [1/2]

XID * XID_STATE::get_xid ( )
inline

◆ get_xid() [2/2]

const XID * XID_STATE::get_xid ( ) const
inline

◆ has_same_xid()

bool XID_STATE::has_same_xid ( const XID xid) const
inline

◆ has_state()

bool XID_STATE::has_state ( xa_states  state) const
inline

◆ is_binlogged()

bool XID_STATE::is_binlogged ( ) const
inline

◆ is_detached()

bool XID_STATE::is_detached ( ) const
inline

◆ reset()

void XID_STATE::reset ( void  )
inline

◆ reset_error()

void XID_STATE::reset_error ( )
inline

◆ set_binlogged()

void XID_STATE::set_binlogged ( )
inline

◆ set_error()

void XID_STATE::set_error ( THD thd)

◆ set_query_id()

void XID_STATE::set_query_id ( query_id_t  query_id)
inline

◆ set_state()

void XID_STATE::set_state ( xa_states  state)
inline

◆ start_detached_xa()

void XID_STATE::start_detached_xa ( const XID xid,
bool  binlogged_arg = false 
)
inline

◆ start_normal_xa()

void XID_STATE::start_normal_xa ( const XID xid)
inline

◆ state_name()

const char * XID_STATE::state_name ( ) const
inline

◆ store_xid_info()

void XID_STATE::store_xid_info ( Protocol protocol,
bool  print_xid_as_hex 
) const

◆ unset_binlogged()

void XID_STATE::unset_binlogged ( )
inline

◆ xa_trans_rolled_back()

bool XID_STATE::xa_trans_rolled_back ( )

Mark a XA transaction as rollback-only if the RM unilaterally rolled back the transaction branch.

Note
If a rollback was requested by the RM, this function sets the appropriate rollback error code and transits the state to XA_ROLLBACK_ONLY.
Returns
true if transaction was rolled back or if the transaction state is XA_ROLLBACK_ONLY. false otherwise.

Member Data Documentation

◆ m_is_binlogged

bool XID_STATE::m_is_binlogged
private

◆ m_is_detached

bool XID_STATE::m_is_detached = false
private

◆ m_xa_lock

std::mutex XID_STATE::m_xa_lock
private

This mutex used for eliminating a possibility to run two XA COMMIT/XA ROLLBACK statements concurrently against the same xid value.

m_xa_lock is used on handling XA COMMIT/XA ROLLBACK and acquired only for external XA branches.

◆ m_xid

XID XID_STATE::m_xid
private

◆ rm_error

uint XID_STATE::rm_error
private

Error reported by the Resource Manager (RM) to the Transaction Manager.

◆ xa_state

xa_states XID_STATE::xa_state
private

Used by external XA only.

◆ xa_state_names

const char * XID_STATE::xa_state_names
staticprivate
Initial value:
= {"NON-EXISTING", "ACTIVE", "IDLE",
"PREPARED", "ROLLBACK ONLY"}

Transaction identifier.

For now, this is only used to catch duplicated external xids.


The documentation for this class was generated from the following files: