@@ -25,90 +25,90 @@ public enum EventType {
2525 /**
2626 * Events of this event type should never occur. Not written to a binary log.
2727 */
28- UNKNOWN ,
28+ UNKNOWN ( 0 ) ,
2929 /**
3030 * A descriptor event that is written to the beginning of the each binary log file. (In MySQL 4.0 and 4.1,
3131 * this event is written only to the first binary log file that the server creates after startup.) This event is
3232 * used in MySQL 3.23 through 4.1 and superseded in MySQL 5.0 by {@link #FORMAT_DESCRIPTION}.
3333 */
34- START_V3 ,
34+ START_V3 ( 1 ) ,
3535 /**
3636 * Written when an updating statement is done.
3737 */
38- QUERY ,
38+ QUERY ( 2 ) ,
3939 /**
4040 * Written when mysqld stops.
4141 */
42- STOP ,
42+ STOP ( 3 ) ,
4343 /**
4444 * Written when mysqld switches to a new binary log file. This occurs when someone issues a FLUSH LOGS statement or
4545 * the current binary log file becomes larger than max_binlog_size.
4646 */
47- ROTATE ,
47+ ROTATE ( 4 ) ,
4848 /**
4949 * Written every time a statement uses an AUTO_INCREMENT column or the LAST_INSERT_ID() function; precedes other
5050 * events for the statement. This is written only before a {@link #QUERY} and is not used in case of RBR.
5151 */
52- INTVAR ,
52+ INTVAR ( 5 ) ,
5353 /**
5454 * Used for LOAD DATA INFILE statements in MySQL 3.23.
5555 */
56- LOAD ,
56+ LOAD ( 6 ) ,
5757 /**
5858 * Not used.
5959 */
60- SLAVE ,
60+ SLAVE ( 7 ) ,
6161 /**
6262 * Used for LOAD DATA INFILE statements in MySQL 4.0 and 4.1.
6363 */
64- CREATE_FILE ,
64+ CREATE_FILE ( 8 ) ,
6565 /**
6666 * Used for LOAD DATA INFILE statements as of MySQL 4.0.
6767 */
68- APPEND_BLOCK ,
68+ APPEND_BLOCK ( 9 ) ,
6969 /**
7070 * Used for LOAD DATA INFILE statements in 4.0 and 4.1.
7171 */
72- EXEC_LOAD ,
72+ EXEC_LOAD ( 10 ) ,
7373 /**
7474 * Used for LOAD DATA INFILE statements as of MySQL 4.0.
7575 */
76- DELETE_FILE ,
76+ DELETE_FILE ( 11 ) ,
7777 /**
7878 * Used for LOAD DATA INFILE statements in MySQL 4.0 and 4.1.
7979 */
80- NEW_LOAD ,
80+ NEW_LOAD ( 12 ) ,
8181 /**
8282 * Written every time a statement uses the RAND() function; precedes other events for the statement. Indicates the
8383 * seed values to use for generating a random number with RAND() in the next statement. This is written only
8484 * before a {@link #QUERY} and is not used in case of RBR.
8585 */
86- RAND ,
86+ RAND ( 13 ) ,
8787 /**
8888 * Written every time a statement uses a user variable; precedes other events for the statement. Indicates the
8989 * value to use for the user variable in the next statement. This is written only before a {@link #QUERY} and
9090 * is not used in case of RBR.
9191 */
92- USER_VAR ,
92+ USER_VAR ( 14 ) ,
9393 /**
9494 * A descriptor event that is written to the beginning of the each binary log file.
9595 * This event is used as of MySQL 5.0; it supersedes {@link #START_V3}.
9696 */
97- FORMAT_DESCRIPTION ,
97+ FORMAT_DESCRIPTION ( 15 ) ,
9898 /**
9999 * Generated for a commit of a transaction that modifies one or more tables of an XA-capable storage engine.
100100 * Normal transactions are implemented by sending a {@link #QUERY} containing a BEGIN statement and a {@link #QUERY}
101101 * containing a COMMIT statement (or a ROLLBACK statement if the transaction is rolled back).
102102 */
103- XID ,
103+ XID ( 16 ) ,
104104 /**
105105 * Used for LOAD DATA INFILE statements as of MySQL 5.0.
106106 */
107- BEGIN_LOAD_QUERY ,
107+ BEGIN_LOAD_QUERY ( 17 ) ,
108108 /**
109109 * Used for LOAD DATA INFILE statements as of MySQL 5.0.
110110 */
111- EXECUTE_LOAD_QUERY ,
111+ EXECUTE_LOAD_QUERY ( 18 ) ,
112112 /**
113113 * This event precedes each row operation event. It maps a table definition to a number, where the table definition
114114 * 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 {
117117 * of TABLE_MAP events: one per table used by events in the sequence.
118118 * Used in case of RBR.
119119 */
120- TABLE_MAP ,
120+ TABLE_MAP ( 19 ) ,
121121 /**
122122 * Describes inserted rows (within a single table).
123123 * Used in case of RBR (5.1.0 - 5.1.15).
124124 */
125- PRE_GA_WRITE_ROWS ,
125+ PRE_GA_WRITE_ROWS ( 20 ) ,
126126 /**
127127 * Describes updated rows (within a single table).
128128 * Used in case of RBR (5.1.0 - 5.1.15).
129129 */
130- PRE_GA_UPDATE_ROWS ,
130+ PRE_GA_UPDATE_ROWS ( 21 ) ,
131131 /**
132132 * Describes deleted rows (within a single table).
133133 * Used in case of RBR (5.1.0 - 5.1.15).
134134 */
135- PRE_GA_DELETE_ROWS ,
135+ PRE_GA_DELETE_ROWS ( 22 ) ,
136136 /**
137137 * Describes inserted rows (within a single table).
138138 * Used in case of RBR (5.1.16 - mysql-trunk).
139139 */
140- WRITE_ROWS ,
140+ WRITE_ROWS ( 23 ) ,
141141 /**
142142 * Describes updated rows (within a single table).
143143 * Used in case of RBR (5.1.16 - mysql-trunk).
144144 */
145- UPDATE_ROWS ,
145+ UPDATE_ROWS ( 24 ) ,
146146 /**
147147 * Describes deleted rows (within a single table).
148148 * Used in case of RBR (5.1.16 - mysql-trunk).
149149 */
150- DELETE_ROWS ,
150+ DELETE_ROWS ( 25 ) ,
151151 /**
152152 * Used to log an out of the ordinary event that occurred on the master. It notifies the slave that something
153153 * happened on the master that might cause data to be in an inconsistent state.
154154 */
155- INCIDENT ,
155+ INCIDENT ( 26 ) ,
156156 /**
157157 * Sent by a master to a slave to let the slave know that the master is still alive. Not written to a binary log.
158158 */
159- HEARTBEAT ,
159+ HEARTBEAT ( 27 ) ,
160160 /**
161161 * In some situations, it is necessary to send over ignorable data to the slave: data that a slave can handle in
162162 * case there is code for handling it, but which can be ignored if it is not recognized.
163163 */
164- IGNORABLE ,
164+ IGNORABLE ( 28 ) ,
165165 /**
166166 * Introduced to record the original query for rows events in RBR.
167167 */
168- ROWS_QUERY ,
168+ ROWS_QUERY ( 29 ) ,
169169 /**
170170 * Describes inserted rows (within a single table).
171171 * Used in case of RBR (5.1.18+).
172172 */
173- EXT_WRITE_ROWS ,
173+ EXT_WRITE_ROWS ( 30 ) ,
174174 /**
175175 * Describes updated rows (within a single table).
176176 * Used in case of RBR (5.1.18+).
177177 */
178- EXT_UPDATE_ROWS ,
178+ EXT_UPDATE_ROWS ( 31 ) ,
179179 /**
180180 * Describes deleted rows (within a single table).
181181 * Used in case of RBR (5.1.18+).
182182 */
183- EXT_DELETE_ROWS ,
183+ EXT_DELETE_ROWS ( 32 ) ,
184184 /**
185185 * Global Transaction Identifier.
186186 */
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+
192193 /**
193194 * Prepared XA transaction terminal event similar to XID except that it is specific to XA transaction.
194195 */
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 );
196207
197208 public static boolean isRowMutation (EventType eventType ) {
198209 return EventType .isWrite (eventType ) ||
@@ -218,4 +229,30 @@ public static boolean isDelete(EventType eventType) {
218229 eventType == EXT_DELETE_ROWS ;
219230 }
220231
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+
221258}
0 commit comments