From 9652975e806146b0637baa599381747abb30c485 Mon Sep 17 00:00:00 2001 From: Roman Khristoforov Date: Tue, 4 Mar 2025 10:39:30 +0200 Subject: [PATCH 1/4] Add SAVEPOINT statement to ignore --- pg_chameleon/lib/mysql_lib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pg_chameleon/lib/mysql_lib.py b/pg_chameleon/lib/mysql_lib.py index 04932d67..7fbe2a6c 100644 --- a/pg_chameleon/lib/mysql_lib.py +++ b/pg_chameleon/lib/mysql_lib.py @@ -17,7 +17,7 @@ def __init__(self): Class constructor, the method sets the class variables and configure the operating parameters from the args provided t the class. """ - self.statement_skip = ['BEGIN', 'COMMIT'] + self.statement_skip = ['BEGIN', 'COMMIT', 'SAVEPOINT'] self.schema_tables = {} self.schema_mappings = {} self.schema_loading = {} From 686814a7214952d73d7a750ce058bfc948c3eaa1 Mon Sep 17 00:00:00 2001 From: Roman Khristoforov Date: Thu, 6 Mar 2025 17:05:12 +0200 Subject: [PATCH 2/4] Use regexp for skip_statements --- pg_chameleon/lib/mysql_lib.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pg_chameleon/lib/mysql_lib.py b/pg_chameleon/lib/mysql_lib.py index 7fbe2a6c..ee3c7b0f 100644 --- a/pg_chameleon/lib/mysql_lib.py +++ b/pg_chameleon/lib/mysql_lib.py @@ -17,7 +17,7 @@ def __init__(self): Class constructor, the method sets the class variables and configure the operating parameters from the args provided t the class. """ - self.statement_skip = ['BEGIN', 'COMMIT', 'SAVEPOINT'] + self.statement_skip = ['^BEGIN$', '^COMMIT$', '^SAVEPOINT.*$'] self.schema_tables = {} self.schema_mappings = {} self.schema_loading = {} @@ -1324,8 +1324,7 @@ def __read_replica_stream(self, batch_data): schema_query = binlogevent.schema.decode() except: schema_query = binlogevent.schema - - if binlogevent.query.strip().upper() not in self.statement_skip and schema_query in self.schema_mappings: + if not any(re.search(pattern, binlogevent.query.strip(), re.IGNORECASE) for pattern in self.statement_skip) and schema_query in self.schema_mappings: close_batch=True destination_schema = self.schema_mappings[schema_query] log_position = binlogevent.packet.log_pos From 06266f8c47a83cb12dece10c0400d659c9a6b18d Mon Sep 17 00:00:00 2001 From: Roman Khristoforov Date: Thu, 6 Mar 2025 17:27:16 +0200 Subject: [PATCH 3/4] Use startsWith for skip_statements --- pg_chameleon/lib/mysql_lib.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pg_chameleon/lib/mysql_lib.py b/pg_chameleon/lib/mysql_lib.py index ee3c7b0f..7206f353 100644 --- a/pg_chameleon/lib/mysql_lib.py +++ b/pg_chameleon/lib/mysql_lib.py @@ -17,7 +17,7 @@ def __init__(self): Class constructor, the method sets the class variables and configure the operating parameters from the args provided t the class. """ - self.statement_skip = ['^BEGIN$', '^COMMIT$', '^SAVEPOINT.*$'] + self.statement_skip = ('BEGIN', 'COMMIT', 'SAVEPOINT') self.schema_tables = {} self.schema_mappings = {} self.schema_loading = {} @@ -1324,7 +1324,7 @@ def __read_replica_stream(self, batch_data): schema_query = binlogevent.schema.decode() except: schema_query = binlogevent.schema - if not any(re.search(pattern, binlogevent.query.strip(), re.IGNORECASE) for pattern in self.statement_skip) and schema_query in self.schema_mappings: + if not binlogevent.query.strip().upper().startswith(self.statement_skip) and schema_query in self.schema_mappings: close_batch=True destination_schema = self.schema_mappings[schema_query] log_position = binlogevent.packet.log_pos From a115fc590566935588262b77ef69a3edcab8f0c2 Mon Sep 17 00:00:00 2001 From: Roman Khristoforov Date: Thu, 6 Mar 2025 17:47:36 +0200 Subject: [PATCH 4/4] revert rm line --- pg_chameleon/lib/mysql_lib.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pg_chameleon/lib/mysql_lib.py b/pg_chameleon/lib/mysql_lib.py index 7206f353..1f735379 100644 --- a/pg_chameleon/lib/mysql_lib.py +++ b/pg_chameleon/lib/mysql_lib.py @@ -1324,6 +1324,7 @@ def __read_replica_stream(self, batch_data): schema_query = binlogevent.schema.decode() except: schema_query = binlogevent.schema + if not binlogevent.query.strip().upper().startswith(self.statement_skip) and schema_query in self.schema_mappings: close_batch=True destination_schema = self.schema_mappings[schema_query]