MySQL 8.0.40
Source Code Documentation
|
Base class of binlog input files. More...
#include <binlog_istream.h>
Public Member Functions | |
Basic_binlog_ifile (Binlog_read_error *binlog_read_error) | |
Basic_binlog_ifile (const Basic_binlog_ifile &)=delete | |
Basic_binlog_ifile & | operator= (const Basic_binlog_ifile &)=delete |
~Basic_binlog_ifile () override | |
bool | open (const char *file_name) |
Open a binlog file. More... | |
void | close () |
Close the binlog file it is reading. More... | |
ssize_t | read (unsigned char *buffer, size_t length) override |
Read some bytes from the input stream. More... | |
bool | seek (my_off_t position) override |
Puts the read position to a given offset. More... | |
my_off_t | position () const |
bool | is_open () const |
const std::string & | file_name () const |
my_off_t | length () override |
Get length of the binlog file. More... | |
Public Member Functions inherited from Basic_seekable_istream | |
~Basic_seekable_istream () override=default | |
Public Member Functions inherited from Basic_istream | |
virtual | ~Basic_istream ()=default |
Protected Member Functions | |
virtual std::unique_ptr< Basic_seekable_istream > | open_file (const char *file_name)=0 |
Open the system layer file. More... | |
Protected Attributes | |
Binlog_read_error * | m_error |
It is convenient for caller to share a Binlog_read_error object between streams. More... | |
Private Member Functions | |
bool | read_binlog_magic () |
Read binlog magic from binlog file and check if it is valid binlog magic. More... | |
Private Attributes | |
my_off_t | m_position = 0 |
The binlog's position where it is reading. More... | |
std::unique_ptr< Basic_seekable_istream > | m_istream |
It is the entry of the low level stream pipeline. More... | |
std::string | m_file_name |
Name of the file opened. More... | |
Base class of binlog input files.
It is a logical binlog file which wraps and hides the detail of lower layer storage implementation. Binlog reader and other binlog code just uses this class to control real storage.
Basic_binlog_ifile::Basic_binlog_ifile | ( | Binlog_read_error * | binlog_read_error | ) |
[in] | binlog_read_error | Basic_binlog_ifile doesn't own an Binlog_read_error. So the caller should provide one to it. When error happens, the error type will be set into 'error'. |
|
delete |
|
override |
void Basic_binlog_ifile::close | ( | ) |
Close the binlog file it is reading.
|
inline |
|
inline |
|
overridevirtual |
Get length of the binlog file.
It is not os file length. The content maybe encrypted or compressed. It is the total length of BINLOG_MAGIC and all raw binlog events.
Implements Basic_seekable_istream.
bool Basic_binlog_ifile::open | ( | const char * | file_name | ) |
Open a binlog file.
[in] | file_name | name of the binlog file which will be opened. |
|
protectedpure virtual |
Open the system layer file.
It is the entry of the stream pipeline. Implementation is delegated to sub-classes. Sub-classes opens system layer files in different way.
[in] | file_name | name of the binlog file which will be opened. |
Implemented in Binlog_ifile, and Relaylog_ifile.
|
delete |
|
inline |
|
overridevirtual |
Read some bytes from the input stream.
It should read exact 'length' bytes unless error happens or it reaches the end of the stream. It should block when reaching the end of a pipe that is not closed.
[out] | buffer | Where data will be put in. |
[in] | length | The number of bytes that you want to read. length should not be larger than max long. |
'length' | Read 'length' bytes successfully |
>=0 | Reach EOF, return the number of bytes actually read. It is between 0 and length-1. |
-1 | Error. |
Implements Basic_istream.
|
private |
Read binlog magic from binlog file and check if it is valid binlog magic.
This function also takes care of setting up any other stream layer (i.e. encryption) when needed.
false | The high level stream layer was recognized as a binary log. |
true | Failure identifying the high level stream layer. |
|
overridevirtual |
Puts the read position to a given offset.
The offset counts from the beginning of the stream. In case an implementing class transforms the data in a way that does not preserve positions, the offset here will be relative to the bytes that are read out from the stream, not relative to the bytes in lower layer storage.
it is allowed for a subclass to return success even if the position is greater than the size of the file. Error may be returned by the next read for this case. Users should call length() if they need to check that the position is within bounds.
[in] | offset | Where the read position will be. |
false | Success |
true | Error |
Implements Basic_seekable_istream.
|
protected |
It is convenient for caller to share a Binlog_read_error object between streams.
So Binlog_read_error pointer is defined here. It should be initialized in constructor by caller.
|
private |
Name of the file opened.
|
private |
It is the entry of the low level stream pipeline.
|
private |
The binlog's position where it is reading.
It is the position in logical binlog file, but not the position of system file.