MySQL 9.0.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...

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...
 
void close ()
 
bool write (const unsigned char *buffer, my_off_t length) override
 Writes data into storage and maintains binlog position. More...
 
bool update (const unsigned char *buffer, my_off_t length, my_off_t offset)
 Updates some bytes in the binlog file. More...
 
bool truncate (my_off_t offset)
 Truncates some data at the end of the binlog file. More...
 
bool flush ()
 
bool sync ()
 
bool flush_and_sync ()
 
my_off_t position ()
 
bool is_empty ()
 
bool is_open ()
 
int get_encrypted_header_size ()
 Returns the encrypted header size of the binary log file. More...
 
my_off_t get_real_file_size ()
 Returns the real file size. More...
 
std::unique_ptr< Truncatable_ostreamget_pipeline_head ()
 Get the pipeline head. More...
 
bool is_encrypted ()
 Check if the log file is encrypted. More...
 
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< 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 ( )
inlineoverride

Member Function Documentation

◆ close()

void MYSQL_BIN_LOG::Binlog_ofile::close ( )
inline

◆ flush()

bool MYSQL_BIN_LOG::Binlog_ofile::flush ( )
inline

◆ flush_and_sync()

bool MYSQL_BIN_LOG::Binlog_ofile::flush_and_sync ( )
inline

◆ get_encrypted_header_size()

int MYSQL_BIN_LOG::Binlog_ofile::get_encrypted_header_size ( )
inline

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 ( )
inline

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 ( )
inline

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 ( )
inline

◆ is_encrypted()

bool MYSQL_BIN_LOG::Binlog_ofile::is_encrypted ( )
inline

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 ( )
inline

◆ open()

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

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()

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

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 ( )
inline

◆ set_encrypted()

void MYSQL_BIN_LOG::Binlog_ofile::set_encrypted ( )
inline

Set that the log file is encrypted.

◆ sync()

bool MYSQL_BIN_LOG::Binlog_ofile::sync ( )
inline

◆ truncate()

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

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 
)
inline

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 
)
inlineoverridevirtual

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 file: