From cc8fbe34f25d87cdbc2495b02cc4ce7da33018ca Mon Sep 17 00:00:00 2001 From: Till Maas Date: Fri, 22 Feb 2013 14:42:41 +0100 Subject: [PATCH] mysql_user: handle unnecessary GRANT revocation --- library/mysql_user | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/library/mysql_user b/library/mysql_user index 9317bbdd7a1..3f40411b0db 100644 --- a/library/mysql_user +++ b/library/mysql_user @@ -213,7 +213,13 @@ def privileges_revoke(cursor, user,host,db_table): query = "REVOKE ALL PRIVILEGES ON %s FROM '%s'@'%s'" % (db_table,user,host) cursor.execute(query) query = "REVOKE GRANT OPTION ON %s FROM '%s'@'%s'" % (db_table,user,host) - cursor.execute(query) + try: + cursor.execute(query) + except MySQLdb.OperationalError, e: + # 1141 -> There is no such grant defined for user ... on host ... + # If this exception is raised, there is no need to revoke the GRANT privilege + if e.args[0] != 1141 or not e.args[1].startswith("There is no such grant defined for user"): + raise e def privileges_grant(cursor, user,host,db_table,priv):