Skip to content

Fix parsing of query field of RowsQueryEvent #602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

dongwook-chan
Copy link
Collaborator

@dongwook-chan dongwook-chan commented Jan 23, 2024

Description

The first byte of payload in RowsQueryEvent must be ignored without being used as the length for the following field query. Yet, the existing code did use this value as length for query and fails whenever parsing query longer than 255 characters which is the maximum value that a single byte can hold.

I fixed the bug referring to code from msql-server.

Other clients in different languages implement the RowsQueryEvent the way mysql-server does and noted below as references.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Other (please specify below)

Checklist

Tests

  • All tests have passed.
  • New tests have been added to cover the changes. (describe below if applicable).

Additional Information

@dongwook-chan dongwook-chan requested a review from sean-k1 January 23, 2024 15:18
Copy link
Collaborator

@sean-k1 sean-k1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

except reivew LGTM

@@ -880,12 +880,11 @@ def __init__(self, from_packet, event_size, table_map, ctl_connection, **kwargs)
super(RowsQueryLogEvent, self).__init__(
from_packet, event_size, table_map, ctl_connection, **kwargs
)
self.query_length = self.packet.read_uint8()
self.query = self.packet.read(self.query_length).decode("utf-8")
self.packet.advance(1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about delete line#875

Copy link
Collaborator

@sean-k1 sean-k1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
except fix lint

@avaitla
Copy link

avaitla commented Feb 29, 2024

This also crashes for our MySQL 8.035. Would love to see it merged in. We are having to use: poetry add git+ssh://git@github.com:dongwook-chan/python-mysql-replication.git

@sean-k1 sean-k1 merged commit d2ef033 into julien-duponchelle:main Mar 2, 2024
sean-k1 added a commit that referenced this pull request Mar 7, 2024
* Fix parsing of query field of RowsQueryEvent(#602)
* fix log statement for BinLogStreamReader.fetchone(#608)
@sean-k1 sean-k1 mentioned this pull request Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants