From 95a5caf562e1777ddac2e2912c5823727b8e61fc Mon Sep 17 00:00:00 2001 From: Felix Hamme Date: Tue, 17 May 2022 13:47:56 +0200 Subject: [PATCH] mysql_user: optimize queries for existing passwords --- plugins/module_utils/user.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/module_utils/user.py b/plugins/module_utils/user.py index 7bb7268..655d847 100644 --- a/plugins/module_utils/user.py +++ b/plugins/module_utils/user.py @@ -121,11 +121,11 @@ def get_existing_authentication(cursor, user): cursor.execute("""select plugin, auth from ( select plugin, password as auth from mysql.user where user=%(user)s union select plugin, authentication_string as auth from mysql.user where user=%(user)s - ) x group by plugin, auth + ) x group by plugin, auth limit 2 """, {'user': user}) else: cursor.execute("""select plugin, authentication_string as auth from mysql.user where user=%(user)s - group by plugin, authentication_string""", {'user': user}) + group by plugin, authentication_string limit 2""", {'user': user}) rows = cursor.fetchall() if len(rows) == 1: return {'plugin': rows[0][0], 'auth_string': rows[0][1]}