MySQL  8.0.19
Source Code Documentation
Transaction_boundary_parser Class Reference

#include <trx_boundary_parser.h>

Inheritance diagram for Transaction_boundary_parser:
Replication_transaction_boundary_parser

Public Types

enum  enum_trx_boundary_parser_context { TRX_BOUNDARY_PARSER_RECEIVER, TRX_BOUNDARY_PARSER_APPLIER }
 The context where the parser is used. More...
 
enum  enum_event_parser_error {
  ER_TRX_BOUND_UNSUPPORTED_UNIGNORABLE_EVENT_IN_STREAM, ER_TRX_BOUND_GTID_LOG_EVENT_IN_STREAM, ER_TRX_BOUND_UNEXPECTED_BEGIN_IN_STREAM, ER_TRX_BOUND_UNEXPECTED_COMMIT_ROLLBACK_OR_XID_LOG_EVENT_IN_STREAM,
  ER_TRX_BOUND_UNEXPECTED_XA_ROLLBACK_IN_STREAM
}
 Internal error indentifiers for parser issues. More...
 

Public Member Functions

 Transaction_boundary_parser (enum_trx_boundary_parser_context context)
 Constructor. More...
 
virtual ~Transaction_boundary_parser ()
 Destructor. More...
 
void reset ()
 Reset the transaction boundary parser state. More...
 
bool is_inside_transaction ()
 State if the transaction boundary parser is inside a transaction. More...
 
bool is_not_inside_transaction ()
 State if the transaction boundary parser is not inside a transaction. More...
 
bool is_error ()
 State if the transaction boundary parser was fed with a sequence of events that the parser wasn't able to parse correctly. More...
 
bool feed_event (binary_log::Log_event_basic_info log_event_info, bool throw_warnings)
 Feed the transaction boundary parser with a Log_event of any type in object type. More...
 
bool check_row_logging_constraints (binary_log::Log_event_basic_info event_info)
 Evaluate given the current info about boundary type, event type and parser state if the given event violates any restriction associated to row based only modes. More...
 
void rollback ()
 Rolls back to the last parser state. More...
 

Private Types

enum  enum_event_boundary_type {
  EVENT_BOUNDARY_TYPE_ERROR = -1, EVENT_BOUNDARY_TYPE_GTID = 0, EVENT_BOUNDARY_TYPE_BEGIN_TRX = 1, EVENT_BOUNDARY_TYPE_END_TRX = 2,
  EVENT_BOUNDARY_TYPE_END_XA_TRX = 3, EVENT_BOUNDARY_TYPE_PRE_STATEMENT = 4, EVENT_BOUNDARY_TYPE_STATEMENT = 5, EVENT_BOUNDARY_TYPE_INCIDENT = 6,
  EVENT_BOUNDARY_TYPE_IGNORE = 7
}
 
enum  enum_event_parser_state {
  EVENT_PARSER_NONE, EVENT_PARSER_GTID, EVENT_PARSER_DDL, EVENT_PARSER_DML,
  EVENT_PARSER_ERROR
}
 

Private Member Functions

enum_event_boundary_type get_event_boundary_type (binary_log::Log_event_basic_info event_info, bool throw_warnings)
 Parses an raw event based on the event parser logic. More...
 
bool update_state (enum_event_boundary_type event_boundary_type, bool throw_warnings)
 Set the boundary parser state based on the event parser logic. More...
 
virtual void log_server_warning (int error, const char *message)
 Log warnings using some defined logging interface. More...
 

Private Attributes

enum_event_parser_state current_parser_state
 Current internal state of the event parser. More...
 
enum_event_parser_state last_parser_state
 Last internal state of the event parser. More...
 
enum_event_boundary_type m_current_boundary_state
 The last processed boundary event type. More...
 
enum_trx_boundary_parser_context m_trx_boundary_parser_context
 In which context of the boundary parser is used. More...
 

Detailed Description

This is the base class for verifying transaction boundaries.

Member Enumeration Documentation

◆ enum_event_boundary_type

Enumerator
EVENT_BOUNDARY_TYPE_ERROR 
EVENT_BOUNDARY_TYPE_GTID 
EVENT_BOUNDARY_TYPE_BEGIN_TRX 
EVENT_BOUNDARY_TYPE_END_TRX 
EVENT_BOUNDARY_TYPE_END_XA_TRX 
EVENT_BOUNDARY_TYPE_PRE_STATEMENT 
EVENT_BOUNDARY_TYPE_STATEMENT 
EVENT_BOUNDARY_TYPE_INCIDENT 
EVENT_BOUNDARY_TYPE_IGNORE 

◆ enum_event_parser_error

Internal error indentifiers for parser issues.

Enumerator
ER_TRX_BOUND_UNSUPPORTED_UNIGNORABLE_EVENT_IN_STREAM 
ER_TRX_BOUND_GTID_LOG_EVENT_IN_STREAM 
ER_TRX_BOUND_UNEXPECTED_BEGIN_IN_STREAM 
ER_TRX_BOUND_UNEXPECTED_COMMIT_ROLLBACK_OR_XID_LOG_EVENT_IN_STREAM 
ER_TRX_BOUND_UNEXPECTED_XA_ROLLBACK_IN_STREAM 

◆ enum_event_parser_state

Enumerator
EVENT_PARSER_NONE 
EVENT_PARSER_GTID 
EVENT_PARSER_DDL 
EVENT_PARSER_DML 
EVENT_PARSER_ERROR 

◆ enum_trx_boundary_parser_context

The context where the parser is used.

Enumerator
TRX_BOUNDARY_PARSER_RECEIVER 
TRX_BOUNDARY_PARSER_APPLIER 

Constructor & Destructor Documentation

◆ Transaction_boundary_parser()

Transaction_boundary_parser::Transaction_boundary_parser ( enum_trx_boundary_parser_context  context)
inline

Constructor.

Parameters
contextIf this parser is used on a receiver or applier context

◆ ~Transaction_boundary_parser()

Transaction_boundary_parser::~Transaction_boundary_parser ( )
virtual

Destructor.

Member Function Documentation

◆ check_row_logging_constraints()

bool Transaction_boundary_parser::check_row_logging_constraints ( binary_log::Log_event_basic_info  event_info)

Evaluate given the current info about boundary type, event type and parser state if the given event violates any restriction associated to row based only modes.

Parameters
event_infothe event information: type, query, is it ignorable
Returns
true if it violates any restrictions false if it passes all tests

◆ feed_event()

bool Transaction_boundary_parser::feed_event ( binary_log::Log_event_basic_info  log_event_info,
bool  throw_warnings 
)

Feed the transaction boundary parser with a Log_event of any type in object type.

Parameters
log_event_infothe event object
throw_warningsIf the function should throw warning messages while updating the boundary parser state. While initializing the Relay_log_info the relay log is scanned backwards and this could generate false errors. So, in this case, we don't want to throw warnings.
Returns
false if the transaction boundary parser accepted the event. true if the transaction boundary parser didn't accepted the event.

◆ get_event_boundary_type()

Transaction_boundary_parser::enum_event_boundary_type Transaction_boundary_parser::get_event_boundary_type ( binary_log::Log_event_basic_info  event_info,
bool  throw_warnings 
)
private

Parses an raw event based on the event parser logic.

Parameters
event_infoInfo about an event: type, query, is it ignorable
throw_warningsIf the function should throw warning messages while updating the boundary parser state.
Returns
What is the boundary type associated to this event

◆ is_error()

bool Transaction_boundary_parser::is_error ( )
inline

State if the transaction boundary parser was fed with a sequence of events that the parser wasn't able to parse correctly.

Returns
false if the boundary parser is not in the error state. true if the boundary parser is in the error state.

◆ is_inside_transaction()

bool Transaction_boundary_parser::is_inside_transaction ( )
inline

State if the transaction boundary parser is inside a transaction.

This "inside a transaction" means that the parser was fed with at least one event of a transaction, but the transaction wasn't completely fed yet. This also means that the last event fed depends on following event(s) to be correctly applied.

Returns
false if the boundary parser is not inside a transaction. true if the boundary parser is inside a transaction.

◆ is_not_inside_transaction()

bool Transaction_boundary_parser::is_not_inside_transaction ( )
inline

State if the transaction boundary parser is not inside a transaction.

This "not inside a transaction" means that the parser was fed with an event that doesn't depend on following events.

Returns
false if the boundary parser is inside a transaction. true if the boundary parser is not inside a transaction.

◆ log_server_warning()

void Transaction_boundary_parser::log_server_warning ( int  error,
const char *  message 
)
privatevirtual

Log warnings using some defined logging interface.

Note
: this method is empty by default. Extend it to add a logging routine.
Parameters
errorthe error number
messagethe error message

Reimplemented in Replication_transaction_boundary_parser.

◆ reset()

void Transaction_boundary_parser::reset ( )

Reset the transaction boundary parser state.

Reset the transaction boundary parser.

This method initialize the boundary parser state.

◆ rollback()

void Transaction_boundary_parser::rollback ( )
inline

Rolls back to the last parser state.

This should be called in the case of a failed queued event.

◆ update_state()

bool Transaction_boundary_parser::update_state ( enum_event_boundary_type  event_boundary_type,
bool  throw_warnings 
)
private

Set the boundary parser state based on the event parser logic.

Update the boundary parser state based on a given boundary type.

Parameters
event_boundary_typethe current event boundary type
throw_warningsIf the function should throw warning messages while updating the boundary parser state.
Returns
true if there is an error while updating the state, like unexpected event order
Parameters
event_boundary_typeThe event boundary type of the event used to fed the boundary parser.
throw_warningsIf the function should throw warnings while updating the boundary parser state. Please see comments on this at feed_event().
Returns
false State updated successfully. true There was an error updating the state.

Member Data Documentation

◆ current_parser_state

enum_event_parser_state Transaction_boundary_parser::current_parser_state
private

Current internal state of the event parser.

◆ last_parser_state

enum_event_parser_state Transaction_boundary_parser::last_parser_state
private

Last internal state of the event parser.

This should be used if we had to roll back the last parsed event.

◆ m_current_boundary_state

enum_event_boundary_type Transaction_boundary_parser::m_current_boundary_state
private

The last processed boundary event type.

◆ m_trx_boundary_parser_context

enum_trx_boundary_parser_context Transaction_boundary_parser::m_trx_boundary_parser_context
private

In which context of the boundary parser is used.


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