mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-04-18 16:31:26 -07:00
Handle divergences between MySQL and MariaDB (#103)
* Initial attempt * First functional approach * Remove unused imports * Add dychotomy handling for mysql_replication * Fix cursor lookup * Fix sanity tests * Cleanup implementation conditional import * Fix unit tests * Fix conditional import to satisfy both sanity and integration tests * Add changelog fragment
This commit is contained in:
parent
a5ee4b3d1a
commit
11958ec46a
12 changed files with 162 additions and 92 deletions
|
@ -277,24 +277,6 @@ from distutils.version import LooseVersion
|
|||
executed_queries = []
|
||||
|
||||
|
||||
def uses_replica_terminology(cursor):
|
||||
"""Checks if REPLICA must be used instead of SLAVE"""
|
||||
cursor.execute("SELECT VERSION() AS version")
|
||||
result = cursor.fetchone()
|
||||
|
||||
if isinstance(result, dict):
|
||||
version_str = result['version']
|
||||
else:
|
||||
version_str = result[0]
|
||||
|
||||
version = LooseVersion(version_str)
|
||||
|
||||
if 'mariadb' in version_str.lower():
|
||||
return version >= LooseVersion('10.5.1')
|
||||
else:
|
||||
return version >= LooseVersion('8.0.22')
|
||||
|
||||
|
||||
def get_master_status(cursor):
|
||||
cursor.execute("SHOW MASTER STATUS")
|
||||
masterstatus = cursor.fetchone()
|
||||
|
@ -520,9 +502,15 @@ def main():
|
|||
else:
|
||||
module.fail_json(msg="unable to find %s. Exception message: %s" % (config_file, to_native(e)))
|
||||
|
||||
cursor.execute("SELECT VERSION()")
|
||||
if 'mariadb' in cursor.fetchone()["VERSION()"].lower():
|
||||
from ansible_collections.community.mysql.plugins.module_utils.implementations.mariadb import replication as impl
|
||||
else:
|
||||
from ansible_collections.community.mysql.plugins.module_utils.implementations.mysql import replication as impl
|
||||
|
||||
# Since MySQL 8.0.22 and MariaDB 10.5.1,
|
||||
# "REPLICA" must be used instead of "SLAVE"
|
||||
if uses_replica_terminology(cursor):
|
||||
if impl.uses_replica_terminology(cursor):
|
||||
replica_term = 'REPLICA'
|
||||
if master_use_gtid == 'slave_pos':
|
||||
module.deprecate('master_use_gtid "slave_pos" value is deprecated, use "replica_pos" instead.',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue