MySQL Internals Manual  /  The Binary Log  /  Event Classes and Types

19.5 Event Classes and Types

Internally, the server uses C++ classes to represent binary log events. Prototypes are in log_event.h. Code for methods of these classes is in log_event.cc.

Log_event is the base class. Other more specific event subclasses are derived from it. Type codes are associated with subclasses because class instance contents are written to binary or relay logs or are sent over the network from master to slave. In those contexts, an event is just a sequence of bytes, not a class structure, so a type code is needed to allow recognition of the event type from the byte sequence.

An event byte sequence has a header part and a data part. The type code appears in the header part of each event.

The possible type codes for events are listed in the Log_event_type enumeration:

enum Log_event_type { 
  UNKNOWN_EVENT= 0, 
  START_EVENT_V3= 1, 
  QUERY_EVENT= 2, 
  STOP_EVENT= 3, 
  ROTATE_EVENT= 4, 
  INTVAR_EVENT= 5, 
  LOAD_EVENT= 6, 
  SLAVE_EVENT= 7, 
  CREATE_FILE_EVENT= 8, 
  APPEND_BLOCK_EVENT= 9, 
  EXEC_LOAD_EVENT= 10, 
  DELETE_FILE_EVENT= 11, 
  NEW_LOAD_EVENT= 12, 
  RAND_EVENT= 13, 
  USER_VAR_EVENT= 14, 
  FORMAT_DESCRIPTION_EVENT= 15, 
  XID_EVENT= 16, 
  BEGIN_LOAD_QUERY_EVENT= 17, 
  EXECUTE_LOAD_QUERY_EVENT= 18, 
  TABLE_MAP_EVENT = 19, 
  PRE_GA_WRITE_ROWS_EVENT = 20, 
  PRE_GA_UPDATE_ROWS_EVENT = 21, 
  PRE_GA_DELETE_ROWS_EVENT = 22, 
  WRITE_ROWS_EVENT = 23, 
  UPDATE_ROWS_EVENT = 24, 
  DELETE_ROWS_EVENT = 25, 
  INCIDENT_EVENT= 26, 
  HEARTBEAT_LOG_EVENT= 27, 
  IGNORABLE_LOG_EVENT= 28,
  ROWS_QUERY_LOG_EVENT= 29,
  WRITE_ROWS_EVENT = 30,
  UPDATE_ROWS_EVENT = 31,
  DELETE_ROWS_EVENT = 32,
  GTID_LOG_EVENT= 33,
  ANONYMOUS_GTID_LOG_EVENT= 34,
  PREVIOUS_GTIDS_LOG_EVENT= 35, 
  ENUM_END_EVENT 
  /* end marker */ 
};

The INTVAR_EVENT type has "subtypes," listed in the Int_event_type enumeration:

enum Int_event_type { 
  INVALID_INT_EVENT = LAST_INSERT_ID_EVENT = INSERT_ID_EVENT = 2 
};

The following table summarizes the relationship between event classes and type codes. Each class is derived from Log_event unless otherwise indicated. As can be seen, an event class is associated with a single type code in most cases, although there are some exceptions:

  • Some classes are not associated with any type code because they are used only as a base class for which to derive subclasses or because they are never written to binary or relay logs or sent from master to slave. For example, Log_event has no type code because it is used only as a base class.

  • A class may be associated with multiple type codes: Load_log_event may contain a type code of either LOAD_EVENT or NEW_LOAD_EVENT.

Value

Type Code

Class

Log_event

  • Base class for most other classes

Muted_query_log_event

  • Added in 5.0.23

  • Removed in 6.0.4

Rows_log_event

  • Added in 5.1.5

  • Base class for Write_rows_log_event, Update_rows_log_event, Delete_rows_log_event

Old_rows_log_event

  • Added in 5.1.22

  • Base class for Write_rows_log_event_old, Update_rows_log_event_old, Delete_rows_log_event_old

0

UNKNOWN_EVENT

Unknown_log_event

1

START_EVENT_V3

Start_log_event_v3

  • Renamed from START_EVENT/Start_log_event in 5.0.0

  • Base class for Format_description_log_event

2

QUERY_EVENT

Query_log_event

  • Base class for Execute_load_query_log_event

3

STOP_EVENT

Stop_log_event

4

ROTATE_EVENT

Rotate_log_event

5

INTVAR_EVENT

Intvar_log_event

6

LOAD_EVENT

Load_log_event

  • Base class for Create_file_log_event

7

SLAVE_EVENT

Slave_log_event

  • Added in 4.0.0

8

CREATE_FILE_EVENT

Create_file_log_event

  • Added in 4.0.0

  • Derived from Load_log_event

9

APPEND_BLOCK_EVENT

Append_block_log_event

  • Added in 4.0.0

  • Base class for Begin_load_query_log_event

10

EXEC_LOAD_EVENT

Execute_load_log_event

  • Added in 4.0.0

11

DELETE_FILE_EVENT

Delete_file_log_event

  • Added in 4.0.0

12

NEW_LOAD_EVENT

Load_log_event

  • Added in 4.0.0

13

RAND_EVENT

Rand_log_event

  • Added in 4.0.5

14

USER_VAR_EVENT

User_var_log_event

  • Added in 4.1.0

15

FORMAT_DESCRIPTION_EVENT

Format_description_log_event

  • Added in 5.0.0

  • Derived from Start_log_event_v3

16

XID_EVENT

Xid_log_event

  • Added in 5.0.3

17

BEGIN_LOAD_QUERY_EVENT

Begin_load_query_log_event

  • Added in 5.0.3

  • Derived from Append_block_log_event

18

EXECUTE_LOAD_QUERY_EVENT

Execute_load_query_log_event

  • Added in 5.0.3

  • Derived from Query_log_event

19

TABLE_MAP_EVENT

Table_map_log_event

  • Added in 5.1.5

20

PRE_GA_WRITE_ROWS_EVENT

Write_rows_log_event_old

  • Added in 5.1.5 as WRITE_ROWS_EVENT/Write_rows_log_event and derived from Rows_log_event

  • Renamed in 5.1.18 to PRE_GA_WRITE_ROWS_EVENT/Write_rows_log_event_old and derived from Write_rows_log_event

  • As of 5.1.22, derived from Old_rows_log_event

21

PRE_GA_UPDATE_ROWS_EVENT

Update_rows_log_event_old

  • Added in 5.1.5 as UPDATE_ROWS_EVENT/Update_rows_log_event and derived from Rows_log_event

  • Renamed in 5.1.18 to PRE_GA_UPDATE_ROWS_EVENT/Update_rows_log_event_old and derived from Update_rows_log_event

  • As of 5.1.22, derived from Old_rows_log_event

22

PRE_GA_DELETE_ROWS_EVENT

Delete_rows_log_event_old

  • Added in 5.1.5 as DELETE_ROWS_EVENT/Delete_rows_log_event and derived from Rows_log_event

  • Renamed in 5.1.18 to PRE_GA_DELETE_ROWS_EVENT/Delete_rows_log_event_old and derived from Delete_rows_log_event

  • As of 5.1.22, derived from Old_rows_log_event

23

WRITE_ROWS_EVENT

Write_rows_log_event

  • Derived from Rows_log_event

  • Renumbered in 5.1.18 from 20 to 23

24

UPDATE_ROWS_EVENT

Update_rows_log_event

  • Derived from Rows_log_event

  • Renumbered in 5.1.18 from 21 to 24

25

DELETE_ROWS_EVENT

Delete_rows_log_event

  • Derived from Rows_log_event

  • Renumbered in 5.1.18 from 22 to 25

26

INCIDENT_EVENT

Incident_log_event

  • Added in 5.1.18

27

HEARTBEAT_LOG_EVENT

Heartbeat_log_event

  • Added in 6.0.5


User Comments
Sign Up Login You must be logged in to post a comment.