From 11b64314df544f38dcf015cfba60b40ae02c26b8 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Wed, 5 Dec 2012 09:51:15 +0100 Subject: [PATCH] Select all fields from the user, as some of them are version-dependent --- library/postgresql_user | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/library/postgresql_user b/library/postgresql_user index 39dd9d5183d..70e7f956cbe 100644 --- a/library/postgresql_user +++ b/library/postgresql_user @@ -146,14 +146,9 @@ def user_alter(cursor, user, password, role_attr_flags): # Handle passwords. if password is not None or role_attr_flags is not None: - # Define columns for select. - columns = 'rolpassword,rolsuper,rolinherit,rolcreaterole,rolcreatedb,rolcanlogin,rolreplication' # Select password and all flag-like columns in order to verify changes. - # rolsuper | rolinherit | rolcreaterole | rolcreatedb | rolcatupdate | - # rolcanlogin | rolreplication | rolconnlimit | rolpassword | rolvaliduntil - # Not sure how to interpolate properly in python yet... - select = "SELECT " + columns + " FROM pg_authid where rolname=%(user)s" - cursor.execute(select, {"columns": columns, "user": user}) + select = "SELECT * FROM pg_authid where rolname=%(user)s" + cursor.execute(select, {"user": user}) # Grab current role attributes. current_role_attrs = cursor.fetchone() @@ -166,7 +161,7 @@ def user_alter(cursor, user, password, role_attr_flags): alter = "ALTER USER %(user)s WITH %(role_attr_flags)s" cursor.execute(alter % {"user": user, "role_attr_flags": role_attr_flags}) # Grab new role attributes. - cursor.execute(select, {"columns": columns, "user": user}) + cursor.execute(select, {"user": user}) new_role_attrs = cursor.fetchone() # Detect any differences between current_ and new_role_attrs.