1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-28 18:48:04 +03:00

Fix MAINTAIN privileges for toast tables and partitions.

Commit 60684dd8 left loose ends when it came to maintaining toast
tables or partitions.

For toast tables, simply skip the privilege check if the toast table
is an indirect target of the maintenance command, because the main
table privileges have already been checked.

For partitions, allow the maintenance command if the user has the
MAINTAIN privilege on the partition or any parent.

Also make CLUSTER emit "skipping" messages when the user doesn't have
privileges, similar to VACUUM.

Author: Nathan Bossart
Reported-by: Pavel Luzanov
Reviewed-by: Pavel Luzanov, Ted Yu
Discussion: https://postgr.es/m/20230113231339.GA2422750@nathanxps13
This commit is contained in:
Jeff Davis
2023-01-13 15:32:37 -08:00
parent ff23b592ad
commit ff9618e82a
16 changed files with 126 additions and 64 deletions

View File

@@ -69,10 +69,7 @@ CLUSTER [VERBOSE]
<para>
<command>CLUSTER</command> without any parameter reclusters all the
previously-clustered tables in the current database that the calling user
owns or has the <literal>MAINTAIN</literal> privilege for, or all such tables
if called by a superuser or a role with privileges of the
<link linkend="predefined-roles-table"><literal>pg_maintain</literal></link>
role. This form of <command>CLUSTER</command> cannot be
has privileges for. This form of <command>CLUSTER</command> cannot be
executed inside a transaction block.
</para>
@@ -134,6 +131,18 @@ CLUSTER [VERBOSE]
<refsect1>
<title>Notes</title>
<para>
To cluster a table, one must have the <literal>MAINTAIN</literal> privilege
on the table or be the table's owner, a superuser, or a role with
privileges of the
<link linkend="predefined-roles-table"><literal>pg_maintain</literal></link>
role. If a role has permission to <command>CLUSTER</command> a partitioned
table, it is also permitted to <command>CLUSTER</command> each of its
partitions, regardless of whether the role has the aforementioned
privileges on the partition. <command>CLUSTER</command> will skip over any
tables that the calling user does not have permission to cluster.
</para>
<para>
In cases where you are accessing single rows randomly
within a table, the actual order of the data in the