|
21 | 21 | from pymysqlreplication._compat import text_type
|
22 | 22 |
|
23 | 23 |
|
24 |
| -__all__ = ["TestDataType"] |
| 24 | +__all__ = ["TestDataType", "TestDataTypeVersion8"] |
25 | 25 |
|
26 | 26 |
|
27 | 27 | def to_binary_dict(d):
|
@@ -954,5 +954,49 @@ def test_varbinary(self):
|
954 | 954 | self.assertEqual(event.rows[0]["values"]["b"], b"\xff\x01\x00\x00")
|
955 | 955 |
|
956 | 956 |
|
| 957 | +class TestDataTypeVersion8(base.PyMySQLReplicationVersion8TestCase): |
| 958 | + def ignoredEvents(self): |
| 959 | + return [GtidEvent, PreviousGtidsEvent] |
| 960 | + |
| 961 | + def create_and_insert_value(self, create_query, insert_query): |
| 962 | + self.execute(create_query) |
| 963 | + self.execute(insert_query) |
| 964 | + self.execute("COMMIT") |
| 965 | + |
| 966 | + self.assertIsInstance(self.stream.fetchone(), RotateEvent) |
| 967 | + self.assertIsInstance(self.stream.fetchone(), FormatDescriptionEvent) |
| 968 | + # QueryEvent for the Create Table |
| 969 | + self.assertIsInstance(self.stream.fetchone(), QueryEvent) |
| 970 | + |
| 971 | + # QueryEvent for the BEGIN |
| 972 | + self.assertIsInstance(self.stream.fetchone(), QueryEvent) |
| 973 | + |
| 974 | + self.assertIsInstance(self.stream.fetchone(), TableMapEvent) |
| 975 | + |
| 976 | + event = self.stream.fetchone() |
| 977 | + if self.isMySQL56AndMore(): |
| 978 | + self.assertEqual(event.event_type, WRITE_ROWS_EVENT_V2) |
| 979 | + else: |
| 980 | + self.assertEqual(event.event_type, WRITE_ROWS_EVENT_V1) |
| 981 | + self.assertIsInstance(event, WriteRowsEvent) |
| 982 | + return event |
| 983 | + |
| 984 | + def test_partition_id(self): |
| 985 | + if not self.isMySQL80AndMore(): |
| 986 | + self.skipTest("Not supported in this version of MySQL") |
| 987 | + create_query = "CREATE TABLE test (id INTEGER) \ |
| 988 | + PARTITION BY RANGE (id) ( \ |
| 989 | + PARTITION p0 VALUES LESS THAN (1), \ |
| 990 | + PARTITION p1 VALUES LESS THAN (2), \ |
| 991 | + PARTITION p2 VALUES LESS THAN (3), \ |
| 992 | + PARTITION p3 VALUES LESS THAN (4), \ |
| 993 | + PARTITION p4 VALUES LESS THAN (5) \ |
| 994 | + )" |
| 995 | + insert_query = "INSERT INTO test (id) VALUES(3)" |
| 996 | + event = self.create_and_insert_value(create_query, insert_query) |
| 997 | + self.assertEqual(event.extra_data_type, 1) |
| 998 | + self.assertEqual(event.partition_id, 3) |
| 999 | + |
| 1000 | + |
957 | 1001 | if __name__ == "__main__":
|
958 | 1002 | unittest.main()
|
0 commit comments