MySQL 9.1.0
Source Code Documentation
Thd_mem_cnt Class Reference

#include <sql_class.h>

Public Member Functions

 Thd_mem_cnt ()
 
 ~Thd_mem_cnt ()
 
void set_thd (THD *thd)
 
void enable ()
 
void disable ()
 
void alloc_cnt (size_t size)
 Increase memory counter at 'alloc' operation. More...
 
void free_cnt (size_t size)
 Decrease memory counter at 'free' operation. More...
 
int reset ()
 Function resets current memory counter mode and adjusts global memory counter according to thread memory counter. More...
 
void flush ()
 Function flushes memory counters before deleting the memory counter object. More...
 
void restore_mode ()
 Restore original memory counter mode. More...
 
void no_error_mode ()
 Set NO ERROR memory counter mode. More...
 
void set_curr_mode (uint mode_arg)
 Function sets current memory counter mode. More...
 
void set_orig_mode (uint mode_arg)
 Function sets original memory counter mode. More...
 
bool is_error () const
 Check if memory counter error is issued. More...
 
void set_thd_error_status () const
 Set THD error status using memory counter diagnostics area. More...
 

Private Member Functions

int generate_error (int err_no, ulonglong mem_limit, ulonglong mem_size)
 Generate OOM error and set therad to KILL_CONNECTION state. More...
 
bool is_error_mode () const
 Check if memory counter is in error mode. More...
 
bool is_error_log_mode () const
 Check if memory counter is in error log mode. More...
 

Private Attributes

bool m_enabled {false}
 
THDm_thd {nullptr}
 
Diagnostics_area m_da {false}
 
ulonglong mem_counter {0}
 
ulonglong max_conn_mem {0}
 
ulonglong glob_mem_counter {0}
 
uint curr_mode {MEM_CNT_DEFAULT}
 
uint orig_mode {MEM_CNT_DEFAULT}
 
bool is_connection_stage {true}
 

Constructor & Destructor Documentation

◆ Thd_mem_cnt()

Thd_mem_cnt::Thd_mem_cnt ( )
inline

◆ ~Thd_mem_cnt()

Thd_mem_cnt::~Thd_mem_cnt ( )
inline

Member Function Documentation

◆ alloc_cnt()

void Thd_mem_cnt::alloc_cnt ( size_t  size)

Increase memory counter at 'alloc' operation.

Update global memory counter.

Parameters
sizeamount of memory allocated.

◆ disable()

void Thd_mem_cnt::disable ( )

◆ enable()

void Thd_mem_cnt::enable ( )
inline

◆ flush()

void Thd_mem_cnt::flush ( )

Function flushes memory counters before deleting the memory counter object.

◆ free_cnt()

void Thd_mem_cnt::free_cnt ( size_t  size)

Decrease memory counter at 'free' operation.

Parameters
sizeamount of memory freed.

◆ generate_error()

int Thd_mem_cnt::generate_error ( int  err_no,
ulonglong  mem_limit,
ulonglong  mem_size 
)
private

Generate OOM error and set therad to KILL_CONNECTION state.

Do nothing if thread is already killed or any error is already issued.

Parameters
err_noError number.
mem_limitMemory limit.
mem_sizeMemory size.
Returns
-1 if OOM error is generated, 0 otherwise.

◆ is_error()

bool Thd_mem_cnt::is_error ( ) const
inline

Check if memory counter error is issued.

Return values
trueif memory counter error is issued, false otherwise.

◆ is_error_log_mode()

bool Thd_mem_cnt::is_error_log_mode ( ) const
inlineprivate

Check if memory counter is in error log mode.

Return values
trueif memory counter is in error log mode, false otherwise.

◆ is_error_mode()

bool Thd_mem_cnt::is_error_mode ( ) const
inlineprivate

Check if memory counter is in error mode.

Return values
trueif memory counter is in error mode, false otherwise.

◆ no_error_mode()

void Thd_mem_cnt::no_error_mode ( )
inline

Set NO ERROR memory counter mode.

◆ reset()

int Thd_mem_cnt::reset ( void  )

Function resets current memory counter mode and adjusts global memory counter according to thread memory counter.

Returns
-1 if OOM error, 0 otherwise.

◆ restore_mode()

void Thd_mem_cnt::restore_mode ( )
inline

Restore original memory counter mode.

◆ set_curr_mode()

void Thd_mem_cnt::set_curr_mode ( uint  mode_arg)
inline

Function sets current memory counter mode.

Parameters
mode_argcurrent memory counter mode.

◆ set_orig_mode()

void Thd_mem_cnt::set_orig_mode ( uint  mode_arg)
inline

Function sets original memory counter mode.

Parameters
mode_argoriginal memory counter mode.

◆ set_thd()

void Thd_mem_cnt::set_thd ( THD thd)
inline

◆ set_thd_error_status()

void Thd_mem_cnt::set_thd_error_status ( ) const

Set THD error status using memory counter diagnostics area.

Member Data Documentation

◆ curr_mode

uint Thd_mem_cnt::curr_mode {MEM_CNT_DEFAULT}
private

◆ glob_mem_counter

ulonglong Thd_mem_cnt::glob_mem_counter {0}
private

◆ is_connection_stage

bool Thd_mem_cnt::is_connection_stage {true}
private

◆ m_da

Diagnostics_area Thd_mem_cnt::m_da {false}
private

◆ m_enabled

bool Thd_mem_cnt::m_enabled {false}
private

◆ m_thd

THD* Thd_mem_cnt::m_thd {nullptr}
private

◆ max_conn_mem

ulonglong Thd_mem_cnt::max_conn_mem {0}
private

◆ mem_counter

ulonglong Thd_mem_cnt::mem_counter {0}
private

◆ orig_mode

uint Thd_mem_cnt::orig_mode {MEM_CNT_DEFAULT}
private

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