Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-27933

setting the version system server variable changes type of VERSION()

Details

    Description

      We noticed some issues when trying to use `mariadb-devel` containers from quay.io/mariadb-foundation/mariadb-devel with mysqlclient that are not reproducible with containers from the docker hub :

      • `0` is not recognized as `Decimal`
      • `VERSION()` returns bytes instead of string
      • `SHOW FULL TABLES;` doesn't return anything

      To reproduce you can execute any query:

      import MySQLdb 
      db = MySQLdb.connect(host="mariadb-db", user="root", database="django")
      cursor = db.cursor()
      cursor.execute("SELECT VERSION()")
      

      it crashes with:

      Traceback (most recent call last):
        File "tests/runtests.py", line 6, in <module>
          cursor.execute("SELECT VERSION()")
        File "/usr/local/lib/python3.8/site-packages/MySQLdb/cursors.py", line 206, in execute
          res = self._query(query)
        File "/usr/local/lib/python3.8/site-packages/MySQLdb/cursors.py", line 321, in _query
          self._post_get_result()
        File "/usr/local/lib/python3.8/site-packages/MySQLdb/cursors.py", line 355, in _post_get_result
          self._rows = self._fetch_row(0)
        File "/usr/local/lib/python3.8/site-packages/MySQLdb/cursors.py", line 328, in _fetch_row
          return self._result.fetch_row(size, self._fetch_type)
      decimal.InvalidOperation: [<class 'decimal.ConversionSyntax'>]
      

      when I will remove 0 to Decimal converter than VERSION() returns bytes instead of strings:

      import MySQLdb
      from MySQLdb.converters import conversions
       
      converters = conversions
      converters.pop(0, None)
       
      db = MySQLdb.connect(host="mariadb-db", user="root", database="django", conv=converters)
      cursor = db.cursor()                                                        
      cursor.execute("SELECT VERSION()")                                          
      version = cursor.fetchone()[0]
      print(type(version), version)
      

      <class 'bytes'> b'10.7.4-MariaDB-507084517fad72346ab631e3c7493154000df0a7'
      

      Attachments

        Issue Links

          Activity

            danblack Daniel Black added a comment -

            Confirmed, manually changing the version somehow interferes with its type.

            $  sql/mysqld --no-defaults --port 3801 --datadir=/tmp/${PWD##*/}-datadir --socket=/tmp/${PWD##*/}.sock --plugin-dir=${PWD}/mysql-test/var/plugins/ --verbose --version=10.8-manually-set
            

            danblack Daniel Black added a comment - Confirmed, manually changing the version somehow interferes with its type. $ sql/mysqld --no-defaults --port 3801 --datadir=/tmp/${PWD##*/}-datadir --socket=/tmp/${PWD##*/}.sock --plugin-dir=${PWD}/mysql-test/var/plugins/ --verbose --version=10.8-manually-set
            danblack Daniel Black added a comment -

            Actually:

            $  sql/mysqld --no-defaults --port 3801 --datadir=/tmp/${PWD##*/}-datadir --socket=/tmp/${PWD##*/}.sock --plugin-dir=${PWD}/mysql-test/var/plugins/ --verbose --version=5.5.5-10.8-manually-set
            

            $ python MDEV-27933-test.py 
            <class 'str'> 5.5.5-10.8-manually-set
            (.py3) 
            

            mysqlclient is probably relying on 5.5.5 as a mariadb identifier

            danblack Daniel Black added a comment - Actually: $ sql/mysqld --no-defaults --port 3801 --datadir=/tmp/${PWD##*/}-datadir --socket=/tmp/${PWD##*/}.sock --plugin-dir=${PWD}/mysql-test/var/plugins/ --verbose --version=5.5.5-10.8-manually-set $ python MDEV-27933-test.py <class 'str'> 5.5.5-10.8-manually-set (.py3) mysqlclient is probably relying on 5.5.5 as a mariadb identifier
            danblack Daniel Black added a comment -

            Getting MDEV-17093 merged would negate the need for me to set the version manually in the debug/devel container images.

            danblack Daniel Black added a comment - Getting MDEV-17093 merged would negate the need for me to set the version manually in the debug/devel container images.

            Fixed in MDEV-27304

            serg Sergei Golubchik added a comment - Fixed in MDEV-27304
            danblack Daniel Black added a comment -

            Removed version fixing in generated quay.io containers - https://github.com/MariaDB/mariadb.org-tools/commit/bafe0532097db4f515df7f48f3aaa53b192f817f

            mysqlclient's handling was somewhere deep in the linked C/C (probably MySQLs).

            danblack Daniel Black added a comment - Removed version fixing in generated quay.io containers - https://github.com/MariaDB/mariadb.org-tools/commit/bafe0532097db4f515df7f48f3aaa53b192f817f mysqlclient's handling was somewhere deep in the linked C/C (probably MySQLs).

            People

              serg Sergei Golubchik
              felixx Mariusz Felisiak
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.