feat: adds support for show binary log status statement

This commit is contained in:
Dennis Urtubia 2024-05-27 21:50:51 -03:00
parent a80b805619
commit dddce3f55f
2 changed files with 15 additions and 4 deletions

View file

@ -0,0 +1,4 @@
---
minor_changes:
- mysql_replication - Adds support for `SHOW BINARY LOG STATUS` on getprimary mode.

View file

@ -297,8 +297,11 @@ queries:
import os import os
import warnings import warnings
from ansible_collections.community.mysql.plugins.module_utils.version import LooseVersion
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.mysql.plugins.module_utils.mysql import ( from ansible_collections.community.mysql.plugins.module_utils.mysql import (
get_server_version,
get_server_implementation,
mysql_connect, mysql_connect,
mysql_driver, mysql_driver,
mysql_driver_fail_msg, mysql_driver_fail_msg,
@ -310,10 +313,14 @@ executed_queries = []
def get_primary_status(cursor): def get_primary_status(cursor):
# TODO: when it's available to change on MySQL's side, term = "MASTER"
# change MASTER to PRIMARY using the approach from
# get_replica_status() function. Same for other functions. version = get_server_version(cursor)
cursor.execute("SHOW MASTER STATUS") if get_server_implementation(cursor) == "mysql" and LooseVersion(version) >= LooseVersion("8.2.0"):
term = "BINARY LOG"
cursor.execute("SHOW %s STATUS" % term)
primarystatus = cursor.fetchone() primarystatus = cursor.fetchone()
return primarystatus return primarystatus