6
6
import pymysql
7
7
import decimal
8
8
import zlib
9
- from pymysql .protocol import MysqlPacket
9
+ from pymysql .connection import MysqlPacket
10
10
from typing import Dict , List , NoReturn , Tuple , Type , Union
11
11
from pymysqlreplication .constants .STATUS_VAR_KEY import *
12
12
from pymysqlreplication .exceptions import StatusVariableMismatch
@@ -211,12 +211,7 @@ class MariadbAnnotateRowsEvent(BinLogEvent):
211
211
If you want to check this binlog, change the value of the flag(line 382 of the 'binlogstream.py') option to 2
212
212
https://mariadb.com/kb/en/annotate_rows_event/
213
213
214
- <<<<<<< HEAD
215
214
:ivar sql_statement: str - The SQL statement
216
- =======
217
- Attributes:
218
- sql_statement: str - The SQL statement
219
- >>>>>>> 8811fca (docs: add typing in MariadbGtidListEvent, MariadbAnnotateRowsEvent)
220
215
"""
221
216
def __init__ (self , from_packet , event_size , table_map , ctl_connection , ** kwargs ):
222
217
super ().__init__ (from_packet , event_size , table_map , ctl_connection , ** kwargs )
@@ -231,22 +226,11 @@ class MariadbGtidListEvent(BinLogEvent):
231
226
for more information: `[see MariadbGtidListEvent] <https://mariadb.com/kb/en/gtid_list_event/>`_
232
227
233
228
:ivar gtid_length: int - Number of GTIDs
234
- <<<<<<< HEAD
235
- :ivar gtid_list: list - list of 'MariadbGtidObejct'
236
-
237
- 'MariadbGtidObejct' Attributes:
238
- domain_id: Replication Domain ID
239
- server_id: Server_ID
240
- gtid_seq_no: GTID sequence
241
- gtid: 'domain_id'+ 'server_id' + 'gtid_seq_no'
242
- =======
243
229
:ivar gtid_list: List - list of 'MariadbGtidObejct'
244
-
245
230
:ivar domain_id: int - Replication Domain ID (MariadbGtidObject)
246
231
:ivar server_id: int -Server_ID (MariadbGtidObject)
247
232
:ivar gtid_seq_no: int - GTID sequence (MariadbGtidObject)
248
233
:ivar gtid: str - 'domain_id'+ 'server_id' + 'gtid_seq_no' (MariadbGtidObject)
249
- >>>>>>> 8811fca (docs: add typing in MariadbGtidListEvent, MariadbAnnotateRowsEvent)
250
234
"""
251
235
def __init__ (self , from_packet , event_size , table_map , ctl_connection , ** kwargs ):
252
236
@@ -270,15 +254,10 @@ def __init__(self, from_packet, event_size, table_map, ctl_connection, **kwargs)
270
254
271
255
class RotateEvent (BinLogEvent ):
272
256
"""
273
- <<<<<<< HEAD
274
257
Change MySQL bin log file
275
258
Represents information for the slave to know the name of the binary log it is going to receive.
276
- =======
277
- The event changes MySQL bin log file.
278
- It represents information for the slave to know the name of the binary log it is going to receive.
279
- >>>>>>> 07b561d (add type hints to the rest of the events, improve docstring readability in some events)
280
259
281
- For more information: `[see details ] <https://dev.mysql.com/doc/dev/mysql-server/latest/classbinary__log_1_1Rotate__event.html>`_.
260
+ For more information: `[see RotateEvent ] <https://dev.mysql.com/doc/dev/mysql-server/latest/classbinary__log_1_1Rotate__event.html>`_.
282
261
283
262
In detail, the class creates the following python objects in the constructor:
284
263
@@ -309,19 +288,12 @@ class XAPrepareEvent(BinLogEvent):
309
288
An XA prepare event is generated for a XA prepared transaction.
310
289
Like Xid_event, it contains XID of the **prepared** transaction.
311
290
312
- For more information: `[see details] <https://dev.mysql.com/doc/refman/8.0/en/xa-statements.html>`_.
313
-
314
- <<<<<<< HEAD
315
- :ivar one_phase: current XA transaction commit method
316
- :ivar xid_format_id: a number that identifies the format used by the gtrid and bqual values
317
- :ivar xid: serialized XID representation of XA transaction (xid_gtrid + xid_bqual)
318
- =======
319
- In detail, the class creates the following python objects in the constructor:
291
+ For more information: `[see XAPrepareEvent] <https://dev.mysql.com/doc/refman/8.0/en/xa-statements.html>`_.
320
292
321
293
:ivar one_phase: str - current XA transaction commit method
322
294
:ivar xid_format_id: int - a number that identifies the format used by the gtrid and bqual values
323
295
:ivar xid: str - serialized XID representation of XA transaction (xid_gtrid + xid_bqual)
324
- >>>>>>> 07b561d (add type hints to the rest of the events, improve docstring readability in some events)
296
+
325
297
"""
326
298
def __init__ (self ,
327
299
from_packet : Type [MysqlPacket ],
@@ -354,35 +326,14 @@ def _dump(self) -> None:
354
326
355
327
class FormatDescriptionEvent (BinLogEvent ):
356
328
"""
357
- <<<<<<< HEAD
358
- Represents a Format Description Event in the MySQL binary log.
329
+ The event Represents a Format Description Event in the MySQL binary log.
359
330
360
331
This event is written at the start of a binary log file for binlog version 4.
361
332
It provides the necessary information to decode subsequent events in the file.
362
333
363
334
:ivar binlog_version: int - Version of the binary log format.
364
335
:ivar mysql_version_str: str - Server's MySQL version in string format.
365
336
"""
366
-
367
- def __init__ (self , from_packet , event_size , table_map , ctl_connection , ** kwargs ):
368
- super ().__init__ (from_packet , event_size , table_map ,
369
- ctl_connection , ** kwargs )
370
- self .binlog_version = struct .unpack ('<H' , self .packet .read (2 ))
371
- self .mysql_version_str = self .packet .read (50 ).rstrip (b'\0 ' ).decode ()
372
- numbers = self .mysql_version_str .split ('-' )[0 ]
373
- self .mysql_version = tuple (map (int , numbers .split ('.' )))
374
- == == == =
375
- The event represents a Format Description Event in the MySQL binary log .
376
-
377
- This event is written at the start of a binary log file for binlog version 4.
378
- It provides the necessary information to decode subsequent events in the file .
379
-
380
- In detail , the class creates the following python objects in the constructor :
381
- >> >> >> > 07 b561d (add type hints to the rest of the events , improve docstring readability in some events )
382
-
383
- :ivar binlog_version : str - Version of the binary log format
384
- :ivar mysql_version_str : str - Server 's MySQL version in string format
385
- """
386
337
def __init__ (self ,
387
338
from_packet : Type [MysqlPacket ],
388
339
event_size : int ,
@@ -407,24 +358,13 @@ class StopEvent(BinLogEvent):
407
358
408
359
409
360
class XidEvent (BinLogEvent ):
410
- <<<<<<< HEAD
411
- """
412
- A COMMIT event generated when COMMIT of a transaction that modifies one or more tables of an XA - capable storage engine occurs .
413
-
414
- For more information : `[see details] <https://mariadb.com/kb/en/xid_event/>` _ .
415
-
416
- :ivar xid : uint - Transaction ID for 2 Phase Commit .
417
- == == == =
418
- >> > >> > > 07 b561d (add type hints to the rest of the events , improve docstring readability in some events )
419
361
"""
420
- A COMMIT event is generated when COMMIT of a transaction that modifies
362
+ A COMMIT event generated when COMMIT of a transaction that modifies
421
363
one or more tables of an XA-capable storage engine occurs.
422
364
423
- For more information : `[see details ] <https://mariadb.com/kb/en/xid_event/>`_.
365
+ For more information: `[see XidEvent ] <https://mariadb.com/kb/en/xid_event/>`_.
424
366
425
- In detail, the class creates the following python objects in the constructor:
426
-
427
- :ivar xid: int - Transaction ID for 2 Phase Commit
367
+ :ivar xid: uint - Transaction ID for 2 Phase Commit.
428
368
"""
429
369
def __init__ (self ,
430
370
from_packet : Type [MysqlPacket ],
@@ -457,19 +397,11 @@ class HeartbeatLogEvent(BinLogEvent):
457
397
(see Binlog_sender::send_events in sql/rpl_binlog_sender.cc)
458
398
459
399
Warning:
460
- <<<<<<< HEAD
461
400
That makes 106 bytes of data for skipped event in the binlog.
462
401
*this is also the case with GTID replication*.
463
402
To mitigate such behavior, you are expected to keep the binlog small
464
403
(see max_binlog_size, defaults to 1G).
465
404
In any case, the timestamp is 0 (as in 1970-01-01T00:00:00).
466
- =======
467
- That makes 106 bytes of data for skipped event in the binlog.
468
- *this is also the case with GTID replication*.
469
- To mitigate such behavior, you are expected to keep the binlog small
470
- (see max_binlog_size, defaults to 1G).
471
- In any case, the timestamp is 0 (as in 1970-01-01T00:00:00).
472
- >>>>>>> 07b561d (add type hints to the rest of the events, improve docstring readability in some events)
473
405
474
406
In detail, the class creates the following python objects in the constructor:
475
407
@@ -532,15 +464,10 @@ def __init__(self,
532
464
self .schema : str = self .packet .read (self .schema_length )
533
465
self .packet .advance (1 )
534
466
535
- << << < << HEAD
467
+ #string[EOF] query
536
468
query = self .packet .read (event_size - 13 - self .status_vars_length
537
469
- self .schema_length - 1 )
538
- self .query = query .decode ("utf-8" , errors = 'backslashreplace' )
539
- == == == =
540
- self .query : str = self .packet .read (event_size - 13 - self .status_vars_length
541
- - self .schema_length - 1 ).decode ("utf-8" )
542
- >> >> > >> 07 b561d (add type hints to the rest of the events , improve docstring readability in some events )
543
- #string[EOF] query
470
+ self .query :str = query .decode ("utf-8" , errors = 'backslashreplace' )
544
471
545
472
def _dump (self ) -> None :
546
473
"""Dump the python objects for the event."""
@@ -605,11 +532,7 @@ def _read_status_vars_value_for_key(self, key: int) -> Union[None, NoReturn]:
605
532
elif key == Q_TIME_ZONE_CODE : # 0x05
606
533
time_zone_len = self .packet .read_uint8 ()
607
534
if time_zone_len :
608
- << < << < < HEAD
609
- self .time_zone = self .packet .read (time_zone_len )
610
- == == == =
611
535
self .time_zone : str = self .packet .read (time_zone_len )
612
- >> >> > >> 07 b561d (add type hints to the rest of the events , improve docstring readability in some events )
613
536
elif key == Q_CATALOG_NZ_CODE : # 0x06
614
537
catalog_len = self .packet .read_uint8 ()
615
538
if catalog_len :
@@ -756,19 +679,11 @@ def _dump(self) -> None:
756
679
757
680
class IntvarEvent (BinLogEvent ):
758
681
"""
759
- <<<<<<< HEAD
760
682
Stores the value of auto-increment variables.
761
683
This event will be created just before a QueryEvent.
762
684
763
685
:ivar type: int - 1 byte identifying the type of variable stored.
764
- =======
765
- The event stores the value of auto-increment variables.
766
- It will be created just before a QueryEvent.
767
-
768
- In detail, the class creates the following python objects in the constructor:
769
-
770
- :ivar type: int - 1 byte identifying the type of variable stored. \
771
- >>>>>>> 07b561d (add type hints to the rest of the events, improve docstring readability in some events)
686
+
772
687
Can be either LAST_INSERT_ID_EVENT (1) or INSERT_ID_EVENT (2).
773
688
:ivar value: int - The value of the variable
774
689
"""
@@ -804,11 +719,7 @@ class RandEvent(BinLogEvent):
804
719
:ivar seed1: int - value for the first seed
805
720
:ivar seed2: int - value for the second seed
806
721
"""
807
- << < << << HEAD
808
- def __init__ (self , from_packet , event_size , table_map , ctl_connection , ** kwargs ):
809
- super ().__init__ (from_packet , event_size , table_map ,
810
- ctl_connection , ** kwargs )
811
- == == == =
722
+
812
723
def __init__ (self ,
813
724
from_packet : Type [MysqlPacket ],
814
725
event_size : int ,
@@ -817,7 +728,6 @@ def __init__(self,
817
728
** kwargs : str ):
818
729
super ().__init__ (from_packet , event_size , table_map , ctl_connection , ** kwargs )
819
730
820
- >> > >> >> 07 b561d (add type hints to the rest of the events , improve docstring readability in some events )
821
731
# Payload
822
732
self ._seed1 : int = self .packet .read_uint64 ()
823
733
self ._seed2 : int = self .packet .read_uint64 ()
0 commit comments