From c194df3e5178f462647270d24108bda4aed5e20a Mon Sep 17 00:00:00 2001 From: MattMontgomeryKochava Date: Sun, 13 Feb 2022 10:18:53 -0600 Subject: [PATCH] Add version comments to limit IF EXISTS clause only to versions that support it. --- plugins/module_utils/user.py | 2 +- plugins/modules/mysql_role.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/module_utils/user.py b/plugins/module_utils/user.py index e68591a..3b51824 100644 --- a/plugins/module_utils/user.py +++ b/plugins/module_utils/user.py @@ -368,7 +368,7 @@ def user_delete(cursor, user, host, host_all, check_mode): hostnames = [host] for hostname in hostnames: - cursor.execute("DROP USER IF EXISTS %s@%s", (user, hostname)) + cursor.execute("DROP USER /*!50700 IF EXISTS */ /*M!100103 IF EXISTS */ %s@%s", (user, hostname)) return True diff --git a/plugins/modules/mysql_role.py b/plugins/modules/mysql_role.py index 8525ac6..159bcf0 100644 --- a/plugins/modules/mysql_role.py +++ b/plugins/modules/mysql_role.py @@ -741,7 +741,7 @@ class Role(): if check_mode and self.exists: return True - self.cursor.execute('DROP ROLE %s', (self.name,)) + self.cursor.execute('DROP ROLE /*!50700 IF EXISTS */ /*M!100100 IF EXISTS */ %s', (self.name,)) return True def update_members(self, users, check_mode=False, append_members=False,