Skip to content

Commit

Permalink
get dbms from ctl_connection in BinLogEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
roy0424 committed Dec 4, 2023
1 parent c8f83fe commit 59202a2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions pymysqlreplication/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(
self._processed = True
self.complete = True
self._verify_event()
self.dbms = None
self.dbms = self._ctl_connection._get_dbms()

def _read_table_id(self):
# Table ID is 6 byte
Expand Down Expand Up @@ -105,7 +105,7 @@ def __init__(self, from_packet, event_size, table_map, ctl_connection, **kwargs)
self.gno = struct.unpack("<Q", self.packet.read(8))[0]
self.lt_type = self.packet.read(1)[0]

if self.dbms == "mysql" and self.mysql_version >= (5, 7):
if self.mysql_version >= (5, 7):
self.last_committed = struct.unpack("<Q", self.packet.read(8))[0]
self.sequence_number = struct.unpack("<Q", self.packet.read(8))[0]

Expand Down Expand Up @@ -368,10 +368,6 @@ def __init__(self, from_packet, event_size, table_map, ctl_connection, **kwargs)
self.binlog_version = struct.unpack("<H", self.packet.read(2))
self.mysql_version_str = self.packet.read(50).rstrip(b"\0").decode()
numbers = self.mysql_version_str.split("-")[0]
if "MariaDB" in self.mysql_version_str:
self.dbms = "mariadb"
else:
self.dbms = "mysql"
self.mysql_version = tuple(map(int, numbers.split(".")))
self.created = struct.unpack("<I", self.packet.read(4))[0]
self.common_header_len = struct.unpack("<B", self.packet.read(1))[0]
Expand Down
2 changes: 1 addition & 1 deletion pymysqlreplication/row_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ def __init__(self, from_packet, event_size, table_map, ctl_connection, **kwargs)
self.column_count = self.packet.read_length_coded_binary()

self.columns = []
self.dbms = self._ctl_connection._get_dbms()
self.dbms = self.dbms or self._ctl_connection._get_dbms()
# Read columns meta data
column_types = bytearray(self.packet.read(self.column_count))
self.packet.read_length_coded_binary()
Expand Down

0 comments on commit 59202a2

Please sign in to comment.