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.94.2) (envelope-from ) id 1rPrWf-00ElGp-V7 for pgsql-docs@arkaria.postgresql.org; Tue, 16 Jan 2024 22:03:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rPrWd-008Yxu-4o for pgsql-docs@arkaria.postgresql.org; Tue, 16 Jan 2024 22:03:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rPrWc-008Yxg-So for pgsql-docs@lists.postgresql.org; Tue, 16 Jan 2024 22:03:14 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rPrWV-002Bf4-Pt for pgsql-docs@postgresql.org; Tue, 16 Jan 2024 22:03:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=momjian.us; s=2024011501; h=Content-Type:MIME-Version:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description: In-Reply-To:References; bh=3xIy47BXG+mcqVGXp02k8GYdQrjXT36YvM/Sbv4/FBQ=; b=Mt JTvoLcz/mCbaBmxjXUB4iCDEQlq9MPNa+U0X8W6yo3VFwzoZCGGKq7rF2LbW6HRlpcrOPuF+vFC52 /8QzqRoeoOxQFf++8ZR6u6u6wW7VdMSLIR3JphXtGt3hYFVIL5ZV8jA9piMUGkVAq1W4C+Mn/jYls 1RQv2kjWV0x/ZFQpM7hos6yUD27EYrDdYAm0MgyBZvPrU2NdR2N7qHjRiJ6R+WQi7oolI4yDilXTe Em6RblycAaJWlDcz9GmX+8DadG5/R6+01O2jXXrEa58zYQw2UdiisDYt3P2qxz8SqhiJ48nV0x3SV /1N60IibYBYOYkpGLjd1735AJOJAFCKQ==; Received: from bruce by momjian.us with local (Exim 4.96) (envelope-from ) id 1rPrWU-00ElwU-0a; Tue, 16 Jan 2024 17:03:06 -0500 Date: Tue, 16 Jan 2024 17:03:06 -0500 From: Bruce Momjian To: PostgreSQL-documentation Cc: Robert Haas Subject: CREATE ROLE inheritance details Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="mkRRXG4AMhl7evcO" Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --mkRRXG4AMhl7evcO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline I am unhappy with the documentation adjustments made to CREATE ROLE in Postgres 16 by this commit: commit e3ce2de09d Author: Robert Haas Date: Thu Aug 25 10:06:02 2022 -0400 Allow grant-level control of role inheritance behavior. The GRANT statement can now specify WITH INHERIT TRUE or WITH INHERIT FALSE to control whether the member inherits the granted role's permissions. For symmetry, you can now likewise write WITH ADMIN TRUE or WITH ADMIN FALSE to turn ADMIN OPTION on or off. If a GRANT does not specify WITH INHERIT, the behavior based on whether the member role is marked INHERIT or NOINHERIT. This means that if all roles are marked INHERIT or NOINHERIT before any role grants are performed, the behavior is identical to what we had before; otherwise, it's different, because ALTER ROLE [NO]INHERIT now only changes the default behavior of future grants, and has no effect on existing ones. Patch by me. Reviewed and testing by Nathan Bossart and Tushar Ahuja, with design-level comments from various others. Discussion: http://postgr.es/m/CA+Tgmoa5Sf4PiWrfxA=sGzDKg0Ojo3dADw=wAHOhR9dggV=RmQ@mail.gmail.com It seems to have removed important details about how inherit works beyond GRANT. Using the attached script, test_inh.sh, I generated SQL queries contained in attached file test_inh.sql, and this generated this output showing that the inheritance setting of the role being added as a member controls the inheritance status of the membership: rolname | Is member of role | inherit_option ------------------+-------------------+---------------- init_1_noinherit | user_1_inherit | f init_1_noinherit | user_2_noinherit | f init_1_noinherit | user_3_inherit | f init_1_noinherit | user_4_noinherit | f init_2_inherit | user_5_inherit | t init_2_inherit | user_6_noinherit | t init_2_inherit | user_7_inherit | t init_2_inherit | user_8_noinherit | t user_1_inherit | init_3_noinherit | t user_2_noinherit | init_3_noinherit | f user_3_inherit | init_4_inherit | t user_4_noinherit | init_4_inherit | f user_5_inherit | init_3_noinherit | t user_6_noinherit | init_3_noinherit | f user_7_inherit | init_4_inherit | t user_8_noinherit | init_4_inherit | f I have attached a patch to re-add this information, and clarify it. I would like to apply this to PG 16 and master. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Only you can decide what is important to you. --mkRRXG4AMhl7evcO Content-Type: application/x-sh Content-Disposition: attachment; filename="test_inh.sh" Content-Transfer-Encoding: quoted-printable X=3D1=0Acat <NOINHERIT - When the GRANT statement is used to confer - membership in one role to another role, the GRANT - may use the WITH INHERIT clause to specify whether - the privileges of the granted role should be inherited - by the new member. If the GRANT statement does not - specify either inheritance behavior, the new GRANT - will be created WITH INHERIT TRUE if the member - role is set to INHERIT and to - WITH INHERIT FALSE if it is set to - NOINHERIT. + This controls the membership inheritance status when a new role + is added as a member using the IN ROLE clause, + when this role is later added as a member of a new role with the + ROLE clause, and the default inheritance when + adding this role as a member using the GRANT + statement. In such GRANT statements, the + role's inheritance status will be used unless overridden by the + GRANT WITH INHERIT clause. + + + + Role membership with the inherit attribute can automatically + use whatever database privileges have been granted to all + roles it is directly or indirectly a member of, though the + chain stops at memberships without the inherit attribute. + Without role inheritance, the only other value of membership + is via SET ROLE, assuming the membership has + the SET attribute. @@ -286,8 +294,8 @@ in sync when changing the above synopsis! The IN ROLE clause causes the new role to be automatically added as a member of the specified existing roles. (Note that there is no option to add the new role as an - administrator; use a separate GRANT command - to do that.) + administrator or to disallow SET ROLE; use a + separate GRANT command to do that.) @@ -460,8 +468,10 @@ CREATE ROLE name [ WITH ADMIN The behavior specified by the SQL standard is most closely approximated - by giving users the NOINHERIT attribute, while roles are - given the INHERIT attribute. + by giving LOGIN roles + the NOINHERIT attribute, while + NOLOGINroles are given the INHERIT + attribute. --mkRRXG4AMhl7evcO--