Skip to content

Fix BUG96280 #55

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

Closed
wants to merge 2 commits into from
Closed

Fix BUG96280 #55

wants to merge 2 commits into from

Conversation

n-someya
Copy link

@n-someya n-someya commented Nov 8, 2019

This PR fix BUG96280: When fetching binary result (include BLOB, VARBINARY data type) from a prepared cursor, UnicodeDecodeError has occurred.

What’s change?

  • Add a checking for blob data type and return the bytearray.
  • Add a fallback and return the bytearray value if the UnicodeDecodeError occur.
  • Add unit test for above changes.

@@ -475,9 +475,18 @@ def _parse_binary_values(self, fields, packet, charset='utf-8'):
elif field[1] == FieldType.TIME:
(packet, value) = self._parse_binary_time(packet, field)
values.append(value)
elif field[1] in (FieldType.BLOB, FieldType.TINY_BLOB,
FieldType.MEDIUM_BLOB, FieldType.LONG_BLOB):
Copy link

Choose a reason for hiding this comment

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

This is wrong fix. Field type is not column type. MEDIUM_BLOB field type is used to MEDIUM_TEXT column too.
You need to check charsetnr==63. (see this)

When filed type is BLOB and charsetnr != 63, it is TEXT column.
When filed type is BLOB and charsetnr == 63, it is BLOB column.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for your review.
I understand that field type BLOB include both TEXT and BLOB data type.

Currently, mysql-connector-python drop charsetnr info at parse column-packet. (https://github.com/mysql/mysql-connector-python/blob/master/lib/mysql/connector/protocol.py#L279)

I think it is too big impact to change the structure of column info tuple for this issue.
So I only remove field type checking.
Fallback processing is an alternative checking charsetnr.

@mysql-oca-bot
Copy link

Hi, thank you for your contribution. Please confirm this code is submitted under the terms of the OCA (Oracle's Contribution Agreement) you have previously signed by cutting and pasting the following text as a comment:
"I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it."
Thanks

@n-someya
Copy link
Author

n-someya commented Nov 9, 2019

I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

@mysql-oca-bot
Copy link

Hi, thank you for your contribution. Your code has been assigned to an internal queue. Please follow
bug http://bugs.mysql.com/bug.php?id=96280 for updates.
Thanks

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