Skip to content

Commit 19989d8

Browse files
committed
Doc: fix missing explanation of default object privileges.
The GRANT reference page, which lists the default privileges for new objects, failed to mention that USAGE is granted by default for data types and domains. As a lesser sin, it also did not specify anything about the initial privileges for sequences, FDWs, foreign servers, or large objects. Fix that, and add a comment to acldefault() in the probably vain hope of getting people to maintain this list in future. Noted by Laurenz Albe, though I editorialized on the wording a bit. Back-patch to all supported branches, since they all have this behavior. Discussion: https://postgr.es/m/1507620895.4152.1.camel@cybertec.at
1 parent 36c687a commit 19989d8

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

doc/src/sgml/ref/grant.sgml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,22 @@ GRANT <replaceable class="PARAMETER">role_name</replaceable> [, ...] TO <replace
156156
<para>
157157
PostgreSQL grants default privileges on some types of objects to
158158
<literal>PUBLIC</literal>. No privileges are granted to
159-
<literal>PUBLIC</literal> by default on tables,
160-
columns, schemas or tablespaces. For other types, the default privileges
159+
<literal>PUBLIC</literal> by default on
160+
tables,
161+
table columns,
162+
sequences,
163+
foreign data wrappers,
164+
foreign servers,
165+
large objects,
166+
schemas,
167+
or tablespaces.
168+
For other types of objects, the default privileges
161169
granted to <literal>PUBLIC</literal> are as follows:
162-
<literal>CONNECT</literal> and <literal>CREATE TEMP TABLE</literal> for
163-
databases; <literal>EXECUTE</literal> privilege for functions; and
164-
<literal>USAGE</literal> privilege for languages.
170+
<literal>CONNECT</literal> and <literal>TEMPORARY</literal> (create
171+
temporary tables) privileges for databases;
172+
<literal>EXECUTE</literal> privilege for functions; and
173+
<literal>USAGE</literal> privilege for languages and data types
174+
(including domains).
165175
The object owner can, of course, <command>REVOKE</command>
166176
both default and expressly granted privileges. (For maximum
167177
security, issue the <command>REVOKE</> in the same transaction that

src/backend/utils/adt/acl.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,9 @@ hash_aclitem(PG_FUNCTION_ARGS)
722722
* acldefault() --- create an ACL describing default access permissions
723723
*
724724
* Change this routine if you want to alter the default access policy for
725-
* newly-created objects (or any object with a NULL acl entry).
725+
* newly-created objects (or any object with a NULL acl entry). When
726+
* you make a change here, don't forget to update the GRANT man page,
727+
* which explains all the default permissions.
726728
*
727729
* Note that these are the hard-wired "defaults" that are used in the
728730
* absence of any pg_default_acl entry.

0 commit comments

Comments
 (0)