@@ -54,7 +54,18 @@ def _dump(self):
54
54
pass
55
55
56
56
class GtidEvent (BinLogEvent ):
57
- """GTID change in binlog event
57
+ """
58
+ GTID change in binlog event
59
+
60
+ For more information: `[GTID] <https://mariadb.com/kb/en/gtid/>`_ `[see also] <https://dev.mysql.com/doc/dev/mysql-server/latest/classbinary__log_1_1Gtid__event.html>`_
61
+
62
+ :ivar commit_flag: 1byte - 00000001 = Transaction may have changes logged with SBR.
63
+ In 5.6, 5.7.0-5.7.18, and 8.0.0-8.0.1, this flag is always set. Starting in 5.7.19 and 8.0.2, this flag is cleared if the transaction only contains row events. It is set if any part of the transaction is written in statement format.
64
+ :ivar sid: 16 byte sequence - UUID representing the SID
65
+ :ivar gno: int - Group number, second component of GTID.
66
+ :ivar lt_type: int(1 byte) - The type of logical timestamp used in the logical clock fields.
67
+ :ivar last_committed: Store the transaction's commit parent sequence_number
68
+ :ivar sequence_number: The transaction's logical timestamp assigned at prepare phase
58
69
"""
59
70
def __init__ (self , from_packet , event_size , table_map , ctl_connection , ** kwargs ):
60
71
super ().__init__ (from_packet , event_size , table_map ,
@@ -71,7 +82,8 @@ def __init__(self, from_packet, event_size, table_map, ctl_connection, **kwargs)
71
82
72
83
@property
73
84
def gtid (self ):
74
- """GTID = source_id:transaction_id
85
+ """
86
+ GTID = source_id:transaction_id
75
87
Eg: 3E11FA47-71CA-11E1-9E33-C80AA9429562:23
76
88
See: http://dev.mysql.com/doc/refman/5.6/en/replication-gtids-concepts.html"""
77
89
nibbles = binascii .hexlify (self .sid ).decode ('ascii' )
@@ -93,8 +105,15 @@ def __repr__(self):
93
105
94
106
class MariadbGtidEvent (BinLogEvent ):
95
107
"""
96
- GTID change in binlog event in MariaDB
97
- https://mariadb.com/kb/en/gtid_event/
108
+ GTID(Global Transaction Identifier) change in binlog event in MariaDB
109
+
110
+ For more information: `[see details] <https://mariadb.com/kb/en/gtid_event/>`_.
111
+
112
+ :ivar server_id: int - The ID of the server where the GTID event occurred.
113
+ :ivar gtid_seq_no: int - The sequence number of the GTID event.
114
+ :ivar domain_id: int - The domain ID associated with the GTID event.
115
+ :ivar flags: int - Flags related to the GTID event.
116
+ :ivar gtid: str - The Global Transaction Identifier in the format ‘domain_id-server_id-gtid_seq_no’.
98
117
"""
99
118
def __init__ (self , from_packet , event_size , table_map , ctl_connection , ** kwargs ):
100
119
@@ -118,7 +137,7 @@ class MariadbBinLogCheckPointEvent(BinLogEvent):
118
137
More details are available in the MariaDB Knowledge Base:
119
138
https://mariadb.com/kb/en/binlog_checkpoint_event/
120
139
121
- :ivar filename_length: int - The length of the filename.
140
+ :ivar filename_length: int - The length of the filename.
122
141
:ivar filename: str - The name of the file saved at the checkpoint.
123
142
"""
124
143
@@ -137,8 +156,7 @@ class MariadbAnnotateRowsEvent(BinLogEvent):
137
156
If you want to check this binlog, change the value of the flag(line 382 of the 'binlogstream.py') option to 2
138
157
https://mariadb.com/kb/en/annotate_rows_event/
139
158
140
- Attributes:
141
- sql_statement: The SQL statement
159
+ :ivar sql_statement: str - The SQL statement
142
160
"""
143
161
def __init__ (self , from_packet , event_size , table_map , ctl_connection , ** kwargs ):
144
162
super ().__init__ (from_packet , event_size , table_map , ctl_connection , ** kwargs )
@@ -153,15 +171,14 @@ class MariadbGtidListEvent(BinLogEvent):
153
171
GTID List event
154
172
https://mariadb.com/kb/en/gtid_list_event/
155
173
156
- Attributes:
157
- gtid_length: Number of GTIDs
158
- gtid_list: list of 'MariadbGtidObejct'
174
+ :ivar gtid_length: int - Number of GTIDs
175
+ :ivar gtid_list: list - list of 'MariadbGtidObejct'
159
176
160
- 'MariadbGtidObejct' Attributes:
161
- domain_id: Replication Domain ID
162
- server_id: Server_ID
163
- gtid_seq_no: GTID sequence
164
- gtid: 'domain_id'+ 'server_id' + 'gtid_seq_no'
177
+ 'MariadbGtidObejct' Attributes:
178
+ domain_id: Replication Domain ID
179
+ server_id: Server_ID
180
+ gtid_seq_no: GTID sequence
181
+ gtid: 'domain_id'+ 'server_id' + 'gtid_seq_no'
165
182
"""
166
183
def __init__ (self , from_packet , event_size , table_map , ctl_connection , ** kwargs ):
167
184
@@ -184,11 +201,14 @@ def __init__(self, from_packet, event_size, table_map, ctl_connection, **kwargs)
184
201
185
202
186
203
class RotateEvent (BinLogEvent ):
187
- """Change MySQL bin log file
204
+ """
205
+ Change MySQL bin log file
206
+ Represents information for the slave to know the name of the binary log it is going to receive.
188
207
189
- Attributes:
190
- position: Position inside next binlog
191
- next_binlog: Name of next binlog file
208
+ For more information: `[see details] <https://dev.mysql.com/doc/dev/mysql-server/latest/classbinary__log_1_1Rotate__event.html>`_.
209
+
210
+ :ivar position: int - Position inside next binlog
211
+ :ivar next_binlog: str - Name of next binlog file
192
212
"""
193
213
def __init__ (self , from_packet , event_size , table_map , ctl_connection , ** kwargs ):
194
214
super ().__init__ (from_packet , event_size , table_map ,
@@ -204,12 +224,15 @@ def dump(self):
204
224
205
225
206
226
class XAPrepareEvent (BinLogEvent ):
207
- """An XA prepare event is generated for a XA prepared transaction.
208
- Like Xid_event it contains XID of the *prepared* transaction
209
-
210
- Attributes:
211
- one_phase: current XA transaction commit method
212
- xid: serialized XID representation of XA transaction
227
+ """
228
+ An XA prepare event is generated for a XA prepared transaction.
229
+ Like Xid_event, it contains XID of the **prepared** transaction.
230
+
231
+ For more information: `[see details] <https://dev.mysql.com/doc/refman/8.0/en/xa-statements.html>`_.
232
+
233
+ :ivar one_phase: current XA transaction commit method
234
+ :ivar xid_format_id: a number that identifies the format used by the gtrid and bqual values
235
+ :ivar xid: serialized XID representation of XA transaction (xid_gtrid + xid_bqual)
213
236
"""
214
237
def __init__ (self , from_packet , event_size , table_map , ctl_connection , ** kwargs ):
215
238
super ().__init__ (from_packet , event_size , table_map ,
@@ -235,6 +258,16 @@ def _dump(self):
235
258
236
259
237
260
class FormatDescriptionEvent (BinLogEvent ):
261
+ """
262
+ Represents a Format Description Event in the MySQL binary log.
263
+
264
+ This event is written at the start of a binary log file for binlog version 4.
265
+ It provides the necessary information to decode subsequent events in the file.
266
+
267
+ :ivar binlog_version: int - Version of the binary log format.
268
+ :ivar mysql_version_str: str - Server's MySQL version in string format.
269
+ """
270
+
238
271
def __init__ (self , from_packet , event_size , table_map , ctl_connection , ** kwargs ):
239
272
super ().__init__ (from_packet , event_size , table_map ,
240
273
ctl_connection , ** kwargs )
@@ -253,10 +286,12 @@ class StopEvent(BinLogEvent):
253
286
254
287
255
288
class XidEvent (BinLogEvent ):
256
- """A COMMIT event
289
+ """
290
+ A COMMIT event generated when COMMIT of a transaction that modifies one or more tables of an XA-capable storage engine occurs.
257
291
258
- Attributes:
259
- xid: Transaction ID for 2PC
292
+ For more information: `[see details] <https://mariadb.com/kb/en/xid_event/>`_.
293
+
294
+ :ivar xid: uint - Transaction ID for 2 Phase Commit.
260
295
"""
261
296
262
297
def __init__ (self , from_packet , event_size , table_map , ctl_connection , ** kwargs ):
@@ -271,22 +306,26 @@ def _dump(self):
271
306
272
307
class HeartbeatLogEvent (BinLogEvent ):
273
308
"""A Heartbeat event
274
- Heartbeats are sent by the master only if there are no unsent events in the
275
- binary log file for a period longer than the interval defined by
276
- MASTER_HEARTBEAT_PERIOD connection setting.
277
-
278
- A mysql server will also play those to the slave for each skipped
279
- events in the log. I (baloo) believe the intention is to make the slave
280
- bump its position so that if a disconnection occurs, the slave only
281
- reconnects from the last skipped position (see Binlog_sender::send_events
282
- in sql/rpl_binlog_sender.cc). That makes 106 bytes of data for skipped
283
- event in the binlog. *this is also the case with GTID replication*. To
284
- mitigate such behavior, you are expected to keep the binlog small (see
285
- max_binlog_size, defaults to 1G).
286
- In any case, the timestamp is 0 (as in 1970-01-01T00:00:00).
309
+ Heartbeats are sent by the master.
310
+ Master sends heartbeats when there are no unsent events in the binary log file after certain period of time.
311
+ The interval is defined by MASTER_HEARTBEAT_PERIOD connection setting.
287
312
288
- Attributes:
289
- ident: Name of the current binlog
313
+ `[see MASTER_HEARTBEAT_PERIOD] <https://dev.mysql.com/doc/refman/8.0/en/change-master-to.html>`_.
314
+
315
+ A Mysql server also does it for each skipped events in the log.
316
+ This is because to make the slave bump its position so that
317
+ if a disconnection occurs, the slave will only reconnects from the lasted skipped position. (Baloo's idea)
318
+
319
+ (see Binlog_sender::send_events in sql/rpl_binlog_sender.cc)
320
+
321
+ Warning:
322
+ That makes 106 bytes of data for skipped event in the binlog.
323
+ *this is also the case with GTID replication*.
324
+ To mitigate such behavior, you are expected to keep the binlog small
325
+ (see max_binlog_size, defaults to 1G).
326
+ In any case, the timestamp is 0 (as in 1970-01-01T00:00:00).
327
+
328
+ :ivar ident: Name of the current binlog
290
329
"""
291
330
292
331
def __init__ (self , from_packet , event_size , table_map , ctl_connection , ** kwargs ):
@@ -301,8 +340,19 @@ def _dump(self):
301
340
302
341
303
342
class QueryEvent (BinLogEvent ):
304
- '''This event is trigger when a query is run of the database.
305
- Only replicated queries are logged.'''
343
+ """
344
+ QueryEvent is generated for each query that modified database.
345
+ If row-based replication is used, DML will not be logged as RowsEvent instead.
346
+
347
+ :ivar slave_proxy_id: int - The id of the thread that issued this statement on the master server
348
+ :ivar execution_time: int - The time from when the query started to when it was logged in the binlog, in seconds.
349
+ :ivar schema_length: int - The length of the name of the currently selected database.
350
+ :ivar error_code: int - Error code generated by the master
351
+ :ivar status_vars_length: int - The length of the status variable
352
+
353
+ :ivar schema: str - The name of the currently selected database.
354
+ :ivar query: str - The query executed.
355
+ """
306
356
def __init__ (self , from_packet , event_size , table_map , ctl_connection , ** kwargs ):
307
357
super ().__init__ (from_packet , event_size , table_map ,
308
358
ctl_connection , ** kwargs )
@@ -343,8 +393,7 @@ def _read_status_vars_value_for_key(self, key):
343
393
Parsing logic from mysql-server source code edited by dongwook-chan
344
394
https://github.com/mysql/mysql-server/blob/beb865a960b9a8a16cf999c323e46c5b0c67f21f/libbinlogevents/src/statement_events.cpp#L181-L336
345
395
346
- Args:
347
- key: key for status variable
396
+ :ivar key: key for status variable
348
397
"""
349
398
if key == Q_FLAGS2_CODE : # 0x00
350
399
self .flags2 = self .packet .read_uint32 ()
@@ -425,10 +474,11 @@ def _read_status_vars_value_for_key(self, key):
425
474
426
475
class BeginLoadQueryEvent (BinLogEvent ):
427
476
"""
477
+ This event is written into the binary log file for LOAD DATA INFILE events
478
+ if the server variable binlog_mode was set to "STATEMENT".
428
479
429
- Attributes:
430
- file_id
431
- block-data
480
+ :ivar file_id: the id of the file
481
+ :ivar block-data: data block about "LOAD DATA INFILE"
432
482
"""
433
483
def __init__ (self , from_packet , event_size , table_map , ctl_connection , ** kwargs ):
434
484
super ().__init__ (from_packet , event_size , table_map ,
@@ -446,18 +496,20 @@ def _dump(self):
446
496
447
497
class ExecuteLoadQueryEvent (BinLogEvent ):
448
498
"""
449
-
450
- Attributes:
451
- slave_proxy_id
452
- execution_time
453
- schema_length
454
- error_code
455
- status_vars_length
456
-
457
- file_id
458
- start_pos
459
- end_pos
460
- dup_handling_flags
499
+ This event handles "LOAD DATA INFILE" statement.
500
+ LOAD DATA INFILE statement reads data from file and insert into database's table.
501
+ Since QueryEvent cannot explain this special action, ExecuteLoadQueryEvent is needed.
502
+ So it is similar to a QUERY_EVENT except that it has extra static fields.
503
+
504
+ :ivar slave_proxy_id: int - The id of the thread that issued this statement on the master server
505
+ :ivar execution_time: int - The number of seconds that the statement took to execute
506
+ :ivar schema_length: int - The length of the default database's name when the statement was executed.
507
+ :ivar error_code: int - The error code resulting from execution of the statement on the master
508
+ :ivar status_vars_length: int - The length of the status variable block
509
+ :ivar file_id: int - The id of the loaded file
510
+ :ivar start_pos: int - Offset from the start of the statement to the beginning of the filename
511
+ :ivar end_pos: int - Offset from the start of the statement to the end of the filename
512
+ :ivar dup_handling_flags: int - How LOAD DATA INFILE handles duplicated data (0x0: error, 0x1: ignore, 0x2: replace)
461
513
"""
462
514
def __init__ (self , from_packet , event_size , table_map , ctl_connection , ** kwargs ):
463
515
super ().__init__ (from_packet , event_size , table_map ,
@@ -491,10 +543,12 @@ def _dump(self):
491
543
492
544
class IntvarEvent (BinLogEvent ):
493
545
"""
494
-
495
- Attributes:
496
- type
497
- value
546
+ Stores the value of auto-increment variables.
547
+ This event will be created just before a QueryEvent.
548
+
549
+ :ivar type: int - 1 byte identifying the type of variable stored.
550
+ Can be either LAST_INSERT_ID_EVENT (1) or INSERT_ID_EVENT (2).
551
+ :ivar value: int - The value of the variable
498
552
"""
499
553
def __init__ (self , from_packet , event_size , table_map , ctl_connection , ** kwargs ):
500
554
super ().__init__ (from_packet , event_size , table_map ,
@@ -738,6 +792,11 @@ def dump(self):
738
792
739
793
740
794
class NotImplementedEvent (BinLogEvent ):
795
+ """
796
+ Used as a temporary class for events that have not yet been implemented.
797
+
798
+ The event referencing this class skips parsing.
799
+ """
741
800
def __init__ (self , from_packet , event_size , table_map , ctl_connection , ** kwargs ):
742
801
super ().__init__ (
743
802
from_packet , event_size , table_map , ctl_connection , ** kwargs )
0 commit comments