MySQL 8.3.0
Source Code Documentation
Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR > Class Template Reference

It owns an allocator, a byte stream, an event_data stream and an event object stream. More...

#include <binlog_reader.h>

Inheritance diagram for Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >:
[legend]

Public Types

typedef EVENT_DATA_ISTREAM Event_data_istream
 
typedef EVENT_OBJECT_ISTREAM< Event_data_istreamEvent_object_istream
 

Public Member Functions

 Basic_binlog_file_reader (bool verify_checksum, unsigned int max_event_size=UINT_MAX)
 
 Basic_binlog_file_reader (const Basic_binlog_file_reader &)=delete
 
 Basic_binlog_file_reader (const Basic_binlog_file_reader &&)=delete
 
Basic_binlog_file_readeroperator= (const Basic_binlog_file_reader &)=delete
 
Basic_binlog_file_readeroperator= (const Basic_binlog_file_reader &&)=delete
 
 ~Basic_binlog_file_reader () override
 
bool open (const char *file_name, my_off_t offset=0, Format_description_log_event **fdle=nullptr)
 Open a binlog file and set read position to offset. More...
 
void close ()
 Close the binlog file. More...
 
bool is_open () const
 
my_off_t position () const override
 Return the current position in bytes, relative to the beginning of the file. More...
 
bool seek (my_off_t pos)
 
bool read_event_data (unsigned char **data, unsigned int *length)
 Wrapper of EVENT_DATA_ISTREAM::read_event_data. More...
 
Log_eventread_event_object () override
 wrapper of EVENT_OBJECT_ISTREAM::read_event_object. More...
 
bool has_fatal_error () const override
 Return true if there was a previous error. More...
 
Binlog_read_error::Error_type get_error_type () const override
 Return the error happened in the stream pipeline. More...
 
const char * get_error_str () const override
 Return the error message of the error happened in the stream pipeline. More...
 
IFILE * ifile ()
 
Event_data_istreamevent_data_istream ()
 
Event_object_istreamevent_object_istream ()
 
ALLOCATOR * allocator ()
 
void set_format_description_event (const mysql::binlog::event::Format_description_event &fde)
 
const mysql::binlog::event::Format_description_eventformat_description_event () const override
 Return a pointer the currently used Format_description_log_event. More...
 
my_off_t event_start_pos ()
 
void reset_error ()
 Resets the error. More...
 
- Public Member Functions inherited from IBasic_binlog_file_reader
 IBasic_binlog_file_reader ()=default
 
 IBasic_binlog_file_reader (IBasic_binlog_file_reader &)=delete
 
 IBasic_binlog_file_reader (IBasic_binlog_file_reader &&)=delete
 
IBasic_binlog_file_readeroperator= (IBasic_binlog_file_reader &)=delete
 
IBasic_binlog_file_readeroperator= (IBasic_binlog_file_reader &&)=delete
 
virtual ~IBasic_binlog_file_reader ()=default
 

Private Member Functions

Format_description_log_eventread_fdle (my_off_t offset)
 Read the Format_description_log_events before 'offset'. More...
 

Private Attributes

Binlog_read_error m_error
 
IFILE m_ifile
 
Event_data_istream m_data_istream
 
Event_object_istream m_object_istream
 
ALLOCATOR m_allocator
 
mysql::binlog::event::Format_description_event m_fde
 
bool m_verify_checksum = false
 
my_off_t m_event_start_pos = 0
 

Detailed Description

template<class IFILE, class EVENT_DATA_ISTREAM, template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR>
class Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >

It owns an allocator, a byte stream, an event_data stream and an event object stream.

The stream pipeline is setup in the constructor. All the objects required for reading a binlog file is initialized in reader class.

It maintains the Format_description_event which is needed for reading the following binlog events. A default format_description_event is initialized at the beginning. Then it will be replaced by the one read from the binlog file.

Some convenient functions is added to encapsulate the access of IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM. It makes the code simpler for reading a binlog file.

Member Typedef Documentation

◆ Event_data_istream

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
typedef EVENT_DATA_ISTREAM Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::Event_data_istream

◆ Event_object_istream

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
typedef EVENT_OBJECT_ISTREAM<Event_data_istream> Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::Event_object_istream

Constructor & Destructor Documentation

◆ Basic_binlog_file_reader() [1/3]

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::Basic_binlog_file_reader ( bool  verify_checksum,
unsigned int  max_event_size = UINT_MAX 
)
inline

◆ Basic_binlog_file_reader() [2/3]

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::Basic_binlog_file_reader ( const Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR > &  )
delete

◆ Basic_binlog_file_reader() [3/3]

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::Basic_binlog_file_reader ( const Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR > &&  )
delete

◆ ~Basic_binlog_file_reader()

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::~Basic_binlog_file_reader ( )
inlineoverride

Member Function Documentation

◆ allocator()

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
ALLOCATOR * Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::allocator ( )
inline

◆ close()

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
void Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::close ( )
inline

Close the binlog file.

◆ event_data_istream()

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
Event_data_istream * Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::event_data_istream ( )
inline

◆ event_object_istream()

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
Event_object_istream * Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::event_object_istream ( )
inline

◆ event_start_pos()

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
my_off_t Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::event_start_pos ( )
inline

◆ format_description_event()

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
const mysql::binlog::event::Format_description_event & Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::format_description_event ( ) const
inlineoverridevirtual

Return a pointer the currently used Format_description_log_event.

The event is a member by this reader, so the caller must not use the returned reference after this reader has been deleted.

Implements IBasic_binlog_file_reader.

◆ get_error_str()

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
const char * Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::get_error_str ( ) const
inlineoverridevirtual

Return the error message of the error happened in the stream pipeline.

Implements IBasic_binlog_file_reader.

◆ get_error_type()

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
Binlog_read_error::Error_type Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::get_error_type ( ) const
inlineoverridevirtual

Return the error happened in the stream pipeline.

Implements IBasic_binlog_file_reader.

◆ has_fatal_error()

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
bool Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::has_fatal_error ( ) const
inlineoverridevirtual

Return true if there was a previous error.

Implements IBasic_binlog_file_reader.

◆ ifile()

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
IFILE * Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::ifile ( )
inline

◆ is_open()

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
bool Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::is_open ( ) const
inline

◆ open()

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
bool Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::open ( const char *  file_name,
my_off_t  offset = 0,
Format_description_log_event **  fdle = nullptr 
)
inline

Open a binlog file and set read position to offset.

It will read and store Format_description_event automatically if offset is bigger than current position and fde is nullptr. Otherwise fde is use instead of finding fde from the file if fde is not null.

Parameters
[in]file_namename of the binlog file which will be opened.
[in]offsetThe position where it starts to read.
[out]fdleFor returning an Format_description_log_event object.
Return values
falseSuccess
trueError

◆ operator=() [1/2]

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
Basic_binlog_file_reader & Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::operator= ( const Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR > &&  )
delete

◆ operator=() [2/2]

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
Basic_binlog_file_reader & Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::operator= ( const Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR > &  )
delete

◆ position()

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
my_off_t Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::position ( ) const
inlineoverridevirtual

Return the current position in bytes, relative to the beginning of the file.

Implements IBasic_binlog_file_reader.

◆ read_event_data()

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
bool Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::read_event_data ( unsigned char **  data,
unsigned int *  length 
)
inline

Wrapper of EVENT_DATA_ISTREAM::read_event_data.

◆ read_event_object()

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
Log_event * Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::read_event_object ( )
inlineoverridevirtual

wrapper of EVENT_OBJECT_ISTREAM::read_event_object.

Implements IBasic_binlog_file_reader.

◆ read_fdle()

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
Format_description_log_event * Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::read_fdle ( my_off_t  offset)
inlineprivate

Read the Format_description_log_events before 'offset'.

Parameters
[in]offsetThe position where the read should stop.
Returns
A valid Format_description_log_event pointer or nullptr.

◆ reset_error()

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
void Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::reset_error ( )
inline

Resets the error.

Sets it to Binlog_read_error::SUCCESS.

◆ seek()

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
bool Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::seek ( my_off_t  pos)
inline

◆ set_format_description_event()

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
void Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::set_format_description_event ( const mysql::binlog::event::Format_description_event fde)
inline

Member Data Documentation

◆ m_allocator

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
ALLOCATOR Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::m_allocator
private

◆ m_data_istream

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
Event_data_istream Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::m_data_istream
private

◆ m_error

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
Binlog_read_error Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::m_error
private

◆ m_event_start_pos

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
my_off_t Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::m_event_start_pos = 0
private

◆ m_fde

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
mysql::binlog::event::Format_description_event Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::m_fde
private

◆ m_ifile

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
IFILE Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::m_ifile
private

◆ m_object_istream

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
Event_object_istream Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::m_object_istream
private

◆ m_verify_checksum

template<class IFILE , class EVENT_DATA_ISTREAM , template< class > class EVENT_OBJECT_ISTREAM, class ALLOCATOR >
bool Basic_binlog_file_reader< IFILE, EVENT_DATA_ISTREAM, EVENT_OBJECT_ISTREAM, ALLOCATOR >::m_verify_checksum = false
private

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