MySQL 8.0.39
Source Code Documentation
binary_log::Transaction_payload_event Class Reference

Event that encloses all the events of a transaction. More...

#include <control_events.h>

Inheritance diagram for binary_log::Transaction_payload_event:
[legend]

Public Types

using Buffer_sequence_view_t = mysqlns::buffer::Buffer_sequence_view<>
 
- Public Types inherited from binary_log::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...
 

Public Member Functions

 Transaction_payload_event (const char *payload, uint64_t payload_size, uint16_t compression_type, uint64_t uncompressed_size)
 Construct an object from the given fields. More...
 
 Transaction_payload_event (const char *buf, const Format_description_event *fde)
 Decode the event from a buffer. More...
 
 ~Transaction_payload_event () override
 
void set_compression_type (transaction::compression::type type)
 Set the compression type used for the enclosed payload. More...
 
transaction::compression::type get_compression_type () const
 
void set_payload_size (uint64_t size)
 Set the (compressed) size of the payload in this event. More...
 
uint64_t get_payload_size () const
 
void set_uncompressed_size (uint64_t size)
 Set the uncompressed size of the payload. More...
 
uint64_t get_uncompressed_size () const
 Return the alleged uncompressed size according to the field stored in the event. More...
 
void set_payload (const char *data)
 Set the (possibly compressed) payload for the event. More...
 
const char * get_payload () const
 
void set_payload (Buffer_sequence_view_t *buffer_sequence_view)
 Set the (possibly compressed) payload for the event. More...
 
std::string to_string () const
 
- Public Member Functions inherited from binary_log::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...
 

Static Public Attributes

static constexpr size_t compression_type_max_length = 1 + 1 + 1
 There are four fields: "compression type", "payload size", "uncompressed size", and "end mark". More...
 
static constexpr size_t payload_size_max_length = 1 + 1 + 9
 
static constexpr size_t uncompressed_size_max_length = 1 + 1 + 9
 
static constexpr size_t end_mark_max_length = 1
 
static constexpr size_t max_payload_data_header_length
 The maximum size of the "payload data header". More...
 
static constexpr size_t max_length_of_all_headers
 The maximum size of all headers, i.e., everything but the payload. More...
 
static constexpr size_t max_payload_length
 The maximum length of the payload size, defined such that the total event size does not exceed max_log_event_size. More...
 
- Static Public Attributes inherited from binary_log::Binary_log_event
static const int LOG_EVENT_TYPES = (ENUM_END_EVENT - 1)
 

Protected Attributes

const char * m_payload {nullptr}
 The compressed data, when entire payload is in one chunk. More...
 
Buffer_sequence_view_tm_buffer_sequence_view
 The compressed data, when payload consists of a sequence of buffers. More...
 
uint64_t m_payload_size {0}
 The size of the compressed data. More...
 
transaction::compression::type m_compression_type
 The compression algorithm that was used. More...
 
uint64_t m_uncompressed_size {0}
 The uncompressed size of the data. More...
 

Private Member Functions

Transaction_payload_eventoperator= (const Transaction_payload_event &)=delete
 
 Transaction_payload_event (const Transaction_payload_event &)=delete
 

Additional Inherited Members

- Protected Member Functions inherited from binary_log::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

Event that encloses all the events of a transaction.

It is used for carrying compressed payloads, and contains compression metadata.

Member Typedef Documentation

◆ Buffer_sequence_view_t

Constructor & Destructor Documentation

◆ Transaction_payload_event() [1/3]

binary_log::Transaction_payload_event::Transaction_payload_event ( const Transaction_payload_event )
privatedelete

◆ Transaction_payload_event() [2/3]

binary_log::Transaction_payload_event::Transaction_payload_event ( const char *  payload,
uint64_t  payload_size,
uint16_t  compression_type,
uint64_t  uncompressed_size 
)

Construct an object from the given fields.

Parameters
payloadThe (compressed) payload data.
payload_sizeThe size of payload in bytes.
compression_typethe compression type that was used to compress payload.
uncompressed_sizethe size of the data when uncompressed.

The function does not validate that the payload matches the metadata provided.

◆ Transaction_payload_event() [3/3]

binary_log::Transaction_payload_event::Transaction_payload_event ( const char *  buf,
const Format_description_event fde 
)

Decode the event from a buffer.

Parameters
bufThe buffer to decode.
fdeThe format description event used to decode the buffer.

◆ ~Transaction_payload_event()

binary_log::Transaction_payload_event::~Transaction_payload_event ( )
overridedefault

Member Function Documentation

◆ get_compression_type()

transaction::compression::type binary_log::Transaction_payload_event::get_compression_type ( ) const
inline
Returns
the compression type.

◆ get_payload()

const char * binary_log::Transaction_payload_event::get_payload ( ) const
inline
Returns
the payload of the event.

◆ get_payload_size()

uint64_t binary_log::Transaction_payload_event::get_payload_size ( ) const
inline
Returns
The payload size.

◆ get_uncompressed_size()

uint64_t binary_log::Transaction_payload_event::get_uncompressed_size ( ) const
inline

Return the alleged uncompressed size according to the field stored in the event.

This cannot be trusted; the actual size can only be computed by decompressing the event.

◆ operator=()

Transaction_payload_event & binary_log::Transaction_payload_event::operator= ( const Transaction_payload_event )
privatedelete

◆ set_compression_type()

void binary_log::Transaction_payload_event::set_compression_type ( transaction::compression::type  type)
inline

Set the compression type used for the enclosed payload.

Note
API clients must call either all or none of set_payload, set_payload_size, set_compression_type, and set_uncompressed_size.
Parameters
typethe compression type.

◆ set_payload() [1/2]

void binary_log::Transaction_payload_event::set_payload ( Buffer_sequence_view_t buffer_sequence_view)

Set the (possibly compressed) payload for the event.

The payload is given as a Buffer_sequence_view. The ownership of the data remains with the caller; the caller must ensure that the iterators remain valid for as long as this event needs them.

Note
API clients must call either all or none of set_payload, set_payload_size, set_compression_type, and set_uncompressed_size.
Parameters
buffer_sequence_viewContainer holding the data.

◆ set_payload() [2/2]

void binary_log::Transaction_payload_event::set_payload ( const char *  data)
inline

Set the (possibly compressed) payload for the event.

The ownership and responsibility to destroy the data is transferred to the event.

Note
API clients must call either all or none of set_payload, set_payload_size, set_compression_type, and set_uncompressed_size.
Parameters
dataThe payload of the event.

◆ set_payload_size()

void binary_log::Transaction_payload_event::set_payload_size ( uint64_t  size)
inline

Set the (compressed) size of the payload in this event.

Note
API clients must call either all or none of set_payload, set_payload_size, set_compression_type, and set_uncompressed_size.
Parameters
sizeThe compressed size of the payload.

◆ set_uncompressed_size()

void binary_log::Transaction_payload_event::set_uncompressed_size ( uint64_t  size)
inline

Set the uncompressed size of the payload.

Note
API clients must call either all or none of set_payload, set_payload_size, set_compression_type, and set_uncompressed_size.
Parameters
sizeThe uncompressed size of the payload.

◆ to_string()

std::string binary_log::Transaction_payload_event::to_string ( ) const
Returns
a textual representation of this event.

Member Data Documentation

◆ compression_type_max_length

constexpr size_t binary_log::Transaction_payload_event::compression_type_max_length = 1 + 1 + 1
staticconstexpr

There are four fields: "compression type", "payload size", "uncompressed size", and "end mark".

Each of the three first fields is stored as a triple, where:

  • the first element is a type code,
  • the second element is a number containing the length of the third element, and
  • the third element is the value. The last field, "end mark", is stored as only a type code. All elements are stored in the "net_store_length" format. net_store_length stores 64 bit numbers in a variable length format, using 1 to 9 bytes depending on the magnitude of the value; 1 for values up to 250, longer for bigger values.

So:

  • The first element in each triple is always length 1 since type codes are small;
  • the second element in each triple is always length 1 since the third field is at most 9 bytes;
  • the third field in each triple is:
    • at most 1 for the "compression type" since type codes are small;
    • at most 9 for the "payload size" and "uncompressed size".
  • the end mark is always 1 byte since it is a constant value less than 250

◆ end_mark_max_length

constexpr size_t binary_log::Transaction_payload_event::end_mark_max_length = 1
staticconstexpr

◆ m_buffer_sequence_view

Buffer_sequence_view_t* binary_log::Transaction_payload_event::m_buffer_sequence_view
protected

The compressed data, when payload consists of a sequence of buffers.

◆ m_compression_type

transaction::compression::type binary_log::Transaction_payload_event::m_compression_type
protected
Initial value:

The compression algorithm that was used.

◆ m_payload

const char* binary_log::Transaction_payload_event::m_payload {nullptr}
protected

The compressed data, when entire payload is in one chunk.

◆ m_payload_size

uint64_t binary_log::Transaction_payload_event::m_payload_size {0}
protected

The size of the compressed data.

◆ m_uncompressed_size

uint64_t binary_log::Transaction_payload_event::m_uncompressed_size {0}
protected

The uncompressed size of the data.

This is the same as m_payload_size if the algorithms is NONE.

◆ max_length_of_all_headers

constexpr size_t binary_log::Transaction_payload_event::max_length_of_all_headers
staticconstexpr
Initial value:
=
#define LOG_EVENT_HEADER_LEN
Definition: binlog_event.h:421
@ TRANSACTION_PAYLOAD_HEADER_LEN
Definition: binlog_event.h:868
static constexpr size_t max_payload_data_header_length
The maximum size of the "payload data header".
Definition: control_events.h:791

The maximum size of all headers, i.e., everything but the payload.

This includes common-header, post-header, and payload data header.

◆ max_payload_data_header_length

constexpr size_t binary_log::Transaction_payload_event::max_payload_data_header_length
staticconstexpr
Initial value:
=
static constexpr size_t end_mark_max_length
Definition: control_events.h:781
static constexpr size_t compression_type_max_length
There are four fields: "compression type", "payload size", "uncompressed size", and "end mark".
Definition: control_events.h:778
static constexpr size_t uncompressed_size_max_length
Definition: control_events.h:780
static constexpr size_t payload_size_max_length
Definition: control_events.h:779

The maximum size of the "payload data header".

Any log event consists of the common-header (19 bytes, same format for all event types), followed by a post-header (size defined per event type; 0 for payload events), followed by data (variable length and defined by each event type). For payload events, the data contains a payload data header (these 4 fields), followed by the payload (compressed data).

◆ max_payload_length

constexpr size_t binary_log::Transaction_payload_event::max_payload_length
staticconstexpr
Initial value:
=
static constexpr size_t max_length_of_all_headers
The maximum size of all headers, i.e., everything but the payload.
Definition: control_events.h:800
constexpr size_t max_log_event_size
The maximum value for MAX_ALLOWED_PACKET.
Definition: binlog_event.h:426

The maximum length of the payload size, defined such that the total event size does not exceed max_log_event_size.

◆ payload_size_max_length

constexpr size_t binary_log::Transaction_payload_event::payload_size_max_length = 1 + 1 + 9
staticconstexpr

◆ uncompressed_size_max_length

constexpr size_t binary_log::Transaction_payload_event::uncompressed_size_max_length = 1 + 1 + 9
staticconstexpr

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