From fbfa2d6521cd318710735cdca8912b2b52727702 Mon Sep 17 00:00:00 2001 From: mirageoasis Date: Fri, 13 Oct 2023 16:34:51 +0900 Subject: [PATCH 1/4] feat : added check mysql 8.0.16 --- pymysqlreplication/bitmap.py | 2 ++ pymysqlreplication/tests/base.py | 7 +++++++ pymysqlreplication/tests/benchmark.py | 4 ++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pymysqlreplication/bitmap.py b/pymysqlreplication/bitmap.py index b02da8a1..2a3f6a3e 100644 --- a/pymysqlreplication/bitmap.py +++ b/pymysqlreplication/bitmap.py @@ -1,3 +1,4 @@ +# fmt: off bitCountInByte = [ 0, 1, @@ -256,6 +257,7 @@ 7, 8, ] +# fmt: on # Calculate total bit counts in a bitmap diff --git a/pymysqlreplication/tests/base.py b/pymysqlreplication/tests/base.py index b288be84..ad35f835 100644 --- a/pymysqlreplication/tests/base.py +++ b/pymysqlreplication/tests/base.py @@ -84,6 +84,13 @@ def isMySQL8014AndMore(self): return True return version == 8.0 and version_detail >= 14 + def isMySQL8016AndMore(self): + version = float(self.getMySQLVersion().rsplit(".", 1)[0]) + version_detail = int(self.getMySQLVersion().rsplit(".", 1)[1]) + if version > 8.0: + return True + return version == 8.0 and version_detail >= 16 + def isMariaDB(self): if self.__is_mariaDB is None: self.__is_mariaDB = ( diff --git a/pymysqlreplication/tests/benchmark.py b/pymysqlreplication/tests/benchmark.py index 3cd47bd9..c109985c 100644 --- a/pymysqlreplication/tests/benchmark.py +++ b/pymysqlreplication/tests/benchmark.py @@ -25,12 +25,12 @@ def consume_events(): only_events=[UpdateRowsEvent], only_tables=["test"], ) - start = time.clock() + start = time.perf_counter() i = 0.0 for binlogevent in stream: i += 1.0 if i % 1000 == 0: - print(f"{i / (time.clock()- start)} event by seconds ({i} total)") + print(f"{i / (time.perf_counter()- start)} event by seconds ({i} total)") stream.close() From 3ca5db7bf43e3bc05c628091b9a9d2e882d2b427 Mon Sep 17 00:00:00 2001 From: mirageoasis Date: Fri, 13 Oct 2023 16:40:05 +0900 Subject: [PATCH 2/4] remove : removed python2 unichr --- pymysqlreplication/tests/test_data_type.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/pymysqlreplication/tests/test_data_type.py b/pymysqlreplication/tests/test_data_type.py index cece10c3..4eb9c921 100644 --- a/pymysqlreplication/tests/test_data_type.py +++ b/pymysqlreplication/tests/test_data_type.py @@ -1,5 +1,4 @@ import copy -import platform import json from pymysqlreplication import BinLogStreamReader import unittest @@ -776,10 +775,7 @@ def test_encoding_latin1(self): db["charset"] = "latin1" self.connect_conn_control(db) - if platform.python_version_tuple()[0] == "2": - string = unichr(233) - else: - string = "\u00e9" + string = "\u00e9" create_query = ( "CREATE TABLE test (test CHAR(12)) CHARACTER SET latin1 COLLATE latin1_bin;" @@ -790,10 +786,7 @@ def test_encoding_latin1(self): self.assertEqual(event.rows[0]["values"]["test"], string) def test_encoding_utf8(self): - if platform.python_version_tuple()[0] == "2": - string = unichr(0x20AC) - else: - string = "\u20ac" + string = "\u20ac" create_query = ( "CREATE TABLE test (test CHAR(12)) CHARACTER SET utf8 COLLATE utf8_bin;" From bb78cd2c7c8ff2c2d09efff129cf2c421a7ec837 Mon Sep 17 00:00:00 2001 From: mirageoasis Date: Fri, 13 Oct 2023 16:59:30 +0900 Subject: [PATCH 3/4] fixed : partition_id is above 16 --- pymysqlreplication/tests/test_data_type.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pymysqlreplication/tests/test_data_type.py b/pymysqlreplication/tests/test_data_type.py index 4eb9c921..4c03ab1c 100644 --- a/pymysqlreplication/tests/test_data_type.py +++ b/pymysqlreplication/tests/test_data_type.py @@ -798,7 +798,7 @@ def test_encoding_utf8(self): self.assertMultiLineEqual(event.rows[0]["values"]["test"], string) def test_partition_id(self): - if not self.isMySQL80AndMore(): + if not self.isMySQL8016AndMore(): self.skipTest("Not supported in this version of MySQL") create_query = "CREATE TABLE test (id INTEGER) \ PARTITION BY RANGE (id) ( \ @@ -963,7 +963,7 @@ def create_and_insert_value(self, create_query, insert_query): return event def test_partition_id(self): - if not self.isMySQL80AndMore(): + if not self.isMySQL8016AndMore(): self.skipTest("Not supported in this version of MySQL") create_query = "CREATE TABLE test (id INTEGER) \ PARTITION BY RANGE (id) ( \ From 213f9b833ad10a290343267cdbafc60b3223f374 Mon Sep 17 00:00:00 2001 From: mirageoasis Date: Fri, 13 Oct 2023 17:02:58 +0900 Subject: [PATCH 4/4] bitCountInByte should be ignored in formatting --- pymysqlreplication/bitmap.py | 272 +++-------------------------------- 1 file changed, 16 insertions(+), 256 deletions(-) diff --git a/pymysqlreplication/bitmap.py b/pymysqlreplication/bitmap.py index 2a3f6a3e..804968d7 100644 --- a/pymysqlreplication/bitmap.py +++ b/pymysqlreplication/bitmap.py @@ -1,261 +1,21 @@ # fmt: off bitCountInByte = [ - 0, - 1, - 1, - 2, - 1, - 2, - 2, - 3, - 1, - 2, - 2, - 3, - 2, - 3, - 3, - 4, - 1, - 2, - 2, - 3, - 2, - 3, - 3, - 4, - 2, - 3, - 3, - 4, - 3, - 4, - 4, - 5, - 1, - 2, - 2, - 3, - 2, - 3, - 3, - 4, - 2, - 3, - 3, - 4, - 3, - 4, - 4, - 5, - 2, - 3, - 3, - 4, - 3, - 4, - 4, - 5, - 3, - 4, - 4, - 5, - 4, - 5, - 5, - 6, - 1, - 2, - 2, - 3, - 2, - 3, - 3, - 4, - 2, - 3, - 3, - 4, - 3, - 4, - 4, - 5, - 2, - 3, - 3, - 4, - 3, - 4, - 4, - 5, - 3, - 4, - 4, - 5, - 4, - 5, - 5, - 6, - 2, - 3, - 3, - 4, - 3, - 4, - 4, - 5, - 3, - 4, - 4, - 5, - 4, - 5, - 5, - 6, - 3, - 4, - 4, - 5, - 4, - 5, - 5, - 6, - 4, - 5, - 5, - 6, - 5, - 6, - 6, - 7, - 1, - 2, - 2, - 3, - 2, - 3, - 3, - 4, - 2, - 3, - 3, - 4, - 3, - 4, - 4, - 5, - 2, - 3, - 3, - 4, - 3, - 4, - 4, - 5, - 3, - 4, - 4, - 5, - 4, - 5, - 5, - 6, - 2, - 3, - 3, - 4, - 3, - 4, - 4, - 5, - 3, - 4, - 4, - 5, - 4, - 5, - 5, - 6, - 3, - 4, - 4, - 5, - 4, - 5, - 5, - 6, - 4, - 5, - 5, - 6, - 5, - 6, - 6, - 7, - 2, - 3, - 3, - 4, - 3, - 4, - 4, - 5, - 3, - 4, - 4, - 5, - 4, - 5, - 5, - 6, - 3, - 4, - 4, - 5, - 4, - 5, - 5, - 6, - 4, - 5, - 5, - 6, - 5, - 6, - 6, - 7, - 3, - 4, - 4, - 5, - 4, - 5, - 5, - 6, - 4, - 5, - 5, - 6, - 5, - 6, - 6, - 7, - 4, - 5, - 5, - 6, - 5, - 6, - 6, - 7, - 5, - 6, - 6, - 7, - 6, - 7, - 7, - 8, + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8, ] # fmt: on