Re: how to switch user in postgres

David G. Johnston <david.g.johnston@gmail.com>

From: "David G. Johnston" <david.g.johnston@gmail.com>
To: ikramuddin <ikram.amani815@gmail.com>
Cc: pgsql-performance@lists.postgresql.org
Date: 2026-04-11T18:33:58Z
Lists: pgsql-performance
This seems quite misplaced on the -performance mailing list.

On Sat, Apr 11, 2026 at 10:55 AM ikramuddin <ikram.amani815@gmail.com>
wrote:

>
> As i was working through postgresql user and role privileges i faced an
> unexpected behavious when we revoke connect on database from a user then
> why still we need to revoke usage on schema basis and then revoke select ,
> insert , update privileges at table table. second when i did all this one
> by one and then tried to connect to same database using \c database_name
> user_name, it failed that is perfect which i expected but when i tried to
> connect through postgres as a superuser it connect still it is fine. but
> then i write the command set role simon it connected even i revoked the
> connect privileges from the role .
>


> plz guide it is a bug or this behavious left intentionally.
>

Intentional, every object has its own permissions that are granted to roles
independently of others.


> finance=> reset role'
> finance'> ;
> finance'> ';
> ERROR:  syntax error at or near "'
> ;
> '"
> LINE 1: reset role'
>
                  ^
> finance=> reset role;
> RESET
>

You had a typo in the first attempt...

For everything else I really don't feel like trying to read your mind.  If
you have questions about specific outcomes or whatnot please ask them
directly.  But there are no known bugs here and I presume you haven't
demonstrated any - everything is working as intended.

David J.