@@ -68,6 +68,17 @@ in sync when changing the above synopsis!
68
68
Note that roles are defined at the database cluster
69
69
level, and so are valid in all databases in the cluster.
70
70
</para>
71
+
72
+ <para>
73
+ During role creation it is possible to immediately assign the newly created
74
+ role to be a member of an existing role, and also assign existing roles
75
+ to be members of the newly created role. The rules for which initial
76
+ role membership options are enabled described below in the
77
+ <literal>IN ROLE</literal>, <literal>ROLE</literal>, and
78
+ <literal>ADMIN</literal> clauses. The <xref linkend="sql-grant"/>
79
+ command has fine-grained option control during membership creation,
80
+ and the ability to modify these options after the new role is created.
81
+ </para>
71
82
</refsect1>
72
83
73
84
<refsect1>
@@ -135,24 +146,21 @@ in sync when changing the above synopsis!
135
146
<term><literal>NOINHERIT</literal></term>
136
147
<listitem>
137
148
<para>
138
- When the <literal>GRANT</literal> statement is used to confer
139
- membership in one role to another role, the <literal>GRANT</literal>
140
- may use the <literal>WITH INHERIT</literal> clause to specify whether
141
- the privileges of the granted role should be <quote>inherited</quote>
142
- by the new member. If the <literal>GRANT</literal> statement does not
143
- specify either inheritance behavior, the new <literal>GRANT</literal>
144
- will be created <literal>WITH INHERIT TRUE</literal> if the member
145
- role is set to <literal>INHERIT</literal> and to
146
- <literal>WITH INHERIT FALSE</literal> if it is set to
147
- <literal>NOINHERIT</literal>.
149
+ This affects the membership inheritance status when this
150
+ role is added as a member of another role, both in this and
151
+ future commands. Specifically, it controls the inheritance
152
+ status of memberships added with this command using the
153
+ <literal>IN ROLE</literal> clause, and in later commands using
154
+ the <literal>ROLE</literal> clause. It is also used as the
155
+ default inheritance status when adding this role as a member
156
+ using the <literal>GRANT</literal> command. If not specified,
157
+ <literal>INHERIT</literal> is the default.
148
158
</para>
149
159
150
160
<para>
151
161
In <productname>PostgreSQL</productname> versions before 16,
152
- the <literal>GRANT</literal> statement did not support
153
- <literal>WITH INHERIT</literal>. Therefore, changing this role-level
154
- property would also change the behavior of already-existing grants.
155
- This is no longer the case.
162
+ inheritance was a role-level attribute that controlled all runtime
163
+ membership checks for that role.
156
164
</para>
157
165
</listitem>
158
166
</varlistentry>
@@ -287,9 +295,10 @@ in sync when changing the above synopsis!
287
295
<para>
288
296
The <literal>IN ROLE</literal> clause causes the new role to
289
297
be automatically added as a member of the specified existing
290
- roles. (Note that there is no option to add the new role as an
291
- administrator; use a separate <command>GRANT</command> command
292
- to do that.)
298
+ roles. The new membership will have the <literal>SET</literal>
299
+ option enabled and the <literal>ADMIN</literal> option disabled.
300
+ The <literal>INHERIT</literal> option will be enabled unless the
301
+ <literal>NOINHERIT</literal> option is specified.
293
302
</para>
294
303
</listitem>
295
304
</varlistentry>
@@ -308,8 +317,12 @@ in sync when changing the above synopsis!
308
317
<listitem>
309
318
<para>
310
319
The <literal>ROLE</literal> clause causes one or more specified
311
- existing roles to be automatically added as members of the new
312
- role. This in effect makes the new role a <quote>group</quote>.
320
+ existing roles to be automatically added as members, with the
321
+ <literal>SET</literal> option enabled. This in effect makes the
322
+ new role a <quote>group</quote>. Roles named in this clause
323
+ with role-level the <literal>INHERIT</literal> attribute will have
324
+ the <literal>INHERIT</literal> option enabled in the new membership.
325
+ New memberships will have the <literal>ADMIN</literal> option disabled.
313
326
</para>
314
327
</listitem>
315
328
</varlistentry>
@@ -318,10 +331,10 @@ in sync when changing the above synopsis!
318
331
<term><literal>ADMIN</literal> <replaceable class="parameter">role_name</replaceable></term>
319
332
<listitem>
320
333
<para>
321
- The <literal>ADMIN</literal> clause is like <literal>ROLE</literal>,
322
- but the named roles are added to the new role <literal>WITH ADMIN
323
- OPTION</literal>, giving them the right to grant membership in this role
324
- to others.
334
+ The <literal>ADMIN</literal> clause has the same effect as
335
+ <literal>ROLE</literal>, but the named roles are added as members
336
+ of the new role with <literal>ADMIN</literal> enabled, giving
337
+ them the right to grant membership in the new role to others.
325
338
</para>
326
339
</listitem>
327
340
</varlistentry>
@@ -374,15 +387,19 @@ in sync when changing the above synopsis!
374
387
</para>
375
388
376
389
<para>
377
- The <literal>INHERIT</literal> attribute governs inheritance of grantable
378
- privileges (that is, access privileges for database objects and role
379
- memberships). It does not apply to the special role attributes set by
380
- <command>CREATE ROLE</command> and <command>ALTER ROLE</command>. For example, being
381
- a member of a role with <literal>CREATEDB</literal> privilege does not immediately
382
- grant the ability to create databases, even if <literal>INHERIT</literal> is set;
383
- it would be necessary to become that role via
384
- <link linkend="sql-set-role"><command>SET ROLE</command></link> before
385
- creating a database.
390
+ The role attributes defined here are non-inheritable, i.e., being a
391
+ member of a role with, e.g., <literal>CREATEDB</literal> will not
392
+ allow the member to create new databases even if the membership grant
393
+ has the <literal>INHERIT</literal> option. Of course, if the membership
394
+ grant has the <literal>SET</literal> option the member role would be able to
395
+ <link linkend="sql-set-role"><command>SET ROLE</command></link> to the
396
+ createdb role and then create a new database.
397
+ </para>
398
+
399
+ <para>
400
+ The membership grants created by the
401
+ <literal>IN ROLE</literal>, <literal>ROLE</literal>, and <literal>ADMIN</literal>
402
+ clauses have the role executing this command as the grantee.
386
403
</para>
387
404
388
405
<para>
@@ -481,8 +498,10 @@ CREATE ROLE <replaceable class="parameter">name</replaceable> [ WITH ADMIN <repl
481
498
482
499
<para>
483
500
The behavior specified by the SQL standard is most closely approximated
484
- by giving users the <literal>NOINHERIT</literal> attribute, while roles are
485
- given the <literal>INHERIT</literal> attribute.
501
+ creating SQL-standard users as <productname>PostgreSQL</productname>
502
+ roles with the <literal>NOINHERIT</literal> option, and SQL-standard
503
+ roles as <productname>PostgreSQL</productname> roles with the
504
+ <literal>INHERIT</literal> option.
486
505
</para>
487
506
</refsect1>
488
507
0 commit comments