MySQL 8.4.2
Source Code Documentation
mysql::binlog::event::Format_description_event Class Reference

For binlog version 4. More...

#include <control_events.h>

Inheritance diagram for mysql::binlog::event::Format_description_event:
[legend]

Public Member Functions

 Format_description_event (uint8_t binlog_ver, const char *server_ver)
 Format_description_event 1st constructor. More...
 
 Format_description_event (const char *buf, const Format_description_event *fde)
 The layout of Format_description_event data part is as follows: More...
 
 Format_description_event (const Format_description_event &)=default
 
Format_description_eventoperator= (const Format_description_event &)=default
 
unsigned long get_product_version () const
 This method is used to find out the version of server that originated the current FD instance. More...
 
bool is_version_before_checksum () const
 This method checks the MySQL version to determine whether checksums may be present in the events contained in the binary log. More...
 
void calc_server_version_split ()
 This method populates the array server_version_split which is then used for lookups to find if the server which created this event has some known bug. More...
 
 ~Format_description_event () override
 
bool header_is_valid () const
 
bool version_is_valid () const
 
- Public Member Functions inherited from mysql::binlog::event::Binary_log_event
virtual ~Binary_log_event ()=0
 
 Binary_log_event (const Binary_log_event &)=default
 
 Binary_log_event (Binary_log_event &&)=default
 
Binary_log_eventoperator= (const Binary_log_event &)=default
 
Binary_log_eventoperator= (Binary_log_event &&)=default
 
enum Log_event_type get_event_type () const
 Helper method. More...
 
const Log_event_headerheader () const
 Return a const pointer to the header of the log event. More...
 
Log_event_headerheader ()
 Return a non-const pointer to the header of the log event. More...
 
const Log_event_footerfooter () const
 Return a const pointer to the footer of the log event. More...
 
Log_event_footerfooter ()
 Return a non-const pointer to the footer of the log event. More...
 
Event_readerreader ()
 Returns a reference to the event Event_reader object. More...
 

Public Attributes

time_t created
 If this event is at the start of the first binary log since server startup 'created' should be the timestamp when the event (and the binary log) was created. More...
 
uint16_t binlog_version
 
char server_version [ST_SERVER_VER_LEN]
 
bool dont_set_created
 
uint8_t common_header_len
 The size of the fixed header which all events have (for binlogs written by this version, this is equal to LOG_EVENT_HEADER_LEN), except FORMAT_DESCRIPTION_EVENT and ROTATE_EVENT (those have a header of size LOG_EVENT_MINIMAL_HEADER_LEN). More...
 
std::vector< uint8_t > post_header_len
 
unsigned char server_version_split [ST_SERVER_VER_SPLIT_LEN]
 
uint8_t number_of_event_types
 

Additional Inherited Members

- Public Types inherited from mysql::binlog::event::Binary_log_event
enum  enum_post_header_length {
  QUERY_HEADER_MINIMAL_LEN = (4 + 4 + 1 + 2) , QUERY_HEADER_LEN = (QUERY_HEADER_MINIMAL_LEN + 2) , STOP_HEADER_LEN = 0 , START_V3_HEADER_LEN = (2 + ST_SERVER_VER_LEN + 4) ,
  ROTATE_HEADER_LEN = 8 , INTVAR_HEADER_LEN = 0 , APPEND_BLOCK_HEADER_LEN = 4 , DELETE_FILE_HEADER_LEN = 4 ,
  RAND_HEADER_LEN = 0 , USER_VAR_HEADER_LEN = 0 , FORMAT_DESCRIPTION_HEADER_LEN = (START_V3_HEADER_LEN + 1 + LOG_EVENT_TYPES) , XID_HEADER_LEN = 0 ,
  BEGIN_LOAD_QUERY_HEADER_LEN = APPEND_BLOCK_HEADER_LEN , ROWS_HEADER_LEN_V1 = 8 , TABLE_MAP_HEADER_LEN = 8 , EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN = (4 + 4 + 4 + 1) ,
  EXECUTE_LOAD_QUERY_HEADER_LEN , INCIDENT_HEADER_LEN = 2 , HEARTBEAT_HEADER_LEN = 0 , IGNORABLE_HEADER_LEN = 0 ,
  ROWS_HEADER_LEN_V2 = 10 , TRANSACTION_CONTEXT_HEADER_LEN = 18 , VIEW_CHANGE_HEADER_LEN = 52 , XA_PREPARE_HEADER_LEN = 0 ,
  TRANSACTION_PAYLOAD_HEADER_LEN = 0
}
 The lengths for the fixed data part of each event. More...
 
- Static Public Attributes inherited from mysql::binlog::event::Binary_log_event
static const int LOG_EVENT_TYPES = (ENUM_END_EVENT - 1)
 
- Protected Member Functions inherited from mysql::binlog::event::Binary_log_event
 Binary_log_event (Log_event_type type_code)
 This constructor is used to initialize the type_code of header object m_header. More...
 
 Binary_log_event (const char **buf, const Format_description_event *fde)
 This constructor will create a new object of Log_event_header and initialize the variable m_header, which in turn will be used to initialize Log_event's member common_header. More...
 

Detailed Description

For binlog version 4.

This event is saved by threads which read it, as they need it for future use (to decode the ordinary events).

Binary Format

The Post-Header has six components:

Post-Header for Format_description_event
Name Format

Description

created 4 byte unsigned integer The creation timestamp, if non-zero, is the time in seconds when this event was created
binlog_version 2 byte unsigned integer This is 1 in MySQL 3.23 and 3 in MySQL 4.0 and 4.1 (In MySQL 5.0 and up, FORMAT_DESCRIPTION_EVENT is used instead of START_EVENT_V3 and for them its 4).
server_version char array of 50 bytes The MySQL server's version (example: 4.0.14-debug-log), padded with 0x00 bytes on the right
common_header_len 1 byte unsigned integer The length of the event header. This value includes the extra_headers field, so this header length - 19 yields the size of the extra_headers field.
post_header_len array of type 1 byte unsigned integer The lengths for the fixed data part of each event
server_version_split unsigned char array Stores the server version of the server and splits them in three parts
number_of_event_types 1 byte unsigned integer number of event types present in the server

Constructor & Destructor Documentation

◆ Format_description_event() [1/3]

mysql::binlog::event::Format_description_event::Format_description_event ( uint8_t  binlog_ver,
const char *  server_ver 
)

Format_description_event 1st constructor.

This constructor can be used to create the event to write to the binary log (when the server starts or when FLUSH LOGS)

Parameters
binlog_verthe binlog version for which we want to build an event. It should only be 4, old versions are not compatible anymore since 8.0.2.
server_verThe MySQL server's version.

This will be used to initialize the post_header_len, for binlog version 4.

◆ Format_description_event() [2/3]

mysql::binlog::event::Format_description_event::Format_description_event ( const char *  buf,
const Format_description_event fde 
)

The layout of Format_description_event data part is as follows:

The problem with this constructor is that the fixed header may have a length different from this version, but we don't know this length as we have not read the Format_description_log_event which says it, yet.

+=====================================+
| event  | binlog_version   19 : 2    | = 4
| data   +----------------------------+
|        | server_version   21 : 50   |
|        +----------------------------+
|        | create_timestamp 71 : 4    |
|        +----------------------------+
|        | header_length    75 : 1    |
|        +----------------------------+
|        | post-header      76 : n    | = array of n bytes, one byte
|        | lengths for all            |   per event type that the
|        | event types                |   server knows about
+=====================================+
Parameters
bufContains the serialized event.
fdeAn FDE event (see Rotate_event constructor for more info).
Note
The fde passed to this constructor was created through another constructor of FDE class.

This length is in the post-header of the event, but we don't know where the post-header starts.

So this type of event HAS to:

  • either have the header's length at the beginning (in the header, at a fixed position which will never be changed), not in the post-header. That would make the header be "shifted" compared to other events.
  • or have a header of size LOG_EVENT_MINIMAL_HEADER_LEN (19), in all future versions, so that we know for sure.

I (Guilhem) chose the 2nd solution. Rotate has the same constraint (because it is sent before Format_description_log_event).

◆ Format_description_event() [3/3]

mysql::binlog::event::Format_description_event::Format_description_event ( const Format_description_event )
default

◆ ~Format_description_event()

mysql::binlog::event::Format_description_event::~Format_description_event ( )
overridedefault

Member Function Documentation

◆ calc_server_version_split()

void mysql::binlog::event::Format_description_event::calc_server_version_split ( )

This method populates the array server_version_split which is then used for lookups to find if the server which created this event has some known bug.

◆ get_product_version()

unsigned long mysql::binlog::event::Format_description_event::get_product_version ( ) const

This method is used to find out the version of server that originated the current FD instance.

Returns
the version of server.
the version of server

◆ header_is_valid()

bool mysql::binlog::event::Format_description_event::header_is_valid ( ) const
inline

◆ is_version_before_checksum()

bool mysql::binlog::event::Format_description_event::is_version_before_checksum ( ) const

This method checks the MySQL version to determine whether checksums may be present in the events contained in the binary log.

This method checks the MySQL version to determine whether checksums may be present in the events contained in the bainry log.

Return values
trueif the event's version is earlier than one that introduced the replication event checksum.
falseotherwise.

◆ operator=()

Format_description_event & mysql::binlog::event::Format_description_event::operator= ( const Format_description_event )
default

◆ version_is_valid()

bool mysql::binlog::event::Format_description_event::version_is_valid ( ) const
inline

Member Data Documentation

◆ binlog_version

uint16_t mysql::binlog::event::Format_description_event::binlog_version

◆ common_header_len

uint8_t mysql::binlog::event::Format_description_event::common_header_len

The size of the fixed header which all events have (for binlogs written by this version, this is equal to LOG_EVENT_HEADER_LEN), except FORMAT_DESCRIPTION_EVENT and ROTATE_EVENT (those have a header of size LOG_EVENT_MINIMAL_HEADER_LEN).

◆ created

time_t mysql::binlog::event::Format_description_event::created

If this event is at the start of the first binary log since server startup 'created' should be the timestamp when the event (and the binary log) was created.

In the other case (i.e. this event is at the start of a binary log created by FLUSH LOGS or automatic rotation), 'created' should be 0. This "trick" is used by MySQL >=4.0.14 slaves to know whether they must drop stale temporary tables and whether they should abort unfinished transaction.

Note that when 'created'!=0, it is always equal to the event's timestamp; indeed Format_description_event is written only in binlog.cc where the first constructor below is called, in which 'created' is set to 'when'. So in fact 'created' is a useless variable. When it is 0 we can read the actual value from timestamp ('when') and when it is non-zero we can read the same value from timestamp ('when'). Conclusion:

  • we use timestamp to print when the binlog was created.
  • we use 'created' only to know if this is a first binlog or not.

◆ dont_set_created

bool mysql::binlog::event::Format_description_event::dont_set_created

◆ number_of_event_types

uint8_t mysql::binlog::event::Format_description_event::number_of_event_types

◆ post_header_len

std::vector<uint8_t> mysql::binlog::event::Format_description_event::post_header_len

◆ server_version

char mysql::binlog::event::Format_description_event::server_version[ST_SERVER_VER_LEN]

◆ server_version_split

unsigned char mysql::binlog::event::Format_description_event::server_version_split[ST_SERVER_VER_SPLIT_LEN]

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