MySQL 9.0.0
Source Code Documentation
MVCC Class Reference

The MVCC read view manager. More...

#include <read0read.h>

Public Member Functions

 MVCC (ulint size)
 Constructor. More...
 
 ~MVCC ()
 Destructor. More...
 
void view_open (ReadView *&view, trx_t *trx)
 Allocate and create a view. More...
 
void view_close (ReadView *&view, bool own_mutex)
 Close a view created by the above function. More...
 
void clone_oldest_view (ReadView *view)
 Clones the oldest view and stores it in view. More...
 
ulint size () const
 

Static Public Member Functions

static bool is_view_active (ReadView *view)
 
static void set_view_creator_trx_id (ReadView *view, trx_id_t id)
 Set the view creator transaction id. More...
 

Private Member Functions

bool validate () const
 Validates a read view list. More...
 
ReadViewget_view ()
 Find a free view from the active list, if none found then allocate a new view. More...
 
ReadViewget_oldest_view () const
 Get the oldest view in the system. More...
 
 MVCC (const MVCC &)
 
MVCCoperator= (const MVCC &)
 
typedef UT_LIST_BASE_NODE_T (ReadView, m_view_list) view_list_t
 

Private Attributes

view_list_t m_free
 Free views ready for reuse. More...
 
view_list_t m_views
 Active and closed views, the closed views will have the creator trx id set to TRX_ID_MAX. More...
 

Detailed Description

The MVCC read view manager.

Constructor & Destructor Documentation

◆ MVCC() [1/2]

MVCC::MVCC ( ulint  size)
explicit

Constructor.

Parameters
sizeNumber of views to pre-allocate

◆ ~MVCC()

MVCC::~MVCC ( )

Destructor.

Free all the views in the m_free list

◆ MVCC() [2/2]

MVCC::MVCC ( const MVCC )
private

Member Function Documentation

◆ clone_oldest_view()

void MVCC::clone_oldest_view ( ReadView view)

Clones the oldest view and stores it in view.

No need to call view_close(). The caller owns the view that is passed in. It will also move the closed views from the m_views list to the m_free list. This function is called by Purge to determine whether it should purge the delete marked record or not.

Parameters
viewPreallocated view, owned by the caller

◆ get_oldest_view()

ReadView * MVCC::get_oldest_view ( ) const
inlineprivate

Get the oldest view in the system.

Get the oldest (active) view in the system.

It will also move the delete marked read views from the views list to the freed list.

Returns
oldest view if found or NULL
oldest view if found or NULL

◆ get_view()

ReadView * MVCC::get_view ( )
inlineprivate

Find a free view from the active list, if none found then allocate a new view.

This function will also attempt to move delete marked views from the active list to the freed list.

Returns
a view to use
a view to use

◆ is_view_active()

static bool MVCC::is_view_active ( ReadView view)
inlinestatic
Returns
true if the view is active and valid

◆ operator=()

MVCC & MVCC::operator= ( const MVCC )
private

◆ set_view_creator_trx_id()

static void MVCC::set_view_creator_trx_id ( ReadView view,
trx_id_t  id 
)
inlinestatic

Set the view creator transaction id.

Note: This should be set only for views created by RW transactions.

Parameters
viewSet the creator trx id for this view
idTransaction id to set

◆ size()

ulint MVCC::size ( ) const
Returns
the number of active views

◆ UT_LIST_BASE_NODE_T()

typedef MVCC::UT_LIST_BASE_NODE_T ( ReadView  ,
m_view_list   
)
private

◆ validate()

bool MVCC::validate ( ) const
private

Validates a read view list.

◆ view_close()

void MVCC::view_close ( ReadView *&  view,
bool  own_mutex 
)

Close a view created by the above function.

Parameters
viewview allocated by trx_open.
own_mutextrue if caller owns trx_sys_t::mutex

◆ view_open()

void MVCC::view_open ( ReadView *&  view,
trx_t trx 
)

Allocate and create a view.

Parameters
viewView owned by this class created for the caller. Must be freed by calling view_close()
trxTransaction instance of caller

If no new RW transaction has been started since the last view was created then reuse the the existing view.

Member Data Documentation

◆ m_free

view_list_t MVCC::m_free
private

Free views ready for reuse.

◆ m_views

view_list_t MVCC::m_views
private

Active and closed views, the closed views will have the creator trx id set to TRX_ID_MAX.


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