Search code examples
postgresqlpsqlpostgresql-10postgresql-11

ALTER ROLE SET settings location


I have been going through the documentation about setting PG parameters. I understand the behavior of postgresql.conf and postgresql.auto.conf, especially with ALTER SYSTEM variants and the SUPERUSER requirements for these cluster-wide defaults.

I recently came across ALTER ROLE SET which allows regular users to set USER context settings and persistent them (changes first seen on next login and updated only on logins). These values rightly don't appear in the above .conf files - but they must be saved somewhere since they persist to future sessions. pg_settings does reflect the change in the setting column after logging in, but source is still user so there's no way to tell that it came from a persisted value on ROLE as opposed to some session-duration setting.

Where are these ALTER ROLE SET values kept? If ALTER ROLE SET executes, is it guaranteed that if the server restarts or is PITR'd that this change stays? And why doesn't the source reflect something like 'role' to differentiate?


Solution

  • This information is kept in the pg_db_role_setting catalog.

    Consequently, these changes are persistent.

    pg_settings will show the source as user, which is all the information you need, because it must be set on current_user.