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.
Attachments
Activity
Field | Original Value | New Value |
---|---|---|
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: {code}if ( self->fields[column].charsetnr == CHARSET_BINARY){code} while in field_fetch_callback: {code}if ((self->fields[column].flags & BINARY_FLAG || self->fields[column].charsetnr == CHARSET_BINARY)){code} 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 (while glancing through the code, there are more different behaviours, e.g. the numeric values where in one case the signed flag is checked, while not in the other). |
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: {code}if ( self->fields[column].charsetnr == CHARSET_BINARY){code} while in field_fetch_callback: {code}if ((self->fields[column].flags & BINARY_FLAG || self->fields[column].charsetnr == CHARSET_BINARY)){code} 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. |
Fix Version/s | 1.0.6 [ 25218 ] |
Component/s | DBAPI 2.0 [ 14516 ] | |
Resolution | Fixed [ 1 ] | |
Status | Open [ 1 ] | Closed [ 6 ] |
Workflow | MariaDB v3 [ 118538 ] | MariaDB v4 [ 135697 ] |