Skip to content

Commit 10eaaa2

Browse files
joeportelabaloo
authored andcommitted
Raise an explanatory exception when binary logging is not enabled. (#245)
1 parent 47cc48a commit 10eaaa2

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

pymysqlreplication/binlogstream.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
XidEvent, GtidEvent, StopEvent,
1616
BeginLoadQueryEvent, ExecuteLoadQueryEvent,
1717
HeartbeatLogEvent, NotImplementedEvent)
18+
from .exceptions import BinLogNotEnabled
1819
from .row_event import (
1920
UpdateRowsEvent, WriteRowsEvent, DeleteRowsEvent, TableMapEvent)
2021

@@ -305,7 +306,10 @@ def __connect_to_stream(self):
305306
if self.log_file is None or self.log_pos is None:
306307
cur = self._stream_connection.cursor()
307308
cur.execute("SHOW MASTER STATUS")
308-
self.log_file, self.log_pos = cur.fetchone()[:2]
309+
master_status = cur.fetchone()
310+
if master_status is None:
311+
raise BinLogNotEnabled()
312+
self.log_file, self.log_pos = master_status[:2]
309313
cur.close()
310314

311315
prelude = struct.pack('<i', len(self.log_file) + 11) \

pymysqlreplication/exceptions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
class TableMetadataUnavailableError(Exception):
22
def __init__(self, table):
33
Exception.__init__(self,"Unable to find metadata for table {0}".format(table))
4+
5+
6+
class BinLogNotEnabled(Exception):
7+
def __init__(self):
8+
Exception.__init__(self, "MySQL binary loggging is not enabled.")

0 commit comments

Comments
 (0)