Skip to content

Commit

Permalink
feat: adds support for show binary log status statement
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisurtubia committed May 29, 2024
1 parent 6ce2f49 commit 71c2691
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions changelogs/fragments/get_primary_show_binary_log_status.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
minor_changes:

- mysql_replication - Adds support for `SHOW BINARY LOG STATUS` on getprimary mode.
15 changes: 11 additions & 4 deletions plugins/modules/mysql_replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,11 @@
import os
import warnings

from ansible_collections.community.mysql.plugins.module_utils.version import LooseVersion
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.mysql.plugins.module_utils.mysql import (
get_server_version,
get_server_implementation,
mysql_connect,
mysql_driver,
mysql_driver_fail_msg,
Expand All @@ -300,10 +303,14 @@


def get_primary_status(cursor):
# TODO: when it's available to change on MySQL's side,
# change MASTER to PRIMARY using the approach from
# get_replica_status() function. Same for other functions.
cursor.execute("SHOW MASTER STATUS")
term = "MASTER"

version = get_server_version(cursor)
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()
return primarystatus

Expand Down

0 comments on commit 71c2691

Please sign in to comment.