Fix parsing of row events for MySQL8 partitioned table #355
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since MySQL 8.0.16, partition info has been added into extra_data in row event.
Current code is aware of extra_data but doesn't parse it accurately. The program reads
extra_data_length / 8
bytes from packet instead of correct byte-lengthextra_data_length - 2
. This causes the library to skip parsing of extra_data.In some cases exceptions are raised, and in other cases parse result shows incorrect field values as in issue #354. (undefined behavior)
below are the modifications made:
Correct byte-length of extra_data to conform to replication protocol
extra_data_length / 8
->extra_data_length - 2
https://github.com/noplay/python-mysql-replication/blob/3de6ff499f7695a800409341f4f859cac5b724d0/pymysqlreplication/row_event.py#L60
Refer to MySQL Document and MySQL source code for correct bytes-to-read.
Parse extra_data according to extra_data layout to get partition id ( or ndb info)