Temporary role/privileges Is it possible in PostgreSQL to temporary grant roles/privileges to a user? I'm thinking about this as a solution for the situation when there is a need to troubleshoot an issue and an user may need some specific role/privileges (even superuser) only for a short period of time.
GRANT does not have an expiration date, but roles have. So:
CREATE ROLE foo VALID UNTIL '2019-05-01 00:00+02';

GRANT my_privilege_bundle TO foo;

And my_privilege_bundle would be a group role bundling all required privileges.
The manual:

VALID UNTIL 'timestamp'
The VALID UNTIL clause sets a date and time after which the role's password is no longer valid. If this clause is omitted the password will be valid for all time.

Note that this does not end existing sessions. The role just can't make new connections with password after the expiration date. The manual once more

The VALID UNTIL clause defines an expiration time for a password only, not for the role per se. In particular, the expiration time is not enforced when logging in using a non-password-based authentication method.