From 0ee687b517284b3846cc0f79f4f19938357e81f3 Mon Sep 17 00:00:00 2001 From: Lior Sion Date: Thu, 2 May 2013 10:18:52 +0300 Subject: [PATCH 1/2] change names of events to V2 from default according to this post http://dev.mysql.com/doc/internals/en/row-based-replication.html#rows-event events are marked as version 0,1,2 (current) - the code had _V1 and no version at all - I think it would b easier and morefuture compatible to use V2 since it seems V3 is unavoidable. --- pymysqlreplication/constants/BINLOG.py | 6 +++--- pymysqlreplication/packet.py | 6 +++--- pymysqlreplication/row_event.py | 6 +++--- pymysqlreplication/tests/test_basic.py | 12 ++++++------ pymysqlreplication/tests/test_data_type.py | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pymysqlreplication/constants/BINLOG.py b/pymysqlreplication/constants/BINLOG.py index 7a1dec43..a04df297 100644 --- a/pymysqlreplication/constants/BINLOG.py +++ b/pymysqlreplication/constants/BINLOG.py @@ -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 diff --git a/pymysqlreplication/packet.py b/pymysqlreplication/packet.py index a3f4edc9..be7d132f 100644 --- a/pymysqlreplication/packet.py +++ b/pymysqlreplication/packet.py @@ -28,9 +28,9 @@ 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, diff --git a/pymysqlreplication/row_event.py b/pymysqlreplication/row_event.py index 767e5ec8..150bccc9 100644 --- a/pymysqlreplication/row_event.py +++ b/pymysqlreplication/row_event.py @@ -18,9 +18,9 @@ def __init__(self, from_packet, event_size, table_map, ctl_connection): self.flags = struct.unpack(' Date: Mon, 20 May 2013 07:51:05 +0300 Subject: [PATCH 2/2] add support for null event and couple of new usages nullevent is an event that can happen in the steam but we want to skip it. added two sample events like that: INTVAR_EVENT and GTID_LOG_EVENT - those are events that happen when we do GTID enabled replication, but are of no use (at least not for me at this time) in this packages aspect. It might be when we support moving to a different master seamlessly. --- pymysqlreplication/event.py | 4 ++++ pymysqlreplication/packet.py | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pymysqlreplication/event.py b/pymysqlreplication/event.py index 22e24005..e1e2d8db 100644 --- a/pymysqlreplication/event.py +++ b/pymysqlreplication/event.py @@ -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) + self.packet.advance(event_size) \ No newline at end of file diff --git a/pymysqlreplication/packet.py b/pymysqlreplication/packet.py index bae369d6..c570c73f 100644 --- a/pymysqlreplication/packet.py +++ b/pymysqlreplication/packet.py @@ -34,7 +34,9 @@ class BinLogPacketWrapper(object): 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):