Adds support for show binary log status statement (#638)

* feat: adds support for show binary log status statement

* feat: adds support for mariadb show binlog status statement
This commit is contained in:
Dennis Felipe Urtubia 2024-05-30 12:10:36 -03:00 committed by GitHub
parent a80b805619
commit 47610347ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 4 deletions

View file

@ -0,0 +1,4 @@
---
minor_changes:
- mysql_replication - Adds support for `SHOW BINARY LOG STATUS` and `SHOW BINLOG 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,18 @@ 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") server_implementation = get_server_implementation(cursor)
if server_implementation == "mysql" and LooseVersion(version) >= LooseVersion("8.2.0"):
term = "BINARY LOG"
if server_implementation == "mariadb" and LooseVersion(version) >= LooseVersion("10.5.2"):
term = "BINLOG"
cursor.execute("SHOW %s STATUS" % term)
primarystatus = cursor.fetchone() primarystatus = cursor.fetchone()
return primarystatus return primarystatus