Subject: Re: fix and document CLUSTER privileges

From: Gilles Darold <[email-masked]>
Date: Wed, 4 Jan 2023 14:25:13 +0100

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