Skip to content

Support null events and a slight change of names #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pymysqlreplication/constants/BINLOG.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
HEARTBEAT_LOG_EVENT = 0x1b
IGNORABLE_LOG_EVENT= 0x1c
ROWS_QUERY_LOG_EVENT= 0x1d
WRITE_ROWS_EVENT = 0x1e
UPDATE_ROWS_EVENT = 0x1f
DELETE_ROWS_EVENT = 0x20
WRITE_ROWS_EVENT_V2 = 0x1e
UPDATE_ROWS_EVENT_V2 = 0x1f
DELETE_ROWS_EVENT_V2 = 0x20
GTID_LOG_EVENT= 0x21
ANONYMOUS_GTID_LOG_EVENT= 0x22
PREVIOUS_GTIDS_LOG_EVENT= 0x23
4 changes: 4 additions & 0 deletions pymysqlreplication/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,7 @@ def _dump(self):
print("Execution time: %d" % (self.execution_time))
print("Query: %s" % (self.query))

class NullEvent(BinLogEvent):
def __init__(self, from_packet, event_size, table_map, ctl_connection, log_persistancer = None):
super(NullEvent, self).__init__(from_packet, event_size, table_map, ctl_connection, log_persistancer)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats this log_persistancer?

self.packet.advance(event_size)
10 changes: 6 additions & 4 deletions pymysqlreplication/packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ class BinLogPacketWrapper(object):
UPDATE_ROWS_EVENT_V1: UpdateRowsEvent,
WRITE_ROWS_EVENT_V1: WriteRowsEvent,
DELETE_ROWS_EVENT_V1: DeleteRowsEvent,
UPDATE_ROWS_EVENT: UpdateRowsEvent,
WRITE_ROWS_EVENT: WriteRowsEvent,
DELETE_ROWS_EVENT: DeleteRowsEvent,
UPDATE_ROWS_EVENT_V2: UpdateRowsEvent,
WRITE_ROWS_EVENT_V2: WriteRowsEvent,
DELETE_ROWS_EVENT_V2: DeleteRowsEvent,
TABLE_MAP_EVENT: TableMapEvent,
ROTATE_EVENT: RotateEvent,
FORMAT_DESCRIPTION_EVENT: FormatDescriptionEvent,
XID_EVENT: XidEvent
XID_EVENT: XidEvent,
INTVAR_EVENT: NullEvent,
GTID_LOG_EVENT: NullEvent
}

def __init__(self, from_packet, table_map, ctl_connection):
Expand Down
10 changes: 5 additions & 5 deletions pymysqlreplication/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_write_row_event(self):

event = self.stream.fetchone()
if self.isMySQL56AndMore():
self.assertEqual(event.event_type, WRITE_ROWS_EVENT)
self.assertEqual(event.event_type, WRITE_ROWS_EVENT_V2)
else:
self.assertEqual(event.event_type, WRITE_ROWS_EVENT_V1)
self.assertIsInstance(event, WriteRowsEvent)
Expand Down Expand Up @@ -127,7 +127,7 @@ def test_delete_row_event(self):

event = self.stream.fetchone()
if self.isMySQL56AndMore():
self.assertEqual(event.event_type, DELETE_ROWS_EVENT)
self.assertEqual(event.event_type, DELETE_ROWS_EVENT_V2)
else:
self.assertEqual(event.event_type, DELETE_ROWS_EVENT_V1)
self.assertIsInstance(event, DeleteRowsEvent)
Expand Down Expand Up @@ -159,7 +159,7 @@ def test_update_row_event(self):

event = self.stream.fetchone()
if self.isMySQL56AndMore():
self.assertEqual(event.event_type, UPDATE_ROWS_EVENT)
self.assertEqual(event.event_type, UPDATE_ROWS_EVENT_V2)
else:
self.assertEqual(event.event_type, UPDATE_ROWS_EVENT_V1)
self.assertIsInstance(event, UpdateRowsEvent)
Expand Down Expand Up @@ -192,7 +192,7 @@ def test_insert_multiple_row_event(self):

event = self.stream.fetchone()
if self.isMySQL56AndMore():
self.assertEqual(event.event_type, WRITE_ROWS_EVENT)
self.assertEqual(event.event_type, WRITE_ROWS_EVENT_V2)
else:
self.assertEqual(event.event_type, WRITE_ROWS_EVENT_V1)
self.assertIsInstance(event, WriteRowsEvent)
Expand Down Expand Up @@ -272,7 +272,7 @@ def test_delete_multiple_row_event(self):

event = self.stream.fetchone()
if self.isMySQL56AndMore():
self.assertEqual(event.event_type, DELETE_ROWS_EVENT)
self.assertEqual(event.event_type, DELETE_ROWS_EVENT_V2)
else:
self.assertEqual(event.event_type, DELETE_ROWS_EVENT_V1)
self.assertIsInstance(event, DeleteRowsEvent)
Expand Down
2 changes: 1 addition & 1 deletion pymysqlreplication/tests/test_data_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def create_and_insert_value(self, create_query, insert_query):

event = self.stream.fetchone()
if self.isMySQL56AndMore():
self.assertEqual(event.event_type, WRITE_ROWS_EVENT)
self.assertEqual(event.event_type, WRITE_ROWS_EVENT_V2)
else:
self.assertEqual(event.event_type, WRITE_ROWS_EVENT_V1)
self.assertIsInstance(event, WriteRowsEvent)
Expand Down