Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vTJtq-00H4H0-36 for pgsql-admin@arkaria.postgresql.org; Wed, 10 Dec 2025 13:06:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vTJto-00BFD0-13 for pgsql-admin@arkaria.postgresql.org; Wed, 10 Dec 2025 13:06:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vTJtn-00BFCr-2h for pgsql-admin@lists.postgresql.org; Wed, 10 Dec 2025 13:06:32 +0000 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vTJtm-0048Ie-0j for pgsql-admin@lists.postgresql.org; Wed, 10 Dec 2025 13:06:31 +0000 Received: by mail-oi1-x229.google.com with SMTP id 5614622812f47-450c65f3510so3527408b6e.2 for ; Wed, 10 Dec 2025 05:06:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765371989; x=1765976789; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=zt8MulzDHzxJGa1euRSTvQ4bZFL5/RHEM2d7DFYGtf0=; b=JGilCcQLCPqwUIkNPrhbSnoWDrKcJZASRMSrwykNkhuSKb0JJN6eN+0StGaGljCRcn FHzxEWPO4TnxLahRbt27Bpxia01EGEBzDyI6NRAsqnNjT1tEkZ6c565gJvW7pH2tzB8z tqnyIBW4nWxsEELWLXNk2SDuQGPHDT//pZR7EuoM3WAALnSjW1NZGKHqM6dXg5VNfV1k BpS3BC9fnhIAL4B81ceilvmKronWaQptUoFL8g3NYj4gQp1+D/fU7eCXHmOP4HkOoEE8 /LAwRnHG+XTZjrmdmLuCXX0oO9phRVujIiCPzC8YfzlJRmYAQeL4s9AsgsR+dhHkME/q dVHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765371989; x=1765976789; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=zt8MulzDHzxJGa1euRSTvQ4bZFL5/RHEM2d7DFYGtf0=; b=esPCyync0DJBhojrD+uiafTa1QVAmhUQ8ZWWFg7BJtlPmo6fERwmkmTqJgYups8tLi kwlFEn7WpqQYNmVe9A04Xmng74S2sKtSwBRvHlJXwfaB+OdQm6IqL0GB9wdbiiRH1dIo 9EzDhPIZoYQ5L5CkbQBxD5Ui26mWQbfNBD65gVfVXi/S72i1RFnF3hsBsgtTvzU51xYU ZUTHj1KsZAn+UtQAJPCrzNQOtqklpWoKJCIvSVY4HK9yL84yLAIrOiNTNpu0WsRjiBgV Vt9SsUp79VIo0fWOaQQ74GSHxlAdLFo4IsJpfnNObXtmx0rDyvNG+uiAHoIRUz2kUCKL KXQQ== X-Gm-Message-State: AOJu0Yz7sIYa5VULhBl0T/+U8o+Xwds5gJV1QLiViCkW0iiAlca8i2Rd LrXIZ7wqEq1Azl+ELyRb5VPgJIaGkP/1YyeA7VxmamEircBA6/Vne4ITX7dkd/lR144h+EG+z5X M8fIjHK3eqWRhXYN40CMV+0WsNzbDw9/MHclG X-Gm-Gg: ASbGncvqHV/lwkQEGZ5fRqXB+17w4EjpT/2LirurpOcJFGC0Zq6YREJCI4frSRMRcFe vKePXXeJ6XDtjAcBi9Rwd+oerkCOrB4u0Uy6QqT5R08WyoCsplcCDLsEpzVnE4bugU4Ll3enQhH PyHGiZRGDMIuGNDDFYFybUQAF7xudlZBThntaEeVE3Cg/CSoKl3vY4fSs/xV7jQv/cVUJ0DZvD+ geuyRBb78dqGueG/q66NQmnSApWadebQFFDEWmiJ4iSKwtpe5JdzGAh+pqdI1rrNBp7iYGLL9hR bJV3n7VJt/sLS772xWer26lnGyMFLPjif3GTYLAyASLOYppQWWoDoxQA X-Google-Smtp-Source: AGHT+IEY/UT8Ik83ITyg9CsOX5hdTFIwRHHKOSYzelRNqmmVq/XI0U+ZgRp2H21a31l83lBFBSLCWSM36dpS4XKBNQE= X-Received: by 2002:a05:6808:118e:b0:455:8400:f077 with SMTP id 5614622812f47-455865d3dffmr1252197b6e.20.1765371989437; Wed, 10 Dec 2025 05:06:29 -0800 (PST) MIME-Version: 1.0 References: <72acf8ae4e56886081b9f632569f290d3246c33b.camel@cybertec.at> In-Reply-To: <72acf8ae4e56886081b9f632569f290d3246c33b.camel@cybertec.at> From: richard coleman Date: Wed, 10 Dec 2025 08:06:17 -0500 X-Gm-Features: AQt7F2q3kP_DoZauOOGx1lFAw9nZ_KTEanxooJiNjE6yWkcqp8stJovHsRvtrMM Message-ID: Subject: Re: database specific pg_read_all_data / pg_write_all_data To: Laurenz Albe Cc: Pgsql-admin Content-Type: multipart/alternative; boundary="00000000000053b17f064598b2d1" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000053b17f064598b2d1 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Laurenz, Multiple clusters would be nice, but we don't have the available servers to accomodate that. Without the pg_read_all_data role there is apparently no other way in PostgreSQL to automatically assign these privs to each and every table/view that exists or will be created without using the nuclear option and granting super user privs. Unless there is something else that I am missing which could be used when creating your suggested "readonly_dbname" role. It's a shame that PostgreSQL has created some extremely useful built in roles, but then limits them such that they can only be utilized for vanishingly few actual use cases. Hopefully the PostgreSQL devs revisit these built in roles with a thought toward making database specific ones assignable with a mechanism like: *grant *pg_read_all_data* on database *foo* to *user_role*;* Thanks, rik. On Wed, Dec 10, 2025 at 5:01=E2=80=AFAM Laurenz Albe wrote: > On Tue, 2025-12-09 at 16:13 -0500, richard coleman wrote: > > In PostgreSQL 16+ the built in roles such as pg_read_all_data > and pg_write_all_data are a welcome addition to permission setting in > PostgreSQL. > > > > Unfortunately they appear to be server-wide roles. > > > > Woud it be possible to have roles like these that are database specific= ? > > > > If there are 100 databases on a server, it would be extremely helpful t= o > be able to do something like: > > > > grant pg_read_all_data on database foo to user_role; > > > > Otherwise these roles are unusable from a practical stand point on > servers with multiple unrelated databases. > > I think they were mostly added for compatibility with Microsoft SQL Serve= r, > if I remember correctly. > > I suggest creating roles named "readonly_dbname" for each database with > the appropriate privileges and assigning those. > > A different approach would be to use different database clusters for > different > databases. > > Yours, > Laurenz Albe > --00000000000053b17f064598b2d1 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Laurenz,

Multiple clusters would be nic= e, but we don't have the available servers to accomodate that.
Without the pg_read_all_data role there is apparently no other way in=C2= =A0 PostgreSQL to automatically assign these privs to each and every table/= view that exists or will be created without using the nuclear option and gr= anting super user privs.=C2=A0 Unless there is something else that I am mis= sing which could be used when creating your suggested "readonly_dbname= " role.=C2=A0

It's a shame that PostgreSQ= L has created some extremely useful built in roles, but then limits them su= ch that they can only be utilized for vanishingly few actual use cases.

Hopefully the PostgreSQL devs revisit these built in = roles with a thought toward making database specific ones assignable=C2=A0 = with a mechanism like:

grant=C2=A0pg_read_all_data= =C2=A0on database=C2=A0foo=C2=A0to=C2=A0user_role;
<= div>
Thanks,
rik.

<= br>

On Wed, Dec 10, 2025 at 5:01=E2=80=AFAM Laur= enz Albe <laurenz.albe@cyber= tec.at> wrote:
On Tue, 2025-12-09 at 16:13 -0500, richard coleman wrote:
> In PostgreSQL 16+ the built in roles such as=C2=A0pg_read_all_data and= =C2=A0pg_write_all_data are a welcome addition to permission setting in Pos= tgreSQL.
>
> Unfortunately they appear to be server-wide roles.
>
> Woud it be possible to have roles like these that are database specifi= c?
>
> If there are 100 databases on a server, it would be extremely helpful = to be able to do something like:
>
> grant pg_read_all_data on database foo to user_role;
>
> Otherwise these roles are unusable from a practical stand point on ser= vers with multiple unrelated databases.

I think they were mostly added for compatibility with Microsoft SQL Server,=
if I remember correctly.

I suggest creating roles named "readonly_dbname" for each databas= e with
the appropriate privileges and assigning those.

A different approach would be to use different database clusters for differ= ent
databases.

Yours,
Laurenz Albe
--00000000000053b17f064598b2d1--