Bug #90519 Typo in conversion.py:648 causes LONG_BLOB to converted to JSON
Submitted: 20 Apr 2018 2:09 Modified: 20 Apr 2018 5:00
Reporter: Ben Jolitz Email Updates:
Status: Verified Impact on me:
Category:Connector / Python Severity:S2 (Serious)
Version:8.0.11 OS:Any
Assigned to: CPU Architecture:Any

[20 Apr 2018 2:09] Ben Jolitz
Last paragraph of conversion.py reads as:
    def _BLOB_to_python(self, value, dsc=None):  # pylint: disable=C0103
        """Convert BLOB data type to Python"""
        if dsc is not None:
            if dsc[7] & FieldFlag.BINARY:
                if PY2:
                    return value
                return bytes(value)

        return self._STRING_to_python(value, dsc)

    _LONG_BLOB_to_python = _JSON_to_python
    _MEDIUM_BLOB_to_python = _BLOB_to_python
    _TINY_BLOB_to_python = _BLOB_to_python

Permalink on GitHub: https://github.com/mysql/mysql-connector-python/blob/0e84955ecfb53d3b477584557e8345c6427a1...

Notice how LONG BLOB is incorrectly cast to JSON as opposed to BLOB? This causes empty LONG BLOBs to throw an IndexError

How to repeat:
SELECT a column of empty LONG BLOBs or CAST a value to a 0 byte length LONG BLOB.

Suggested fix:
Use _BLOB_to_python instead for _LONG_BLOB_to_python
[20 Apr 2018 5:00] MySQL Verification Team
Hello Ben,

Thank you for the report!