Re: fix and document CLUSTER privileges

Gilles Darold <gilles@migops.com>

From: Gilles Darold <gilles@migops.com>
To: Nathan Bossart <nathandbossart@gmail.com>
Cc: Andrew Dunstan <andrew@dunslane.net>, Justin Pryzby <pryzby@telsasoft.com>, pgsql-hackers@postgresql.org, Robert Haas <robertmhaas@gmail.com>
Date: 2023-01-04T13:25:13Z
Lists: pgsql-hackers
Le 16/12/2022 à 05:57, Nathan Bossart a écrit :
> Here is a new version of the patch.  I've moved the privilege checks to a
> new function, and I added a note in the docs about clustering partitioned
> tables in a transaction block (it's not allowed).
>

Getting into review of this patch I wonder why the CLUSTER command do 
not react as VACUUM FULL command when there is insuffisant privileges. 
For example with a partitioned table (ptnowner) and two partitions 
(ptnowner1 and ptnowner2) with the second partition owned by another 
user, let' say usr2. We have the following report when executing vacuum 
as usr2:

testdb=> VACUUM FULL ptnowner;
WARNING:  permission denied to vacuum "ptnowner", skipping it
WARNING:  permission denied to vacuum "ptnowner1", skipping it
VACUUM

Here only ptnowner2 have been vacuumed which is correct and expected.

For the cluster command:

testdb=> CLUSTER;
CLUSTER


I would have expected something like:

testdb=> CLUSTER;
WARNING:  permission denied to cluster "ptnowner1", skipping it
CLUSTER

I mean that the silent behavior is not very helpful.


This is the current behavior of the CLUSTER command and current patch 
adds a sentence about the silent behavior in the documentation. This is 
good but I just want to ask if we could want to fix this behavior too or 
just keep things like that with the lack of noise.


Best regards,

-- 
Gilles Darold

Commits

  1. Clarify documentation for CLUSTER on partitioned tables.

  2. Fix MAINTAIN privileges for toast tables and partitions.

  3. Have CLUSTER ignore partitions not owned by caller