Skip to content

Commit b882122

Browse files
committed
setting BinlogStream class parameter optional_meta_data
1 parent 8328ce0 commit b882122

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

pymysqlreplication/binlogstream.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ def __init__(self, connection_settings, server_id,
141141
slave_heartbeat=None,
142142
is_mariadb=False,
143143
annotate_rows_event=False,
144-
ignore_decode_errors=False):
144+
ignore_decode_errors=False,
145+
optional_meta_data=False):
145146
"""
146147
Attributes:
147148
ctl_connection_settings: Connection settings for cluster holding
@@ -205,7 +206,7 @@ def __init__(self, connection_settings, server_id,
205206
only_events, ignored_events, filter_non_implemented_events)
206207
self.__fail_on_table_metadata_unavailable = fail_on_table_metadata_unavailable
207208
self.__ignore_decode_errors = ignore_decode_errors
208-
209+
self.__optional_meta_data = optional_meta_data
209210
# We can't filter on packet level TABLE_MAP and rotate event because
210211
# we need them for handling other operations
211212
self.__allowed_events_in_packet = frozenset(
@@ -535,7 +536,8 @@ def fetchone(self):
535536
self.__ignored_schemas,
536537
self.__freeze_schema,
537538
self.__fail_on_table_metadata_unavailable,
538-
self.__ignore_decode_errors)
539+
self.__ignore_decode_errors,
540+
self.__optional_meta_data)
539541

540542
if binlog_event.event_type == ROTATE_EVENT:
541543
self.log_pos = binlog_event.event.position

pymysqlreplication/event.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ def __init__(self, from_packet, event_size, table_map, ctl_connection,
1616
ignored_schemas=None,
1717
freeze_schema=False,
1818
fail_on_table_metadata_unavailable=False,
19-
ignore_decode_errors=False):
19+
ignore_decode_errors=False,
20+
optional_meta_data=False):
2021
self.packet = from_packet
2122
self.table_map = table_map
2223
self.event_type = self.packet.event_type

pymysqlreplication/packet.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ def __init__(self, from_packet, table_map,
104104
ignored_schemas,
105105
freeze_schema,
106106
fail_on_table_metadata_unavailable,
107-
ignore_decode_errors):
107+
ignore_decode_errors,
108+
optional_meta_data):
108109
# -1 because we ignore the ok byte
109110
self.read_bytes = 0
110111
# Used when we want to override a value in the data buffer
@@ -150,7 +151,8 @@ def __init__(self, from_packet, table_map,
150151
ignored_schemas=ignored_schemas,
151152
freeze_schema=freeze_schema,
152153
fail_on_table_metadata_unavailable=fail_on_table_metadata_unavailable,
153-
ignore_decode_errors=ignore_decode_errors)
154+
ignore_decode_errors=ignore_decode_errors,
155+
optional_meta_data=optional_meta_data)
154156
if self.event._processed == False:
155157
self.event = None
156158

pymysqlreplication/row_event.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ def __init__(self, from_packet, event_size, table_map, ctl_connection, **kwargs)
623623
self.__only_schemas = kwargs["only_schemas"]
624624
self.__ignored_schemas = kwargs["ignored_schemas"]
625625
self.__freeze_schema = kwargs["freeze_schema"]
626-
626+
self.__optional_meta_data = kwargs["optional_meta_data"]
627627
# Post-Header
628628
self.table_id = self._read_table_id()
629629

@@ -661,6 +661,8 @@ def __init__(self, from_packet, event_size, table_map, ctl_connection, **kwargs)
661661

662662
if self.table_id in table_map:
663663
self.column_schemas = table_map[self.table_id].column_schemas
664+
elif self.__optional_meta_data:
665+
self.column_schemas = []
664666
else:
665667
self.column_schemas = self._ctl_connection._get_table_information(self.schema, self.table)
666668

@@ -800,10 +802,8 @@ def _sync_column_info(self):
800802
column_schemas = []
801803
if len(self.optional_metadata.column_name_list) == 0:
802804
return
803-
if len(self.column_schemas) == self.column_count:
804-
# If the column schema length matches the number of columns,
805-
# updating column schema information from optional metadata is not advisable.
806-
# The reason is that the information obtained from optional metadata is not sufficient.
805+
if not self.__optional_meta_data:
806+
# If optional_meta_data is False Do not sync Event Time Column Schemas
807807
return
808808

809809
charset_pos = 0

0 commit comments

Comments
 (0)