MySQL 8.0.40
Source Code Documentation
IO_CACHE_binlog_cache_storage Class Reference

A binlog cache implementation based on IO_CACHE. More...

#include <binlog_ostream.h>

Inheritance diagram for IO_CACHE_binlog_cache_storage:
[legend]

Public Member Functions

 IO_CACHE_binlog_cache_storage ()
 
IO_CACHE_binlog_cache_storageoperator= (const IO_CACHE_binlog_cache_storage &)=delete
 
 IO_CACHE_binlog_cache_storage (const IO_CACHE_binlog_cache_storage &)=delete
 
 ~IO_CACHE_binlog_cache_storage () override
 
bool open (const char *dir, const char *prefix, my_off_t cache_size, my_off_t max_cache_size)
 Opens the binlog cache. More...
 
void close ()
 
bool write (const unsigned char *buffer, my_off_t length) override
 Write some bytes into the output stream. More...
 
bool truncate (my_off_t offset) override
 Truncate some data at the end of the output stream. More...
 
bool seek (my_off_t offset) override
 Put the write position to a given offset. More...
 
bool reset ()
 Reset status and drop all data. More...
 
const char * tmp_file_name () const
 Returns the file name if a temporary file is opened, otherwise nullptr is returned. More...
 
size_t disk_writes () const
 Returns the count of calling temporary file's write() More...
 
bool begin (unsigned char **buffer, my_off_t *length)
 Initializes binlog cache for reading and returns the data at the begin. More...
 
bool next (unsigned char **buffer, my_off_t *length)
 Returns next piece of data. More...
 
my_off_t length () const
 
bool flush () override
 Flush data. More...
 
bool sync () override
 Sync. More...
 
- Public Member Functions inherited from Truncatable_ostream
 ~Truncatable_ostream () override=default
 
- Public Member Functions inherited from Basic_ostream
virtual ~Basic_ostream ()=default
 

Private Member Functions

bool enable_encryption ()
 Enable IO Cache temporary file encryption. More...
 
void disable_encryption ()
 Disable IO Cache temporary file encryption. More...
 
bool setup_ciphers_password ()
 Generate a new password for the temporary file encryption. More...
 

Private Attributes

IO_CACHE m_io_cache
 
my_off_t m_max_cache_size = 0
 

Detailed Description

A binlog cache implementation based on IO_CACHE.

Constructor & Destructor Documentation

◆ IO_CACHE_binlog_cache_storage() [1/2]

IO_CACHE_binlog_cache_storage::IO_CACHE_binlog_cache_storage ( )
default

◆ IO_CACHE_binlog_cache_storage() [2/2]

IO_CACHE_binlog_cache_storage::IO_CACHE_binlog_cache_storage ( const IO_CACHE_binlog_cache_storage )
delete

◆ ~IO_CACHE_binlog_cache_storage()

IO_CACHE_binlog_cache_storage::~IO_CACHE_binlog_cache_storage ( )
override

Member Function Documentation

◆ begin()

bool IO_CACHE_binlog_cache_storage::begin ( unsigned char **  buffer,
my_off_t length 
)

Initializes binlog cache for reading and returns the data at the begin.

buffer is controlled by binlog cache implementation, so caller should not release it. If the function sets *length to 0 and no error happens, it has reached the end of the cache.

Parameters
[out]bufferIt points to buffer where data is read.
[out]lengthLength of the data in the buffer.
Return values
falseSuccess
trueError

◆ close()

void IO_CACHE_binlog_cache_storage::close ( )

◆ disable_encryption()

void IO_CACHE_binlog_cache_storage::disable_encryption ( )
private

Disable IO Cache temporary file encryption.

◆ disk_writes()

size_t IO_CACHE_binlog_cache_storage::disk_writes ( ) const

Returns the count of calling temporary file's write()

◆ enable_encryption()

bool IO_CACHE_binlog_cache_storage::enable_encryption ( )
private

Enable IO Cache temporary file encryption.

Return values
falseSuccess.
trueError.

◆ flush()

bool IO_CACHE_binlog_cache_storage::flush ( )
inlineoverridevirtual

Flush data.

Return values
falseSuccess.
trueError.

Implements Truncatable_ostream.

◆ length()

my_off_t IO_CACHE_binlog_cache_storage::length ( ) const

◆ next()

bool IO_CACHE_binlog_cache_storage::next ( unsigned char **  buffer,
my_off_t length 
)

Returns next piece of data.

buffer is controlled by binlog cache implementation, so caller should not release it. If the function sets length to 0 and no error happens, it has reached the end of the cache.

Parameters
[out]bufferIt points to buffer where data is read.
[out]lengthLength of the data in the buffer.
Return values
falseSuccess
trueError

◆ open()

bool IO_CACHE_binlog_cache_storage::open ( const char *  dir,
const char *  prefix,
my_off_t  cache_size,
my_off_t  max_cache_size 
)

Opens the binlog cache.

It creates a memory buffer as long as cache_size. The buffer will be extended up to max_cache_size when writing data. The data exceeding max_cache_size will be written into a temporary file.

Parameters
[in]dirWhere the temporary file will be created
[in]prefixPrefix of the temporary file name
[in]cache_sizeSize of the memory buffer.
[in]max_cache_sizeMaximum size of the memory buffer
Return values
falseSuccess
trueError

◆ operator=()

IO_CACHE_binlog_cache_storage & IO_CACHE_binlog_cache_storage::operator= ( const IO_CACHE_binlog_cache_storage )
delete

◆ reset()

bool IO_CACHE_binlog_cache_storage::reset ( )

Reset status and drop all data.

It looks like a cache never was used after reset.

◆ seek()

bool IO_CACHE_binlog_cache_storage::seek ( my_off_t  offset)
inlineoverridevirtual

Put the write position to a given offset.

The offset counts from the beginning of the file.

Parameters
[in]offsetWhere the write position will be
Return values
falseSuccess
trueError

Implements Truncatable_ostream.

◆ setup_ciphers_password()

bool IO_CACHE_binlog_cache_storage::setup_ciphers_password ( )
private

Generate a new password for the temporary file encryption.

This function is called by reset() that is called every time a transaction commits to cleanup the binary log cache. The file password shall vary not only per temporary file, but also per transaction being committed within a single client connection.

Return values
falseSuccess.
trueError.

◆ sync()

bool IO_CACHE_binlog_cache_storage::sync ( )
inlineoverridevirtual

Sync.

Return values
falseSuccess
trueError

Implements Truncatable_ostream.

◆ tmp_file_name()

const char * IO_CACHE_binlog_cache_storage::tmp_file_name ( ) const

Returns the file name if a temporary file is opened, otherwise nullptr is returned.

◆ truncate()

bool IO_CACHE_binlog_cache_storage::truncate ( my_off_t  offset)
overridevirtual

Truncate some data at the end of the output stream.

Parameters
[in]offsetWhere the output stream will be truncated to.
Return values
falseSuccess
trueError

Implements Truncatable_ostream.

◆ write()

bool IO_CACHE_binlog_cache_storage::write ( const unsigned char *  buffer,
my_off_t  length 
)
overridevirtual

Write some bytes into the output stream.

When all data is written into the stream successfully, then it return false. Otherwise, true is returned. It will never returns false when partial data is written into the stream.

Parameters
[in]bufferData to be written
[in]lengthLength of the data
Return values
falseSuccess.
trueError.

Implements Basic_ostream.

Member Data Documentation

◆ m_io_cache

IO_CACHE IO_CACHE_binlog_cache_storage::m_io_cache
private

◆ m_max_cache_size

my_off_t IO_CACHE_binlog_cache_storage::m_max_cache_size = 0
private

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