Skip to content

Commit

Permalink
Fix time and date handling on upgraded MariaDB
Browse files Browse the repository at this point in the history
In MariaDB 10.1.2 a new temporal format was introduced from
MySQL 5.6 that alters how the `TIME`, `DATETIME` and `TIMESTAMP`
columns operate at lower levels. These changes allow these temporal
data types to have fractional parts and negative values.
You can disable this feature using the `mysql56_temporal_format`
system variable.

Starting from MariaDB 10.5.1 columns with old temporal formats are
marked with a `/* mariadb-5.3 */` comment in the output of
`SHOW CREATE TABLE`, `SHOW COLUMNS`, `DESCRIBE` statements, as well
as in the `COLUMN_TYPE` column of the `INFORMATION_SCHEMA.COLUMNS`
Table.

Since the python bindings use the `DESCRIBE` statement to identify
the type of an MySQL entry, the comment must be stripped off.

This happens on old MariaDB databases upgraded automatically
during system upgrade, e.g.: Debian 10 -> 11.

Ref: https://mariadb.com/kb/en/datetime/

Fixes #384
  • Loading branch information
rcrdnalor committed Nov 21, 2021
1 parent 57a388e commit 645ad05
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mythtv/bindings/python/MythTV/database.py
Expand Up @@ -1119,10 +1119,11 @@ def __str__(self): return str(list(self))
def __repr__(self): return py23_repr(str(self))
def __iter__(self): return self.iterkeys()
def __init__(self, result):
# remove comments in 'type' like "datetime /* mariadb-5.3 */"
data = [(row[0],
OrdDict(zip( \
('type','null','key','default','extra'),
row[1:])) \
('type','null','key','default','extra'),
(row[1].split('/*', 1)[0].rstrip(), ) + row[2:])) \
)for row in result]
OrdDict.__init__(self, data)
def __getitem__(self,key):
Expand Down

0 comments on commit 645ad05

Please sign in to comment.