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,
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 |
|
|
||
|
|
||
|
|
||
|
|
||
0 |
|
|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
Despite the "V3" in the type code name,
START_EVENT_V3 currently is used as the type
code not only for v3 start events, but also for v1 start events.
The original symbol for type code 1 was
START_EVENT in the format now known as v1.
Later, when v3 was developed, type code 1 was reused and the
symbol associated with it was renamed from
START_EVENT to
START_EVENT_V3. The start events for both v1
and v3 therefore have a type code of 1, although the event
structures differ and must be distinguished by examining their
contents.
Up to MySQL 5.1.17, event type codes from 20 to 22 were associated with symbols and classes as follows:
Value |
Type Code |
Class |
20 |
|
|
21 |
|
|
22 |
|
|
In 5.1.18, the symbols and classes were renamed:
Value |
Type Code |
Class |
20 |
|
|
21 |
|
|
22 |
|
|
Also in 5.1.18, the original symbols were reused with different values and new implementations of the classes that used the original names:
Value |
Type Code |
Class |
23 |
|
|
24 |
|
|
25 |
|
|
Events with type codes 20 to 22 are obsolete now and appear only in binary logs created by servers from MySQL 5.1.5 to 5.1.17.
