From cad84ca2bfc3c89a95090946b2228b287eaee8a1 Mon Sep 17 00:00:00 2001 From: ebang091 Date: Mon, 16 Oct 2023 23:54:48 +0900 Subject: [PATCH 1/2] refactor: check is_mariadb when needed in _connect_to_stream(BinlogStreamReader) --- pymysqlreplication/binlogstream.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pymysqlreplication/binlogstream.py b/pymysqlreplication/binlogstream.py index 6009f1a9..10edf35c 100644 --- a/pymysqlreplication/binlogstream.py +++ b/pymysqlreplication/binlogstream.py @@ -374,9 +374,10 @@ def __connect_to_stream(self): # Mariadb, when it tries to replace GTID events with dummy ones. Given that this library understands GTID # events, setting the capability to 4 circumvents this error. # If the DB is mysql, this won't have any effect so no need to run this in a condition - cur = self._stream_connection.cursor() - cur.execute("SET @mariadb_slave_capability=4") - cur.close() + if(self.is_mariadb): + cur = self._stream_connection.cursor() + cur.execute("SET @mariadb_slave_capability=4") + cur.close() self._register_slave() From d673f200ac41f0f15f8732fb2fbbf040bce112ea Mon Sep 17 00:00:00 2001 From: ebang091 Date: Tue, 17 Oct 2023 00:12:34 +0900 Subject: [PATCH 2/2] refactor --- pymysqlreplication/binlogstream.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymysqlreplication/binlogstream.py b/pymysqlreplication/binlogstream.py index 10edf35c..6b0b912e 100644 --- a/pymysqlreplication/binlogstream.py +++ b/pymysqlreplication/binlogstream.py @@ -374,7 +374,7 @@ def __connect_to_stream(self): # Mariadb, when it tries to replace GTID events with dummy ones. Given that this library understands GTID # events, setting the capability to 4 circumvents this error. # If the DB is mysql, this won't have any effect so no need to run this in a condition - if(self.is_mariadb): + if self.is_mariadb: cur = self._stream_connection.cursor() cur.execute("SET @mariadb_slave_capability=4") cur.close()