[MDEV-27933] setting the version system server variable changes type of VERSION() Created: 2022-02-24  Updated: 2022-02-28  Resolved: 2022-02-25

Status: Closed
Project: MariaDB Server
Component/s: libmariadb
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.7
Fix Version/s: 10.2.42, 10.3.33, 10.4.23, 10.5.14, 10.6.6

Type: Bug Priority: Major
Reporter: Mariusz Felisiak Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: crash, docker

Issue Links:
Duplicate
duplicates MDEV-27304 SHOW ... result columns are right-ali... Closed
Relates
relates to MDEV-17093 Print version_source_revision in the ... Closed

 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'



 Comments   
Comment by Daniel Black [ 2022-02-24 ]

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

Comment by Daniel Black [ 2022-02-24 ]

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

Comment by Daniel Black [ 2022-02-24 ]

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

Comment by Sergei Golubchik [ 2022-02-25 ]

Fixed in MDEV-27304

Comment by Daniel Black [ 2022-02-28 ]

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).

Generated at Thu Feb 08 09:56:44 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.