MySQL  8.0.19
Source Code Documentation
mtr_t Struct Reference

Mini-transaction handle and buffer. More...

#include <mtr0mtr.h>

Classes

class  Command
 
struct  Impl
 State variables of the mtr. More...
 

Public Member Functions

 mtr_t ()
 
 ~mtr_t ()
 
void start (bool sync=true, bool read_only=false)
 Start a mini-transaction. More...
 
bool is_async () const
 
void set_sync ()
 Request a future commit to be synchronous. More...
 
void commit ()
 Commit the mini-transaction. More...
 
ulint get_savepoint () const
 Return current size of the buffer. More...
 
void release_s_latch_at_savepoint (ulint savepoint, rw_lock_t *lock)
 Release the (index tree) s-latch stored in an mtr memo after a savepoint. More...
 
void release_block_at_savepoint (ulint savepoint, buf_block_t *block)
 Release the block in an mtr memo after a savepoint. More...
 
void sx_latch_at_savepoint (ulint savepoint, buf_block_t *block)
 SX-latch a not yet latched block after a savepoint. More...
 
void x_latch_at_savepoint (ulint savepoint, buf_block_t *block)
 X-latch a not yet latched block after a savepoint. More...
 
mtr_log_t get_log_mode () const
 Get the logging mode. More...
 
mtr_log_t set_log_mode (mtr_log_t mode)
 Change the logging mode. More...
 
uint32_t read_ulint (const byte *ptr, mlog_id_t type) const
 Read 1 - 4 bytes from a file page buffered in the buffer pool. More...
 
void s_lock (rw_lock_t *lock, const char *file, ulint line)
 Locks a rw-latch in S mode. More...
 
void x_lock (rw_lock_t *lock, const char *file, ulint line)
 Locks a rw-latch in X mode. More...
 
void sx_lock (rw_lock_t *lock, const char *file, ulint line)
 Locks a rw-latch in X mode. More...
 
void x_lock_space (fil_space_t *space, const char *file, ulint line)
 Acquire a tablespace X-latch. More...
 
void memo_release (const void *object, ulint type)
 Release an object in the memo stack. More...
 
void release_page (const void *ptr, mtr_memo_type_t type)
 Release a page latch. More...
 
void set_modified ()
 Note that the mini-transaction has modified data. More...
 
void discard_modifications ()
 Set the state to not-modified. More...
 
lsn_t commit_lsn () const
 Get the LSN of commit(). More...
 
void enter_ibuf ()
 Note that we are inside the change buffer code. More...
 
void exit_ibuf ()
 Note that we have exited from the change buffer code. More...
 
bool is_inside_ibuf () const
 
bool is_active () const
 
FlushObserverget_flush_observer () const
 Get flush observer. More...
 
void set_flush_observer (FlushObserver *observer)
 Set flush observer. More...
 
bool memo_contains_flagged (const void *ptr, ulint flags) const
 Check if memo contains the given item. More...
 
buf_block_tmemo_contains_page_flagged (const byte *ptr, ulint flags) const
 Check if memo contains the given page. More...
 
void memo_modify_page (const byte *ptr)
 Mark the given latched page as modified. More...
 
void print () const
 Print info of an mtr handle. More...
 
bool has_committed () const
 
bool is_committing () const
 
bool has_modifications () const
 
const mtr_buf_tget_memo () const
 
mtr_buf_tget_memo ()
 
size_t get_expected_log_size () const
 Computes the number of bytes that would be written to the redo log if mtr was committed right now (excluding headers of log blocks). More...
 
void wait_for_flush ()
 
bool is_dirty () const
 
void added_rec ()
 Note that a record has been added to the log. More...
 
const mtr_buf_tget_log () const
 Get the buffered redo log of this mini-transaction. More...
 
mtr_buf_tget_log ()
 Get the buffered redo log of this mini-transaction. More...
 
void memo_push (void *object, mtr_memo_type_t type)
 Push an object to an mtr memo stack. More...
 

Static Public Member Functions

static bool memo_contains (mtr_buf_t *memo, const void *object, ulint type)
 Check if memo contains the given item. More...
 
static bool is_block_dirtied (const buf_block_t *block)
 Check if this mini-transaction is dirtying a clean page. More...
 

Private Attributes

Impl m_impl
 
lsn_t m_commit_lsn
 LSN at commit time. More...
 
bool m_sync
 true if it is synchronous mini-transaction More...
 

Friends

class Command
 

Detailed Description

Mini-transaction handle and buffer.

Constructor & Destructor Documentation

◆ mtr_t()

mtr_t::mtr_t ( )
inline

◆ ~mtr_t()

mtr_t::~mtr_t ( )
inline

Member Function Documentation

◆ added_rec()

void mtr_t::added_rec ( )
inline

Note that a record has been added to the log.

◆ commit()

void mtr_t::commit ( )

Commit the mini-transaction.

Commit a mini-transaction.

◆ commit_lsn()

lsn_t mtr_t::commit_lsn ( ) const
inline

Get the LSN of commit().

Returns
the commit LSN
Return values
0if the transaction only modified temporary tablespaces

◆ discard_modifications()

void mtr_t::discard_modifications ( )
inline

Set the state to not-modified.

This will not log the changes. This is only used during redo log apply, to avoid logging the changes.

◆ enter_ibuf()

void mtr_t::enter_ibuf ( )
inline

Note that we are inside the change buffer code.

◆ exit_ibuf()

void mtr_t::exit_ibuf ( )
inline

Note that we have exited from the change buffer code.

◆ get_expected_log_size()

size_t mtr_t::get_expected_log_size ( ) const
inline

Computes the number of bytes that would be written to the redo log if mtr was committed right now (excluding headers of log blocks).

Returns
number of bytes of the colllected log records increased by 1 if MLOG_MULTI_REC_END would already be required

◆ get_flush_observer()

FlushObserver* mtr_t::get_flush_observer ( ) const
inline

Get flush observer.

Returns
flush observer

◆ get_log() [1/2]

mtr_buf_t* mtr_t::get_log ( )
inline

Get the buffered redo log of this mini-transaction.

Returns
redo log

◆ get_log() [2/2]

const mtr_buf_t* mtr_t::get_log ( ) const
inline

Get the buffered redo log of this mini-transaction.

Returns
redo log

◆ get_log_mode()

mtr_log_t mtr_t::get_log_mode ( ) const
inline

Get the logging mode.

Returns
logging mode

◆ get_memo() [1/2]

mtr_buf_t* mtr_t::get_memo ( )
inline
Returns
the memo stack

◆ get_memo() [2/2]

const mtr_buf_t* mtr_t::get_memo ( ) const
inline
Returns
the memo stack

◆ get_savepoint()

ulint mtr_t::get_savepoint ( ) const
inline

Return current size of the buffer.

Returns
savepoint

◆ has_committed()

bool mtr_t::has_committed ( ) const
inline
Returns
true if the mini-transaction has committed

◆ has_modifications()

bool mtr_t::has_modifications ( ) const
inline
Returns
true if mini-transaction contains modifications.

◆ is_active()

bool mtr_t::is_active ( ) const
inline

◆ is_async()

bool mtr_t::is_async ( ) const
inline
Returns
whether this is an asynchronous mini-transaction.

◆ is_block_dirtied()

bool mtr_t::is_block_dirtied ( const buf_block_t block)
static

Check if this mini-transaction is dirtying a clean page.

Check if a mini-transaction is dirtying a clean page.

Parameters
blockblock being x-fixed
Returns
true if the mtr is dirtying a clean page.
true if the mtr is dirtying a clean page.

◆ is_committing()

bool mtr_t::is_committing ( ) const
inline
Returns
true if the mini-transaction is committing

◆ is_dirty()

bool mtr_t::is_dirty ( ) const
inline
Returns
true if a record was added to the mini-transaction

◆ is_inside_ibuf()

bool mtr_t::is_inside_ibuf ( ) const
inline
Returns
true if we are inside the change buffer code

◆ memo_contains()

bool mtr_t::memo_contains ( mtr_buf_t memo,
const void *  object,
ulint  type 
)
static

Check if memo contains the given item.

Parameters
memomemo stack
objectobject to search
typetype of object
Returns
true if contains
true if contains

◆ memo_contains_flagged()

bool mtr_t::memo_contains_flagged ( const void *  ptr,
ulint  flags 
) const

Check if memo contains the given item.

Parameters
ptrobject to search
flagsspecify types of object (can be ORred) of MTR_MEMO_PAGE_S_FIX ... values
Returns
true if contains

◆ memo_contains_page_flagged()

buf_block_t * mtr_t::memo_contains_page_flagged ( const byte ptr,
ulint  flags 
) const

Check if memo contains the given page.

Parameters
[in]ptrpointer to within buffer frame
[in]flagsspecify types of object with OR of MTR_MEMO_PAGE_S_FIX... values
Returns
the block
Return values
NULLif not found

◆ memo_modify_page()

void mtr_t::memo_modify_page ( const byte ptr)

Mark the given latched page as modified.

Parameters
[in]ptrpointer to within buffer frame

◆ memo_push()

void mtr_t::memo_push ( void *  object,
mtr_memo_type_t  type 
)
inline

Push an object to an mtr memo stack.

Parameters
objectobject
typeobject type: MTR_MEMO_S_LOCK, ...

◆ memo_release()

void mtr_t::memo_release ( const void *  object,
ulint  type 
)

Release an object in the memo stack.

Parameters
objectobject
typeobject type: MTR_MEMO_S_LOCK, ...

◆ print()

void mtr_t::print ( ) const

Print info of an mtr handle.

◆ read_ulint()

uint32_t mtr_t::read_ulint ( const byte ptr,
mlog_id_t  type 
) const
inline

Read 1 - 4 bytes from a file page buffered in the buffer pool.

Parameters
ptrpointer from where to read
typeMLOG_1BYTE, MLOG_2BYTES, MLOG_4BYTES
Returns
value read

◆ release_block_at_savepoint()

void mtr_t::release_block_at_savepoint ( ulint  savepoint,
buf_block_t block 
)
inline

Release the block in an mtr memo after a savepoint.

◆ release_page()

void mtr_t::release_page ( const void *  ptr,
mtr_memo_type_t  type 
)

Release a page latch.

Parameters
[in]ptrpointer to within a page frame
[in]typeobject type: MTR_MEMO_PAGE_X_FIX, ...

◆ release_s_latch_at_savepoint()

void mtr_t::release_s_latch_at_savepoint ( ulint  savepoint,
rw_lock_t lock 
)
inline

Release the (index tree) s-latch stored in an mtr memo after a savepoint.

Parameters
savepointvalue returned by
See also
set_savepoint.
Parameters
locklatch to release

◆ s_lock()

void mtr_t::s_lock ( rw_lock_t lock,
const char *  file,
ulint  line 
)
inline

Locks a rw-latch in S mode.

NOTE: use mtr_s_lock().

Parameters
lockrw-lock
filefile name from where called
lineline number in file

◆ set_flush_observer()

void mtr_t::set_flush_observer ( FlushObserver observer)
inline

Set flush observer.

Parameters
[in]observerflush observer

◆ set_log_mode()

mtr_log_t mtr_t::set_log_mode ( mtr_log_t  mode)
inline

Change the logging mode.

Parameters
modelogging mode
Returns
old mode

◆ set_modified()

void mtr_t::set_modified ( )
inline

Note that the mini-transaction has modified data.

◆ set_sync()

void mtr_t::set_sync ( )
inline

Request a future commit to be synchronous.

◆ start()

void mtr_t::start ( bool  sync = true,
bool  read_only = false 
)

Start a mini-transaction.

Parameters
synctrue if it is a synchronous mini-transaction
read_onlytrue if read only mini-transaction

◆ sx_latch_at_savepoint()

void mtr_t::sx_latch_at_savepoint ( ulint  savepoint,
buf_block_t block 
)
inline

SX-latch a not yet latched block after a savepoint.

◆ sx_lock()

void mtr_t::sx_lock ( rw_lock_t lock,
const char *  file,
ulint  line 
)
inline

Locks a rw-latch in X mode.

NOTE: use mtr_sx_lock().

Parameters
lockrw-lock
filefile name from where called
lineline number in file

◆ wait_for_flush()

void mtr_t::wait_for_flush ( )

◆ x_latch_at_savepoint()

void mtr_t::x_latch_at_savepoint ( ulint  savepoint,
buf_block_t block 
)
inline

X-latch a not yet latched block after a savepoint.

◆ x_lock()

void mtr_t::x_lock ( rw_lock_t lock,
const char *  file,
ulint  line 
)
inline

Locks a rw-latch in X mode.

NOTE: use mtr_x_lock().

Parameters
lockrw-lock
filefile name from where called
lineline number in file

◆ x_lock_space()

void mtr_t::x_lock_space ( fil_space_t space,
const char *  file,
ulint  line 
)

Acquire a tablespace X-latch.

NOTE: use mtr_x_lock_space().

Parameters
[in]spacetablespace instance
[in]filefile name from where called
[in]lineline number in file
[in]spacetablespace instance
[in]filefile name from where called
[in]lineline number in file

Friends And Related Function Documentation

◆ Command

friend class Command
friend

Member Data Documentation

◆ m_commit_lsn

lsn_t mtr_t::m_commit_lsn
private

LSN at commit time.

◆ m_impl

Impl mtr_t::m_impl
private

◆ m_sync

bool mtr_t::m_sync
private

true if it is synchronous mini-transaction


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