@@ -25,90 +25,90 @@ public enum EventType {
25
25
/**
26
26
* Events of this event type should never occur. Not written to a binary log.
27
27
*/
28
- UNKNOWN ,
28
+ UNKNOWN ( 0 ) ,
29
29
/**
30
30
* A descriptor event that is written to the beginning of the each binary log file. (In MySQL 4.0 and 4.1,
31
31
* this event is written only to the first binary log file that the server creates after startup.) This event is
32
32
* used in MySQL 3.23 through 4.1 and superseded in MySQL 5.0 by {@link #FORMAT_DESCRIPTION}.
33
33
*/
34
- START_V3 ,
34
+ START_V3 ( 1 ) ,
35
35
/**
36
36
* Written when an updating statement is done.
37
37
*/
38
- QUERY ,
38
+ QUERY ( 2 ) ,
39
39
/**
40
40
* Written when mysqld stops.
41
41
*/
42
- STOP ,
42
+ STOP ( 3 ) ,
43
43
/**
44
44
* Written when mysqld switches to a new binary log file. This occurs when someone issues a FLUSH LOGS statement or
45
45
* the current binary log file becomes larger than max_binlog_size.
46
46
*/
47
- ROTATE ,
47
+ ROTATE ( 4 ) ,
48
48
/**
49
49
* Written every time a statement uses an AUTO_INCREMENT column or the LAST_INSERT_ID() function; precedes other
50
50
* events for the statement. This is written only before a {@link #QUERY} and is not used in case of RBR.
51
51
*/
52
- INTVAR ,
52
+ INTVAR ( 5 ) ,
53
53
/**
54
54
* Used for LOAD DATA INFILE statements in MySQL 3.23.
55
55
*/
56
- LOAD ,
56
+ LOAD ( 6 ) ,
57
57
/**
58
58
* Not used.
59
59
*/
60
- SLAVE ,
60
+ SLAVE ( 7 ) ,
61
61
/**
62
62
* Used for LOAD DATA INFILE statements in MySQL 4.0 and 4.1.
63
63
*/
64
- CREATE_FILE ,
64
+ CREATE_FILE ( 8 ) ,
65
65
/**
66
66
* Used for LOAD DATA INFILE statements as of MySQL 4.0.
67
67
*/
68
- APPEND_BLOCK ,
68
+ APPEND_BLOCK ( 9 ) ,
69
69
/**
70
70
* Used for LOAD DATA INFILE statements in 4.0 and 4.1.
71
71
*/
72
- EXEC_LOAD ,
72
+ EXEC_LOAD ( 10 ) ,
73
73
/**
74
74
* Used for LOAD DATA INFILE statements as of MySQL 4.0.
75
75
*/
76
- DELETE_FILE ,
76
+ DELETE_FILE ( 11 ) ,
77
77
/**
78
78
* Used for LOAD DATA INFILE statements in MySQL 4.0 and 4.1.
79
79
*/
80
- NEW_LOAD ,
80
+ NEW_LOAD ( 12 ) ,
81
81
/**
82
82
* Written every time a statement uses the RAND() function; precedes other events for the statement. Indicates the
83
83
* seed values to use for generating a random number with RAND() in the next statement. This is written only
84
84
* before a {@link #QUERY} and is not used in case of RBR.
85
85
*/
86
- RAND ,
86
+ RAND ( 13 ) ,
87
87
/**
88
88
* Written every time a statement uses a user variable; precedes other events for the statement. Indicates the
89
89
* value to use for the user variable in the next statement. This is written only before a {@link #QUERY} and
90
90
* is not used in case of RBR.
91
91
*/
92
- USER_VAR ,
92
+ USER_VAR ( 14 ) ,
93
93
/**
94
94
* A descriptor event that is written to the beginning of the each binary log file.
95
95
* This event is used as of MySQL 5.0; it supersedes {@link #START_V3}.
96
96
*/
97
- FORMAT_DESCRIPTION ,
97
+ FORMAT_DESCRIPTION ( 15 ) ,
98
98
/**
99
99
* Generated for a commit of a transaction that modifies one or more tables of an XA-capable storage engine.
100
100
* Normal transactions are implemented by sending a {@link #QUERY} containing a BEGIN statement and a {@link #QUERY}
101
101
* containing a COMMIT statement (or a ROLLBACK statement if the transaction is rolled back).
102
102
*/
103
- XID ,
103
+ XID ( 16 ) ,
104
104
/**
105
105
* Used for LOAD DATA INFILE statements as of MySQL 5.0.
106
106
*/
107
- BEGIN_LOAD_QUERY ,
107
+ BEGIN_LOAD_QUERY ( 17 ) ,
108
108
/**
109
109
* Used for LOAD DATA INFILE statements as of MySQL 5.0.
110
110
*/
111
- EXECUTE_LOAD_QUERY ,
111
+ EXECUTE_LOAD_QUERY ( 18 ) ,
112
112
/**
113
113
* This event precedes each row operation event. It maps a table definition to a number, where the table definition
114
114
* consists of database and table names and column definitions. The purpose of this event is to enable replication
@@ -117,82 +117,93 @@ public enum EventType {
117
117
* of TABLE_MAP events: one per table used by events in the sequence.
118
118
* Used in case of RBR.
119
119
*/
120
- TABLE_MAP ,
120
+ TABLE_MAP ( 19 ) ,
121
121
/**
122
122
* Describes inserted rows (within a single table).
123
123
* Used in case of RBR (5.1.0 - 5.1.15).
124
124
*/
125
- PRE_GA_WRITE_ROWS ,
125
+ PRE_GA_WRITE_ROWS ( 20 ) ,
126
126
/**
127
127
* Describes updated rows (within a single table).
128
128
* Used in case of RBR (5.1.0 - 5.1.15).
129
129
*/
130
- PRE_GA_UPDATE_ROWS ,
130
+ PRE_GA_UPDATE_ROWS ( 21 ) ,
131
131
/**
132
132
* Describes deleted rows (within a single table).
133
133
* Used in case of RBR (5.1.0 - 5.1.15).
134
134
*/
135
- PRE_GA_DELETE_ROWS ,
135
+ PRE_GA_DELETE_ROWS ( 22 ) ,
136
136
/**
137
137
* Describes inserted rows (within a single table).
138
138
* Used in case of RBR (5.1.16 - mysql-trunk).
139
139
*/
140
- WRITE_ROWS ,
140
+ WRITE_ROWS ( 23 ) ,
141
141
/**
142
142
* Describes updated rows (within a single table).
143
143
* Used in case of RBR (5.1.16 - mysql-trunk).
144
144
*/
145
- UPDATE_ROWS ,
145
+ UPDATE_ROWS ( 24 ) ,
146
146
/**
147
147
* Describes deleted rows (within a single table).
148
148
* Used in case of RBR (5.1.16 - mysql-trunk).
149
149
*/
150
- DELETE_ROWS ,
150
+ DELETE_ROWS ( 25 ) ,
151
151
/**
152
152
* Used to log an out of the ordinary event that occurred on the master. It notifies the slave that something
153
153
* happened on the master that might cause data to be in an inconsistent state.
154
154
*/
155
- INCIDENT ,
155
+ INCIDENT ( 26 ) ,
156
156
/**
157
157
* Sent by a master to a slave to let the slave know that the master is still alive. Not written to a binary log.
158
158
*/
159
- HEARTBEAT ,
159
+ HEARTBEAT ( 27 ) ,
160
160
/**
161
161
* In some situations, it is necessary to send over ignorable data to the slave: data that a slave can handle in
162
162
* case there is code for handling it, but which can be ignored if it is not recognized.
163
163
*/
164
- IGNORABLE ,
164
+ IGNORABLE ( 28 ) ,
165
165
/**
166
166
* Introduced to record the original query for rows events in RBR.
167
167
*/
168
- ROWS_QUERY ,
168
+ ROWS_QUERY ( 29 ) ,
169
169
/**
170
170
* Describes inserted rows (within a single table).
171
171
* Used in case of RBR (5.1.18+).
172
172
*/
173
- EXT_WRITE_ROWS ,
173
+ EXT_WRITE_ROWS ( 30 ) ,
174
174
/**
175
175
* Describes updated rows (within a single table).
176
176
* Used in case of RBR (5.1.18+).
177
177
*/
178
- EXT_UPDATE_ROWS ,
178
+ EXT_UPDATE_ROWS ( 31 ) ,
179
179
/**
180
180
* Describes deleted rows (within a single table).
181
181
* Used in case of RBR (5.1.18+).
182
182
*/
183
- EXT_DELETE_ROWS ,
183
+ EXT_DELETE_ROWS ( 32 ) ,
184
184
/**
185
185
* Global Transaction Identifier.
186
186
*/
187
- GTID ,
188
- ANONYMOUS_GTID ,
189
- PREVIOUS_GTIDS ,
190
- TRANSACTION_CONTEXT ,
191
- VIEW_CHANGE ,
187
+ GTID (33 ),
188
+ ANONYMOUS_GTID (34 ),
189
+ PREVIOUS_GTIDS (35 ),
190
+ TRANSACTION_CONTEXT (36 ),
191
+ VIEW_CHANGE (37 ),
192
+
192
193
/**
193
194
* Prepared XA transaction terminal event similar to XID except that it is specific to XA transaction.
194
195
*/
195
- XA_PREPARE ;
196
+ XA_PREPARE (38 ),
197
+
198
+ /**
199
+ * MariaDB Events
200
+ */
201
+
202
+ ANNOTATE_ROWS (160 ),
203
+ BINLOG_CHECKPOINT (161 ),
204
+ MARIADB_GTID (162 ),
205
+ MARIADB_GTID_LIST (163 ),
206
+ START_ENCRYPTION (164 );
196
207
197
208
public static boolean isRowMutation (EventType eventType ) {
198
209
return EventType .isWrite (eventType ) ||
@@ -218,4 +229,30 @@ public static boolean isDelete(EventType eventType) {
218
229
eventType == EXT_DELETE_ROWS ;
219
230
}
220
231
232
+ private final int eventNumber ;
233
+ private static EventType [] typesByEventNumber ;
234
+
235
+ public int getEventNumber () {
236
+ return eventNumber ;
237
+ }
238
+
239
+ private static void setEvent (int eventNumber , EventType t ) {
240
+ if (typesByEventNumber == null ) {
241
+ typesByEventNumber = new EventType [256 ];
242
+ }
243
+ if (typesByEventNumber [eventNumber ] != null ) {
244
+ throw new IllegalArgumentException ("duplicate event number: " + eventNumber );
245
+ }
246
+ typesByEventNumber [eventNumber ] = t ;
247
+ }
248
+
249
+ private EventType (int eventNumber ) {
250
+ this .eventNumber = eventNumber ;
251
+ setEvent (eventNumber ,this );
252
+ }
253
+
254
+ public static EventType byEventNumber (int eventNumber ) {
255
+ return typesByEventNumber [eventNumber ];
256
+ }
257
+
221
258
}
0 commit comments