MySQL 26.7.0
Source Code Documentation
MYSQL_BIN_LOG::Binlog_ofile Class Reference

Logical binlog file which wraps and hides the detail of lower layer storage implementation. More...

#include <binlog_ofile.h>

Inheritance diagram for MYSQL_BIN_LOG::Binlog_ofile:
[legend]

Public Member Functions

 ~Binlog_ofile () override
 
bool open (PSI_file_key log_file_key, const char *binlog_name, myf flags, bool existing=false)
 Opens the binlog file. More...
 
virtual void close ()
 
virtual bool write (const unsigned char *buffer, my_off_t length) override
 Writes data into storage and maintains binlog position. More...
 
virtual bool update (const unsigned char *buffer, my_off_t length, my_off_t offset)
 Updates some bytes in the binlog file. More...
 
virtual bool truncate (my_off_t offset)
 Truncates some data at the end of the binlog file. More...
 
virtual bool flush ()
 
virtual bool sync ()
 
virtual bool flush_and_sync ()
 
virtual my_off_t position ()
 
virtual bool is_empty ()
 
virtual bool is_open ()
 
virtual int get_encrypted_header_size ()
 Returns the encrypted header size of the binary log file. More...
 
virtual my_off_t get_real_file_size ()
 Returns the real file size. More...
 
virtual std::unique_ptr< Truncatable_ostreamget_pipeline_head ()
 Get the pipeline head. More...
 
virtual bool is_encrypted ()
 Check if the log file is encrypted. More...
 
virtual void set_encrypted ()
 Set that the log file is encrypted. More...
 
- Public Member Functions inherited from Basic_ostream
virtual ~Basic_ostream ()=default
 

Static Public Member Functions

static std::unique_ptr< MYSQL_BIN_LOG::Binlog_ofileopen_existing (PSI_file_key log_file_key, const char *binlog_name, myf flags)
 Opens an existing binlog file. More...
 

Private Attributes

my_off_t m_position = 0
 
int m_encrypted_header_size = 0
 
std::unique_ptr< Truncatable_ostreamm_pipeline_head
 
bool m_encrypted = false
 

Detailed Description

Logical binlog file which wraps and hides the detail of lower layer storage implementation.

Binlog code just use this class to control real storage

Constructor & Destructor Documentation

◆ ~Binlog_ofile()

MYSQL_BIN_LOG::Binlog_ofile::~Binlog_ofile ( )
override

Member Function Documentation

◆ close()

void MYSQL_BIN_LOG::Binlog_ofile::close ( )
virtual

◆ flush()

bool MYSQL_BIN_LOG::Binlog_ofile::flush ( )
virtual

◆ flush_and_sync()

bool MYSQL_BIN_LOG::Binlog_ofile::flush_and_sync ( )
virtual

◆ get_encrypted_header_size()

int MYSQL_BIN_LOG::Binlog_ofile::get_encrypted_header_size ( )
virtual

Returns the encrypted header size of the binary log file.

Return values
0The file is not encrypted.
>0The encryption header size.

◆ get_pipeline_head()

std::unique_ptr< Truncatable_ostream > MYSQL_BIN_LOG::Binlog_ofile::get_pipeline_head ( )
virtual

Get the pipeline head.

Return values
Returnsthe pipeline head or nullptr.

◆ get_real_file_size()

my_off_t MYSQL_BIN_LOG::Binlog_ofile::get_real_file_size ( )
virtual

Returns the real file size.

While position() returns the "file size" from the plain binary log events stream point of view, this function considers the encryption header when it exists.

Returns
The real file size considering the encryption header.

◆ is_empty()

bool MYSQL_BIN_LOG::Binlog_ofile::is_empty ( )
virtual

◆ is_encrypted()

bool MYSQL_BIN_LOG::Binlog_ofile::is_encrypted ( )
virtual

Check if the log file is encrypted.

Return values
Trueif the log file is encrypted.
Falseif the log file is not encrypted.

◆ is_open()

bool MYSQL_BIN_LOG::Binlog_ofile::is_open ( )
virtual

◆ open()

bool MYSQL_BIN_LOG::Binlog_ofile::open ( PSI_file_key  log_file_key,
const char *  binlog_name,
myf  flags,
bool  existing = false 
)

Opens the binlog file.

It opens the lower layer storage.

Parameters
[in]log_file_keyThe PSI_file_key for this stream
[in]binlog_nameThe file to be opened
[in]flagsThe flags used by IO_CACHE.
[in]existingTrue if opening the file, false if creating a new one.
Return values
falseSuccess
trueError

◆ open_existing()

std::unique_ptr< MYSQL_BIN_LOG::Binlog_ofile > MYSQL_BIN_LOG::Binlog_ofile::open_existing ( PSI_file_key  log_file_key,
const char *  binlog_name,
myf  flags 
)
static

Opens an existing binlog file.

It opens the lower layer storage reusing the existing file password if needed.

Parameters
[in]log_file_keyThe PSI_file_key for this stream
[in]binlog_nameThe file to be opened
[in]flagsThe flags used by IO_CACHE.
Return values
std::unique_ptrA Binlog_ofile object pointer.
nullptrError.

◆ position()

my_off_t MYSQL_BIN_LOG::Binlog_ofile::position ( )
virtual

◆ set_encrypted()

void MYSQL_BIN_LOG::Binlog_ofile::set_encrypted ( )
virtual

Set that the log file is encrypted.

◆ sync()

bool MYSQL_BIN_LOG::Binlog_ofile::sync ( )
virtual

◆ truncate()

bool MYSQL_BIN_LOG::Binlog_ofile::truncate ( my_off_t  offset)
virtual

Truncates some data at the end of the binlog file.

Parameters
[in]offsetwhere the binlog file will be truncated to.
Return values
falseSuccess
trueError

◆ update()

bool MYSQL_BIN_LOG::Binlog_ofile::update ( const unsigned char *  buffer,
my_off_t  length,
my_off_t  offset 
)
virtual

Updates some bytes in the binlog file.

If is only used for clearing LOG_EVENT_BINLOG_IN_USE_F.

Parameters
[in]bufferthe data will be written
[in]lengththe length of the data
[in]offsetthe offset of the bytes will be updated
Return values
falseSuccess
trueError

◆ write()

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

Writes data into storage and maintains binlog position.

Parameters
[in]bufferthe data will be written
[in]lengththe length of the data
Return values
falseSuccess
trueError

Implements Basic_ostream.

Member Data Documentation

◆ m_encrypted

bool MYSQL_BIN_LOG::Binlog_ofile::m_encrypted = false
private

◆ m_encrypted_header_size

int MYSQL_BIN_LOG::Binlog_ofile::m_encrypted_header_size = 0
private

◆ m_pipeline_head

std::unique_ptr<Truncatable_ostream> MYSQL_BIN_LOG::Binlog_ofile::m_pipeline_head
private

◆ m_position

my_off_t MYSQL_BIN_LOG::Binlog_ofile::m_position = 0
private

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