Re: BUG #18725: "set role" requires "grant connect on database"

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: postgresql_tdba(at)ldbv(dot)bayern(dot)de
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18725: "set role" requires "grant connect on database"
Date: 2024-11-27 18:11:00
Message-ID: 1895477.1732731060@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> After minor release update to version 16.5 or 16.6 "set role" to role
> without "grant connect on database" generates error:

> "ERROR: Benutzer hat das CONNECT-Privileg nicht.keine Berechtigung für
> Datenbank »...«
> FEHLER: keine Berechtigung für Datenbank »...«
> SQL state: 42501
> Detail: Benutzer hat das CONNECT-Privileg nicht.
> Context: paralleler Arbeitsprozess"

This bug report is not actionable, because you didn't show what
you did to provoke the error. I did a little bit of testing
by guessing what you might be talking about, and I don't see
a problem:

regression=# create role r;
CREATE ROLE
regression=# create database d;
CREATE DATABASE
regression=# revoke connect on database d from public;
REVOKE
regression=# \c d
You are now connected to database "d" as user "postgres".
d=# set role r; -- should work, and does
SET
d=> reset role;
RESET
d=# create user joe;
CREATE ROLE
d=# grant r to joe;
GRANT ROLE
d=# alter user joe set role = r;
ALTER ROLE
d=# \c d joe -- should fail, and does
connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL: permission denied for database "d"
DETAIL: User does not have CONNECT privilege.
Previous connection kept
d=# grant connect on database d to joe;
GRANT
d=# \c d joe -- now it should work, and does
You are now connected to database "d" as user "joe".
d=> show role;
role
------
r
(1 row)

Please provide a self-contained script that reproduces
your problem.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Nathan Bossart 2024-11-27 18:12:10 Re: BUG #18711: Attempting a connection with a database name longer than 63 characters now fails
Previous Message Bertrand Drouvot 2024-11-27 18:03:43 Re: BUG #18711: Attempting a connection with a database name longer than 63 characters now fails