MySQL 9.1.0
Source Code Documentation
Transaction_state_tracker Class Reference

#include <session_tracker.h>

Inheritance diagram for Transaction_state_tracker:
[legend]

Public Member Functions

 Transaction_state_tracker ()
 Constructor. More...
 
bool enable (THD *thd) override
 Called in the constructor of THD. More...
 
bool check (THD *, set_var *) override
 To be invoked when the tracker's system variable is checked (ON_CHECK). More...
 
bool update (THD *thd) override
 Enable/disable the tracker based on @session_track_transaction_info's value. More...
 
bool store (THD *thd, String &buf) override
 Store the transaction state (and, optionally, characteristics) as length-encoded string in the specified buffer. More...
 
void mark_as_changed (THD *thd, LEX_CSTRING tracked_item_name) override
 Mark the tracker as changed. More...
 
void set_read_flags (THD *thd, enum enum_tx_read_flags flags)
 Change transaction characteristics. More...
 
void set_isol_level (THD *thd, enum enum_tx_isol_level level)
 Set isolation level pertaining to the next transaction. More...
 
void clear_trx_state (THD *thd, uint clear)
 Change transaction state. More...
 
void add_trx_state (THD *thd, uint add)
 Add flags pertaining to the current statement or transaction. More...
 
void add_trx_state_from_thd (THD *thd)
 Add "unsafe statement" flag if applicable. More...
 
void end_trx (THD *thd)
 Register the end of an (implicit or explicit) transaction. More...
 
enum_tx_state calc_trx_state (thr_lock_type l, bool has_trx)
 Helper function: turn table info into table access flag. More...
 
uint get_trx_state () const
 Get (possibly still incomplete) state. More...
 
- Public Member Functions inherited from State_tracker
 State_tracker ()
 Constructor. More...
 
virtual ~State_tracker ()=default
 Destructor. More...
 
bool is_enabled () const
 Getters. More...
 
bool is_changed () const
 
virtual void claim_memory_ownership (bool claim)
 

Private Types

enum  enum_tx_changed { TX_CHG_NONE = 0 , TX_CHG_STATE = 1 , TX_CHG_CHISTICS = 2 }
 

Private Member Functions

void reset ()
 Reset the m_changed flag for next statement. More...
 
void update_change_flags (THD *thd)
 

Private Attributes

uint tx_changed
 any trackable changes caused by this statement? More...
 
uint tx_curr_state
 transaction state More...
 
uint tx_reported_state
 
enum enum_tx_read_flags tx_read_flags
 r/w or r/o set? session default? More...
 
enum enum_tx_isol_level tx_isol_level
 isolation level More...
 

Additional Inherited Members

- Protected Attributes inherited from State_tracker
bool m_enabled
 Is tracking enabled for a particular session state type ? More...
 
bool m_changed
 Has the session state type changed ? More...
 

Member Enumeration Documentation

◆ enum_tx_changed

Enumerator
TX_CHG_NONE 

no changes from previous stmt

TX_CHG_STATE 

state has changed from previous stmt

TX_CHG_CHISTICS 

characteristics have changed from previous stmt

Constructor & Destructor Documentation

◆ Transaction_state_tracker()

Transaction_state_tracker::Transaction_state_tracker ( )

Constructor.

Constructor for transaction state tracker.

Member Function Documentation

◆ add_trx_state()

void Transaction_state_tracker::add_trx_state ( THD thd,
uint  add 
)

Add flags pertaining to the current statement or transaction.

May be called repeatedly within the same execution cycle, e.g. to add access info for more tables.

Parameters
thdThe thd handle.
addThe flags to add

◆ add_trx_state_from_thd()

void Transaction_state_tracker::add_trx_state_from_thd ( THD thd)

Add "unsafe statement" flag if applicable.

Parameters
thdThe thd handle.

◆ calc_trx_state()

enum_tx_state Transaction_state_tracker::calc_trx_state ( thr_lock_type  l,
bool  has_trx 
)

Helper function: turn table info into table access flag.

Accepts table lock type and engine type flag (transactional/ non-transactional), and returns the corresponding access flag out of TX_READ_TRX, TX_READ_UNSAFE, TX_WRITE_TRX, TX_WRITE_UNSAFE.

Parameters
lThe table's access/lock type
has_trxWhether the table's engine is transactional
Returns
The table access flag

◆ check()

bool Transaction_state_tracker::check ( THD thd,
set_var var 
)
inlineoverridevirtual

To be invoked when the tracker's system variable is checked (ON_CHECK).

Implements State_tracker.

◆ clear_trx_state()

void Transaction_state_tracker::clear_trx_state ( THD thd,
uint  clear 
)

Change transaction state.

Clear flags pertaining to the current statement or transaction.

May be called repeatedly within the same execution cycle.

Parameters
thdThe thd handle.
clearThe flags to clear

◆ enable()

bool Transaction_state_tracker::enable ( THD thd)
inlineoverridevirtual

Called in the constructor of THD.

Implements State_tracker.

◆ end_trx()

void Transaction_state_tracker::end_trx ( THD thd)

Register the end of an (implicit or explicit) transaction.

Parameters
thdThe thd handle

◆ get_trx_state()

uint Transaction_state_tracker::get_trx_state ( ) const
inline

Get (possibly still incomplete) state.

◆ mark_as_changed()

void Transaction_state_tracker::mark_as_changed ( THD thd,
LEX_CSTRING  tracked_item_name 
)
overridevirtual

Mark the tracker as changed.

Implements State_tracker.

◆ reset()

void Transaction_state_tracker::reset ( void  )
private

Reset the m_changed flag for next statement.

◆ set_isol_level()

void Transaction_state_tracker::set_isol_level ( THD thd,
enum enum_tx_isol_level  level 
)

Set isolation level pertaining to the next transaction.

Parameters
thdThe thd handle.
levelThe isolation level to set

◆ set_read_flags()

void Transaction_state_tracker::set_read_flags ( THD thd,
enum enum_tx_read_flags  flags 
)

Change transaction characteristics.

Set read flags (read only/read write) pertaining to the next transaction.

Parameters
thdThe thd handle.
flagsThe flags to set

◆ store()

bool Transaction_state_tracker::store ( THD thd,
String buf 
)
overridevirtual

Store the transaction state (and, optionally, characteristics) as length-encoded string in the specified buffer.

Once the data is stored, we reset the flags related to state-change (see reset()).

Parameters
thdThe thd handle.
[in,out]bufBuffer to store the information to.
Returns
false Success true Error

Implements State_tracker.

◆ update()

bool Transaction_state_tracker::update ( THD thd)
overridevirtual

Enable/disable the tracker based on @session_track_transaction_info's value.

Parameters
thdThe thd handle.
Returns
true if updating the tracking level failed, false otherwise

Implements State_tracker.

◆ update_change_flags()

void Transaction_state_tracker::update_change_flags ( THD thd)
inlineprivate

Member Data Documentation

◆ tx_changed

uint Transaction_state_tracker::tx_changed
private

any trackable changes caused by this statement?

◆ tx_curr_state

uint Transaction_state_tracker::tx_curr_state
private

transaction state

◆ tx_isol_level

enum enum_tx_isol_level Transaction_state_tracker::tx_isol_level
private

isolation level

◆ tx_read_flags

enum enum_tx_read_flags Transaction_state_tracker::tx_read_flags
private

r/w or r/o set? session default?

◆ tx_reported_state

uint Transaction_state_tracker::tx_reported_state
private

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