Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qBpFf-0000jH-Dm for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Jun 2023 04:15:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qBpFe-00014E-B2 for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Jun 2023 04:15:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qBpFe-000141-2N for pgsql-hackers@lists.postgresql.org; Wed, 21 Jun 2023 04:15:26 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qBpFa-003kWJ-Jv for pgsql-hackers@postgresql.org; Wed, 21 Jun 2023 04:15:25 +0000 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1b50d7b4aaaso24276885ad.3 for ; Tue, 20 Jun 2023 21:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687320920; x=1689912920; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=UEs1XLEAzvgOJQO7qyOjP1RxgMbo0tIN0NqBUmKc5lc=; b=iMlHqwFtcPrhzEkUkI35t4IxBfIwbiT7BzhkCNXwdjMSUZbUQdx8CXa6Jq5ZCx7sbu /DXpT1YAN21PekFKLaZ2Bexbo0mVtEwRclbLtefrw174r88blZz2YUp8d4/NaMt64D3e lLwU88F6d94riVgQCPQlp6FNgV8zbfPKIuN2ZtKbYD6UnVCrZ4A5bLgOEQFPTTJRgxq7 HAzT9fxcCPdfehRyjSCoIpfQLVD5JQnB/WE+4QPsocNckbyhhrwN4JB94Da39APhoPSi QDjrm6RqNDZMC0mKilVklFTMLEHEI+9EG29rbbEVXdeJ5p3gMi3LO73J8HRg+MDcpIiQ qLNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687320920; x=1689912920; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=UEs1XLEAzvgOJQO7qyOjP1RxgMbo0tIN0NqBUmKc5lc=; b=Lije0OYEy5zFXt1Gl4MSJ+JL6w8KqGbUnOb2Zp/JtbHJKuAlaJyxvcpf82ihll5+UP Wlx1UweNMVxIaDWefVtRP6I6zONJ7GDiy355BSdH0EfFIAUqyfhqk9i/jSrTo76EceMW yWVCZ4/8+XsEmEKyWZ4RW8FAjvWTH31traB8PKM+l5zetgiAZEU0GkkLitBmr9Iz9kpO jVBllgXlaqTpmBpDvmK3oAxw3AMKAFo/hVALraUSTJZwS0OIp3gzFzhLeaI+GHQbJCkg tYGQv+62QKg/BmKn94Hep+6lEJ6g4GZyRSMYwLsuBcLskpE/53MuEJ8l8jdK7ooCEUqC ILNA== X-Gm-Message-State: AC+VfDxi5fFcg4BKyxoNl7PsJDuHOWCx53nzzAskZT8VqDJhdWZ+Q7DF ZZW+pUmePutpkGP7KtPx3Zw= X-Google-Smtp-Source: ACHHUZ7OdL5uRdybqSU/bBs+sh855xdAHuz+coS70EbRebdvCd6bRofrh/toM9bmvnOQCbmJM7TX6g== X-Received: by 2002:a17:903:11c3:b0:1b0:45e:fb02 with SMTP id q3-20020a17090311c300b001b0045efb02mr10381117plh.35.1687320920408; Tue, 20 Jun 2023 21:15:20 -0700 (PDT) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id l9-20020a170903244900b001a95f632340sm50866pls.46.2023.06.20.21.15.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 21:15:19 -0700 (PDT) Date: Tue, 20 Jun 2023 21:15:18 -0700 From: Nathan Bossart To: Michael Paquier Cc: Jeff Davis , Ted Yu , Pavel Luzanov , Justin Pryzby , pgsql-hackers@postgresql.org Subject: Re: allow granting CLUSTER, REFRESH MATERIALIZED VIEW, and REINDEX Message-ID: <20230621041518.GA774124@nathanxps13> References: <20230613235442.GA222795@nathanxps13> <20230614181711.GA488295@nathanxps13> <20230615041044.GA736001@nathanxps13> <20230615235700.GA877311@nathanxps13> <20230616052025.GA1026700@nathanxps13> <20230619215534.GA442477@nathanxps13> <20230620225257.GA771663@nathanxps13> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Jun 21, 2023 at 10:21:04AM +0900, Michael Paquier wrote: > Looking at 0001.. Thanks for taking a look. > -step s2_auth { SET ROLE regress_cluster_part; } > +step s2_auth { SET ROLE regress_cluster_part; SET client_min_messages = ERROR; } > > Is this change necessary because the ordering of the WARNING messages > generated for denied permissions is not guaranteed? Yes. > From the generated vacuum.out: > -- Only one partition owned by other user. > ALTER TABLE vacowned_parted OWNER TO CURRENT_USER; > SET ROLE regress_vacuum; > VACUUM vacowned_parted; > WARNING: permission denied to vacuum "vacowned_parted", skipping it > WARNING: permission denied to vacuum "vacowned_part2", skipping it > > This is interesting. In this case, regress_vacuum owns only one > partition, but we would be able to vacuum it even when querying > vacowned_parted. Seeing from [1], this is intentional as per the > argument that VACUUM/ANALYZE can take multiple relations. Am I > getting that right? That's different from CLUSTER or REINDEX, where > not owning the partitioned table fails immediately. Yes. > I think that there is a testing gap with the coverage of CLUSTER. > "Ownership of partitions is checked" is a test that looks for the case > where regress_ptnowner owns the partitioned table and one of its > partitions, checking that the leaf not owned is skipped, but we don't > have a test where we attempt a CLUSTER on the partitioned table with > regress_ptnowner *not* owning the partitioned table, only one or more > of its partitions owned by regress_ptnowner. In this case, the > command would fail. We could add something for this, but it'd really just exercise the checks in RangeVarCallbackMaintainsTable(), which already has a decent amount of coverage. > - privilege on the catalog. If a role has permission to > - REINDEX a partitioned table, it is also permitted to > - REINDEX each of its partitions, regardless of whether the > - role has the aforementioned privileges on the partition. Of course, > - superusers can always reindex anything. > + privilege on the catalog. Of course, superusers can always reindex anything. > > With 0001 applied, if a user is marked as an owner of a partitioned > table, all the partitions are reindexed even if this user does not own > a portion of them, making this change incorrect while the former is > more correct? The former wording would be true from the perspective that REINDEX on a partitioned table will flow down to its partitions and skip privilege checks on them, but it's incomplete because REINDEX on the individual partitions might still fail due to privileges (even if the user has privileges to REINDEX the partitioned table). After both patches are applied, the privilege documentation is distilled down to Reindexing a single index or table requires having the MAINTAIN privilege on the table. plus some assorted notes about REINDEX DATABASE/SCHEMA/SYSTEM. I think the proposed wording is accurate, but I can see the argument that it leaves some ambiguity for the partitioned table case. Perhaps we should add something like Note that while REINDEX on a partitioned index or table requires MAINTAIN on the partitioned table, such commands skip the privilege checks when processing the individual partitions. Thoughts? I'm trying to keep the privilege documentation for maintenance commands as simple as possible, so I'm hoping to avoid adding too much text dedicated to these special cases. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com