Uploaded image for project: 'MariaDB Connector/Python'
  1. MariaDB Connector/Python
  2. CONPY-138

different behaviour on column with "COLLATE utf8mb4_bin" on select with and without parameter

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • None
    • 1.0.6
    • DBAPI 2.0
    • 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

          People

            georg Georg Richter
            udessauer Ulrich Dessauer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.