Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have to collect some information of PostgreSQL roles. One piece of information is whether the role has different settings than 'usual', usual meaning here default values for only a few parameters (eg. log_statement).

So far I have only one idea: loop over all the users and issue the commands

\c postgres username

SHOW log_statement;

and then process the output.

I am wondering whether there is a similar method like querying the pg_settings view, showing per-user settings? I don't need to know session-specific differences, only those that are persisted.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You can get the role configuration by querying pg_catalog.pg_shadow or pg_catalog.pg_user, as the following:

--Query pg_shadow

francs=# select usename,useconfig from pg_shadow ;
   usename    |           useconfig           
--------------+-------------------------------
 postgres     | 
 user_a       | 
 user_b       | 
 skytf_select | {"search_path=skytf, public"}
 francs       | 
 dwetl        | 
 skytf        | 
(7 rows)

francs=# alter role francs  set log_statement='all';
ALTER ROLE

francs=# select usename,useconfig from pg_shadow ;
   usename    |           useconfig           
--------------+-------------------------------
 postgres     | 
 user_a       | 
 user_b       | 
 skytf_select | {"search_path=skytf, public"}
 rancs        | {log_statement=all}
 dwetl        | 
 skytf        | 
(7 rows)
share|improve this answer
    
Thanks a lot! I started browsing the source code and came to pg_db_role_setting which contains the data, but of course the views you mentioned are easier to use. –  dezso Apr 19 '13 at 9:53
    
@dezso: I find pg_db_role_setting is better later, thanks . –  francs Apr 20 '13 at 3:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.