Skip to content

Commit

Permalink
Merge pull request #518 from 23-OSSCA-python-mysql-replication/python…
Browse files Browse the repository at this point in the history
…2_minor_fix

python2 minor fix
  • Loading branch information
dongwook-chan authored Oct 19, 2023
2 parents 32fa176 + 213f9b8 commit d180d65
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 269 deletions.
274 changes: 18 additions & 256 deletions pymysqlreplication/bitmap.py
Original file line number Diff line number Diff line change
@@ -1,261 +1,23 @@
# 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


# Calculate total bit counts in a bitmap
Expand Down
7 changes: 7 additions & 0 deletions pymysqlreplication/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,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 = (
Expand Down
4 changes: 2 additions & 2 deletions pymysqlreplication/tests/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
15 changes: 4 additions & 11 deletions pymysqlreplication/tests/test_data_type.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import copy
import platform
import json
from pymysqlreplication import BinLogStreamReader
import unittest
Expand Down Expand Up @@ -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;"
Expand All @@ -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;"
Expand All @@ -805,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) ( \
Expand Down Expand Up @@ -970,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) ( \
Expand Down

0 comments on commit d180d65

Please sign in to comment.