Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
None
-
None
Description
Querying a column of type string (254) with "COLLATE utf8mb4_bin" leads to different results when caliing with or without parameter. With parameter the result type is "bytes", without it is "str" (as expected). The reason seems to be in the file mariadb_codecs.c as the function field_fetch_fromtext has a different implementation than field_fetch_callback to convert the result to a python object.
If you look for the case MYSQL_TYPE_STRING in each method, you will see the difference:
field_fetch_fromtext:
if ( self->fields[column].charsetnr == CHARSET_BINARY)
|
while in field_fetch_callback:
if ((self->fields[column].flags & BINARY_FLAG ||
|
self->fields[column].charsetnr == CHARSET_BINARY))
|
Removing the self->fields[column].flags & BINARY_FLAG results in a consistent result.
But I'm not sure, if this has some side effects, as (at least I assume) this different implementation has some reasons. If not, I would suggest to consolidate these two functions to use the same code for converting the result.