Skip to content
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

Return raw bytes or bytearray if decoding fails #45

Closed
wants to merge 1 commit into from

Conversation

meikomeik
Copy link

Decoding bytearrays can fail if the value is
binary data. Add a fallback and return the
raw value if the decode function throws a
UnicodeDecodeError.

Decoding bytearrays can fail if the value is
binary data. Add a fallback and return the
raw value if the decode function throws a
UnicodeDecodeError.
@meikomeik
Copy link
Author

meikomeik commented Oct 25, 2018

Let me explain why I did this PR.
The company where I am working monitors mysql servers and runs a nagios
check that will query 'SHOW PROCESSLIST' and check for log running processes.
When ever we are inserting binary data our nagios check crashed with the following
exception:

File "/usr/lib/nagios/igmonplugins/check_mysql_processes.py", line 163, in get_processes
self.processes = self.execute('SHOW PROCESSLIST')
File "/usr/lib/nagios/igmonplugins/check_mysql_processes.py", line 159, in execute
return [dict(zip(col_names, r)) for r in self.cursor.fetchall()]
File "/usr/lib/python3/dist-packages/mysql/connector/cursor.py", line 898, in fetchall
rows = [row_to_python(row, self.description) for row in rows]
File "/usr/lib/python3/dist-packages/mysql/connector/cursor.py", line 898, in
rows = [row_to_python(row, self.description) for row in rows]
File "/usr/lib/python3/dist-packages/mysql/connector/conversion.py", line 407, in row_to_python
result[i] = self._cache_field_types[field_type](row[i], field)
File "/usr/lib/python3/dist-packages/mysql/connector/conversion.py", line 567, in _STRING_to_python
return value.decode(self.charset)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 59: invalid start byte

To circumvent this crash we would like to catch this exception and just return
the raw value.

@mysql-oca-bot
Copy link

Hi, thank you for submitting this pull request. In order to consider your code we need you to sign the Oracle Contribution Agreement (OCA). Please review the details and follow the instructions at http://www.oracle.com/technetwork/community/oca-486395.html
Please make sure to include your MySQL bug system user (email) in the returned form.
Thanks

@meikomeik
Copy link
Author

Hi, my OCA was just approved and processed. You can find my name (Meik Milevczik) on this page:
http://www.oracle.com/technetwork/community/oca-486395.html

Is there anything else I need to do to get this PR accepted?

@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

@meikomeik
Copy link
Author

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=93065 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
2 participants